}
public void requestRedraw () {
this.view.renderJS(false);
+ this.sourceview.loadFile();
}
public void forwardSearch (bool change_focus) {
// my vars (def)
public bool loading;
public bool allow_node_scroll;
+ public string propSelected;
// ctor
public Xcls_sourceview(Xcls_WindowRooView _owner )
// my vars (dec)
this.loading = true;
this.allow_node_scroll = true;
+ this.propSelected = "";
// set gobject values
this.el.editable = false;
this.el.override_font(description);
this.loading = true;
- var buf = this.el.get_buffer();
- buf.notify.connect((ps) => {
- if (this.loading) {
- return;
- }
- if (ps.name != "cursor-position") {
- return;
- }
- 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();
-
- var node = _this.file.lineToNode(ln);
-
- if (node == null) {
- print("can not find node\n");
- return;
- }
- var ltree = _this.main_window.windowstate.left_tree;
- var tp = ltree.model.treePathFromNode(node);
- print("got tree path %s\n", tp);
- if (tp != "") {
- this.allow_node_scroll = false;
- print("changing cursor on tree..\n");
- ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false);
- // scrolling is disabled... as node selection calls scroll 10ms after it changes.
- GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {
- this.allow_node_scroll = true;
- return false;
- });
- }
-
- // highlight the node..
-
- });
+ //var buf = this.el.get_buffer();
+ //buf.notify.connect(this.onCursorChanged);
}
+
+ //listeners
+ this.el.button_release_event.connect( () => {
+ this.onCursorChanged();
+
+ return false;
+ });
}
// user defined functions
+ public void onCursorChanged (/*ParamSpec ps*/) {
+ 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();
+ print("cursor changed line : %d\n", ln);
+ var node = _this.file.lineToNode(ln+1);
+
+ if (node == null) {
+ print("can not find node\n");
+ return;
+ }
+ var prop = node.lineToProp(ln+1);
+ print("prop : %s", prop == null ? "???" : prop);
+
+
+
+
+
+
+ var ltree = _this.main_window.windowstate.left_tree;
+ var tp = ltree.model.treePathFromNode(node);
+ print("got tree path %s\n", tp);
+ if (tp != "") {
+ this.allow_node_scroll = false; /// block node scrolling..
+
+
+ //print("changing cursor on tree..\n");
+
+
+
+ // let's try allowing editing on the methods.
+ // a little klunky at present..
+ this.propSelected = "";
+ if (prop != null) {
+ //see if we can find it..
+ var kv = prop.split(":");
+ if (kv[0] == "p") {
+
+ //var k = prop.get_key(kv[1]);
+ // fixme -- need to determine if it's an editable property...
+ this.propSelected = prop;
+
+ } else if (kv[0] == "l") {
+ this.propSelected = prop;
+
+ }
+ }
+ ltree.view.setCursor(tp, "editor");
+ // ltree.view.el.set_cursor(new Gtk.TreePath.from_string(tp), null, false);
+ this.nodeSelected(node);
+
+ // scrolling is disabled... as node selection calls scroll 10ms after it changes.
+ GLib.Timeout.add_full(GLib.Priority.DEFAULT,100 , () => {
+ this.allow_node_scroll = true;
+ return false;
+ });
+ }
+
+ // highlight the node..
+ }
public void nodeSelected (JsRender.Node? sel) {
// clear all the marks..
- Gtk.TextIter start;
+ Gtk.TextIter start;
Gtk.TextIter end;
sbuf.get_bounds (out start, out end);
this.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);
}
-
+ var start_line = sel.line_start;
+ var end_line = sel.line_end;
+
+
+ this.el.editable = false;
+ // now if we have selected a property...
+ if (this.propSelected.length> 0 ) {
+
+ int nstart, nend;
+ if (sel.getPropertyRange(this.propSelected, out nstart, out nend) && nend > nstart) {
+ start_line = nstart;
+ end_line = nend;
+ this.el.editable = true;
+ }
+ print("propSelected = %s range %d -> %d\n", this.propSelected, nstart, nend);
+
+
+ }
+
+
for (var i = 0; i < buf.get_line_count();i++) {
- if (i < sel.line_start || i > sel.line_end) {
+ if (i < (start_line -1) || i > (end_line -1)) {
sbuf.get_iter_at_line(out iter, i);
sbuf.create_source_mark(null, "grey", iter);
if (_this.file == null || _this.file.xtype != "Roo") {
- print("xtype != Gtk");
+ print("xtype != Roo");
this.loading = false;
return;
}
- var valafn = "";
- try {
- var regex = new Regex("\\.bjs$");
-
-
- valafn = regex.replace(_this.file.path,_this.file.path.length , 0 , ".js");
- } catch (GLib.RegexError e) {
- this.loading = false;
- return;
- }
-
-
- if (!FileUtils.test(valafn,FileTest.IS_REGULAR) ) {
- print("File path has no errors\n");
- this.loading = false;
- return ;
- }
-
- string str;
- try {
-
- GLib.FileUtils.get_contents (valafn, out str);
- } catch (Error e) {
- this.loading = false;
- return ;
- }
-
+ // get the string from the rendered tree...
+
+ var str = _this.file.toSource();
+
// print("setting str %d\n", str.length);
buf.set_text(str, str.length);
var lm = Gtk.SourceLanguageManager.get_default();