X-Git-Url: http://git.roojs.org/?p=app.Builder.js;a=blobdiff_plain;f=Builder4%2FEditor.js;fp=Builder4%2FEditor.js;h=7e5d039d084f571f1b96a626f4108b649f44461d;hp=4822afa622f2a9b0411c6b40c8d20fc2be866ad0;hb=2357117f2dbfda5d1282c5cc730534781e244d7e;hpb=a8abe74a436a317a7574a85149f17ecf9f72daa1 diff --git a/Builder4/Editor.js b/Builder4/Editor.js index 4822afa62..7e5d039d0 100644 --- a/Builder4/Editor.js +++ b/Builder4/Editor.js @@ -12,96 +12,51 @@ XObject = imports.XObject.XObject; Editor=new XObject({ xtype: Gtk.Window, listeners : { - delete_event : function (self, event) { - if (!this.get('/Editor.RightEditor').save()) { - // no hiding with errors. - return true; - } - this.el.hide(); - this.get('/Editor').activePath = false; - return true; - } - /*-- - - (event) => { - if (!Editor.RightEditor.save()) { - // no hiding with errors. - return true; - } - _this.el.hide(); - _this.active_path = ""; - return true; - } - - */, - configure_event : function (self, object) { - this.pos = this.el.get_position(); - - return false; - } - /*-- - (object) => { + configure_event : (object) => { _this.pos = true; this.el.get_position(out _this.pos_root_x, out _this.pos_root_y); return false; - } - */, - show : function (self) { - if (this.pos) { - this.el.set_uposition(this.pos.root_x,this.pos.root_y); - } - } - /*-- - () => { + }, + show : () => { if (this.pos) { _this.el.move(this.pos_root_x,this.pos_root_y); } } - - */ }, height_request : 300, id : "Editor", title : "Application Builder - Code Editor", width_request : 500, - init : function() { - XObject.prototype.init.call(this); - // this.show_all(); - }, - save : function (self, event) { - if (!this.get('/Editor.RightEditor').save()) { + 'bool:save' : () { + + if (!Editor.RightEditor.save()) { // no hiding with errors. return true; } - this.get('/Editor').activePath = false; - this.el.hide(); + _this.active_path = ""; + _this.el.hide(); return true; - } - /*-- - - bool () { + }, + init : function() { + XObject.prototype.init.call(this); + // this.show_all(); + }, + show_all : (event) => { if (!Editor.RightEditor.save()) { // no hiding with errors. return true; } - _this.active_path = ""; _this.el.hide(); + _this.active_path = ""; return true; - - } - */, - show_all : function() { - - } - /*-- - void () { + }, + 'void:show_all' : () { this.el.show_all(); - } - */, + }, items : [ { xtype: Gtk.VBox, @@ -115,16 +70,9 @@ Editor=new XObject({ { xtype: Gtk.ToolButton, listeners : { - clicked : function (self) { - - this.get('/Editor.RightEditor').save(); - } - /*-- - () => { + clicked : () => { Editor.RightEditor.save(); } - - */ }, id : "save_button", label : "Save" @@ -135,25 +83,7 @@ Editor=new XObject({ xtype: Gtk.ScrolledWindow, id : "RightEditor", pack : "add", - save : function() { - // make sure we have an active path.. - if (!this.get('/Editor').activePath) { - return true; - } - - var str = this.get('/Editor.buffer').toString(); - if (!this.get('/Editor.buffer').checkSyntax()) { - this.get('/StandardErrorDialog').show("Fix errors in code and save.."); - return false; - } - - this.get('/LeftPanel.model').changed( str , false); - this.get('/Editor').dirty = false; - this.get('/Editor.save_button').el.sensitive = false; - return true; - } - /*-- - bool () { + 'bool:save' : () { print("editor.rightbutton.save"); if (_this.active_path.length < 1 ) { print("skip - no active path"); @@ -173,26 +103,12 @@ Editor=new XObject({ _this.save_button.el.sensitive = false; print("set save button grey"); return true; - } - - */, + }, items : [ { xtype: GtkSource.View, listeners : { - key_release_event : function (self, event) { - - if (event.key.keyval == 115 && (event.key.state & Gdk.ModifierType.CONTROL_MASK ) ) { - print("SAVE: ctrl-S pressed"); - this.save(); - return false; - } - // print(event.key.keyval) - - return false; - } - /*-- - (event) => { + key_release_event : (event) => { if (event.keyval == 115 && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) { print("SAVE: ctrl-S pressed"); @@ -204,29 +120,17 @@ Editor=new XObject({ return false; } - */ }, id : "view", indent_width : 4, pack : "add", auto_indent : true, - init : function() { - XObject.prototype.init.call(this); - var description = Pango.Font.description_from_string("monospace") - description.set_size(8000); - this.el.modify_font(description); - - } - /*-- - - var description = Pango.FontDescription.from_string("monospace"); + init : var description = Pango.FontDescription.from_string("monospace"); description.set_size(8000); - this.el.override_font(description); - - - */, + this.el.override_font(description);, insert_spaces_instead_of_tabs : true, - load : function(str) { + show_line_numbers : true, + 'void:load' : (string str) { // show the help page for the active node.. //this.get('/Help').show(); @@ -234,59 +138,37 @@ Editor=new XObject({ // this.get('/BottomPane').el.set_current_page(0); this.el.get_buffer().set_text(str, str.length); - var lm = GtkSource.LanguageManager.get_default(); + var lm = Gtk.SourceLanguageManager.get_default(); - this.el.get_buffer().set_language(lm.get_language('js')); + ((Gtk.SourceBuffer)(this.el.get_buffer())) .set_language(lm.get_language("js")); var buf = this.el.get_buffer(); var cursor = buf.get_mark("insert"); - var iter= new Gtk.TextIter; - buf.get_iter_at_mark(iter, cursor); + Gtk.TextIter iter; + buf.get_iter_at_mark(out iter, cursor); iter.set_line(1); iter.set_line_offset(4); buf.move_mark(cursor, iter); cursor = buf.get_mark("selection_bound"); - iter= new Gtk.TextIter; - buf.get_iter_at_mark(iter, cursor); + //iter= new Gtk.TextIter; + buf.get_iter_at_mark(out iter, cursor); iter.set_line(1); iter.set_line_offset(4); buf.move_mark(cursor, iter); - this.get('/Editor').dirty = false; + Editor.dirty = false; this.el.grab_focus(); - this.get('/Editor.save_button').el.sensitive = false; + _this.save_button.el.sensitive = false; }, - save : function() { - - return this.get('/Editor.RightEditor').save(); - - } - /*-- - void () { + 'void:save' : () { Editor.RightEditor.save(); - } - */, - show_line_numbers : true, + }, items : [ { xtype: GtkSource.Buffer, listeners : { - changed : function (self) { - - if(this.checkSyntax()) { - this.get('/Editor.save_button').el.sensitive = true; - } - // print("EDITOR CHANGED"); - this.get('/Editor').dirty = true; - - // this.get('/LeftPanel.model').changed( str , false); - return false; - } - - /*-- - - () => { + changed : () => { // check syntax?? if(this.checkSyntax()) { Editor.save_button.el.sensitive = true; @@ -297,15 +179,14 @@ Editor=new XObject({ // this.get('/LeftPanel.model').changed( str , false); return ; } - - - */ }, id : "buffer", pack : "set_buffer", - checkSyntax : function() { + 'bool:checkSyntax' : () { + /* var str = this.toString(); - var res = ''; + var res = ""; + /* try { // print('var res = ' + str); Seed.check_syntax('var res = ' + str); @@ -325,30 +206,10 @@ Editor=new XObject({ this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({ red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF })); - - return true; - } - /*-- - bool () { - // we could try running valac... ?? but it's a bit confusing.. + */ return true; - - } - - - */, - toString : function() { - - var s = new Gtk.TextIter(); - var e = new Gtk.TextIter(); - this.el.get_start_iter(s); - this.el.get_end_iter(e); - var ret = this.el.get_text(s,e,true); - //print("TO STRING? " + ret); - return ret; - } - /*-- - string () { + }, + 'string:toString' : () { Gtk.TextIter s; Gtk.TextIter e; @@ -358,8 +219,6 @@ Editor=new XObject({ //print("TO STRING? " + ret); return ret; } - - */ } ] }