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();
43 show : function (self) {
45 this.el.set_uposition(this.pos.root_x,this.pos.root_y);
51 title : "Application Builder - Editor",
54 XObject.prototype.init.call(this);
57 save : function (self, event) {
58 if (!this.get('/Editor.RightEditor').save()) {
59 // no hiding with errors.
62 this.get('/Editor').activePath = false;
73 pack : "pack_start,false,true",
76 xtype: Gtk.ToolButton,
78 clicked : function (self) {
80 this.get('/Editor.RightEditor').save();
89 xtype: Gtk.ScrolledWindow,
93 // make sure we have an active path..
94 if (!this.get('/Editor').activePath) {
98 var str = this.get('/Editor.buffer').toString();
99 if (!this.get('/Editor.buffer').checkSyntax()) {
100 this.get('/StandardErrorDialog').show("Fix errors in code and save..");
104 this.get('/LeftPanel.model').changed( str , false);
105 this.get('/Editor').dirty = false;
106 this.get('/Editor.save_button').el.sensitive = false;
111 xtype: GtkSource.View,
113 key_release_event : function (self, event) {
115 if (event.key.keyval == 115 && (event.key.state & Gdk.ModifierType.CONTROL_MASK ) ) {
116 print("SAVE: ctrl-S pressed");
120 // print(event.key.keyval)
130 XObject.prototype.init.call(this);
131 var description = Pango.Font.description_from_string("monospace")
132 description.set_size(8000);
133 this.el.modify_font(description);
136 insert_spaces_instead_of_tabs : true,
137 load : function(str) {
139 // show the help page for the active node..
140 //this.get('/Help').show();
143 // this.get('/BottomPane').el.set_current_page(0);
144 this.el.get_buffer().set_text(str, str.length);
145 var lm = GtkSource.LanguageManager.get_default();
147 this.el.get_buffer().set_language(lm.get_language('js'));
148 var buf = this.el.get_buffer();
149 var cursor = buf.get_mark("insert");
150 var iter= new Gtk.TextIter;
151 buf.get_iter_at_mark(iter, cursor);
153 iter.set_line_offset(4);
154 buf.move_mark(cursor, iter);
157 cursor = buf.get_mark("selection_bound");
158 iter= new Gtk.TextIter;
159 buf.get_iter_at_mark(iter, cursor);
161 iter.set_line_offset(4);
162 buf.move_mark(cursor, iter);
163 this.get('/Editor').dirty = false;
164 this.el.grab_focus();
165 this.get('/Editor.save_button').el.sensitive = false;
169 return this.get('/Editor.RightEditor').save();
171 show_line_numbers : true,
174 xtype: GtkSource.Buffer,
176 changed : function (self) {
178 if(this.checkSyntax()) {
179 this.get('/Editor.save_button').el.sensitive = true;
181 // print("EDITOR CHANGED");
182 this.get('/Editor').dirty = true;
184 // this.get('/LeftPanel.model').changed( str , false);
190 checkSyntax : function() {
191 var str = this.toString();
194 // print('var res = ' + str);
195 Seed.check_syntax('var res = ' + str);
200 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
201 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
203 print("SYNTAX ERROR IN EDITOR");
209 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
210 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
215 toString : function() {
217 var s = new Gtk.TextIter();
218 var e = new Gtk.TextIter();
219 this.el.get_start_iter(s);
220 this.el.get_end_iter(e);
221 var ret = this.el.get_text(s,e,true);
222 //print("TO STRING? " + ret);
235 XObject.cache['/Editor'] = Editor;