Class: EditorController
Instance Attribute Summary
#app, #components, #data, #parent, #view
Instance Method Summary
collapse
#add_component, #add_item, #init, #initialize, #item_controller_class, #on_component_added, #on_component_adding
#add_watcher, #fire, #forward, #watch, #watchers
Instance Method Details
#autocompletion_item_selecting(item) ⇒ Object
62
63
64
65
|
# File 'lib/troshka/editor/controller.rb', line 62
def autocompletion_item_selecting(item)
@line.replace_selection_text item
view.autocompletion_item_selected @line.text, @line.cursor
end
|
#autocompletion_list_requesting(text, cursor) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/troshka/editor/controller.rb', line 49
def autocompletion_list_requesting(text, cursor)
@line = Line.new text, cursor
list = completer.complete @line.text(@line.word), @line.text
unless list.empty?
prefix = list.first.dup
prefix.chop! while @line.text.rindex(prefix).nil?
@line.selection = [cursor - prefix.size, cursor]
view.autocompletion_list_requested list, @line.selection
end
end
|
#code_entering(text) ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/troshka/editor/controller.rb', line 41
def code_entering(text)
time_begin = Time.now
result = shell.run text
time_end = Time.now
result[:time] = (time_end - time_begin) * 1000
fire :code_evaluated, result
end
|
#completer ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/troshka/editor/controller.rb', line 13
def completer
if @completer.nil?
begin
require_relative 'bond_completer'
rescue LoadError
require_relative 'completer'
ensure
@completer = Completer.new
end
end
@completer
end
|
#on_code_selected(e) ⇒ Object
67
68
69
|
# File 'lib/troshka/editor/controller.rb', line 67
def on_code_selected(e)
view.replace_code e.msg
end
|
#on_starting(e) ⇒ Object
5
6
7
|
# File 'lib/troshka/editor/controller.rb', line 5
def on_starting(e)
watch app.components[:output]
end
|
#shell ⇒ Object
9
10
11
|
# File 'lib/troshka/editor/controller.rb', line 9
def shell
@shell ||= Shell.new
end
|
#view_class ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/troshka/editor/controller.rb', line 26
def view_class
if @view_class.nil?
begin
require_relative 'qscintilla_view'
rescue LoadError
require_relative 'qtextedit_view'
ensure
@view_class = EditorView
end
end
@view_class
end
|