2 "build_module" : "builder",
5 "# JsRender.JsRender file" : "null",
6 "# JsRender.Node node" : "null",
7 "# Xcls_MainWindow window" : "null",
8 "# bool dirty" : false,
10 "# int pos_root_x" : "",
11 "# int pos_root_y" : "",
12 "# string activeEditor" : "\"\"",
13 "# string key" : "\"\"",
14 "# string ptype" : "\"\"",
15 "$ homogeneous" : false,
19 "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
20 "Gtk.SourceSearchContext searchcontext" : "null",
21 "bool hexpand" : true,
22 "bool vexpand" : true,
23 "int last_search_end" : 0,
26 "$ homogeneous" : false,
28 "* pack" : "pack_start,false,true",
29 "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
33 "* pack" : "pack_start,false,false",
39 " _this.saveContents();",
48 "* pack" : "pack_start,true,true",
49 "bool editable" : false,
51 "int width_request" : 100,
56 "* ctor" : "new Gtk.HScale.with_range (6, 30, 1)",
59 "\tthis.el.set_range(6,30);",
60 "\tthis.el.set_value(8);",
64 "* pack" : "pack_end,true,true",
65 "bool draw_value" : true,
66 "bool has_origin" : true,
67 "bool sensitive" : true,
73 "\t var description = Pango.FontDescription.from_string(\"monospace\");",
74 "\t print(\"resize to %d\", (int)val*1000);",
75 " description.set_size((int)val*1000);",
76 " _this.view.el.override_font(description);",
88 "* init" : "this.el.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);",
89 "* pack" : "pack_end,true,true",
93 "$ Gtk.SourceDrawSpacesFlags draw_spaces" : "Gtk.SourceDrawSpacesFlags.LEADING + Gtk.SourceDrawSpacesFlags.TRAILING + Gtk.SourceDrawSpacesFlags.TAB + Gtk.SourceDrawSpacesFlags.SPACE",
94 "$ gboolean auto_indent" : true,
95 "$ show_line_numbers" : true,
100 "\t\tvar description = Pango.FontDescription.from_string(\"monospace\");",
101 "\t\tdescription.set_size(8000);",
103 "\t\t this.el.override_font(description);",
106 "\t\tthis.el.completion.add_provider(new Palete.CompletionProvider(_this));",
107 " } catch (GLib.Error e) {}",
109 "\tthis.el.completion.unblock_interactive();",
110 "\tthis.el.completion.select_on_show\t\t\t= true; // select",
111 "\tthis.el.completion.show_headers\t\t\t= false;",
112 "\tthis.el.completion.remember_info_visibility\t\t= true;",
115 " var attrs = new Gtk.SourceMarkAttributes();",
116 " var pink = Gdk.RGBA();",
117 " pink.parse ( \"pink\");",
118 " attrs.set_background ( pink);",
119 " attrs.set_icon_name ( \"process-stop\"); ",
120 " attrs.query_tooltip_text.connect(( mark) => {",
121 " //print(\"tooltip query? %s\\n\", mark.name);",
122 " return mark.name;",
125 " this.el.set_mark_attributes (\"ERR\", attrs, 1);",
127 " var wattrs = new Gtk.SourceMarkAttributes();",
128 " var blue = Gdk.RGBA();",
129 " blue.parse ( \"#ABF4EB\");",
130 " wattrs.set_background ( blue);",
131 " wattrs.set_icon_name ( \"process-stop\"); ",
132 " wattrs.query_tooltip_text.connect(( mark) => {",
133 " //print(\"tooltip query? %s\\n\", mark.name);",
134 " return mark.name;",
137 " this.el.set_mark_attributes (\"WARN\", wattrs, 1);",
141 " var dattrs = new Gtk.SourceMarkAttributes();",
142 " var purple = Gdk.RGBA();",
143 " purple.parse ( \"#EEA9FF\");",
144 " dattrs.set_background ( purple);",
145 " dattrs.set_icon_name ( \"process-stop\"); ",
146 " dattrs.query_tooltip_text.connect(( mark) => {",
147 " //print(\"tooltip query? %s\\n\", mark.name);",
148 " return mark.name;",
151 " this.el.set_mark_attributes (\"DEPR\", dattrs, 1);",
156 "bool insert_spaces_instead_of_tabs" : true,
157 "gboolean highlight_current_line" : true,
158 "gboolean show_line_marks" : true,
164 "* pack" : "set_buffer",
165 "bool check_queued" : false,
166 "bool check_running" : false,
168 "int error_line" : "-1",
172 " // check syntax??",
174 " _this.save_button.el.sensitive = true;",
175 " print(\"EDITOR CHANGED\");",
176 " this.checkSyntax();",
178 " _this.dirty = true;",
180 " // this.get('/LeftPanel.model').changed( str , false);",
188 "xtype" : "SourceBuffer",
189 "| bool checkSyntax" : [
192 " if (this.check_running) {",
193 " print(\"Check is running\\n\");",
194 " if (this.check_queued) { ",
195 " print(\"Check is already queued\");",
198 " this.check_queued = true;",
199 " print(\"Adding queued Check \");",
200 " GLib.Timeout.add_seconds(1, () => {",
201 " this.check_queued = false;",
203 " this.checkSyntax();",
210 " var str = this.toString();",
213 " if (this.error_line > 0) {",
214 " Gtk.TextIter start;",
215 " Gtk.TextIter end; ",
216 " this.el.get_bounds (out start, out end);",
218 " this.el.remove_source_marks (start, end, null);",
220 " if (str.length < 1) {",
221 " print(\"checkSyntax - empty string?\\n\");",
225 " if (_this.file.xtype == \"PlainFile\") {",
227 " // assume it's gtk...",
228 " this.check_running = true;",
230 " if (!_this.window.windowstate.valasource.checkPlainFileSpawn(",
234 " this.check_running = false;",
240 " if (_this.file == null) {",
243 " var p = _this.file.project.palete;",
247 " this.check_running = true;",
250 " if (_this.file.language == \"js\") {",
251 " this.check_running = false;",
252 " print(\"calling validate javascript\\n\"); ",
253 " Gee.HashMap<int,string> errors;",
254 " p.javascriptHasErrors(",
255 " \t\t_this.window.windowstate,",
263 " return this.highlightErrors(errors); ",
268 " print(\"calling validate vala\\n\"); ",
269 " // clear the buttons.",
272 " if (! _this.window.windowstate.valasource.checkFileWithNodePropChange(",
279 " this.check_running = false;",
284 " //print(\"done mark line\\n\");",
286 " return true; // at present allow saving - even if it's invalid..",
290 "| string toString" : [
295 " this.el.get_start_iter(out s);",
296 " this.el.get_end_iter(out e);",
297 " var ret = this.el.get_text(s,e,true);",
298 " //print(\"TO STRING? \" + ret);",
303 "| bool highlightErrors" : [
304 "( Gee.HashMap<int,string> validate_res) {",
306 " this.error_line = validate_res.size;",
308 " if (this.error_line < 1) {",
311 " var tlines = this.el.get_line_count ();",
312 " Gtk.TextIter iter;",
313 " var valiter = validate_res.map_iterator();",
314 " while (valiter.next()) {",
316 " // print(\"get inter\\n\");",
317 " var eline = valiter.get_key();",
318 " if (eline > tlines) {",
321 " this.el.get_iter_at_line( out iter, eline);",
322 " //print(\"mark line\\n\");",
323 " this.el.create_source_mark(valiter.get_value(), \"ERR\", iter);",
328 "| bool highlightErrorsJson" : [
329 "(string type, Json.Object obj) {",
330 " Gtk.TextIter start;",
331 " Gtk.TextIter end; ",
332 " this.el.get_bounds (out start, out end);",
334 " this.el.remove_source_marks (start, end, type);",
337 " // we should highlight other types of errors..",
339 " if (!obj.has_member(type)) {",
340 " print(\"Return has no errors\\n\");",
344 " if (_this.window.windowstate.state != WindowState.State.CODEONLY ",
351 " var err = obj.get_object_member(type);",
354 " if (_this.file == null) {",
358 " var valafn = _this.file.path;",
360 " if (_this.file.xtype != \"PlainFile\") {",
367 " var regex = new Regex(\"\\\\.bjs$\");",
368 " // should not happen",
371 " valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , \".vala\");",
372 " } catch (GLib.RegexError e) {",
379 " if (!err.has_member(valafn)) {",
380 " print(\"File path has no errors\\n\");",
384 " var lines = err.get_object_member(valafn);",
387 " if (obj.has_member(\"line_offset\")) {",
388 " offset = (int)obj.get_int_member(\"line_offset\") + 1;",
394 " var tlines = this.el.get_line_count () +1;",
396 " lines.foreach_member((obj, line, node) => {",
398 " Gtk.TextIter iter;",
399 " // print(\"get inter\\n\");",
400 " var eline = int.parse(line) - offset;",
401 " print(\"GOT ERROR on line %s -- converted to %d\\n\", line,eline);",
404 " if (eline > tlines || eline < 0) {",
407 " this.el.get_iter_at_line( out iter, eline);",
408 " //print(\"mark line\\n\");",
409 " var msg = \"Line: %d\".printf(eline+1);",
410 " var ar = lines.get_array_member(line);",
411 " for (var i = 0 ; i < ar.get_length(); i++) {",
412 "\t\t msg += (msg.length > 0) ? \"\\n\" : \"\";",
413 "\t\t msg += ar.get_string_element(i);",
417 " this.el.create_source_mark(msg, type, iter);",
431 "key_release_event" : [
434 " if (event.keyval == 115 && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {",
435 " print(\"SAVE: ctrl-S pressed\");",
436 " _this.saveContents();",
439 " // print(event.key.keyval)",
448 "uint tab_width" : 4,
449 "xtype" : "SourceView",
453 "// show the help page for the active node..",
454 " //this.get('/Help').show();",
457 " // this.get('/BottomPane').el.set_current_page(0);",
458 " var buf = (Gtk.SourceBuffer)this.el.get_buffer();",
459 " buf.set_text(str, str.length);",
460 " buf.set_undo_manager(null);",
462 " var lm = Gtk.SourceLanguageManager.get_default();",
463 " var lang = \"vala\";",
464 " if (_this.file != null) {",
465 " lang = _this.file.language;",
467 " print(\"lang=%s, content_type = %s\\n\", lang, _this.file.content_type);",
468 " var lg = _this.file.content_type.length > 0 ?",
469 " lm.guess_language(_this.file.path, _this.file.content_type) :",
470 " lm.get_language(lang);",
473 " ((Gtk.SourceBuffer)(this.el.get_buffer())) .set_language(lg); ",
475 " this.el.insert_spaces_instead_of_tabs = true;",
476 " if (lg != null) {",
477 "\t\tprint(\"sourcelanguage = %s\\n\", lg.name);",
478 "\t\tif (lg.name == \"Vala\") {",
479 "\t\t this.el.insert_spaces_instead_of_tabs = false;",
482 " _this.dirty = false;",
483 " this.el.grab_focus();",
484 " _this.save_button.el.sensitive = false;",
489 "xtype" : "ScrolledWindow"
492 "string id" : "Editor",
494 "| bool saveContents" : [
498 " if (_this.file == null) {",
506 " var str = _this.buffer.toString();",
508 " _this.buffer.checkSyntax();",
512 " // LeftPanel.model.changed( str , false);",
513 " _this.dirty = false;",
514 " _this.save_button.el.sensitive = false;",
516 " // find the text for the node..",
517 " if (_this.file.xtype != \"PlainFile\") {",
518 " if (ptype == \"listener\") {",
519 " this.node.listeners.set(key,str);",
522 " this.node.props.set(key,str);",
525 " _this.file.setSource( str );",
528 " // call the signal..",
536 "(JsRender.JsRender file, JsRender.Node? node, string ptype, string key)",
538 " this.file = file; ",
539 " this.ptype = \"\";",
541 " this.node = null;",
542 "\tthis.searchcontext = null;",
544 " if (file.xtype != \"PlainFile\") {",
546 " this.ptype = ptype;",
548 " this.node = node;",
549 " string val = \"\";",
550 " // find the text for the node..",
551 " if (ptype == \"listener\") {",
552 " val = node.listeners.get(key);",
555 " val = node.props.get(key);",
557 " this.view.load(val);",
558 " this.key_edit.el.show();",
559 " this.key_edit.el.text = key; ",
562 " this.view.load( file.toSource() );",
563 " this.key_edit.el.hide();",
571 "\tvar s = new Gtk.SourceSearchSettings();",
573 "\tthis.searchcontext = new Gtk.SourceSearchContext(this.buffer.el,s);",
574 "\tthis.searchcontext .set_highlight(true);",
575 "\ts.set_search_text(txt);",
576 "\tGtk.TextIter beg, st,en;",
578 "\tthis.buffer.el.get_start_iter(out beg);",
579 "\tthis.searchcontext.forward(beg, out st, out en);",
580 "\tthis.last_search_end = 0;",
582 "\treturn this.searchcontext.get_occurrences_count();",
590 "| void forwardSearch" : [
591 "(bool change_focus) {",
593 "\tif (this.searchcontext == null) {",
597 "\tGtk.TextIter beg, st,en;",
599 "\tthis.buffer.el.get_iter_at_offset(out beg, this.last_search_end);",
600 "\tif (!this.searchcontext.forward(beg, out st, out en)) {",
602 "\t\tthis.last_search_end = 0;",
604 "\t\tthis.last_search_end = en.get_offset();",
605 "\t\tif (change_focus) {",
606 "\t\t\tthis.view.el.grab_focus();",
608 "\t\tthis.buffer.el.place_cursor(st);",
609 "\t\tthis.view.el.scroll_to_iter(st, 0.1f, true, 0.0f, 0.5f);",
615 "| void scroll_to_line" : [
618 "\tGLib.Timeout.add(500, () => {",
620 "\t\tvar buf = this.view.el.get_buffer();",
622 "\t\tvar sbuf = (Gtk.SourceBuffer) buf;",
625 "\t\tGtk.TextIter iter; ",
626 "\t\tsbuf.get_iter_at_line(out iter, line);",
627 "\t\tthis.view.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
638 "path" : "/home/alan/gitlive/roobuilder/src/Builder4/Editor.bjs",