public Xcls_view view;
public Xcls_inspectorcontainer inspectorcontainer;
public Xcls_sourceview sourceview;
+ public Xcls_buffer buffer;
// my vars (def)
public Gtk.Widget lastObj;
this.el.editable = false;
this.el.show_line_marks = true;
this.el.show_line_numbers = true;
+ var child_0 = new Xcls_buffer( _this );
+ child_0.ref();
+ this.el.set_buffer ( child_0.el );
// init method
//} else {
if (scroll) {
-
+ print("scrolling to node -- should occur on node picking.\n");
this.el.scroll_to_iter(iter, 0.1f, true, 0.0f, 0.5f);
}
end_line = nend;
this.el.editable = true;
}
- print("propSelected = %s range %d -> %d\n", this.propSelected, nstart, nend);
+ print("propSelected = %s range %d -> %d\n", this.propSelected, start_line, end_line);
}
var buf = this.el.get_buffer();
var cpos = buf.cursor_position;
-
+ print("BEFORE LOAD cursor = %d\n", cpos);
- var vadj = this.el.get_vadjustment();
+ var vadj_pos = this.el.get_vadjustment().get_value();
- var buf = this.el.get_buffer();
+
buf.set_text("",0);
var sbuf = (Gtk.SourceBuffer) buf;
sbuf.get_bounds (out start, out end);
sbuf.remove_source_marks (start, end, null); // remove all marks..
- Gtk.TextIter cpos_iter;
- buf.get_iter_at_offset(out cpos_iter, cpos);
- buf.place_cursor(cpos_iter);
-
- this.el.set_vadjustment(vadj);
-
-
-
+ GLib.Timeout.add(500, () => {
+
+ print("RESORTING cursor to = %d\n", cpos);
+ Gtk.TextIter cpos_iter;
+ buf.get_iter_at_offset(out cpos_iter, cpos);
+ buf.place_cursor(cpos_iter);
+
+ this.el.get_vadjustment().set_value(vadj_pos);;
+ this.onCursorChanged();
+ return false;
+ });
+
this.loading = false;
+ _this.buffer.dirty = false;
}
public void highlightErrorsJson (string type, Json.Object obj) {
Gtk.TextIter start;
}
}
+ public class Xcls_buffer : Object
+ {
+ public Gtk.SourceBuffer el;
+ private Xcls_WindowRooView _this;
+
+
+ // my vars (def)
+ public bool check_queued;
+ public bool dirty;
+ public int error_line;
+ public bool check_running;
+
+ // ctor
+ public Xcls_buffer(Xcls_WindowRooView _owner )
+ {
+ _this = _owner;
+ _this.buffer = this;
+ this.el = new Gtk.SourceBuffer( null );
+
+ // my vars (dec)
+ this.check_queued = false;
+ this.dirty = false;
+ this.error_line = -1;
+ this.check_running = false;
+
+ // set gobject values
+
+ //listeners
+ this.el.changed.connect( () => {
+ // check syntax??
+ // ??needed..??
+ // _this.save_button.el.sensitive = true;
+ ///?? has changed occured during loading?
+ if (_this.sourceview.loading) {
+ return;
+ }
+
+ print("- PREVIEW EDITOR CHANGED--");
+
+
+ //this.checkSyntax();
+
+ this.dirty = true;
+
+
+ return ;
+ });
+ }
+
+ // user defined functions
+ public string toString () {
+
+ Gtk.TextIter s;
+ Gtk.TextIter e;
+ this.el.get_start_iter(out s);
+ this.el.get_end_iter(out e);
+ var ret = this.el.get_text(s,e,true);
+ //print("TO STRING? " + ret);
+ return ret;
+ }
+ public bool checkSyntax () {
+
+ if (this.check_running) {
+ print("Check is running\n");
+ if (this.check_queued) {
+ print("Check is already queued");
+ return true;
+ }
+ this.check_queued = true;
+ print("Adding queued Check ");
+ GLib.Timeout.add_seconds(1, () => {
+ this.check_queued = false;
+
+ this.checkSyntax();
+ return false;
+ });
+
+
+ return true;
+ }
+ var str = this.toString();
+
+ // needed???
+ if (this.error_line > 0) {
+ Gtk.TextIter start;
+ Gtk.TextIter end;
+ this.el.get_bounds (out start, out end);
+
+ this.el.remove_source_marks (start, end, null);
+ }
+ if (str.length < 1) {
+ print("checkSyntax - empty string?\n");
+ return true;
+ }
+
+ if (_this.file.xtype == "PlainFile") {
+
+ // assume it's gtk...
+ this.check_running = true;
+ /*
+ if (!_this.window.windowstate.valasource.checkPlainFileSpawn(
+ _this.file,
+ str
+ )) {
+ this.check_running = false;
+ }
+ */
+ return true;
+
+ }
+ if (_this.file == null) {
+ return true;
+ }
+ var p = Palete.factory(_this.file.xtype);
+
+
+
+ this.check_running = true;
+
+
+ if (_this.file.language == "js") {
+ this.check_running = false;
+ print("calling validate javascript\n");
+ /* return this.highlightErrors(p.validateJavascript(
+ str,
+ _this.key,
+ _this.ptype,
+ _this.file,
+ _this.node
+ ));
+ */
+ }
+
+
+ print("calling validate vala\n");
+ // clear the buttons.
+
+ /*
+ if (! _this.window.windowstate.valasource.checkFileWithNodePropChange(
+ _this.file,
+ _this.node,
+ _this.key,
+ _this.ptype,
+ str
+ )) {
+ this.check_running = false;
+ }
+
+ */
+
+ //print("done mark line\n");
+
+ return true; // at present allow saving - even if it's invalid..
+ }
+ }
+