// my vars (def)
public bool loading;
public bool allow_node_scroll;
- public string propSelected;
+ public string prop_selected;
+ public JsRender.Node? node_selected;
// ctor
public Xcls_sourceview(Xcls_WindowRooView _owner )
// my vars (dec)
this.loading = true;
this.allow_node_scroll = true;
- this.propSelected = "";
+ this.prop_selected = "";
+ this.node_selected = null;
// set gobject values
this.el.editable = false;
-
+ // ---------- this selects the tree's node...
var ltree = _this.main_window.windowstate.left_tree;
var tp = ltree.model.treePathFromNode(node);
// let's try allowing editing on the methods.
// a little klunky at present..
- this.propSelected = "";
+ this.prop_selected = "";
if (prop != null) {
//see if we can find it..
var kv = prop.split(":");
//var k = prop.get_key(kv[1]);
// fixme -- need to determine if it's an editable property...
- this.propSelected = prop;
+ this.prop_selected = prop;
} else if (kv[0] == "l") {
- this.propSelected = prop;
+ this.prop_selected = prop;
}
}
}
// highlight the node..
+ }
+ public void clearGreySelection () {
+ // clear all the marks..
+ Gtk.TextIter start;
+ Gtk.TextIter end;
+
+ sbuf.get_bounds (out start, out end);
+ sbuf.remove_source_marks (start, end, "grey");
+
+
}
public void nodeSelected (JsRender.Node? sel, bool scroll ) {
-
+
// this is connected in widnowstate
- print("node selected\n");
- var buf = this.el.get_buffer();
-
- var sbuf = (Gtk.SourceBuffer) buf;
-
+
+ // not sure why....
while(Gtk.events_pending()) {
Gtk.main_iteration();
}
+ this.node_selected = sel;
+
+ print("node selected\n");
+ var buf = this.el.get_buffer();
+ var sbuf = (Gtk.SourceBuffer) buf;
+
+
+ this.clearGreySelection();
+
+
- // clear all the marks..
- Gtk.TextIter start;
- Gtk.TextIter end;
-
- sbuf.get_bounds (out start, out end);
- sbuf.remove_source_marks (start, end, "grey");
-
-
if (sel == null) {
print("no selected node\n");
// no highlighting..
this.el.editable = false;
- var before_cursor_string = "";
+ var colon_pos = 0;
+
// now if we have selected a property...
- if (this.propSelected.length> 0 ) {
+ if (this.prop_selected.length> 0 ) {
int nstart, nend;
- if (sel.getPropertyRange(this.propSelected, out nstart, out nend) && nend > nstart) {
+ if (sel.getPropertyRange(this.prop_selected, out nstart, out nend) && nend > nstart) {
start_line = nstart;
end_line = nend;
this.el.editable = true;
+ print("start line = %d, end line = %d\n", start_line, end_line);
- if (start_line == cursor_at_line) {
// see if we are 'right of ':'
// get an iter for the start of the line.
- Gtk.TextIter start_line_iter;
- this.el.buffer.get_iter_at_line(out start_line_iter, cursor_at_line);
+ Gtk.TextIter start_line_iter,end_line_iter;
+ this.el.buffer.get_iter_at_line(out start_line_iter, start_line -1);
+ this.el.buffer.get_iter_at_line(out end_line_iter, start_line -1);
+
+
+
+
+ if (end_line_iter.forward_to_line_end()) {
+ var first_line = this.el.buffer.get_text(start_line_iter, end_line_iter, false);
+ print("first line = %s\n", first_line);
+ if (first_line.contains(":")) {
+ colon_pos = start_line_iter.get_offset() + first_line.index_of(":");
+ }
+ print("colon_pos = %d\n", colon_pos);
+ }
+ print("is cursor at line? %d ?= %d\n", start_line -1 , cursor_at_line);
+ if (start_line - 1 == cursor_at_line) {
+ print("cursor is on current line.\n");
var before_cursor_string = this.el.buffer.get_text(start_line_iter, cur_iter, false);
+ print("before cursor string = %s\n", before_cursor_string);
if (!before_cursor_string.contains(":")) {
this.el.editable = false;
}
}
- print("propSelected = %s range %d -> %d\n", this.propSelected, start_line, end_line);
+ print("propSelected = %s range %d -> %d\n", this.prop_selected, start_line, end_line);
}
-
+ print("checking selection\n");
// check selection - if it's out of 'bounds'
// save?
this.el.editable = false;
}
+ if (colon_pos > 0 &&
+ (sel_start_iter.get_offset() < colon_pos || sel_end_iter.get_offset() < colon_pos)
+
+ ) {
+ this.el.editable = false;
+ }
+
+
}