"$ xns" : "GtkSource",
"* pack" : "set_buffer",
"bool dirty" : false,
+ "bool in_cursor_change" : false,
"id" : "buffer",
"int error_line" : "-1",
+ "int last_line" : "-1",
"listeners" : {
"changed" : [
" () => {",
"",
" ",
""
+ ],
+ "cursor_moved" : [
+ "( ) => {",
+ "GLib.debug(\"cursor moved called\");",
+ "",
+ "",
+ " \tif (this.in_cursor_change ) {",
+ " GLib.debug(\"cursor changed : %d [ignoring nested call)\", this.el.cursor_position);",
+ " return;",
+ " }",
+ " ",
+ " GLib.debug(\"cursor changed : %d\", this.el.cursor_position);",
+ " Gtk.TextIter cpos;",
+ " this.el.get_iter_at_offset(out cpos, this.el.cursor_position);",
+ " ",
+ " var ln = cpos.get_line();",
+ " if (this.last_line == ln ){",
+ " \treturn;",
+ "\t}",
+ "\tthis.last_line = ln;",
+ " var node = _this.file.lineToNode(ln);",
+ "",
+ " if (node == null) {",
+ " print(\"can not find node\\n\");",
+ " return;",
+ " }",
+ " this.in_cursor_change = true;",
+ " var ltree = _this.main_window.windowstate.left_tree;",
+ " ltree.model.selectNode(node);",
+ " this.in_cursor_change = false;",
+ "}",
+ ""
]
},
"xtype" : "Buffer",
]
},
"xtype" : "EventControllerKey"
- },
- {
- "$ xns" : "Gtk",
- "listeners" : {
- "released" : [
- "(n_press, x, y) => {",
- "",
- "\tprint(\"BUTTON RELEASE EVENT\\n\");",
- "\t_this.sourceview.onCursorChanged();",
- "\t//this.button_is_pressed = false;",
- "\t ",
- "}",
- ""
- ]
- },
- "xtype" : "GestureClick"
}
],
"listeners" : {
" ",
" _this.main_window.windowstate.updateErrorMarksAll();",
" ",
- " // what does this do?",
+ " // restore the cursor position?",
+ " // after reloading the contents.",
" GLib.Timeout.add(500, () => {",
- "",
+ "\t\t_this.buffer.in_cursor_change = true;",
" print(\"RESORTING cursor to = %d\\n\", cpos);",
"\t\tGtk.TextIter cpos_iter;",
"\t\tbuf.get_iter_at_offset(out cpos_iter, cpos);",
"\t\tbuf.place_cursor(cpos_iter); ",
"\t\t",
"\t\tthis.el.get_vadjustment().set_value(vadj_pos);;",
- "\t\t",
- "",
- "\t\tthis.onCursorChanged();",
+ "\t\t_this.buffer.in_cursor_change = false;",
+ " ",
"\t\t",
"\t\t",
"\t\t//_this.buffer.checkSyntax();",
""
],
"| void nodeSelected" : [
- "(JsRender.Node? sel, bool scroll ) {",
+ "(JsRender.Node? sel, bool scroll) {",
" ",
" ",
- "\t",
+ " if (this.loading) {",
+ " \treturn;",
+ "\t}",
" // this is connected in widnowstate",
+ " print(\"Roo-view - node selected\\n\");",
+ " var buf = this.el.get_buffer();",
+ " ",
+ " var sbuf = (GtkSource.Buffer) buf;",
"",
- "",
- "\t// not sure why.... ",
- " // while(Gtk.events_pending()) {",
- " // Gtk.main_iteration();",
- " // }",
" ",
- " this.node_selected = sel;",
" ",
- " // this.updateGreySelection(scroll);",
+ " ",
+ " // clear all the marks..",
+ " Gtk.TextIter start;",
+ " Gtk.TextIter end; ",
+ " ",
+ " sbuf.get_bounds (out start, out end);",
+ " sbuf.remove_source_marks (start, end, \"grey\");",
" ",
+ " this.node_selected = sel;",
+ " if (sel == null) {",
+ " // no highlighting..",
+ " return;",
+ " }",
+ " Gtk.TextIter iter; ",
+ " sbuf.get_iter_at_line(out iter, sel.line_start);",
" ",
" ",
- "}",
- "",
- " ",
- ""
- ],
- "| void onCursorChanged" : [
- "(/*ParamSpec ps*/) {",
- "",
- "\t\tif (!this.key_is_pressed && !this.button_is_pressed) {",
- "\t\t\treturn;",
- "\t\t}",
- "",
- "\t if (this.loading) {",
- " return;",
- " }",
- " // if (ps.name != \"cursor-position\") {",
- " // return;",
- " // }",
- "",
- " var buf = this.el.get_buffer();",
- " //print(\"cursor changed : %d\\n\", buf.cursor_position);",
- " Gtk.TextIter cpos;",
- " buf.get_iter_at_offset(out cpos, buf.cursor_position);",
- " ",
- " var ln = cpos.get_line();",
- " ",
- " ",
- " // --- select node at line....",
- " ",
- " var node = _this.file.lineToNode(ln+1);",
- " ",
- " if (node == null) {",
- " print(\"can not find node\\n\");",
- " return;",
+ " Gtk.TextIter cur_iter;",
+ " sbuf.get_iter_at_offset(out cur_iter, sbuf.cursor_position);",
+ " ",
+ " //var cur_line = cur_iter.get_line();",
+ " //if (cur_line > sel.line_start && cur_line < sel.line_end) {",
+ " ",
+ " //} else {",
+ " if (! _this.buffer.in_cursor_change) {",
+ " \tthis.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);",
+ "\t}",
+ " ",
+ " ",
+ " ",
+ " for (var i = 0; i < buf.get_line_count();i++) {",
+ " if (i < sel.line_start || i > sel.line_end) {",
+ " ",
+ " sbuf.get_iter_at_line(out iter, i);",
+ " sbuf.create_source_mark(null, \"grey\", iter);",
+ " ",
" }",
- " var prop = node.lineToProp(ln+1);",
- " print(\"prop : %s\", prop == null ? \"???\" : prop.name);",
- " ",
- " ",
- " // ---------- this selects the tree's node...",
- " ",
- " var ltree = _this.main_window.windowstate.left_tree;",
- " ltree.model.selectNode(node);",
- " ",
- "\t ",
- " //print(\"changing cursor on tree..\\n\");",
- " ",
+ " ",
+ " }",
+ " ",
"",
- " ",
- " // let's try allowing editing on the methods.",
- " // a little klunky at present..",
- " this.prop_selected = \"\";",
- " /*",
- " if (prop != null) {",
- " \t\t//see if we can find it..",
- " \t\tvar kv = prop.split(\":\");",
- " \t\tif (kv[0] == \"p\") {",
- " \t\t",
- " \t\t//var k = prop.get_key(kv[1]);",
- " \t\t// fixme -- need to determine if it's an editable property...",
- " \t\tthis.prop_selected = prop;",
- " \t\t",
- " \t\t} else if (kv[0] == \"l\") {",
- " \t\t\t this.prop_selected = prop;",
- " \t\t\t",
- " \t\t}",
- " }",
- " */",
- " // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false); ",
- " //this.nodeSelected(node,false);",
- " ",
- " // scrolling is disabled... as node selection calls scroll 10ms after it changes.",
- " ",
- " ",
- " // highlight the node..",
"}",
- " "
+ ""
],
"| void updateGreySelection" : [
"(bool scroll) { ",