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);",
87 "* init" : "this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
88 "* pack" : "pack_end,true,true",
92 "$ Gtk.SourceDrawSpacesFlags draw_spaces" : "Gtk.SourceDrawSpacesFlags.LEADING + Gtk.SourceDrawSpacesFlags.TRAILING + Gtk.SourceDrawSpacesFlags.TAB + Gtk.SourceDrawSpacesFlags.SPACE",
93 "$ gboolean auto_indent" : true,
94 "$ show_line_numbers" : true,
99 "\t\tvar description = Pango.FontDescription.from_string(\"monospace\");",
100 "\t\tdescription.set_size(8000);",
102 "\t\t this.el.override_font(description);",
105 "\t\tthis.el.completion.add_provider(new Palete.CompletionProvider(_this));",
106 " } catch (GLib.Error e) {}",
108 "\tthis.el.completion.unblock_interactive();",
109 "\tthis.el.completion.select_on_show\t\t\t= true; // select",
110 "\tthis.el.completion.show_headers\t\t\t= false;",
111 "\tthis.el.completion.remember_info_visibility\t\t= true;",
114 " var attrs = new Gtk.SourceMarkAttributes();",
115 " var pink = Gdk.RGBA();",
116 " pink.parse ( \"pink\");",
117 " attrs.set_background ( pink);",
118 " attrs.set_icon_name ( \"process-stop\"); ",
119 " attrs.query_tooltip_text.connect(( mark) => {",
120 " //print(\"tooltip query? %s\\n\", mark.name);",
121 " return mark.name;",
124 " this.el.set_mark_attributes (\"ERR\", attrs, 1);",
126 " var wattrs = new Gtk.SourceMarkAttributes();",
127 " var blue = Gdk.RGBA();",
128 " blue.parse ( \"#ABF4EB\");",
129 " wattrs.set_background ( blue);",
130 " wattrs.set_icon_name ( \"process-stop\"); ",
131 " wattrs.query_tooltip_text.connect(( mark) => {",
132 " //print(\"tooltip query? %s\\n\", mark.name);",
133 " return mark.name;",
136 " this.el.set_mark_attributes (\"WARN\", wattrs, 1);",
140 " var dattrs = new Gtk.SourceMarkAttributes();",
141 " var purple = Gdk.RGBA();",
142 " purple.parse ( \"#EEA9FF\");",
143 " dattrs.set_background ( purple);",
144 " dattrs.set_icon_name ( \"process-stop\"); ",
145 " dattrs.query_tooltip_text.connect(( mark) => {",
146 " //print(\"tooltip query? %s\\n\", mark.name);",
147 " return mark.name;",
150 " this.el.set_mark_attributes (\"DEPR\", dattrs, 1);",
155 "bool insert_spaces_instead_of_tabs" : true,
156 "gboolean highlight_current_line" : true,
157 "gboolean show_line_marks" : true,
163 "* pack" : "set_buffer",
164 "bool check_queued" : false,
165 "bool check_running" : false,
167 "int error_line" : "-1",
171 " // check syntax??",
173 " _this.save_button.el.sensitive = true;",
174 " print(\"EDITOR CHANGED\");",
175 " this.checkSyntax();",
177 " _this.dirty = true;",
179 " // this.get('/LeftPanel.model').changed( str , false);",
187 "xtype" : "SourceBuffer",
188 "| bool checkSyntax" : [
191 " if (this.check_running) {",
192 " print(\"Check is running\\n\");",
193 " if (this.check_queued) { ",
194 " print(\"Check is already queued\");",
197 " this.check_queued = true;",
198 " print(\"Adding queued Check \");",
199 " GLib.Timeout.add_seconds(1, () => {",
200 " this.check_queued = false;",
202 " this.checkSyntax();",
209 " var str = this.toString();",
212 " if (this.error_line > 0) {",
213 " Gtk.TextIter start;",
214 " Gtk.TextIter end; ",
215 " this.el.get_bounds (out start, out end);",
217 " this.el.remove_source_marks (start, end, null);",
219 " if (str.length < 1) {",
220 " print(\"checkSyntax - empty string?\\n\");",
224 " if (_this.file.xtype == \"PlainFile\") {",
226 " // assume it's gtk...",
227 " this.check_running = true;",
229 " if (!_this.window.windowstate.valasource.checkPlainFileSpawn(",
233 " this.check_running = false;",
239 " if (_this.file == null) {",
242 " var p = _this.file.project.palete;",
246 " this.check_running = true;",
249 " if (_this.file.language == \"js\") {",
250 " this.check_running = false;",
251 " print(\"calling validate javascript\\n\"); ",
252 " Gee.HashMap<int,string> errors;",
253 " p.javascriptHasErrors(",
254 " \t\t_this.window.windowstate,",
257 " _this.file, // no reference not node?",
260 " return this.highlightErrors(errors); ",
265 " print(\"calling validate vala\\n\"); ",
266 " // clear the buttons.",
269 " if (! _this.window.windowstate.valasource.checkFileWithNodePropChange(",
275 " this.check_running = false;",
280 " //print(\"done mark line\\n\");",
282 " return true; // at present allow saving - even if it's invalid..",
286 "| bool highlightErrors" : [
287 "( Gee.HashMap<int,string> validate_res) {",
289 " this.error_line = validate_res.size;",
291 " if (this.error_line < 1) {",
294 " var tlines = this.el.get_line_count ();",
295 " Gtk.TextIter iter;",
296 " var valiter = validate_res.map_iterator();",
297 " while (valiter.next()) {",
299 " // print(\"get inter\\n\");",
300 " var eline = valiter.get_key();",
301 " if (eline > tlines) {",
304 " this.el.get_iter_at_line( out iter, eline);",
305 " //print(\"mark line\\n\");",
306 " this.el.create_source_mark(valiter.get_value(), \"ERR\", iter);",
311 "| bool highlightErrorsJson" : [
312 "(string type, Json.Object obj) {",
313 " Gtk.TextIter start;",
314 " Gtk.TextIter end; ",
315 " this.el.get_bounds (out start, out end);",
317 " this.el.remove_source_marks (start, end, type);",
320 " // we should highlight other types of errors..",
322 " if (!obj.has_member(type)) {",
323 " print(\"Return has no errors\\n\");",
327 " if (_this.window.windowstate.state != WindowState.State.CODEONLY ",
334 " var err = obj.get_object_member(type);",
337 " if (_this.file == null) {",
341 " var valafn = _this.file.path;",
343 " if (_this.file.xtype != \"PlainFile\") {",
350 " var regex = new Regex(\"\\\\.bjs$\");",
351 " // should not happen",
354 " valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");",
355 " } catch (GLib.RegexError e) {",
362 " if (!err.has_member(valafn)) {",
363 " print(\"File path has no errors\\n\");",
367 " var lines = err.get_object_member(valafn);",
370 " if (obj.has_member(\"line_offset\")) {",
371 " offset = (int)obj.get_int_member(\"line_offset\") + 1;",
377 " var tlines = this.el.get_line_count () +1;",
379 " lines.foreach_member((obj, line, node) => {",
381 " Gtk.TextIter iter;",
382 " // print(\"get inter\\n\");",
383 " var eline = int.parse(line) - offset;",
384 " print(\"GOT ERROR on line %s -- converted to %d\\n\", line,eline);",
387 " if (eline > tlines || eline < 0) {",
390 " this.el.get_iter_at_line( out iter, eline);",
391 " //print(\"mark line\\n\");",
392 " var msg = \"Line: %d\".printf(eline+1);",
393 " var ar = lines.get_array_member(line);",
394 " for (var i = 0 ; i < ar.get_length(); i++) {",
395 "\t\t msg += (msg.length > 0) ? \"\\n\" : \"\";",
396 "\t\t msg += ar.get_string_element(i);",
400 " this.el.create_source_mark(msg, type, iter);",
411 "| string toString" : [
416 " this.el.get_start_iter(out s);",
417 " this.el.get_end_iter(out e);",
418 " var ret = this.el.get_text(s,e,true);",
419 " //print(\"TO STRING? \" + ret);",
427 "key_release_event" : [
430 " if (event.keyval == 115 && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
431 " print(\"SAVE: ctrl-S pressed\");",
432 " _this.saveContents();",
435 " // print(event.key.keyval)",
444 "uint tab_width" : 4,
445 "xtype" : "SourceView",
449 "// show the help page for the active node..",
450 " //this.get('/Help').show();",
453 " // this.get('/BottomPane').el.set_current_page(0);",
454 " var buf = (Gtk.SourceBuffer)this.el.get_buffer();",
455 " buf.set_text(str, str.length);",
456 " buf.set_undo_manager(null);",
458 " var lm = Gtk.SourceLanguageManager.get_default();",
459 " var lang = \"vala\";",
460 " if (_this.file != null) {",
461 " lang = _this.file.language;",
463 " print(\"lang=%s, content_type = %s\\n\", lang, _this.file.content_type);",
464 " var lg = _this.file.content_type.length > 0 ?",
465 " lm.guess_language(_this.file.path, _this.file.content_type) :",
466 " lm.get_language(lang);",
469 " ((Gtk.SourceBuffer)(this.el.get_buffer())) .set_language(lg); ",
471 " this.el.insert_spaces_instead_of_tabs = true;",
472 " if (lg != null) {",
473 "\t\tprint(\"sourcelanguage = %s\\n\", lg.name);",
474 "\t\tif (lg.name == \"Vala\") {",
475 "\t\t this.el.insert_spaces_instead_of_tabs = false;",
478 " _this.dirty = false;",
479 " this.el.grab_focus();",
480 " _this.save_button.el.sensitive = false;",
485 "xtype" : "ScrolledWindow"
489 "| bool saveContents" : [
493 " if (_this.file == null) {",
499 " var str = _this.buffer.toString();",
501 " _this.buffer.checkSyntax();",
505 " // LeftPanel.model.changed( str , false);",
506 " _this.dirty = false;",
507 " _this.save_button.el.sensitive = false;",
509 " // find the text for the node..",
510 " if (_this.file.xtype != \"PlainFile\") {",
511 " // in theory these properties have to exist!?!",
512 " \tthis.prop.val = str;",
513 " this.window.windowstate.left_props.reload();",
515 " _this.file.setSource( str );",
518 " // call the signal..",
528 "\tvar s = new Gtk.SourceSearchSettings();",
530 "\tthis.searchcontext = new Gtk.SourceSearchContext(this.buffer.el,s);",
531 "\tthis.searchcontext .set_highlight(true);",
532 "\ts.set_search_text(txt);",
533 "\tGtk.TextIter beg, st,en;",
535 "\tthis.buffer.el.get_start_iter(out beg);",
536 "\tthis.searchcontext.forward(beg, out st, out en);",
537 "\tthis.last_search_end = 0;",
539 "\treturn this.searchcontext.get_occurrences_count();",
547 "| void forwardSearch" : [
548 "(bool change_focus) {",
550 "\tif (this.searchcontext == null) {",
554 "\tGtk.TextIter beg, st,en;",
556 "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end);",
557 "\tif (!this.searchcontext.forward(beg, out st, out en)) {",
559 "\t\tthis.last_search_end = 0;",
561 "\t\tthis.last_search_end = en.get_offset();",
562 "\t\tif (change_focus) {",
563 "\t\t\tthis.view.el.grab_focus();",
565 "\t\tthis.buffer.el.place_cursor(st);",
566 "\t\tthis.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);",
574 "\t this.file = null; ",
576 " this.node = null;",
577 " this.prop = null;",
578 "\tthis.searchcontext = null;",
583 "| void scroll_to_line" : [
586 "\tGLib.Timeout.add(500, () => {",
588 "\t\tvar buf = this.view.el.get_buffer();",
590 "\t\tvar sbuf = (Gtk.SourceBuffer) buf;",
593 "\t\tGtk.TextIter iter; ",
594 "\t\tsbuf.get_iter_at_line(out iter, line);",
595 "\t\tthis.view.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
602 "(JsRender.JsRender file, JsRender.Node? node, JsRender.NodeProp? prop)",
605 " this.file = file; ",
607 " if (file.xtype != \"PlainFile\") {",
608 " \tthis.prop = prop;",
609 " this.node = node;",
611 " // find the text for the node..",
612 " this.view.load( prop.val );",
613 " this.key_edit.el.show();",
614 " this.key_edit.el.text = prop.rtype + \" \" + prop.name; ",
617 " this.view.load( file.toSource() );",
618 " this.key_edit.el.hide();",
628 "path" : "/home/alan/gitlive/roobuilder/src/Builder4/Editor.bjs",