Class: Qx::Scintilla

Inherits:
Qsci::Scintilla
  • Object
show all
Defined in:
lib/troshka/editor/qxscintilla.rb

Instance Method Summary collapse

Constructor Details

#initializeScintilla

Returns a new instance of Scintilla.



6
7
8
9
10
11
# File 'lib/troshka/editor/qxscintilla.rb', line 6

def initialize
  super
  connect(SIGNAL "userListActivated(int, const QString)") do |id, text|
    @autocompletion_activated.(id, text) rescue nil
  end
end

Instance Method Details

#current_column_numberObject



38
39
40
41
# File 'lib/troshka/editor/qxscintilla.rb', line 38

def current_column_number
  #  SCI_GETCOLUMN = 2129
  SendScintilla(2129,pos,0)
end

#current_lineObject



86
87
88
# File 'lib/troshka/editor/qxscintilla.rb', line 86

def current_line
  {text: current_line_text, line_number: current_line_number}
end

#current_line_numberObject

Operations



33
34
35
36
# File 'lib/troshka/editor/qxscintilla.rb', line 33

def current_line_number
  # SCI_LINEFROMPOSITION
  SendScintilla(2166,pos,0)
end

#current_line_textObject



52
53
54
# File 'lib/troshka/editor/qxscintilla.rb', line 52

def current_line_text
  line_text current_line_number
end

#current_positionObject



82
83
84
# File 'lib/troshka/editor/qxscintilla.rb', line 82

def current_position
  {line: current_line_number, column: current_column_number}
end

#key_pressed(&blk) ⇒ Object



28
29
30
# File 'lib/troshka/editor/qxscintilla.rb', line 28

def key_pressed(&blk)
  @key_pressed = blk
end

#keyPressEvent(event) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/troshka/editor/qxscintilla.rb', line 13

def keyPressEvent(event)
  e = OpenStruct.new
  e.key = event.key
  e.modifiers = event.modifiers
  e.continue = true

  @key_pressed.(e) rescue nil
  super event if e.continue
end

#line_length(line) ⇒ Object



43
44
45
46
# File 'lib/troshka/editor/qxscintilla.rb', line 43

def line_length(line)
  # SCI_GETLINEENDPOSITION
  SendScintilla(2136, line, 0)
end

#line_text(line_number) ⇒ Object



48
49
50
# File 'lib/troshka/editor/qxscintilla.rb', line 48

def line_text(line_number)
  text line_number
end

#move_cursor(position) ⇒ Object



66
67
68
69
70
71
72
# File 'lib/troshka/editor/qxscintilla.rb', line 66

def move_cursor(position)
  line, column = position[:line], position[:column]
  line ||= current_line_number
  column ||= current_column_number
  
  setCursorPosition line, column
end

#move_cursor_to_endObject



78
79
80
# File 'lib/troshka/editor/qxscintilla.rb', line 78

def move_cursor_to_end
  setCursorPosition number_of_lines, line_length(number_of_lines)
end

#number_of_linesObject



74
75
76
# File 'lib/troshka/editor/qxscintilla.rb', line 74

def number_of_lines
  lines
end

#replace_line(text, line_number = nil) ⇒ Object



61
62
63
64
# File 'lib/troshka/editor/qxscintilla.rb', line 61

def replace_line(text, line_number=nil)
  select_line
  replaceSelectedText text
end

#select_line(line_number = nil) ⇒ Object



56
57
58
59
# File 'lib/troshka/editor/qxscintilla.rb', line 56

def select_line(line_number=nil)
  line ||= current_line_number
  setSelection line, 0, line, line_length(line)
end

#user_list_activated(&block) ⇒ Object

Events



24
25
26
# File 'lib/troshka/editor/qxscintilla.rb', line 24

def user_list_activated(&block)
  @autocompletion_activated = block
end