3 Pango = imports.gi.Pango;
4 GLib = imports.gi.GLib;
6 GObject = imports.gi.GObject;
7 GtkSource = imports.gi.GtkSource;
8 WebKit = imports.gi.WebKit;
10 console = imports.console;
11 XObject = imports.XObject.XObject;
15 delete_event : function (self, event) {
16 if (!this.get('/Editor.RightEditor').save()) {
17 // no hiding with errors.
21 this.get('/Editor').activePath = false;
27 if (!Editor.RightEditor.save()) {
28 // no hiding with errors.
32 _this.activePath = false;
37 configure_event : function (self, object) {
38 this.pos = this.el.get_position();
45 _this.pos = this.get_position();
51 show : function (self) {
53 this.el.set_uposition(this.pos.root_x,this.pos.root_y);
59 title : "Application Builder - Editor",
62 XObject.prototype.init.call(this);
65 save : function (self, event) {
66 if (!this.get('/Editor.RightEditor').save()) {
67 // no hiding with errors.
70 this.get('/Editor').activePath = false;
81 pack : "pack_start,false,true",
84 xtype: Gtk.ToolButton,
86 clicked : function (self) {
88 this.get('/Editor.RightEditor').save();
97 xtype: Gtk.ScrolledWindow,
101 // make sure we have an active path..
102 if (!this.get('/Editor').activePath) {
106 var str = this.get('/Editor.buffer').toString();
107 if (!this.get('/Editor.buffer').checkSyntax()) {
108 this.get('/StandardErrorDialog').show("Fix errors in code and save..");
112 this.get('/LeftPanel.model').changed( str , false);
113 this.get('/Editor').dirty = false;
114 this.get('/Editor.save_button').el.sensitive = false;
119 xtype: GtkSource.View,
121 key_release_event : function (self, event) {
123 if (event.key.keyval == 115 && (event.key.state & Gdk.ModifierType.CONTROL_MASK ) ) {
124 print("SAVE: ctrl-S pressed");
128 // print(event.key.keyval)
138 XObject.prototype.init.call(this);
139 var description = Pango.Font.description_from_string("monospace")
140 description.set_size(8000);
141 this.el.modify_font(description);
144 insert_spaces_instead_of_tabs : true,
145 load : function(str) {
147 // show the help page for the active node..
148 //this.get('/Help').show();
151 // this.get('/BottomPane').el.set_current_page(0);
152 this.el.get_buffer().set_text(str, str.length);
153 var lm = GtkSource.LanguageManager.get_default();
155 this.el.get_buffer().set_language(lm.get_language('js'));
156 var buf = this.el.get_buffer();
157 var cursor = buf.get_mark("insert");
158 var iter= new Gtk.TextIter;
159 buf.get_iter_at_mark(iter, cursor);
161 iter.set_line_offset(4);
162 buf.move_mark(cursor, iter);
165 cursor = buf.get_mark("selection_bound");
166 iter= new Gtk.TextIter;
167 buf.get_iter_at_mark(iter, cursor);
169 iter.set_line_offset(4);
170 buf.move_mark(cursor, iter);
171 this.get('/Editor').dirty = false;
172 this.el.grab_focus();
173 this.get('/Editor.save_button').el.sensitive = false;
177 return this.get('/Editor.RightEditor').save();
179 show_line_numbers : true,
182 xtype: GtkSource.Buffer,
184 changed : function (self) {
186 if(this.checkSyntax()) {
187 this.get('/Editor.save_button').el.sensitive = true;
189 // print("EDITOR CHANGED");
190 this.get('/Editor').dirty = true;
192 // this.get('/LeftPanel.model').changed( str , false);
198 checkSyntax : function() {
199 var str = this.toString();
202 // print('var res = ' + str);
203 Seed.check_syntax('var res = ' + str);
208 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
209 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
211 print("SYNTAX ERROR IN EDITOR");
217 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
218 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
223 toString : function() {
225 var s = new Gtk.TextIter();
226 var e = new Gtk.TextIter();
227 this.el.get_start_iter(s);
228 this.el.get_end_iter(e);
229 var ret = this.el.get_text(s,e,true);
230 //print("TO STRING? " + ret);
243 XObject.cache['/Editor'] = Editor;