Builder4/Editor.bjs
[app.Builder.js] / Builder4 / Editor.bjs
1 {
2     "id": "file-gtk-17",
3     "name": "Editor",
4     "parent": "",
5     "title": false,
6     "path": "/home/alan/gitlive/app.Builder/Builder4/Editor.bjs",
7     "items": [
8         {
9             "listeners": {
10                 "delete_event": "function (self, event) {\n    if (!this.get('/Editor.RightEditor').save()) {\n        // no hiding with errors.\n        return true;\n    }\n    this.el.hide();\n    this.get('/Editor').activePath = false;\n    return true;\n}\n/*--\n\n(event) => {\n    if (!Editor.RightEditor.save()) {\n        // no hiding with errors.\n        return true;\n    }\n    _this.el.hide();\n    _this.active_path = \"\";\n    return true;\n}\n\n*/",
11                 "configure_event": "function (self, object) {\n    this.pos = this.el.get_position();\n\n    return false;\n}\n/*--\n (object) => {\n    _this.pos = true;\n    this.el.get_position(out _this.pos_root_x, out _this.pos_root_y);\n\n\n    return false;\n}\n*/\n",
12                 "show": "function (self) {\n    if (this.pos) {\n        this.el.set_uposition(this.pos.root_x,this.pos.root_y);\n    }\n}\n/*--\n () => {\n    if (this.pos) {\n        _this.el.move(this.pos_root_x,this.pos_root_y);\n    }\n}\n\n*/"
13             },
14             ".activeEditor": "string:\"\"",
15             ".active_path": "string:\"\"",
16             ".dirty": "bool:false",
17             ".pos": "bool:false",
18             ".pos_root_x": "int",
19             ".pos_root_y": "int",
20             "height_request": 300,
21             "id": "Editor",
22             "title": "Application Builder  - Code  Editor",
23             "width_request": 500,
24             "xtype": "Window",
25             "|init": "function() {\n    XObject.prototype.init.call(this);\n   // this.show_all();\n}\n",
26             "|save": "function (self, event) {\n    if (!this.get('/Editor.RightEditor').save()) {\n        // no hiding with errors.\n        return true;\n    }\n    this.get('/Editor').activePath = false;\n    this.el.hide();\n    return true;\n}\n/*--\n\nbool ()  {\n\n    if (!Editor.RightEditor.save()) {\n        // no hiding with errors.\n        return true;\n    }\n    _this.active_path = \"\";\n    _this.el.hide();\n    return true;\n\n}\n*/",
27             "|xns": "Gtk",
28             "items": [
29                 {
30                     "pack": "add",
31                     "xtype": "VBox",
32                     "|xns": "Gtk",
33                     "items": [
34                         {
35                             "pack": "pack_start,false,true",
36                             "xtype": "Toolbar",
37                             "|xns": "Gtk",
38                             "items": [
39                                 {
40                                     "listeners": {
41                                         "clicked": "function (self) {\n\n  this.get('/Editor.RightEditor').save();\n}\n/*--\n() => { \n    Editor.RightEditor.save();\n}\n\n*/\n"
42                                     },
43                                     "id": "save_button",
44                                     "label": "Save",
45                                     "xtype": "ToolButton",
46                                     "|xns": "Gtk"
47                                 }
48                             ]
49                         },
50                         {
51                             "id": "RightEditor",
52                             "pack": "add",
53                             "xtype": "ScrolledWindow",
54                             "|save": "function() {\n    // make sure we have an active path..\n     if (!this.get('/Editor').activePath) {\n        return true;\n     }\n     \n     var str = this.get('/Editor.buffer').toString();\n     if (!this.get('/Editor.buffer').checkSyntax()) {\n         this.get('/StandardErrorDialog').show(\"Fix errors in code and save..\"); \n         return false;\n     }\n     \n     this.get('/LeftPanel.model').changed(  str , false);\n     this.get('/Editor').dirty = false;\n     this.get('/Editor.save_button').el.sensitive = false;\n     return true;\n}\n/*--\nbool () {\n     print(\"editor.rightbutton.save\");\n     if (_this.active_path.length  < 1 ) {\n          print(\"skip - no active path\");\n        return true;\n     }\n     \n     var str = Editor.buffer.toString();\n     \n     if (!Editor.buffer.checkSyntax()) {\n         print(\"check syntax failed\");\n         //this.get('/StandardErrorDialog').show(\"Fix errors in code and save..\"); \n         return false;\n     }\n     \n     // LeftPanel.model.changed(  str , false);\n     _this.dirty = false;\n     _this.save_button.el.sensitive = false;\n     print(\"set save button grey\");\n     return true;\n}\n\n*/",
55                             "|xns": "Gtk",
56                             "items": [
57                                 {
58                                     "listeners": {
59                                         "key_release_event": "function (self, event) {\n    \n    if (event.key.keyval == 115 && (event.key.state & Gdk.ModifierType.CONTROL_MASK ) ) {\n        print(\"SAVE: ctrl-S  pressed\");\n        this.save();\n        return false;\n    }\n   // print(event.key.keyval)\n    \n    return false;\n}\n/*--\n(event) => {\n    \n    if (event.key.keyval == 115 && (event.key.state & Gdk.ModifierType.CONTROL_MASK ) > 0 ) {\n        print(\"SAVE: ctrl-S  pressed\");\n        this.save();\n        return false;\n    }\n   // print(event.key.keyval)\n    \n    return false;\n\n}\n*/\n\n"
60                                     },
61                                     "id": "view",
62                                     "indent_width": 4,
63                                     "pack": "add",
64                                     "xtype": "View",
65                                     "|auto_indent": "true",
66                                     "|init": "function() {\n    XObject.prototype.init.call(this);\n     var description = Pango.Font.description_from_string(\"monospace\")\n    description.set_size(8000);\n    this.el.modify_font(description);\n\n}\n/*--\n\n    var description =   Pango.FontDescription.from_string(\"monospace\");\n    description.set_size(8000);\n    this.el.override_font(description);\n\n\n*/\n",
67                                     "|insert_spaces_instead_of_tabs": "true",
68                                     "|load": "function(str) {\n\n// show the help page for the active node..\n   //this.get('/Help').show();\n\n\n  // this.get('/BottomPane').el.set_current_page(0);\n    this.el.get_buffer().set_text(str, str.length);\n    var lm = GtkSource.LanguageManager.get_default();\n    \n    this.el.get_buffer().set_language(lm.get_language('js'));\n    var buf = this.el.get_buffer();\n    var cursor = buf.get_mark(\"insert\");\n    var iter= new Gtk.TextIter;\n    buf.get_iter_at_mark(iter, cursor);\n    iter.set_line(1);\n    iter.set_line_offset(4);\n    buf.move_mark(cursor, iter);\n    \n    \n    cursor = buf.get_mark(\"selection_bound\");\n    iter= new Gtk.TextIter;\n    buf.get_iter_at_mark(iter, cursor);\n    iter.set_line(1);\n    iter.set_line_offset(4);\n    buf.move_mark(cursor, iter);\n    this.get('/Editor').dirty = false;\n    this.el.grab_focus();\n     this.get('/Editor.save_button').el.sensitive = false;\n}",
69                                     "|save": "function() {\n    \n    return this.get('/Editor.RightEditor').save();\n\n}\n/*--\nvoid () {\n\n    Editor.RightEditor.save();\n}\n*/",
70                                     "|show_line_numbers": "true",
71                                     "|xns": "GtkSource",
72                                     "items": [
73                                         {
74                                             "listeners": {
75                                                 "changed": "function (self) {\n\n    if(this.checkSyntax()) {\n        this.get('/Editor.save_button').el.sensitive = true;\n    }\n   // print(\"EDITOR CHANGED\");\n    this.get('/Editor').dirty = true;\n\n    // this.get('/LeftPanel.model').changed(  str , false);\n    return false;\n}\n\n/*--\n\n() => {\n    // check syntax??\n        if(this.checkSyntax()) {\n        Editor.save_button.el.sensitive = true;\n    }\n   // print(\"EDITOR CHANGED\");\n    Editor.dirty = true;\n\n    // this.get('/LeftPanel.model').changed(  str , false);\n    return ;\n}\n\n\n*/\n\n\n"
76                                             },
77                                             "id": "buffer",
78                                             "pack": "set_buffer",
79                                             "xtype": "Buffer",
80                                             "|checkSyntax": "function() {\n    var str = this.toString();\n    var res = '';\n    try {\n      //  print('var res = ' + str);\n        Seed.check_syntax('var res = ' + str);\n        \n       \n    } catch (e) {\n        \n        this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({\n            red: 0xFFFF, green: 0xCCCC , blue : 0xCCCC\n           }));\n        print(\"SYNTAX ERROR IN EDITOR\");   \n        print(e);\n        // print(str);\n        //console.dump(e);\n        return false;\n    }\n     this.get('/RightEditor.view').el.modify_base(Gtk.StateType.NORMAL, new Gdk.Color({\n        red: 0xFFFF, green: 0xFFFF , blue : 0xFFFF\n       }));\n    \n    return true;\n}\n/*--\nbool () { \n    // we could try running valac... ?? but it's a bit confusing..\n    return true;\n\n}\n\n\n*/",
81                                             "|toString": "function() {\n    \n    var s = new Gtk.TextIter();\n    var e = new Gtk.TextIter();\n    this.el.get_start_iter(s);\n    this.el.get_end_iter(e);\n    var ret = this.el.get_text(s,e,true);\n    //print(\"TO STRING? \" + ret);\n    return ret;\n}\n/*--\nstring () {\n    \n    Gtk.TextIter s;\n    Gtk.TextIter e;\n    this.el.get_start_iter(out s);\n    this.el.get_end_iter(out e);\n    var ret = this.el.get_text(s,e,true);\n    //print(\"TO STRING? \" + ret);\n    return ret;\n}\n\n*/",
82                                             "|xns": "GtkSource"
83                                         }
84                                     ]
85                                 }
86                             ]
87                         }
88                     ]
89                 }
90             ]
91         }
92     ],
93     "permname": "",
94     "modOrder": ""
95 }