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;
24 configure_event : function (self, object) {
25 this.pos = this.el.get_position();
30 show : function (self) {
32 this.el.set_uposition(this.pos.root_x,this.pos.root_y);
38 title : "Application Builder - Editor",
40 save : function (self, event) {
41 if (!this.get('/Editor.RightEditor').save()) {
42 // no hiding with errors.
45 this.get('/Editor').activePath = false;
50 XObject.prototype.init.call(this);
60 pack : "pack_start,false,true",
66 activate : function (self) {
68 this.get('/Editor.RightEditor').save();
77 xtype: Gtk.ScrolledWindow,
81 // make sure we have an active path..
82 if (!this.get('/Editor').activePath) {
86 var str = this.get('/Editor.buffer').toString();
87 if (!this.get('/Editor.buffer').checkSyntax()) {
88 this.get('/StandardErrorDialog').show("Fix errors in code and save..");
92 this.get('/LeftPanel.model').changed( str , false);
93 this.get('/Editor').dirty = false;
94 this.get('/Editor.save_button').el.sensitive = false;
99 xtype: GtkSource.View,
101 key_release_event : function (self, event) {
103 if (event.key.keyval == 115 && (event.key.state & Gdk.ModifierType.CONTROL_MASK ) ) {
104 print("SAVE: ctrl-S pressed");
108 // print(event.key.keyval)
118 XObject.prototype.init.call(this);
119 var description = Pango.font_description_from_string("monospace")
120 description.set_size(8000);
121 this.el.modify_font(description);
124 insert_spaces_instead_of_tabs : true,
125 load : function(str) {
127 // show the help page for the active node..
128 //this.get('/Help').show();
131 // this.get('/BottomPane').el.set_current_page(0);
132 this.el.get_buffer().set_text(str, str.length);
133 var lm = GtkSource.LanguageManager.get_default();
135 this.el.get_buffer().set_language(lm.get_language('js'));
136 var buf = this.el.get_buffer();
137 var cursor = buf.get_mark("insert");
139 buf.get_iter_at_mark(ret, cursor);
140 ret.iter.set_line(1);
141 ret.iter.set_line_offset(4);
142 buf.move_mark(cursor, ret.iter);
145 cursor = buf.get_mark("selection_bound");
147 buf.get_iter_at_mark(ret, cursor);
148 ret.iter.set_line(1);
149 ret.iter.set_line_offset(4);
150 buf.move_mark(cursor, ret.iter);
151 this.get('/Editor').dirty = false;
152 this.el.grab_focus();
153 this.get('/Editor.save_button').el.sensitive = false;
157 return this.get('/Editor.RightEditor').save();
159 show_line_numbers : true,
162 xtype: GtkSource.Buffer,
164 changed : function (self) {
166 if(this.checkSyntax()) {
167 this.get('/Editor.save_button').el.sensitive = true;
169 // print("EDITOR CHANGED");
170 this.get('/Editor').dirty = true;
172 // this.get('/LeftPanel.model').changed( str , false);
178 checkSyntax : function() {
179 var str = this.toString();
182 // print('var res = ' + str);
183 Seed.check_syntax('var res = ' + str);
188 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
189 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
191 print("SYNTAX ERROR IN EDITOR");
197 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
198 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
203 toString : function() {
207 this.el.get_start_iter(s).value;
208 this.el.get_end_iter(e).value;
210 var ret = this.el.get_text(s.iter,e.iter,true);
211 //print("TO STRING? " + ret);
224 XObject.cache['/Editor'] = Editor;