class EditorController

Public Instance Methods

autocompletion_item_selecting(item) click to toggle source
# 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) click to toggle source
# 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) click to toggle source

Events

# 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() click to toggle source
# 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) click to toggle source
# File lib/troshka/editor/controller.rb, line 67
def on_code_selected(e)
  view.replace_code e.msg
end
on_starting(e) click to toggle source
# File lib/troshka/editor/controller.rb, line 5
def on_starting(e)
  watch app.components[:output]
end
shell() click to toggle source
# File lib/troshka/editor/controller.rb, line 9
def shell
  @shell ||= Shell.new
end
view_class() click to toggle source
# 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