2 valac --pkg gio-2.0 --pkg posix --pkg gtk+-3.0 --pkg libnotify --pkg gtksourceview-3.0 --pkg libwnck-3.0 \
3 /tmp/Editor.vala -o /tmp/Editor
8 static int main (string[] args) {
18 public static Xcls_Editor Editor;
20 public class Xcls_Editor
23 private static Xcls_Editor _this;
25 public Xcls_save_button save_button;
26 public Xcls_RightEditor RightEditor;
27 public Xcls_view view;
28 public Xcls_buffer buffer;
33 public int pos_root_x;
34 public int pos_root_y;
35 public string activeEditor;
36 public string active_path;
41 this.el = new Gtk.Window();
48 this.activeEditor = "";
49 this.active_path = "";
52 this.el.height_request = 300;
53 this.el.title = "Application Builder - Code Editor";
54 this.el.width_request = 500;
55 var child_0 = new Xcls_VBox2();
56 this.el.add ( child_0.el );
59 this.el.configure_event.connect( (object) => {
61 this.el.get_position(out _this.pos_root_x, out _this.pos_root_y);
68 this.el.show.connect( () => {
70 _this.el.move(this.pos_root_x,this.pos_root_y);
76 // userdefined functions
78 // skip listeners - not pipe
80 // skip .bool:dirty - already used
82 // skip .bool:pos - already used
84 // skip .int:pos_root_x - already used
86 // skip .int:pos_root_y - already used
88 // skip .string:activeEditor - already used
90 // skip .string:active_path - already used
92 // skip height_request - already used
96 // skip title - already used
98 // skip width_request - already used
100 // skip xtype - not pipe
101 public bool save () {
103 if (!Editor.RightEditor.save()) {
104 // no hiding with errors.
107 _this.active_path = "";
113 // skip |init - already used
115 // skip |show_all - no return type
116 public void show_all () {
122 // skip |xns - no return type
124 // skip items - not pipe
126 // skip xvala_cls - not pipe
128 // skip xvala_xcls - not pipe
130 // skip xvala_id - not pipe
131 public class Xcls_VBox2
140 this.el = new Gtk.VBox( true, 0 );
144 // set gobject values
145 var child_0 = new Xcls_Toolbar3();
146 this.el.pack_start ( child_0.el , false,true );
147 var child_1 = new Xcls_RightEditor();
148 this.el.add ( child_1.el );
151 // userdefined functions
153 // skip |homogeneous - already used
155 // skip pack - not pipe
157 // skip xtype - not pipe
159 // skip |xns - no return type
161 // skip items - not pipe
163 // skip xvala_cls - not pipe
165 // skip xvala_xcls - not pipe
167 // skip xvala_id - not pipe
169 public class Xcls_Toolbar3
171 public Gtk.Toolbar el;
176 public Xcls_Toolbar3()
178 this.el = new Gtk.Toolbar();
182 // set gobject values
183 var child_0 = new Xcls_save_button();
184 this.el.add ( child_0.el );
187 // userdefined functions
189 // skip pack - not pipe
191 // skip xtype - not pipe
193 // skip |xns - no return type
195 // skip items - not pipe
197 // skip xvala_cls - not pipe
199 // skip xvala_xcls - not pipe
201 // skip xvala_id - not pipe
203 public class Xcls_save_button
205 public Gtk.ToolButton el;
210 public Xcls_save_button()
212 this.el = new Gtk.ToolButton( null, "Save" );
213 _this.save_button = this;
217 // set gobject values
220 this.el.clicked.connect( () => {
221 Editor.RightEditor.save();
227 // userdefined functions
229 // skip listeners - not pipe
231 // skip id - not pipe
233 // skip label - already used
235 // skip xtype - not pipe
237 // skip |xns - no return type
239 // skip xvala_cls - not pipe
241 // skip xvala_xcls - not pipe
243 // skip xvala_id - not pipe
245 public class Xcls_RightEditor
247 public Gtk.ScrolledWindow el;
252 public Xcls_RightEditor()
254 this.el = new Gtk.ScrolledWindow( null, null );
255 _this.RightEditor = this;
259 // set gobject values
260 var child_0 = new Xcls_view();
261 this.el.add ( child_0.el );
264 // userdefined functions
266 // skip id - not pipe
268 // skip pack - not pipe
270 // skip xtype - not pipe
271 public bool save () {
272 print("editor.rightbutton.save");
273 if (_this.active_path.length < 1 ) {
274 print("skip - no active path");
278 var str = Editor.buffer.toString();
280 if (!Editor.buffer.checkSyntax()) {
281 print("check syntax failed");
282 //this.get('/StandardErrorDialog').show("Fix errors in code and save..");
286 // LeftPanel.model.changed( str , false);
288 _this.save_button.el.sensitive = false;
289 print("set save button grey");
294 // skip |xns - no return type
296 // skip items - not pipe
298 // skip xvala_cls - not pipe
300 // skip xvala_xcls - not pipe
302 // skip xvala_id - not pipe
304 public class Xcls_view
306 public Gtk.SourceView el;
313 this.el = new Gtk.SourceView();
318 // set gobject values
319 this.el.auto_indent = true;
320 this.el.indent_width = 4;
321 this.el.insert_spaces_instead_of_tabs = true;
322 this.el.show_line_numbers = true;
323 var child_0 = new Xcls_buffer();
324 this.el.set_buffer ( child_0.el );
327 this.el.key_release_event.connect( (event) => {
329 if (event.keyval == 115 && (event.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {
330 print("SAVE: ctrl-S pressed");
334 // print(event.key.keyval)
343 // userdefined functions
345 // skip listeners - not pipe
347 // skip id - not pipe
349 // skip indent_width - already used
351 // skip pack - not pipe
353 // skip xtype - not pipe
355 // skip |auto_indent - already used
357 // skip |init - already used
359 // skip |insert_spaces_instead_of_tabs - already used
361 // skip |show_line_numbers - already used
362 public void load (string str) {
364 // show the help page for the active node..
365 //this.get('/Help').show();
368 // this.get('/BottomPane').el.set_current_page(0);
369 this.el.get_buffer().set_text(str, str.length);
370 var lm = Gtk.SourceLanguageManager.get_default();
372 ((Gtk.SourceBuffer)(this.el.get_buffer())) .set_language(lm.get_language("js"));
373 var buf = this.el.get_buffer();
374 var cursor = buf.get_mark("insert");
376 buf.get_iter_at_mark(out iter, cursor);
378 iter.set_line_offset(4);
379 buf.move_mark(cursor, iter);
382 cursor = buf.get_mark("selection_bound");
383 //iter= new Gtk.TextIter;
384 buf.get_iter_at_mark(out iter, cursor);
386 iter.set_line_offset(4);
387 buf.move_mark(cursor, iter);
388 Editor.dirty = false;
389 this.el.grab_focus();
390 _this.save_button.el.sensitive = false;
392 public void save () {
394 Editor.RightEditor.save();
398 // skip |xns - no return type
400 // skip items - not pipe
402 // skip xvala_cls - not pipe
404 // skip xvala_xcls - not pipe
406 // skip xvala_id - not pipe
408 public class Xcls_buffer
410 public Gtk.SourceBuffer el;
417 this.el = new Gtk.SourceBuffer( null );
422 // set gobject values
425 this.el.changed.connect( () => {
427 if(this.checkSyntax()) {
428 Editor.save_button.el.sensitive = true;
430 // print("EDITOR CHANGED");
433 // this.get('/LeftPanel.model').changed( str , false);
441 // userdefined functions
443 // skip listeners - not pipe
445 // skip id - not pipe
447 // skip pack - not pipe
449 // skip xtype - not pipe
450 public bool checkSyntax () {
452 var str = this.toString();
456 // print('var res = ' + str);
457 Seed.check_syntax('var res = ' + str);
462 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
463 red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC
465 print("SYNTAX ERROR IN EDITOR");
471 this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({
472 red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF
477 public string toString () {
481 this.el.get_start_iter(out s);
482 this.el.get_end_iter(out e);
483 var ret = this.el.get_text(s,e,true);
484 //print("TO STRING? " + ret);
489 // skip |xns - no return type
491 // skip xvala_cls - not pipe
493 // skip xvala_xcls - not pipe
495 // skip xvala_id - not pipe