class Iup::Scintilla
A powerful text element. The API documentation can only hint at the use of this control. For more information see Tecgrafâs documentation on IupScintilla and the Scintilla website.
Example
The following example sets up a Scintilla text widget handling some cpp code. Notice the setup of the keywords and styling settings. Also, the text widget must be placed into a dialog and mapped before its other attributes are set and the dialog shown.
text = Iup::Scintilla.new dlg = Iup::Dialog.new(text) do |d| d.title = 'Scintilla example' d.size = '300x200' end.map text.expand = 'YES' text.lexerlanguage = 'cpp' text.keywords(0, "void struct union enum char short int long double float signed unsigned const static extern auto register volatile bool class private protected public friend inline template virtual asm explicit typename mutable if else switch case default break goto return for while do continue typedef sizeof NULL new delete throw try catch namespace operator this const_cast static_cast dynamic_cast reinterpret_cast true false using typeid and and_eq bitand bitor compl not not_eq or or_eq xor xor_eq") text.stylefont(32, 'Consolas') text.stylefontsize(32, 11) text.styleclearall = 'Yes' text.stylefgcolor(1, '0 128 0') # 1 - C Comment text.stylefgcolor(2, '0 128 0') # 2 - C++ Comment line text.stylefgcolor(4, '128 0 0') # 4 - Number text.stylefgcolor(5, '0 0 255') # 5 - Keyword text.stylefgcolor(6, '160 20 20') # 6 - String text.stylefgcolor(7, '128 0 0') # 7 - Character text.stylefgcolor(9, '0 0 255') # 9 - Preprocessor block text.stylefgcolor(10, '255 0 255') # 10 - Operator text.stylebold(10, 'YES') text.stylehotspot(6, 'YES') text.marginwidth(0, 50) text.property('fold', 1) text.property('fold.compact', 0) text.property('fold.comment', 1) text.property('fold.preprocessor', 1) text.marginwidth(1, 20) text.margintype(1, 'SYMBOL') text.marginmaskfolders(1, 'Yes') text.markerdefine('folder', 'plus') text.markerdefine('folderopen', 'minus') text.markerdefine('folderend', 'empty') text.markerdefine('foldermidtail', 'empty') text.markerdefine('folderopenmid', 'empty') text.markerdefine('foldersub', 'empty') text.markerdefine('foldertail', 'empty') text.foldflags = 'lineafter_contracted' text.marginsensitive(1, 'YES') dlg.show
Public Class Methods
Source
# File lib/wrapped/scintilla.rb, line 76 def initialize unless @@opened # make sure the scintilla library is opened on first use ScintillaLib.IupScintillaOpen @@opened = true end @handle = ScintillaLib.IupScintilla yield self if block_given? end
Creates a new instance. If a block is given, the new instance is yielded to it.
Annotation attributes
Attributes
Deletes all annotations.
A style offset separates the annotation and text.
Setting to enable or display annotations. Values âhiddenâ / âstandardâ / âboxedâ.
Public Instance Methods
Source
# File lib/wrapped/scintilla.rb, line 255 define_id_attribute :annotationstyle
For the âidâ line number, accesses its style.
Source
# File lib/wrapped/scintilla.rb, line 246 define_id_attribute :annotationtext
For the âidâ line number, accesses its annotation.
Auto-completion attributes
Attributes
Returns âYESâ if there is an auto-completion list showing.
Removes any displayed auto-completion list.
Starts the auto-completion.
Controls if remaining characters are deleted once an item is selected. Values âyesâ / ânoâ.
Controls number of rows visible in auto-completion list.
Controls width of auto-completion list, in characters.
Returns current start position of auto-completion list.
Select an item from auto-completion list.
Returns index of currently selected item.
Public Instance Methods
Source
# File lib/wrapped/scintilla.rb, line 282 define_id_writer :autocshow
Shows a list of words with âidâ being the number of characters entered by user.
Brace highlighting attributes
Attributes
Using format âpos1:pos2â, highlights a mis-matching brace.
Using format âpos1:pos2â, highlights the brace.
Public Instance Methods
Source
# File lib/wrapped/scintilla.rb, line 349 define_id_reader :bracematch
Finds a match for the brace at character position âidâ.
Callbacks
Attributes
Callback called when the text is edited, but before its value is actually changed. Callback must respond to call and takes a 4-argument callback: (insert, position, length, text)
-
insert- â1â for inserted text, â0â for deleted text -
position- 0-base character position when change started -
length- size of the cahange -
text- the inserted text value, ââ if text deleted
Callback called when the caret/cursor position is changed. Callback must respond to call and takes a callback which accepts 3 arguments: (line, column, position)
-
line- line number of caret -
column- column number of caret -
position- 0-based character position
Callback called when the mouse is moved. Callback must respond to call and 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.
Called after the value was interactively changed by the user. Called when the selection is changed or when the text is edited. Callback must respond to call and takes no arguments.
Caret and selection attributes
Attributes
Position of the insertion point, in âlin,colâ format.
Position of the insertion point, as a 0-based character position.
Ensures caret is on a visible line.
Accesses the currently selected text.
Identifies selection in format âlin1,col1:lin2,col2â / âallâ / ânoneâ.
Identifies selection in 0-based character position format âpos1:pos2â / âallâ / ânoneâ.
Folding attributes
Attributes
Style of drawn fold lines, one of: âLINEBEFORE_EXPANDEDâ / âLINEBEFORE_CONTRACTEDâ / âLINEAFTER_EXPANDEDâ / âLINEAFTER_CONTRACTEDâ
Expands or closes fold point, based on line number
Public Instance Methods
Source
# File lib/wrapped/scintilla.rb, line 400 define_id_attribute :foldlevel
The fold level of line âidâ.
General attributes
Attributes
Sets border around widget, values âyesâ / ânoâ.
If set, the control can gain focus, values âyesâ / ânoâ.
âclearâ / âcopyâ / âcutâ / âpasteâ, access the clipboard with the current selection.
Defines the mouse shape / cursor for the canvas. Available cursors are shown in the Tecgraf documentation.
âoffâ / âonâ, when enabled, new characters replace the one to the right of the text caret.
ânoâ / âyesâ setting to restrict editing of text.
Size of the container, in character units, value as âwidthxheightâ.
âyesâ / ânoâ controls visibility of right-click popup menu available to user.
Accesses the number of visible columns for the controlâs natural size.
Accesses the number of visible lines for the controlâs natural size.
Returns the number of lines which are visible.
Values âyesâ / ânoâ.
Controls the drawing of visual flags to show word-wrap has occurred. Values âyesâ / ânoâ.
Lexer attributes
Attributes
Returns description of all keyword lists.
Any name supported by Scintilla, e.g. ârubyâ / âbashâ / âtexâ.
Loads a lexer from a given filename.
Returns a list of property names.
Public Instance Methods
Source
# File lib/wrapped/scintilla.rb, line 415 define_id_writer :keywords
Creates a keyword list with an id in range 0 to 8.
Source
# File lib/wrapped/scintilla.rb, line 439 define_property_attribute :property
Access lexer properties.
Margin attributes
Public Instance Methods
Source
# File lib/wrapped/scintilla.rb, line 538 define_id_attribute :margincursor
Accesses the cursor for margin, values âreversearrowâ / âarrowâ.
Source
# File lib/wrapped/scintilla.rb, line 491 define_id_attribute :marginleft
Defines size of blank margin on the left size.
Source
# File lib/wrapped/scintilla.rb, line 456 define_id_attribute :marginmaskfolders
Define if margin âidâ is folding or non-folding, values âyesâ / ânoâ.
Source
# File lib/wrapped/scintilla.rb, line 500 define_id_attribute :marginright
Defines size of blank margin on the right size.
Source
# File lib/wrapped/scintilla.rb, line 466 define_id_attribute :marginsensitive
Define if margin âidâ is sensitive or not, values âyesâ / ânoâ.
Source
# File lib/wrapped/scintilla.rb, line 510 define_id_attribute :margintext
-
id- the line number
Controls text of each line.
Source
# File lib/wrapped/scintilla.rb, line 528 define_id_writer :margintextclearall
Clears text and styles of given margin âidâ.
Source
# File lib/wrapped/scintilla.rb, line 520 define_id_attribute :margintextstyle
-
id- the line number
Controls style of text of each line.
Source
# File lib/wrapped/scintilla.rb, line 473 define_id_attribute :margintype
Define and set type of margin âidâ. Values âsymbolâ / ânumberâ / âtextâ / ârtextâ / âbackgroundâ / âforegroundâ
Source
# File lib/wrapped/scintilla.rb, line 482 define_id_attribute :marginwidth
Defines width of a margin âidâ in pixels.
Marker attributes
Attributes
Returns the last handle created by markeradd.
Returns last line number with marker found by markernext.
Searches for a marker given its handle âidâ and deletes it, if found.
Accesses highlight of folding block when selected. Values âyesâ / ânoâ.
Public Instance Methods
Source
# File lib/wrapped/scintilla.rb, line 575 define_id_writer :bgcolor
Defines background color of given marker number. Values as âr g bâ.
Source
# File lib/wrapped/scintilla.rb, line 623 define_id_writer :markeradd
Adds marker number to given line âidâ.
Source
# File lib/wrapped/scintilla.rb, line 592 define_id_writer :markeralpha
Defines alpha value of given marker number.
Source
# File lib/wrapped/scintilla.rb, line 584 define_id_writer :markerbgcolorsel
Defines highlight background color of given marker number. Values as âr g bâ.
Source
# File lib/wrapped/scintilla.rb, line 548 define_property_writer :markerdefine
Sets marker for given number.
Source
# File lib/wrapped/scintilla.rb, line 631 define_id_writer :markerdelete
Deletes marker number to given line âidâ.
Source
# File lib/wrapped/scintilla.rb, line 638 def markerdeleteall(val) IupLib.IupSetAttribute(@handle, "MARKERDELETEALL", val.to_s) end
Removes given marker from all lines.
Source
# File lib/wrapped/scintilla.rb, line 566 define_id_writer :markerfgcolor
Defines foreground color of given marker number. Values as âr g bâ.
Source
# File lib/wrapped/scintilla.rb, line 648 define_id_reader :markerget
Returns marker mask with markers for given line âidâ.
Source
# File lib/wrapped/scintilla.rb, line 674 define_id_reader :markerlinefromhandle
Searches for a marker given its handle âidâ.
Source
# File lib/wrapped/scintilla.rb, line 657 define_id_writer :markernext
Searches for a given marker mask, starting from line âidâ and moving forwards.
Source
# File lib/wrapped/scintilla.rb, line 666 define_id_writer :markerprevious
Searches for a given marker mask, starting from line âidâ and moving backwards.
Source
# File lib/wrapped/scintilla.rb, line 601 define_id_writer :markerrgbaimage
Defines image to be used on a marker number: must be an Iup::ImageRGBA.
Source
# File lib/wrapped/scintilla.rb, line 609 define_id_writer :markerrgbaimagescale
Defines image scale factor, as a percent (1-100).
Source
# File lib/wrapped/scintilla.rb, line 557 define_id_attribute :markersymbol
Associates marker number with symbol.
Scrolling attributes
Attributes
Adds a scrollbar to the widget. Values âhorizontalâ / âverticalâ / âyesâ / ânoâ.
Make given caret position visible.
Controls document width in pixels, default: 2000.
Search and replace attributes
Attributes
Replaces the target text.
Accesses flags - possible values are âMATCHCASEâ / âWHOLEWORDâ / âWORDSTARTâ / âREGEXPâ / âPOSIXâ. Combine flags using â|â, and clear with nil.
Searches for text string within targetstart targetend bounds.
Character position of end of target.
Sets target start and end based on current selection.
Character position of start of target.
Sets target start and end to the whole document.
Standard attributes
Attributes
Allows control to fill available space in indicated direction. Values ânoâ / âhorizontalâ / âverticalâ / âyesâ.
Returns position in pixels within client window as âx,yâ.
Size of the button, in pixels, value as âwidthxheightâ.
Returns position in pixels on screen as âx,yâ.
Tooltip string.
Style definition attributes
Attributes
Returns all styles to attributes of the default style.
Public Instance Methods
Source
# File lib/wrapped/scintilla.rb, line 757 define_id_attribute :stylebgcolor
Background color for a style, as âr g bâ.
Source
# File lib/wrapped/scintilla.rb, line 766 define_id_attribute :stylebold
Bold setting for a style.
Source
# File lib/wrapped/scintilla.rb, line 775 define_id_attribute :stylecase
Text characteristics for a style.
Source
# File lib/wrapped/scintilla.rb, line 785 define_id_attribute :stylecharset
Alter charset for a style, values include âANSIâ / âEASTEUROPEâ / âRUSSIANâ / âGB2312â / âHANGULâ / âSHIFTJISâ.
Source
# File lib/wrapped/scintilla.rb, line 800 define_id_attribute :styleeolfilled
Whether to set a line to same color set as last character on line, values âyesâ / ânoâ.
Source
# File lib/wrapped/scintilla.rb, line 809 define_id_attribute :stylefgcolor
Foreground color for a style, as âr g bâ.
Source
# File lib/wrapped/scintilla.rb, line 818 define_id_attribute :stylefont
Font name for a style.
Source
# File lib/wrapped/scintilla.rb, line 827 define_id_attribute :stylefontsize
Font size for a style.
Source
# File lib/wrapped/scintilla.rb, line 836 define_id_attribute :stylefontsizefrac
Font size as a fractional point size for a style.
Source
# File lib/wrapped/scintilla.rb, line 845 define_id_attribute :stylehotspot
Marks ranges to respond to mouse clicks.
Source
# File lib/wrapped/scintilla.rb, line 854 define_id_attribute :styleitalic
Italic setting for a style.
Source
# File lib/wrapped/scintilla.rb, line 863 define_id_attribute :stylereset
Resets style to default.
Source
# File lib/wrapped/scintilla.rb, line 872 define_id_attribute :styleunderline
Underline setting for a style.
Source
# File lib/wrapped/scintilla.rb, line 881 define_id_attribute :stylevisible
Values âyesâ / ânoâ, for visible text.
Source
# File lib/wrapped/scintilla.rb, line 890 define_id_attribute :styleweight
Font weight for a style.
Styling attributes
Attributes
Resets and clears styling and folding.
Prepares for styling, setting the start position.
Public Instance Methods
Source
# File lib/wrapped/scintilla.rb, line 910 define_id_writer :styling
Sets style of given length characters using style âidâ.
Tabs and indentation attributes
Attributes
Highlights indentation guide of a given column.
Controls dotted vertical lines to show indentation white space, values ânoneâ / ârealâ / âlookforwardâ / âlookbothâ.
Number of characters for a tab. Default is 8.
Use tabs for indentation or only spaces, values âyesâ / ânoâ.
Text retrieval and modification attributes
Attributes
Inserts a string at the current position.
Inserts a string at the end of the text.
Deletes all text, unless the control is readonly.
Returns the number of characters in the text.
Returns the number of lines in the text.
Returns the text of the line where the caret is.
Inserts a string at the beginning of the text.
Text entered by the user.
Public Instance Methods
Source
# File lib/wrapped/scintilla.rb, line 178 define_id_reader :char
-
id- position in the text.
Returns the character at a given position.
Source
# File lib/wrapped/scintilla.rb, line 194 def deleterange(pos, len) IupLib.IupSetAttribute(@handle, "DELETERANGE", "#{pos},#{len}") end
Deletes a range of text:
-
pos- position of start of range in text -
len- number of characters to delete
Source
# File lib/wrapped/scintilla.rb, line 206 define_id_writer :insert
-
id- position in the text -
str- text string
Inserts a text string at position âidâ.
Source
# File lib/wrapped/scintilla.rb, line 215 define_id_reader :line
-
id- position in the text.
Returns the text of the line referenced by given âidâ.
Undo and redo attributes
Attributes
Redo the last operation if set to âyesâ, or all operations if set to âallâ.
Undo the last operation if set to âyesâ, or all operations if set to âallâ.
Controls collection of undo information, value âyesâ / ânoâ.
White space attributes
Attributes
Controls extra space between lines, beyond maximum ascent.
Controls extra space between lines, beyond maximum descent.
Defines background color of visible white space, in âr g bâ format.
Defines foreground color of visible white space, in âr g bâ format.
Size of dots when separating space characters, default is 3.
Controls the display of white space, values âinvisibleâ / âvisiblealwaysâ / âvisibleafterindentâ.
Zooming attributes
Attributes
Accesses the zoom factor, range -10 to 20.
Increase zoom factor by one point.
Decrease zoom factor by one point.