Class: Iup::Scintilla
- Includes:
- ButtonCallback
- Defined in:
- lib/wrapped/scintilla.rb
Overview
Scintilla widget – TODO: This class’s actions are incomplete
Constant Summary collapse
- @@opened =
false
Instance Attribute Summary
Attributes inherited from Widget
Instance Method Summary collapse
-
#action(callback) ⇒ Object
Action generated when the text is edited, but before its value is actually changed.
-
#caret_cb(callback) ⇒ Object
Action generated when the caret/cursor position is changed.
-
#initialize(&block) ⇒ Scintilla
constructor
A new instance of Scintilla.
-
#motion_cb(callback) ⇒ Object
Action generated when the mouse is moved.
-
#valuechanged_cb(callback) ⇒ Object
Called after the value was interactively changed by the user.
Methods included from ButtonCallback
Methods inherited from Widget
#assign_handle, #enterwindow_cb, #getfocus_cb, #help_cb, #k_any, #killfocus_cb, #leavewindow_cb, #map_cb, #open_controls, #unmap_cb
Methods included from AttributeBuilders
#define_attribute, #define_id_attribute, #define_id_readonly, #define_id_writeonly, #define_property_attribute, #define_property_writeonly, #define_readonly, #define_writeonly
Methods included from CallbackSetter
Constructor Details
#initialize(&block) ⇒ Scintilla
Returns a new instance of Scintilla.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/wrapped/scintilla.rb', line 10 def initialize &block unless @@opened # make sure the scintilla library is opened on first use ScintillaLib.IupScintillaOpen @@opened = true end @handle = ScintillaLib.IupScintilla self.instance_eval &block if block_given? end |
Instance Method Details
#action(callback) ⇒ Object
Action generated when the text is edited, but before its value is actually changed. action takes a 4-argument callback: code, position, length, text called when indexed item is selected code is 1 for inserted text, 0 for deleted text note: text will be null if code is 0 (deleted)
223 224 225 226 227 228 229 230 231 |
# File 'lib/wrapped/scintilla.rb', line 223 def action callback unless callback.arity == 4 raise ArgumentError, 'action callback must take 4 arguments: (code, position, length, text)' end cb = Proc.new do |ih, insert, pos, length, text| callback.call insert, pos, length, text end define_callback cb, 'ACTION', :iiis_i end |
#caret_cb(callback) ⇒ Object
Action generated when the caret/cursor position is changed. caret_cb takes a callback which accepts 3 arguments (line, column, position) of caret
237 238 239 240 241 242 243 244 245 |
# File 'lib/wrapped/scintilla.rb', line 237 def caret_cb callback unless callback.arity == 3 raise ArgumentError, 'caret_cb callback must take 3 arguments: (line, column, position)' end cb = Proc.new do |ih, lin, col, pos| callback.call lin, col, pos end define_callback cb, 'CARET_CB', :iii_i end |
#motion_cb(callback) ⇒ Object
Action generated when the mouse is moved. Callback takes 3 arguments: (x, y, state)
- x
-
x position of mouse
- y
-
y position of mouse
- state
-
status of mouse buttons and certain keyboard keys at the moment the event was generated.
– TODO: include functions, as in button_cb
255 256 257 258 259 260 261 262 263 |
# File 'lib/wrapped/scintilla.rb', line 255 def motion_cb callback unless callback.arity == 3 raise ArgumentError, 'motion_cb callback must take 3 arguments: (x, y, state)' end cb = Proc.new do |ih, x, y, state| callback.call x, y, state end define_callback cb, 'MOTION_CB', :iis_i end |
#valuechanged_cb(callback) ⇒ Object
Called after the value was interactively changed by the user. Called when the selection is changed or when the text is edited.
267 268 269 270 271 272 273 274 275 |
# File 'lib/wrapped/scintilla.rb', line 267 def valuechanged_cb callback unless callback.arity.zero? raise ArgumentError, 'valuechanged_cb callback must take 0 arguments' end cb = Proc.new do |ih| callback.call end define_callback cb, 'VALUECHANGED_CB', :plain end |