package stk
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=bf3724827aa00f2b5072a9f5e5e9293f
sha512=c7804040165317533b1bbaa6a23374a0bce5ba6976a2f48b49c90aa43c510b03134a1b2c353485365f4dd0cee8cb72d7fbe7558ee52e758db886771e262262d8
doc/stk/Stk/Textview/class-textview/index.html
Class Textview.textviewSource
A widget to display the contents of a text buffer. If no buffer is provided, a new one is created.
inherit Stk.Widget.widgetmethod as_textview : textviewProperties
method wrap_mode : wrap_modemethod set_wrap_mode : ?delay:float -> ?propagate:bool -> wrap_mode -> unitHandled tags
Theme is applied only to handled tags, not all defined tags. Tags in textbuffer which are not handled by a textview are ignored. Beware that changing the handled tags does not trigger re-theming (i.e. #apply_theme is not called).
method add_handled_tag : Stk.Texttag.TSet.id -> unitmethod rem_handled_tag : Stk.Texttag.TSet.id -> unitmethod set_handled_tags : Stk.Texttag.TSet.t -> unitBuffer
method buffer : B.tmethod set_buffer : B.t -> unitv#text () returns contents of the buffer as a string. Optional arguments:
start: the start of range to retrieve (default is0).size: the size of range to retrieve.stop: ifsizeis not provided, the end of the range to retrieve.
Set source language of the textbuffer used by the textview. This also adds the language tags (Texttag.Lang.tags) to the handled tags of the textview.
Cursors
method insert_cursor : B.cursorReturns the insert cursor. The insert cursor is the cursor where text is inserted when user types in. It is also the default cursor for methods accepting a cursor as optional argument. A textview must always have a current insert cursor. Raises Not_found if there is not insert cursor.
method set_insert_cursor : B.cursor -> boolSet the insert cursor.
method is_insert_cursor : B.cursor -> boolv#is_insert_cursor c returns true is c is the current insert cursor.
method selection_cursor : B.cursorThe insert cursor and selection cursor are the bounds of the current selection. A textview must always have a selection cursor, created when the widget is created. Raises Not_found if there is no selection cursor.
method cursor_offset : B.cursor -> intReturns the given cursor offset.
method cursor_line_offset : B.cursor -> B.line_offsetReturns the given cursor position as Textbuffer.line_offset.
method add_cursor : ?props:Stk.Props.t ->
?gravity:B.cursor_gravity ->
?line:int ->
?char:int ->
?offset:int ->
unit ->
B.cursoradd_cursor () creates a new cursor. props can be provided to specify properties for this cursor (like its color). See Textbuffer.create_cursor for other arguments.
method remove_cursor : B.cursor -> unitRemoves the given cursor. Beware when removing the insert cursor, it should be replaced by another one.
Move selection cursor at the same position than the insert cursor.
method scroll_to_cursor : ?c:B.cursor -> unit -> unitMake sure the insert cursor (or the cursor given with argument c) is in the displayed area.
Moving cursors
The following methods moves by default the insert cursor, or the selection cursor if a shift key is pressed. The optional argument c can be used to move another cursor.
The methods return the new offset of the cursor, or None if the cursor is invalid.
method move_to_line_start : ?c:B.cursor -> unit -> int optionMoves cursor to beginning of the line where the cursor is.
method move_to_line_end : ?c:B.cursor -> unit -> int optionMoves cursor to the end (before the newline character) of the line where the cursor is.
method line_forward : ?c:B.cursor -> int -> int optionMoves cursor to next line.
method line_backward : ?c:B.cursor -> int -> int optionMoves cursor to previous line.
method dline_forward : ?c:B.cursor -> int -> int optionMoves cursor to next "display line", i.e. next part of the line is the line is wrapped and the cursor is not in the last part of the line, or the next line.
method dline_backward : ?c:B.cursor -> int -> int optionMoves cursor to previous "display line", i.e. the previous part of the line if the line is wrapped and the cursor is not in the first part, or the previous line.
method char_forward : ?c:B.cursor -> int -> int optionv#char_forward n moves cursor n characters forward.
method char_backward : ?c:B.cursor -> int -> int optionv#char_backward n moves cursor n characters backward.
method forward_to_word_end : ?c:B.cursor -> unit -> int optionMoves cursor to next word end, according to waht is a word character in the buffer (see Textbuffer.word_chars).
method backward_to_word_start : ?c:B.cursor -> unit -> int optionMoves cursor to previous word start.
method move_cursor : ?line:int ->
?char:int ->
?offset:int ->
?c:B.cursor ->
unit ->
int optionv#move_cursor () moves cursor to position specified by optional arguments as explained in Textbuffer.move_cursor.
method page_backward : ?c:B.cursor -> unit -> int optionMoves cursor one page backward. Depends on the displayed size of the widget. Typically associated to page-up key.
method page_forward : ?c:B.cursor -> unit -> int optionMoves cursor one page forward. Depends on the displayed size of the widget. Typically associated to page-down key.
Selection
method selection_range : Stk.Rope.range optionReturns the selected range, if any.
v#select_range ~start ~size moves insert and selection cursors to select the specified range.
Inserting and deleting
method insert_at : ?honor_readonly:bool ->
?tags:Stk.Texttag.TSet.id list ->
int ->
string ->
unitv#insert_at offset string inserts string at offset. Options arguments:
honor_readonlyspecifies whether insertion is conditioned by theProps.editableproperty of tags. Default isfalse. It is called withtrueto insert the text the user types in.tagsspecifies tags to associate to inserted characters.
method insert : ?honor_readonly:bool ->
?tags:Stk.Texttag.T.t list ->
?c:B.cursor ->
string ->
unitSame as textview.insert_at but inserts at the position of the insert cursor or the position of a cursor given with argument c.
v#delete () delete contents of buffer. Optional arguments:
start: the start of range to delete (default is0).size: the size of range to delete. Default is buffer size -start.honor_readonlyspecifies whether deletion is conditioned by theProps.editableproperty of tags. Default isfalse. It is called withtrueto delete text from a user action.
method delete_backward : ?honor_readonly:bool -> ?c:B.cursor -> int -> stringv#delete_backward n deletes n characters backward the insert cursor. Optional arguments:
cto indicate another cursor to delete backward from.honor_readonly(default isfalse): same as intextview.delete.
method delete_forward : ?honor_readonly:bool -> ?c:B.cursor -> int -> stringSame as textview.delete_backward but deletes forward from cursor.
v#replace_selection str replaces the selected range, if any, by str, in a single history action. If no range is selected, just insert str at insert cursor. Optional argument honor_readonly is passed to textview.delete and textview.insert methods.
v#cut () cut the selected range, if any, and copies it to clipboard. Optional argument honor_readonly is passed to textview.delete. Returns the deleted string, if any.
v#paste () calls textview.replace_selection with the clipboard text, if any. Optional argument honor_readonly is passed to textview.replace_selection.
History
v#in_action f calls f() between Textbuffer.begin_action and Textbuffer.end_action. The result of f() is returned. If f() raises an exception, the action is ended and the exception if reraised.