Sample/Editor.bjs
[app.Builder.js] / Sample / Editor.bjs
1 {
2     "id": "file-gtk-13",
3     "name": "Editor",
4     "parent": "",
5     "title": false,
6     "path": "/home/alan/gitlive/app.Builder.js/Sample/Editor.bjs",
7     "items": [
8         {
9             "listeners": {
10                 "destroy_event": "function (self, event) {\n    this.el.hide();\n    return true;\n}",
11                 "delete_event": "function (self, event) {\n      this.el.hide();\n    return true;\n}",
12                 "configure_event": "function (self, object) {\n    this.pos = this.el.get_position();\n\n\n    return false;\n}",
13                 "show": "function (self) {\n    if (this.pos) {\n        this.el.set_uposition(this.pos.root_x,this.pos.root_y);\n    }\n}"
14             },
15             "height_request": 300,
16             "id": "EditorWindow",
17             "title": "Application Builder - Editor",
18             "width_request": 500,
19             "xtype": "Window",
20             "|init": "function() {\n    XObject.prototype.init.call(this);\n   // this.show_all();\n}\n",
21             "|xns": "Gtk",
22             "items": [
23                 {
24                     "pack": "add",
25                     "xtype": "VBox",
26                     "|xns": "Gtk",
27                     "items": [
28                         {
29                             "pack": "pack_start,false,true",
30                             "xtype": "Toolbar",
31                             "|xns": "Gtk",
32                             "items": [
33                                 {
34                                     "label": "Save",
35                                     "xtype": "Button",
36                                     "|xns": "Gtk"
37                                 }
38                             ]
39                         },
40                         {
41                             "id": "RightEditor",
42                             "pack": "add",
43                             "xtype": "ScrolledWindow",
44                             "|save": "function() {\n     this.get('/LeftPanel.model').changed(  str , false);\n}\n",
45                             "|xns": "Gtk",
46                             "items": [
47                                 {
48                                     "listeners": {
49                                         "key_release_event": "function (self, event) {\n    if (event.key.keyval != 115 || !(Gdk.ModifierType.CONTROL_MASK & 4) ) {\n        return;\n    }\n    print(event.key.keyval)\n    this.save();\n    return false;\n}"
50                                     },
51                                     "id": "view",
52                                     "indent_width": 4,
53                                     "pack": "add",
54                                     "xtype": "View",
55                                     "|auto_indent": true,
56                                     "|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",
57                                     "|insert_spaces_instead_of_tabs": true,
58                                     "|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}",
59                                     "|save": "function() {\n    var str = this.get('buffer').toString();\n    print(\"SAVE\" + str);\n     this.get('/LeftPanel.model').changed(  str , false);\n}\n",
60                                     "|show_line_numbers": true,
61                                     "|xns": "GtkSource",
62                                     "items": [
63                                         {
64                                             "listeners": {
65                                                 "changed": "function (self) {\n\n    this.checkSyntax();\n   // print(\"EDITOR CHANGED\");\n    this.get('/Editor').dirty = true;\n    // this.get('/LeftPanel.model').changed(  str , false);\n    return false;\n}"
66                                             },
67                                             "id": "buffer",
68                                             "pack": "set_buffer",
69                                             "xtype": "Buffer",
70                                             "|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        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    } 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}\n",
71                                             "|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",
72                                             "|xns": "GtkSource"
73                                         }
74                                     ]
75                                 }
76                             ]
77                         }
78                     ]
79                 }
80             ]
81         }
82     ],
83     "permname": ""
84 }