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;
16 delete_event : function (self, event) {
17 if (!this.get('/Editor.RightEditor').save()) {
18 // no hiding with errors.
22 this.get('/Editor').activePath = false;
25 configure_event : function (self, object) {
26 this.pos = this.el.get_position();
31 show : function (self) {
33 this.el.set_uposition(this.pos.root_x,this.pos.root_y);
39 title : "Application Builder - Editor",
41 save : function (self, event) {
42 if (!this.get('/Editor.RightEditor').save()) {
43 // no hiding with errors.
46 this.get('/Editor').activePath = false;
51 XObject.prototype.init.call(this);
61 pack : "pack_start,false,true",
67 activate : function (self) {
69 this.get('/Editor.RightEditor').save();
78 xtype: Gtk.ScrolledWindow,
82 // make sure we have an active path..
83 if (!this.get('/Editor').activePath) {
87 var str = this.get('/Editor.buffer').toString();
88 if (!this.get('/Editor.buffer').checkSyntax()) {
89 this.get('/StandardErrorDialog').show("Fix errors in code and save..");
93 this.get('/LeftPanel.model').changed( str , false);
94 this.get('/Editor').dirty = false;
95 this.get('/Editor.save_button').el.sensitive = false;
100 xtype: GtkSource.View,
102 key_release_event : function (self, event) {
104 if (event.key.keyval == 115 && (event.key.state & Gdk.ModifierType.CONTROL_MASK ) ) {
105 print("SAVE: ctrl-S pressed");
109 // print(event.key.keyval)
119 XObject.prototype.init.call(this);
120 var description = Pango.font_description_from_string("monospace")
121 description.set_size(8000);
122 this.el.modify_font(description);
125 insert_spaces_instead_of_tabs : true,
126 load : function(str, providertype) {
128 // show the help page for the active node..
129 //this.get('/Help').show();
130 Editor.providertype = providertype;
132 // this.get('/BottomPane').el.set_current_page(0);
133 this.el.get_buffer().set_text(str, str.length);
134 var lm = GtkSource.LanguageManager.get_default();
136 this.el.get_buffer().set_language(lm.get_language('js'));
137 var buf = this.el.get_buffer();
138 var cursor = buf.get_mark("insert");
140 buf.get_iter_at_mark(ret, cursor);
141 ret.iter.set_line(1);
142 ret.iter.set_line_offset(4);
143 buf.move_mark(cursor, ret.iter);
146 cursor = buf.get_mark("selection_bound");
148 buf.get_iter_at_mark(ret, cursor);
149 ret.iter.set_line(1);
150 ret.iter.set_line_offset(4);
151 buf.move_mark(cursor, ret.iter);
152 this.get('/Editor').dirty = false;
153 this.el.grab_focus();
154 this.get('/Editor.save_button').el.sensitive = false;
158 return this.get('/Editor.RightEditor').save();
160 show_line_numbers : true,
163 xtype: GtkSource.Buffer,
165 changed : function (self) {
167 if(this.checkSyntax()) {
168 this.get('/Editor.save_button').el.sensitive = true;
170 // print("EDITOR CHANGED");
171 this.get('/Editor').dirty = true;
173 // this.get('/LeftPanel.model').changed( str , false);
179 checkSyntax : function() {
181 if (Editor.providertype == 'Gtk') {
185 var str = this.toString();
188 // print('var res = ' + str);
189 Seed.check_syntax('var res = ' + str);
194 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
195 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
197 print("SYNTAX ERROR IN EDITOR");
203 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
204 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
209 toString : function() {
213 this.el.get_start_iter(s).value;
214 this.el.get_end_iter(e).value;
216 var ret = this.el.get_text(s.iter,e.iter,true);
217 //print("TO STRING? " + ret);
230 XObject.cache['/Editor'] = Editor;