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 configure_event : (object) => {
17 this.el.get_position(out _this.pos_root_x, out _this.pos_root_y);
24 _this.el.move(this.pos_root_x,this.pos_root_y);
30 title : "Application Builder - Code Editor",
34 if (!Editor.RightEditor.save()) {
35 // no hiding with errors.
38 _this.active_path = "";
44 XObject.prototype.init.call(this);
47 show_all : (event) => {
48 if (!Editor.RightEditor.save()) {
49 // no hiding with errors.
53 _this.active_path = "";
56 'void:show_all' : () {
68 pack : "pack_start,false,true",
71 xtype: Gtk.ToolButton,
74 Editor.RightEditor.save();
83 xtype: Gtk.ScrolledWindow,
87 print("editor.rightbutton.save");
88 if (_this.active_path.length < 1 ) {
89 print("skip - no active path");
93 var str = Editor.buffer.toString();
95 if (!Editor.buffer.checkSyntax()) {
96 print("check syntax failed");
97 //this.get('/StandardErrorDialog').show("Fix errors in code and save..");
101 // LeftPanel.model.changed( str , false);
103 _this.save_button.el.sensitive = false;
104 print("set save button grey");
109 xtype: GtkSource.View,
111 key_release_event : (event) => {
113 if (event.keyval == 115 && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
114 print("SAVE: ctrl-S pressed");
118 // print(event.key.keyval)
128 init : var description = Pango.FontDescription.from_string("monospace");
129 description.set_size(8000);
130 this.el.override_font(description);,
131 insert_spaces_instead_of_tabs : true,
132 show_line_numbers : true,
133 'void:load' : (string str) {
135 // show the help page for the active node..
136 //this.get('/Help').show();
139 // this.get('/BottomPane').el.set_current_page(0);
140 this.el.get_buffer().set_text(str, str.length);
141 var lm = Gtk.SourceLanguageManager.get_default();
143 ((Gtk.SourceBuffer)(this.el.get_buffer())) .set_language(lm.get_language("js"));
144 var buf = this.el.get_buffer();
145 var cursor = buf.get_mark("insert");
147 buf.get_iter_at_mark(out iter, cursor);
149 iter.set_line_offset(4);
150 buf.move_mark(cursor, iter);
153 cursor = buf.get_mark("selection_bound");
154 //iter= new Gtk.TextIter;
155 buf.get_iter_at_mark(out iter, cursor);
157 iter.set_line_offset(4);
158 buf.move_mark(cursor, iter);
159 Editor.dirty = false;
160 this.el.grab_focus();
161 _this.save_button.el.sensitive = false;
165 Editor.RightEditor.save();
169 xtype: GtkSource.Buffer,
173 if(this.checkSyntax()) {
174 Editor.save_button.el.sensitive = true;
176 // print("EDITOR CHANGED");
179 // this.get('/LeftPanel.model').changed( str , false);
185 'bool:checkSyntax' : () {
187 var str = this.toString();
191 // print('var res = ' + str);
192 Seed.check_syntax('var res = ' + str);
197 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
198 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
200 print("SYNTAX ERROR IN EDITOR");
206 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
207 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
212 'string:toString' : () {
216 this.el.get_start_iter(out s);
217 this.el.get_end_iter(out e);
218 var ret = this.el.get_text(s,e,true);
219 //print("TO STRING? " + ret);
232 XObject.cache['/Editor'] = Editor;