troshka 0.0.3 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/troshka +5 -3
- data/lib/shirka/app.rb +41 -0
- data/lib/shirka/components.rb +31 -0
- data/lib/shirka/controller.rb +57 -0
- data/lib/shirka/eventalk.rb +41 -0
- data/lib/shirka/qt.rb +4 -0
- data/lib/shirka/qt/app.rb +21 -0
- data/lib/shirka/qt/list/controller.rb +38 -0
- data/lib/shirka/qt/list/view.rb +23 -0
- data/lib/shirka/qt/list_item/controller.rb +31 -0
- data/lib/shirka/qt/list_item/view.rb +19 -0
- data/lib/shirka/qt/multipanel/controller.rb +8 -0
- data/lib/shirka/qt/multipanel/view.rb +31 -0
- data/lib/shirka/qt/tab/view.rb +16 -0
- data/lib/shirka/qt/tree/controller.rb +40 -0
- data/lib/shirka/qt/tree/view.rb +26 -0
- data/lib/shirka/qt/tree_item/controller.rb +51 -0
- data/lib/shirka/qt/tree_item/view.rb +23 -0
- data/lib/shirka/shirka.rb +8 -0
- data/lib/shirka/view.rb +47 -0
- data/lib/troshka/app.rb +12 -52
- data/lib/troshka/detail/controller.rb +25 -0
- data/lib/troshka/detail/view.rb +5 -0
- data/lib/troshka/detail_panel_enumerable/controller.rb +14 -0
- data/lib/troshka/detail_panel_enumerable/view.rb +5 -0
- data/lib/troshka/detail_panel_hash/controller.rb +14 -0
- data/lib/troshka/detail_panel_hash/view.rb +5 -0
- data/lib/troshka/detail_panel_item_enumerable/controller.rb +14 -0
- data/lib/troshka/detail_panel_item_enumerable/view.rb +10 -0
- data/lib/troshka/detail_panel_item_hash/controller.rb +14 -0
- data/lib/troshka/detail_panel_item_hash/view.rb +10 -0
- data/lib/troshka/detail_panel_item_object/controller.rb +4 -0
- data/lib/troshka/detail_panel_item_object/view.rb +6 -0
- data/lib/troshka/detail_panel_object/controller.rb +5 -0
- data/lib/troshka/detail_panel_object/view.rb +9 -0
- data/lib/troshka/editor/bond_completer.rb +14 -0
- data/lib/troshka/editor/completer.rb +4 -0
- data/lib/troshka/editor/controller.rb +71 -0
- data/lib/troshka/editor/line.rb +43 -0
- data/lib/troshka/editor/qscintilla_view.rb +56 -0
- data/lib/troshka/editor/qtextedit_view.rb +28 -0
- data/lib/troshka/editor/qxscintilla.rb +98 -0
- data/lib/troshka/editor/shell.rb +30 -0
- data/lib/troshka/main/controller.rb +16 -0
- data/lib/troshka/main/view.rb +50 -0
- data/lib/troshka/methods/controller.rb +16 -0
- data/lib/troshka/methods/view.rb +13 -0
- data/lib/troshka/methods_item/controller.rb +4 -0
- data/lib/troshka/methods_item/view.rb +5 -0
- data/lib/troshka/output/controller.rb +13 -0
- data/lib/troshka/output/view.rb +11 -0
- data/lib/troshka/output_item/controller.rb +15 -0
- data/lib/troshka/output_item/view.rb +9 -0
- data/lib/troshka/output_item_code/controller.rb +5 -0
- data/lib/troshka/output_item_code/view.rb +5 -0
- data/lib/troshka/output_item_exception/controller.rb +2 -0
- data/lib/troshka/output_item_exception/view.rb +6 -0
- data/lib/troshka/output_item_obj/controller.rb +2 -0
- data/lib/troshka/output_item_obj/view.rb +2 -0
- data/lib/troshka/output_item_output/controller.rb +5 -0
- data/lib/troshka/output_item_output/view.rb +5 -0
- data/resources/logo.png +0 -0
- metadata +63 -27
- data/lib/troshka.rb +0 -15
- data/lib/troshka/detail.rb +0 -25
- data/lib/troshka/detail_anything.rb +0 -9
- data/lib/troshka/detail_array_hash.rb +0 -86
- data/lib/troshka/editor.rb +0 -113
- data/lib/troshka/output.rb +0 -58
- data/lib/troshka/qt_editor.rb +0 -27
- data/lib/troshka/shell.rb +0 -27
data/bin/troshka
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require_relative '../lib/troshka'
|
3
|
-
|
4
|
-
Troshka::App.new.start
|
2
|
+
require_relative '../lib/troshka/app.rb'
|
5
3
|
|
4
|
+
app = Troshka::App.new
|
5
|
+
app.path = File.expand_path('../lib/troshka', File.dirname(__FILE__))
|
6
|
+
app.icon = File.expand_path('../resources/logo.png', File.dirname(__FILE__))
|
7
|
+
app.start
|
data/lib/shirka/app.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
module Shirka
|
2
|
+
|
3
|
+
class App
|
4
|
+
include Eventalk
|
5
|
+
|
6
|
+
attr_accessor :path
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
setup
|
10
|
+
init
|
11
|
+
end
|
12
|
+
|
13
|
+
def setup
|
14
|
+
end
|
15
|
+
|
16
|
+
def init
|
17
|
+
end
|
18
|
+
|
19
|
+
def start
|
20
|
+
load
|
21
|
+
starting
|
22
|
+
main_controller = MainController.new self
|
23
|
+
main_controller.start
|
24
|
+
started
|
25
|
+
end
|
26
|
+
|
27
|
+
def starting
|
28
|
+
end
|
29
|
+
|
30
|
+
def started
|
31
|
+
end
|
32
|
+
|
33
|
+
def load
|
34
|
+
Dir[path + "/**/{view,controller}.rb"].each do |file|
|
35
|
+
require_relative file
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Shirka
|
2
|
+
|
3
|
+
class Components
|
4
|
+
def initialize
|
5
|
+
@slot_components = Hash.new {|h,k| h[k] = []}
|
6
|
+
@component_slot = {}
|
7
|
+
end
|
8
|
+
|
9
|
+
def add(slot, component)
|
10
|
+
@slot_components[slot] << component
|
11
|
+
@component_slot[component] = slot
|
12
|
+
end
|
13
|
+
|
14
|
+
def slots
|
15
|
+
@slot_components[slot].keys
|
16
|
+
end
|
17
|
+
|
18
|
+
def components
|
19
|
+
@component_slot[component].keys
|
20
|
+
end
|
21
|
+
|
22
|
+
def components_by_slot(slot)
|
23
|
+
@slot_components[slot]
|
24
|
+
end
|
25
|
+
|
26
|
+
def slot_by_component(component)
|
27
|
+
@component_slot[component]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Shirka
|
2
|
+
class Controller
|
3
|
+
include Eventalk
|
4
|
+
|
5
|
+
attr_writer :view
|
6
|
+
attr_reader :components
|
7
|
+
attr_reader :app
|
8
|
+
attr_accessor :parent
|
9
|
+
attr_reader :data
|
10
|
+
|
11
|
+
def initialize(app, parent=nil, data=nil)
|
12
|
+
@app = app
|
13
|
+
@parent = parent
|
14
|
+
@components = Components.new
|
15
|
+
@data = data
|
16
|
+
watch @app
|
17
|
+
init data
|
18
|
+
end
|
19
|
+
|
20
|
+
def init(data)
|
21
|
+
end
|
22
|
+
|
23
|
+
def view_class
|
24
|
+
name = self.class.to_s.sub(/Controller$/, 'View')
|
25
|
+
Object.const_get name rescue ::Shirka::View
|
26
|
+
end
|
27
|
+
|
28
|
+
def view
|
29
|
+
@view ||= view_class.new self
|
30
|
+
end
|
31
|
+
|
32
|
+
def item_controller_class
|
33
|
+
name = self.class.to_s.sub(/Controller$/, 'ItemController')
|
34
|
+
Object.const_get name rescue ::Shirka::Controller
|
35
|
+
end
|
36
|
+
|
37
|
+
def add_item(text='', controller_class=nil)
|
38
|
+
controller_class ||= item_controller_class
|
39
|
+
comp = controller_class.new app, self, text
|
40
|
+
add_component comp
|
41
|
+
end
|
42
|
+
|
43
|
+
def add_component(component, slot=nil)
|
44
|
+
component.parent = self
|
45
|
+
@components.add slot, component
|
46
|
+
component.on_component_adding
|
47
|
+
view.on_view_adding component.view, slot
|
48
|
+
end
|
49
|
+
|
50
|
+
def on_component_adding(data=nil)
|
51
|
+
end
|
52
|
+
|
53
|
+
def on_component_added(data=nil)
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
module Shirka
|
4
|
+
module Eventalk
|
5
|
+
def fire(signal, msg=nil, receivers=nil)
|
6
|
+
if receivers.nil?
|
7
|
+
receivers = watchers
|
8
|
+
else
|
9
|
+
receivers = Array(receivers)
|
10
|
+
end
|
11
|
+
|
12
|
+
receivers.each do |w|
|
13
|
+
method = "on_#{signal}".to_sym
|
14
|
+
if w.respond_to? method
|
15
|
+
e = OpenStruct.new
|
16
|
+
e.signal = signal
|
17
|
+
e.msg = msg
|
18
|
+
e.sender = self
|
19
|
+
w.send method, e
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def forward(event, receivers=nil)
|
25
|
+
fire event.signal, event.msg, receivers
|
26
|
+
end
|
27
|
+
|
28
|
+
def watchers
|
29
|
+
@watchers ||= []
|
30
|
+
end
|
31
|
+
|
32
|
+
def add_watcher(obj)
|
33
|
+
@watchers ||= []
|
34
|
+
@watchers << obj
|
35
|
+
end
|
36
|
+
|
37
|
+
def watch(obj)
|
38
|
+
obj.add_watcher self
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/shirka/qt.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module Shirka
|
2
|
+
module Qt
|
3
|
+
|
4
|
+
class App < ::Shirka::App
|
5
|
+
def setup
|
6
|
+
@qt_app = ::Qt::Application.new []
|
7
|
+
end
|
8
|
+
|
9
|
+
def started
|
10
|
+
fire :starting
|
11
|
+
fire :started
|
12
|
+
@qt_app.exec
|
13
|
+
end
|
14
|
+
|
15
|
+
def icon=(path)
|
16
|
+
@qt_app.setWindowIcon ::Qt::Icon.new(path)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Shirka
|
2
|
+
module Qt
|
3
|
+
|
4
|
+
class ListController < ::Shirka::Controller
|
5
|
+
def init(data)
|
6
|
+
@item_ids = {}
|
7
|
+
data.each { |i| add_item i }
|
8
|
+
end
|
9
|
+
|
10
|
+
def add_item(text='', controller_class=nil)
|
11
|
+
controller_class ||= item_controller_class
|
12
|
+
comp = controller_class.new app, self, text
|
13
|
+
add_component comp
|
14
|
+
end
|
15
|
+
|
16
|
+
def view_class
|
17
|
+
name = self.class.to_s.sub(/Controller$/, 'View')
|
18
|
+
Object.const_get name rescue ::Shirka::Qt::ListView
|
19
|
+
end
|
20
|
+
|
21
|
+
def item_controller_class
|
22
|
+
name = self.class.to_s.sub(/Controller$/, 'ItemController')
|
23
|
+
Object.const_get name rescue ::Shirka::Qt::ListItemController
|
24
|
+
end
|
25
|
+
|
26
|
+
def on_double_clicked(id)
|
27
|
+
controller = @item_ids[id]
|
28
|
+
controller.on_double_clicked
|
29
|
+
end
|
30
|
+
|
31
|
+
def on_component_added(component, data=nil)
|
32
|
+
id = data
|
33
|
+
@item_ids[id] = component
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Shirka
|
2
|
+
module Qt
|
3
|
+
|
4
|
+
class ListView < ::Shirka::View
|
5
|
+
def widget_class
|
6
|
+
::Qt::ListWidget
|
7
|
+
end
|
8
|
+
|
9
|
+
def build(widget)
|
10
|
+
#Double click event
|
11
|
+
widget.connect(SIGNAL "itemDoubleClicked(QListWidgetItem*)") do |item|
|
12
|
+
controller.on_double_clicked item.object_id
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def on_view_adding(view, slot=nil)
|
17
|
+
widget.addItem view.widget
|
18
|
+
widget.scrollToBottom
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Shirka
|
2
|
+
module Qt
|
3
|
+
|
4
|
+
class ListItemController < ::Shirka::Controller
|
5
|
+
def init(data)
|
6
|
+
@text = data.to_s
|
7
|
+
end
|
8
|
+
|
9
|
+
def view_class
|
10
|
+
name = self.class.to_s.sub(/Controller$/, 'View')
|
11
|
+
Object.const_get name rescue ::Shirka::Qt::ListItemView
|
12
|
+
end
|
13
|
+
|
14
|
+
def view
|
15
|
+
@view ||= view_class.new self, @text
|
16
|
+
end
|
17
|
+
|
18
|
+
def id
|
19
|
+
view.id
|
20
|
+
end
|
21
|
+
|
22
|
+
def on_component_adding(data=nil)
|
23
|
+
parent.on_component_added self, id
|
24
|
+
end
|
25
|
+
|
26
|
+
def on_double_clicked
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Shirka
|
2
|
+
module Qt
|
3
|
+
|
4
|
+
class MultipanelView < ::Shirka::View
|
5
|
+
def widget_class
|
6
|
+
::Qt::Widget
|
7
|
+
end
|
8
|
+
|
9
|
+
def build(widget)
|
10
|
+
widget.setLayout ::Qt::StackedLayout.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def on_view_adding(view, slot=nil)
|
14
|
+
layout = widget.layout
|
15
|
+
current_panel = layout.currentWidget
|
16
|
+
|
17
|
+
unless current_panel.nil?
|
18
|
+
layout.removeWidget current_panel
|
19
|
+
current_panel.close
|
20
|
+
end
|
21
|
+
|
22
|
+
layout.addWidget view.widget
|
23
|
+
layout.update
|
24
|
+
widget.show
|
25
|
+
rescue
|
26
|
+
puts $!
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Shirka
|
2
|
+
module Qt
|
3
|
+
|
4
|
+
class TreeController < ::Shirka::Controller
|
5
|
+
def init(data)
|
6
|
+
@item_ids = {}
|
7
|
+
data.each { |i| add_item i } if data.respond_to? :each
|
8
|
+
end
|
9
|
+
|
10
|
+
def view_class
|
11
|
+
name = self.class.to_s.sub(/Controller$/, 'View')
|
12
|
+
Object.const_get name rescue ::Shirka::Qt::TreeView
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def item_controller_class
|
17
|
+
name = self.class.to_s.sub(/Controller$/, 'ItemController')
|
18
|
+
Object.const_get name rescue ::Shirka::Qt::TreeItemController
|
19
|
+
end
|
20
|
+
|
21
|
+
def add_item(text='', controller_class=nil)
|
22
|
+
controller_class ||= item_controller_class
|
23
|
+
comp = controller_class.new app, self, {text: text, root: self}
|
24
|
+
add_component comp
|
25
|
+
end
|
26
|
+
|
27
|
+
def on_double_clicked(id)
|
28
|
+
controller = @item_ids[id]
|
29
|
+
controller.on_double_clicked
|
30
|
+
end
|
31
|
+
|
32
|
+
def on_component_added(component, data=nil)
|
33
|
+
id = data
|
34
|
+
@item_ids[id] = component
|
35
|
+
watch component
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Shirka
|
2
|
+
module Qt
|
3
|
+
|
4
|
+
class TreeView < ::Shirka::View
|
5
|
+
def widget_class
|
6
|
+
::Qt::TreeWidget
|
7
|
+
end
|
8
|
+
|
9
|
+
def build(widget)
|
10
|
+
#Double click event
|
11
|
+
widget.connect(SIGNAL "itemDoubleClicked(QTreeWidgetItem*,int)") do |item, column|
|
12
|
+
controller.on_double_clicked item.object_id
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def style(widget)
|
17
|
+
widget.header.hide
|
18
|
+
end
|
19
|
+
|
20
|
+
def on_view_adding(view, slot=nil)
|
21
|
+
widget.addTopLevelItem view.widget
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|