class Iup::Scintilla

Scintilla widget

Public Class Methods

new(&block) click to toggle source
# 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

Public Instance Methods

action(callback) click to toggle source

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)

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

Action generated when the caret/cursor position is changed. caret_cb takes a callback which accepts 3 arguments (line, column, position) of caret

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

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.

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

Called after the value was interactively changed by the user. Called when the selection is changed or when the text is edited.

# 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