2 "build_module" : "builder",
5 "# JsRender.JsRender? file" : "null",
6 "# JsRender.Node node" : "null",
7 "# JsRender.NodeProp? prop" : "null",
8 "# Xcls_MainWindow window" : "null",
9 "# bool dirty" : false,
11 "# int pos_root_x" : "",
12 "# int pos_root_y" : "",
13 "# string activeEditor" : "\"\"",
14 "$ homogeneous" : false,
18 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
19 "Gtk.SourceSearchContext searchcontext" : "null",
20 "bool hexpand" : true,
21 "bool vexpand" : true,
22 "int last_search_end" : 0,
25 "$ homogeneous" : false,
27 "* pack" : "pack_start,false,true",
28 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
32 "* pack" : "pack_start,false,false",
38 " _this.saveContents();",
47 "* pack" : "pack_start,true,true",
48 "bool editable" : false,
50 "int width_request" : 100,
55 "* ctor" : "new Gtk.HScale.with_range (6, 30, 1)",
58 "\tthis.el.set_range(6,30);",
59 "\tthis.el.set_value(8);",
63 "* pack" : "pack_end,true,true",
64 "bool draw_value" : true,
65 "bool has_origin" : true,
66 "bool sensitive" : true,
72 "\t var description = Pango.FontDescription.from_string(\"monospace\");",
73 "\t print(\"resize to %d\", (int)val*1000);",
74 " description.set_size((int)val*1000);",
75 " _this.view.el.override_font(description);",
88 "this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
91 "* pack" : "pack_end,true,true",
95 "$ Gtk.SourceDrawSpacesFlags draw_spaces" : "Gtk.SourceDrawSpacesFlags.LEADING + Gtk.SourceDrawSpacesFlags.TRAILING + Gtk.SourceDrawSpacesFlags.TAB + Gtk.SourceDrawSpacesFlags.SPACE",
96 "$ gboolean auto_indent" : true,
97 "$ show_line_numbers" : true,
102 "\t\tvar description = Pango.FontDescription.from_string(\"monospace\");",
103 "\t\tdescription.set_size(8000);",
105 "\t\t this.el.override_font(description);",
108 "\t\tthis.el.completion.add_provider(new Palete.CompletionProvider(_this));",
109 " } catch (GLib.Error e) {}",
111 "\tthis.el.completion.unblock_interactive();",
112 "\tthis.el.completion.select_on_show\t\t\t= true; // select",
113 "\tthis.el.completion.show_headers\t\t\t= false;",
114 "\tthis.el.completion.remember_info_visibility\t\t= true;",
117 " var attrs = new Gtk.SourceMarkAttributes();",
118 " var pink = Gdk.RGBA();",
119 " pink.parse ( \"pink\");",
120 " attrs.set_background ( pink);",
121 " attrs.set_icon_name ( \"process-stop\"); ",
122 " attrs.query_tooltip_text.connect(( mark) => {",
123 " //print(\"tooltip query? %s\\n\", mark.name);",
124 " return mark.name;",
127 " this.el.set_mark_attributes (\"ERR\", attrs, 1);",
129 " var wattrs = new Gtk.SourceMarkAttributes();",
130 " var blue = Gdk.RGBA();",
131 " blue.parse ( \"#ABF4EB\");",
132 " wattrs.set_background ( blue);",
133 " wattrs.set_icon_name ( \"process-stop\"); ",
134 " wattrs.query_tooltip_text.connect(( mark) => {",
135 " //print(\"tooltip query? %s\\n\", mark.name);",
136 " return mark.name;",
139 " this.el.set_mark_attributes (\"WARN\", wattrs, 1);",
143 " var dattrs = new Gtk.SourceMarkAttributes();",
144 " var purple = Gdk.RGBA();",
145 " purple.parse ( \"#EEA9FF\");",
146 " dattrs.set_background ( purple);",
147 " dattrs.set_icon_name ( \"process-stop\"); ",
148 " dattrs.query_tooltip_text.connect(( mark) => {",
149 " //print(\"tooltip query? %s\\n\", mark.name);",
150 " return mark.name;",
153 " this.el.set_mark_attributes (\"DEPR\", dattrs, 1);",
158 "bool insert_spaces_instead_of_tabs" : true,
159 "gboolean highlight_current_line" : true,
160 "gboolean show_line_marks" : true,
166 "* pack" : "set_buffer",
167 "bool check_queued" : false,
168 "bool check_running" : false,
170 "int error_line" : "-1",
174 " // check syntax??",
176 " _this.save_button.el.sensitive = true;",
177 " print(\"EDITOR CHANGED\");",
178 " this.checkSyntax();",
180 " _this.dirty = true;",
182 " // this.get('/LeftPanel.model').changed( str , false);",
190 "xtype" : "SourceBuffer",
191 "| bool checkSyntax" : [
194 " if (this.check_running) {",
195 " print(\"Check is running\\n\");",
196 " if (this.check_queued) { ",
197 " print(\"Check is already queued\");",
200 " this.check_queued = true;",
201 " print(\"Adding queued Check \");",
202 " GLib.Timeout.add_seconds(1, () => {",
203 " this.check_queued = false;",
205 " this.checkSyntax();",
212 " var str = this.toString();",
215 " if (this.error_line > 0) {",
216 " Gtk.TextIter start;",
217 " Gtk.TextIter end; ",
218 " this.el.get_bounds (out start, out end);",
220 " this.el.remove_source_marks (start, end, null);",
222 " if (str.length < 1) {",
223 " print(\"checkSyntax - empty string?\\n\");",
227 " if (_this.file.xtype == \"PlainFile\") {",
229 " // assume it's gtk...",
230 " this.check_running = true;",
232 " if (!_this.window.windowstate.valasource.checkPlainFileSpawn(",
236 " this.check_running = false;",
242 " if (_this.file == null) {",
245 " var p = _this.file.project.palete;",
249 " this.check_running = true;",
252 " if (_this.file.language == \"js\") {",
253 " this.check_running = false;",
254 " print(\"calling validate javascript\\n\"); ",
255 " Gee.HashMap<int,string> errors;",
256 " p.javascriptHasErrors(",
257 " \t\t_this.window.windowstate,",
260 " _this.file, // no reference not node?",
263 " return this.highlightErrors(errors); ",
268 " print(\"calling validate vala\\n\"); ",
269 " // clear the buttons.",
272 " if (! _this.window.windowstate.valasource.checkFileWithNodePropChange(",
278 " this.check_running = false;",
283 " //print(\"done mark line\\n\");",
285 " return true; // at present allow saving - even if it's invalid..",
289 "| string toString" : [
294 " this.el.get_start_iter(out s);",
295 " this.el.get_end_iter(out e);",
296 " var ret = this.el.get_text(s,e,true);",
297 " //print(\"TO STRING? \" + ret);",
302 "| bool highlightErrors" : [
303 "( Gee.HashMap<int,string> validate_res) {",
305 " this.error_line = validate_res.size;",
307 " if (this.error_line < 1) {",
310 " var tlines = this.el.get_line_count ();",
311 " Gtk.TextIter iter;",
312 " var valiter = validate_res.map_iterator();",
313 " while (valiter.next()) {",
315 " // print(\"get inter\\n\");",
316 " var eline = valiter.get_key();",
317 " if (eline > tlines) {",
320 " this.el.get_iter_at_line( out iter, eline);",
321 " //print(\"mark line\\n\");",
322 " this.el.create_source_mark(valiter.get_value(), \"ERR\", iter);",
327 "| bool highlightErrorsJson" : [
328 "(string type, Json.Object obj) {",
329 " Gtk.TextIter start;",
330 " Gtk.TextIter end; ",
331 " this.el.get_bounds (out start, out end);",
333 " this.el.remove_source_marks (start, end, type);",
336 " // we should highlight other types of errors..",
338 " if (!obj.has_member(type)) {",
339 " print(\"Return has no errors\\n\");",
343 " if (_this.window.windowstate.state != WindowState.State.CODEONLY ",
350 " var err = obj.get_object_member(type);",
353 " if (_this.file == null) {",
357 " var valafn = _this.file.path;",
359 " if (_this.file.xtype != \"PlainFile\") {",
366 " var regex = new Regex(\"\\\\.bjs$\");",
367 " // should not happen",
370 " valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");",
371 " } catch (GLib.RegexError e) {",
378 " if (!err.has_member(valafn)) {",
379 " print(\"File path has no errors\\n\");",
383 " var lines = err.get_object_member(valafn);",
386 " if (obj.has_member(\"line_offset\")) {",
387 " offset = (int)obj.get_int_member(\"line_offset\") + 1;",
393 " var tlines = this.el.get_line_count () +1;",
395 " lines.foreach_member((obj, line, node) => {",
397 " Gtk.TextIter iter;",
398 " // print(\"get inter\\n\");",
399 " var eline = int.parse(line) - offset;",
400 " print(\"GOT ERROR on line %s -- converted to %d\\n\", line,eline);",
403 " if (eline > tlines || eline < 0) {",
406 " this.el.get_iter_at_line( out iter, eline);",
407 " //print(\"mark line\\n\");",
408 " var msg = \"Line: %d\".printf(eline+1);",
409 " var ar = lines.get_array_member(line);",
410 " for (var i = 0 ; i < ar.get_length(); i++) {",
411 "\t\t msg += (msg.length > 0) ? \"\\n\" : \"\";",
412 "\t\t msg += ar.get_string_element(i);",
416 " this.el.create_source_mark(msg, type, iter);",
430 "key_release_event" : [
433 " if (event.keyval == 115 && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
434 " print(\"SAVE: ctrl-S pressed\");",
435 " _this.saveContents();",
438 " // print(event.key.keyval)",
447 "uint tab_width" : 4,
448 "xtype" : "SourceView",
452 "// show the help page for the active node..",
453 " //this.get('/Help').show();",
456 " // this.get('/BottomPane').el.set_current_page(0);",
457 " var buf = (Gtk.SourceBuffer)this.el.get_buffer();",
458 " buf.set_text(str, str.length);",
459 " buf.set_undo_manager(null);",
461 " var lm = Gtk.SourceLanguageManager.get_default();",
462 " var lang = \"vala\";",
463 " if (_this.file != null) {",
464 " lang = _this.file.language;",
466 " print(\"lang=%s, content_type = %s\\n\", lang, _this.file.content_type);",
467 " var lg = _this.file.content_type.length > 0 ?",
468 " lm.guess_language(_this.file.path, _this.file.content_type) :",
469 " lm.get_language(lang);",
472 " ((Gtk.SourceBuffer)(this.el.get_buffer())) .set_language(lg); ",
474 " this.el.insert_spaces_instead_of_tabs = true;",
475 " if (lg != null) {",
476 "\t\tprint(\"sourcelanguage = %s\\n\", lg.name);",
477 "\t\tif (lg.name == \"Vala\") {",
478 "\t\t this.el.insert_spaces_instead_of_tabs = false;",
481 " _this.dirty = false;",
482 " this.el.grab_focus();",
483 " _this.save_button.el.sensitive = false;",
488 "xtype" : "ScrolledWindow"
491 "string id" : "Editor",
494 "(JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop)",
497 " this.file = file; ",
499 " if (file.xtype != \"PlainFile\") {",
500 " \tthis.prop = prop;",
501 " this.node = node;",
503 " // find the text for the node..",
504 " this.view.load( prop.val );",
505 " this.key_edit.el.show();",
506 " this.key_edit.el.text = prop.rtype + \" \" + prop.name; ",
509 " this.view.load( file.toSource() );",
510 " this.key_edit.el.hide();",
515 "| bool saveContents" : [
519 " if (_this.file == null) {",
525 " var str = _this.buffer.toString();",
527 " _this.buffer.checkSyntax();",
531 " // LeftPanel.model.changed( str , false);",
532 " _this.dirty = false;",
533 " _this.save_button.el.sensitive = false;",
535 " // find the text for the node..",
536 " if (_this.file.xtype != \"PlainFile\") {",
537 " // in theory these properties have to exist!?!",
538 " \tthis.prop.val = str;",
539 " this.window.windowstate.left_props.reload();",
541 " _this.file.setSource( str );",
544 " // call the signal..",
554 "\tvar s = new Gtk.SourceSearchSettings();",
556 "\tthis.searchcontext = new Gtk.SourceSearchContext(this.buffer.el,s);",
557 "\tthis.searchcontext .set_highlight(true);",
558 "\ts.set_search_text(txt);",
559 "\tGtk.TextIter beg, st,en;",
561 "\tthis.buffer.el.get_start_iter(out beg);",
562 "\tthis.searchcontext.forward(beg, out st, out en);",
563 "\tthis.last_search_end = 0;",
565 "\treturn this.searchcontext.get_occurrences_count();",
573 "| void forwardSearch" : [
574 "(bool change_focus) {",
576 "\tif (this.searchcontext == null) {",
580 "\tGtk.TextIter beg, st,en;",
582 "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end);",
583 "\tif (!this.searchcontext.forward(beg, out st, out en)) {",
585 "\t\tthis.last_search_end = 0;",
587 "\t\tthis.last_search_end = en.get_offset();",
588 "\t\tif (change_focus) {",
589 "\t\t\tthis.view.el.grab_focus();",
591 "\t\tthis.buffer.el.place_cursor(st);",
592 "\t\tthis.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);",
600 "\t this.file = null; ",
602 " this.node = null;",
603 " this.prop = null;",
604 "\tthis.searchcontext = null;",
609 "| void scroll_to_line" : [
612 "\tGLib.Timeout.add(500, () => {",
614 "\t\tvar buf = this.view.el.get_buffer();",
616 "\t\tvar sbuf = (Gtk.SourceBuffer) buf;",
619 "\t\tGtk.TextIter iter; ",
620 "\t\tsbuf.get_iter_at_line(out iter, line);",
621 "\t\tthis.view.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
632 "path" : "/home/alan/gitlive/roobuilder/src/Builder4/Editor.bjs",