Separate lines in a multiline grammar
authorEnrico Zini <enrico@enricozini.org>
Thu, 13 Aug 2009 16:09:27 +0000 (17:09 +0100)
committerEnrico Zini <enrico@enricozini.org>
Thu, 13 Aug 2009 16:09:27 +0000 (17:09 +0100)
src/app_polygen.vala

index 3b2538f2db32086b9af87d276203e59c471895fc..b3a997a976394adff725870562dc9036f9db770f 100644 (file)
@@ -63,6 +63,7 @@ protected class PolygenRun : Gtk.VBox
     protected Gtk.TextBuffer text_buffer;
     protected Gtk.TextView text;
     protected Regex unhtml;
+    protected Regex seplines;
 
     public string grm_name { get; set; }
     public string grm_type { get; set; }
@@ -72,6 +73,7 @@ protected class PolygenRun : Gtk.VBox
         grm_name = "";
         grm_type = "";
         unhtml = new Regex("[ ]*<[^>]+>[ ]*", 0, 0);
+        seplines = new Regex("\n");
         text_buffer = new Gtk.TextBuffer(null);
         text = new Gtk.TextView.with_buffer(text_buffer);
         text.wrap_mode = Gtk.WrapMode.WORD;
@@ -116,7 +118,10 @@ protected class PolygenRun : Gtk.VBox
         if (grm_type == "line/html" || grm_type == "block/html")
         {
             result = unhtml.replace(result, (long)res_len, 0, " ", 0);
+        } else if (grm_type == "line/text") {
+            result = seplines.replace(result, (long)res_len, 0, "\n\n", 0);
         }
+        
 
         text_buffer.text = result;
         Gtk.TextIter iter;