wxRuby Documentation Home

# Wx::RichTextCtrl

RichTextCtrl provides a generic, ground-up implementation of a text control
capable of showing multiple styles and images. It inherits from
TextCtrl and so supports all methods and event handlers
available in that class.

RichTextCtrl also sends notification events specific to the rich text
class: see RichTextEvent. It also sends the
standard TextCtrl events EVT_COMMAND_TEXT_ENTER and
EVT_COMMAND_TEXT_UPDATED, and TextUrlEvent when URL
content is clicked.

## Derived from

TextCtrl

Control

Window

EvtHandler

Object

## Data structures

## Methods

- RichTextCtrl.new
- RichTextCtrl#add_image
- RichTextCtrl#add_paragraph
- RichTextCtrl#append_text
- RichTextCtrl#apply_alignment_to_selection
- RichTextCtrl#apply_bold_to_selection
- RichTextCtrl#apply_italic_to_selection
- RichTextCtrl#apply_style
- RichTextCtrl#apply_style_sheet
- RichTextCtrl#apply_underline_to_selection
- RichTextCtrl#batching_undo
- RichTextCtrl#begin_alignment
- RichTextCtrl#begin_batch_undo
- RichTextCtrl#begin_bold
- RichTextCtrl#begin_character_style
- RichTextCtrl#begin_font
- RichTextCtrl#begin_font_size
- RichTextCtrl#begin_italic
- RichTextCtrl#begin_left_indent
- RichTextCtrl#begin_line_spacing
- RichTextCtrl#begin_list_style
- RichTextCtrl#begin_numbered_bullet
- RichTextCtrl#begin_paragraph_spacing
- RichTextCtrl#begin_paragraph_style
- RichTextCtrl#begin_right_indent
- RichTextCtrl#begin_style
- RichTextCtrl#begin_suppress_undo
- RichTextCtrl#begin_symbol_bullet
- RichTextCtrl#begin_text_colour
- RichTextCtrl#begin_underline
- RichTextCtrl#begin_url
- RichTextCtrl#can_copy
- RichTextCtrl#can_cut
- RichTextCtrl#can_delete_selection
- RichTextCtrl#can_paste
- RichTextCtrl#can_redo
- RichTextCtrl#can_undo
- RichTextCtrl#clear
- RichTextCtrl#clear_list_style
- RichTextCtrl#command
- RichTextCtrl#copy
- RichTextCtrl#create
- RichTextCtrl#cut
- RichTextCtrl#delete
- RichTextCtrl#delete_selected_content
- RichTextCtrl#delete_selection
- RichTextCtrl#discard_edits
- RichTextCtrl#do_get_best_size
- RichTextCtrl#end_alignment
- RichTextCtrl#end_all_styles
- RichTextCtrl#end_batch_undo
- RichTextCtrl#end_bold
- RichTextCtrl#end_character_style
- RichTextCtrl#end_font
- RichTextCtrl#end_font_size
- RichTextCtrl#end_italic
- RichTextCtrl#end_left_indent
- RichTextCtrl#end_line_spacing
- RichTextCtrl#end_list_style
- RichTextCtrl#end_numbered_bullet
- RichTextCtrl#end_paragraph_spacing
- RichTextCtrl#end_paragraph_style
- RichTextCtrl#end_right_indent
- RichTextCtrl#end_style
- RichTextCtrl#end_suppress_undo
- RichTextCtrl#end_symbol_bullet
- RichTextCtrl#end_text_colour
- RichTextCtrl#end_underline
- RichTextCtrl#end_url
- RichTextCtrl#extend_selection
- RichTextCtrl#find_next_word_position
- RichTextCtrl#freeze
- RichTextCtrl#get_basic_style
- RichTextCtrl#get_buffer
- RichTextCtrl#get_caret_position
- RichTextCtrl#get_caret_position_for_index
- RichTextCtrl#get_command_processor
- RichTextCtrl#get_default_style_ex
- RichTextCtrl#get_delayed_layout_threshold
- RichTextCtrl#get_filename
- RichTextCtrl#get_first_visible_position
- RichTextCtrl#get_handler_flags
- RichTextCtrl#get_insertion_point
- RichTextCtrl#get_last_position
- RichTextCtrl#get_line_length
- RichTextCtrl#get_line_text
- RichTextCtrl#get_logical_point
- RichTextCtrl#get_number_of_lines
- RichTextCtrl#get_physical_point
- RichTextCtrl#get_range
- RichTextCtrl#get_selection
- RichTextCtrl#get_selection_range
- RichTextCtrl#get_string_selection
- RichTextCtrl#get_style
- RichTextCtrl#get_style_for_range
- RichTextCtrl#get_style_sheet
- RichTextCtrl#get_uncombined_style
- RichTextCtrl#get_value
- RichTextCtrl#get_visible_line_for_caret_position
- RichTextCtrl#has_character_attributes
- RichTextCtrl#has_paragraph_attributes
- RichTextCtrl#has_selection
- RichTextCtrl#hit_test
- RichTextCtrl#init
- RichTextCtrl#init_command_event
- RichTextCtrl#is_default_style_showing
- RichTextCtrl#is_editable
- RichTextCtrl#is_frozen
- RichTextCtrl#is_modified
- RichTextCtrl#is_multi_line
- RichTextCtrl#is_position_visible
- RichTextCtrl#is_selection_aligned
- RichTextCtrl#is_selection_bold
- RichTextCtrl#is_selection_italics
- RichTextCtrl#is_selection_underlined
- RichTextCtrl#is_single_line
- RichTextCtrl#keyboard_navigate
- RichTextCtrl#layout_content
- RichTextCtrl#line_break
- RichTextCtrl#load_file
- RichTextCtrl#mark_dirty
- RichTextCtrl#move_caret
- RichTextCtrl#move_caret_back
- RichTextCtrl#move_caret_forward
- RichTextCtrl#move_down
- RichTextCtrl#move_end
- RichTextCtrl#move_home
- RichTextCtrl#move_left
- RichTextCtrl#move_right
- RichTextCtrl#move_to_line_end
- RichTextCtrl#move_to_line_start
- RichTextCtrl#move_to_paragraph_end
- RichTextCtrl#move_to_paragraph_start
- RichTextCtrl#move_up
- RichTextCtrl#newline
- RichTextCtrl#number_list
- RichTextCtrl#on_clear
- RichTextCtrl#on_context_menu
- RichTextCtrl#on_copy
- RichTextCtrl#on_cut
- RichTextCtrl#on_drop_files
- RichTextCtrl#on_paste
- RichTextCtrl#on_redo
- RichTextCtrl#on_select_all
- RichTextCtrl#on_undo
- RichTextCtrl#on_update_clear
- RichTextCtrl#on_update_copy
- RichTextCtrl#on_update_cut
- RichTextCtrl#on_update_paste
- RichTextCtrl#on_update_redo
- RichTextCtrl#on_update_select_all
- RichTextCtrl#on_update_undo
- RichTextCtrl#page_down
- RichTextCtrl#page_up
- RichTextCtrl#paint_background
- RichTextCtrl#paste
- RichTextCtrl#position_caret
- RichTextCtrl#position_to_xy
- RichTextCtrl#promote_list
- RichTextCtrl#redo
- RichTextCtrl#remove
- RichTextCtrl#replace
- RichTextCtrl#save_file
- RichTextCtrl#scroll_into_view
- RichTextCtrl#select_all
- RichTextCtrl#select_none
- RichTextCtrl#set_and_show_default_style
- RichTextCtrl#set_basic_style
- RichTextCtrl#set_caret_position
- RichTextCtrl#set_default_style
- RichTextCtrl#set_default_style_to_cursor_style
- RichTextCtrl#set_delayed_layout_threshold
- RichTextCtrl#set_editable
- RichTextCtrl#set_filename
- RichTextCtrl#set_font
- RichTextCtrl#set_handler_flags
- RichTextCtrl#set_insertion_point
- RichTextCtrl#set_insertion_point_end
- RichTextCtrl#set_list_style
- RichTextCtrl#set_selection
- RichTextCtrl#set_selection_range
- RichTextCtrl#set_style
- RichTextCtrl#set_style_ex
- RichTextCtrl#set_style_sheet
- RichTextCtrl#set_value
- RichTextCtrl#setup_scrollbars
- RichTextCtrl#show_position
- RichTextCtrl#suppressing_undo
- RichTextCtrl#thaw
- RichTextCtrl#undo
- RichTextCtrl#word_left
- RichTextCtrl#word_right
- RichTextCtrl#write_image
- RichTextCtrl#write_text
- RichTextCtrl#xy_to_position

### RichTextCtrl.new

RichTextCtrl.new(%(arg-type)Window% parent, Integer id = ID_ANY, String value = ’’, Point pos = DEFAULT_POSITION, Size size = DEFAULT_SIZE, Integer style = RE_MULTILINE, Validator validator = DEFAULT_VALIDATOR, String name = TextCtrlNameStr)

Constructors.

### add_image

Range add_image(%(arg-type)Image% image)

Adds an image to the control’s buffer.

### add_paragraph

Range add_paragraph(%(arg-type)String% text)

Adds a new paragraph of text to the end of the buffer.

### append_text

append_text(%(arg-type)String% text)

Sets the insertion point to the end of the buffer and writes the text.

### apply_alignment_to_selection

Boolean apply_alignment_to_selection(%(arg-type)TextAttrAlignment% alignment)

Applies the given alignment to the selection (undoable).

For alignment values, see RichTextAttr.

### apply_bold_to_selection

Boolean apply_bold_to_selection()

Apples bold to the selection (undoable).

### apply_italic_to_selection

Boolean apply_italic_to_selection()

Applies italic to the selection (undoable).

### apply_style

Boolean apply_style(%(arg-type)RichTextStyleDefinition% def)

Applies the given style to the selection.

### apply_style_sheet

Boolean apply_style_sheet(%(arg-type)RichTextStyleSheet% sheet $=$ NULL)

Applies the style sheet to the buffer, matching paragraph styles in the sheet against named styles
in the buffer. This might be useful if the styles have changed. If sheet is NULL, the
sheet set with SetStyleSheet is used.

Currently this applies paragraph styles only.

### apply_underline_to_selection

Boolean apply_underline_to_selection()

Applies underline to the selection (undoable).

### batching_undo

Boolean batching_undo()

Returns if undo commands are being batched.

### begin_alignment

Boolean begin_alignment(%(arg-type)TextAttrAlignment% alignment)

Begins using alignment

For alignment values, see RichTextAttr.

### begin_batch_undo

Boolean begin_batch_undo(%(arg-type)String% cmdName)

Starts batching undo history for commands.

### begin_bold

Boolean begin_bold()

Begins using bold.

### begin_character_style

Boolean begin_character_style(%(arg-type)String% characterStyle)

Begins using the named character style.

### begin_font

Boolean begin_font(%(arg-type)Font% font)

Begins using this font.

### begin_font_size

Boolean begin_font_size(%(arg-type)Integer% pointSize)

Begins using the given point size.

### begin_italic

Boolean begin_italic()

Begins using italic.

### begin_left_indent

Boolean begin_left_indent(%(arg-type)Integer% leftIndent, Integer leftSubIndent = 0)

Begins applying a left indent and subindent in tenths of a millimetre.

The sub-indent is an offset from the left of the paragraph, and is used for all but the
first line in a paragraph. A positive value will cause the first line to appear to the left
of the subsequent lines, and a negative value will cause the first line to be indented
relative to the subsequent lines.

RichTextBuffer uses indentation to render a bulleted item. The left indent is the distance between
the margin and the bullet. The content of the paragraph, including the first line, starts
at leftMargin + leftSubIndent. So the distance between the left edge of the bullet and the
left of the actual paragraph is leftSubIndent.

### begin_line_spacing

Boolean begin_line_spacing(%(arg-type)Integer% lineSpacing)

Begins appling line spacing. spacing is a multiple, where 10 means single-spacing,
15 means 1.5 spacing, and 20 means double spacing. The following constants are
defined for convenience:

#define TEXT_ATTR_LINE_SPACING_NORMAL 10 #define TEXT_ATTR_LINE_SPACING_HALF 15 #define TEXT_ATTR_LINE_SPACING_TWICE 20

### begin_list_style

Boolean begin_list_style(%(arg-type)String% listStyle, Integer level=1, Integer number=1)

Begins using a specified list style. Optionally, you can also pass a level and a number.

### begin_numbered_bullet

Boolean begin_numbered_bullet(%(arg-type)Integer% bulletNumber, Integer leftIndent, Integer leftSubIndent, Integer bulletStyle = TEXT_ATTR_BULLET_STYLE_ARABIC|TEXT_ATTR_BULLET_STYLE_PERIOD)

Begins a numbered bullet. This call will be needed for each item in the list, and the
application should take care of incrementing the numbering.

bulletNumber is a number, usually starting with 1.

leftIndent and leftSubIndent are values in tenths of a millimetre.

bulletStyle is a bitlist of the following values:

#define TEXT_ATTR_BULLET_STYLE_NONE 0×00000000 #define TEXT_ATTR_BULLET_STYLE_ARABIC 0×00000001 #define TEXT_ATTR_BULLET_STYLE_LETTERS_UPPER 0×00000002 #define TEXT_ATTR_BULLET_STYLE_LETTERS_LOWER 0×00000004 #define TEXT_ATTR_BULLET_STYLE_ROMAN_UPPER 0×00000008 #define TEXT_ATTR_BULLET_STYLE_ROMAN_LOWER 0×00000010 #define TEXT_ATTR_BULLET_STYLE_SYMBOL 0×00000020 #define TEXT_ATTR_BULLET_STYLE_BITMAP 0×00000040 #define TEXT_ATTR_BULLET_STYLE_PARENTHESES 0×00000080 #define TEXT_ATTR_BULLET_STYLE_PERIOD 0×00000100 #define TEXT_ATTR_BULLET_STYLE_STANDARD 0×00000200 #define TEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS 0×00000400 #define TEXT_ATTR_BULLET_STYLE_OUTLINE 0×00000800 #define TEXT_ATTR_BULLET_STYLE_ALIGN_LEFT 0×00000000 #define TEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT 0×00001000 #define TEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE 0×00002000

RichTextBuffer uses indentation to render a bulleted item. The left indent is the distance between
the margin and the bullet. The content of the paragraph, including the first line, starts
at leftMargin + leftSubIndent. So the distance between the left edge of the bullet and the
left of the actual paragraph is leftSubIndent.

### begin_paragraph_spacing

Boolean begin_paragraph_spacing(%(arg-type)Integer% before, Integer after)

Begins paragraph spacing; pass the before-paragraph and after-paragraph spacing in tenths of
a millimetre.

### begin_paragraph_style

Boolean begin_paragraph_style(%(arg-type)String% paragraphStyle)

Begins applying the named paragraph style.

### begin_right_indent

Boolean begin_right_indent(%(arg-type)Integer% rightIndent)

Begins a right indent, specified in tenths of a millimetre.

### begin_style

Boolean begin_style(%(arg-type)RichTextAttr% style)

Begins applying a style.

### begin_suppress_undo

Boolean begin_suppress_undo()

Starts suppressing undo history for commands.

### begin_symbol_bullet

Boolean begin_symbol_bullet(%(arg-type)Char% symbol, Integer leftIndent, Integer leftSubIndent, Integer bulletStyle = TEXT_ATTR_BULLET_STYLE_SYMBOL)

Begins applying a symbol bullet, using a character from the current font. See begin_numbered_bullet for
an explanation of how indentation is used to render the bulleted paragraph.

### begin_text_colour

Boolean begin_text_colour(%(arg-type)Colour% colour)

Begins using this colour.

### begin_underline

Boolean begin_underline()

Begins using underlining.

### begin_url

Boolean begin_url(%(arg-type)String% url, String characterStyle = ’’)

Begins applying TEXT_ATTR_URL to the content. Pass a URL and optionally, a character style to apply,
since it is common to mark a URL with a familiar style such as blue text with underlining.

### can_copy

Boolean can_copy()

Returns if selected content can be copied to the clipboard.

### can_cut

Boolean can_cut()

Returns if selected content can be copied to the clipboard and deleted.

### can_delete_selection

Boolean can_delete_selection()

Returns if selected content can be deleted.

### can_paste

Boolean can_paste()

Returns if the clipboard content can be pasted to the buffer.

### can_redo

Boolean can_redo()

Returns if there is a command in the command history that can be redone.

### can_undo

Boolean can_undo()

Returns if there is a command in the command history that can be undone.

### clear

clear()

Clears the buffer content, leaving a single empty paragraph. Cannot be undone.

### clear_list_style

Boolean clear_list_style(%(arg-type)Range% range, Integer flags $=$ RICHTEXT_SETSTYLE_WITH_UNDO) Boolean clear_list_style(%(arg-type)Range% range, Integer flags $=$ RICHTEXT_SETSTYLE_WITH_UNDO)

Clears the list style from the given range, clearing list-related attributes and applying any named paragraph style associated with each paragraph.

flags is a bit list of the following:

- RICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.

See also set_list_style, promote_list, number_list.

### command

command(%(arg-type)CommandEvent% event)

Sends the event to the control.

### copy

copy()

Copies the selected content (if any) to the clipboard.

### create

Boolean create(%(arg-type)Window% parent, Integer id = ID_ANY, String value = ’’, Point pos = DEFAULT_POSITION, Size size = DEFAULT_SIZE, Integer style = RE_MULTILINE, Validator validator = DEFAULT_VALIDATOR, String name = TextCtrlNameStr)

Creates the underlying window.

### cut

cut()

Copies the selected content (if any) to the clipboard and deletes the selection.
This is undoable.

### delete

Boolean delete(%(arg-type)Range% range)

Deletes the content within the given range.

### delete_selected_content

Boolean delete_selected_content(%(arg-type)Integer% newPos = nil)

Deletes content if there is a selection, e.g. when pressing a key.
Returns the new caret position in newPos, or leaves it if there
was no action. This is undoable.

### delete_selection

delete_selection()

Deletes the content in the selection, if any. This is undoable.

### discard_edits

discard_edits()

Sets the buffer’s modified status to , and clears the buffer’s command history.

### do_get_best_size

Size do_get_best_size()

Currently this simply returns `Size(10, 10)`.

### end_alignment

Boolean end_alignment()

Ends alignment.

### end_all_styles

Boolean end_all_styles()

Ends application of all styles in the current style stack.

### end_batch_undo

Boolean end_batch_undo()

Ends batching undo command history.

### end_bold

Boolean end_bold()

Ends using bold.

### end_character_style

Boolean end_character_style()

Ends application of a named character style.

### end_font

Boolean end_font()

Ends using a font.

### end_font_size

Boolean end_font_size()

Ends using a point size.

### end_italic

Boolean end_italic()

Ends using italic.

### end_left_indent

Boolean end_left_indent()

Ends left indent.

### end_line_spacing

Boolean end_line_spacing()

Ends line spacing.

### end_list_style

Boolean end_list_style()

Ends using a specified list style.

### end_numbered_bullet

Boolean end_numbered_bullet()

Ends application of a numbered bullet.

### end_paragraph_spacing

Boolean end_paragraph_spacing()

Ends paragraph spacing.

### end_paragraph_style

Boolean end_paragraph_style()

Ends application of a named character style.

### end_right_indent

Boolean end_right_indent()

Ends right indent.

### end_style

Boolean end_style()

Ends the current style.

### end_suppress_undo

Boolean end_suppress_undo()

Ends suppressing undo command history.

### end_symbol_bullet

Boolean end_symbol_bullet()

Ends applying a symbol bullet.

### end_text_colour

Boolean end_text_colour()

Ends applying a text colour.

### end_underline

Boolean end_underline()

End applying underlining.

### end_url

Boolean end_url()

Ends applying a URL.

### extend_selection

Boolean extend_selection(%(arg-type)Integer% oldPosition, Integer newPosition, Integer flags)

Helper function for extending the selection, returning if the selection was
changed. Selections are in caret positions.

### find_next_word_position

Integer find_next_word_position(%(arg-type)Integer% direction = 1)

Helper function for finding the caret position for the next word. Direction
is 1 (forward) or -1 (backwards).

### freeze

freeze()

Call this function to prevent refresh and allow fast updates, and then Thaw to
refresh the control.

### get_basic_style

RichTextAttr get_basic_style()

Gets the basic (overall) style. This is the style of the whole
buffer before further styles are applied, unlike the default style, which
only affects the style currently being applied (for example, setting the default
style to bold will cause subsequently inserted text to be bold).

### get_buffer

RichTextBuffer get_buffer()

Returns the buffer associated with the control.

### get_caret_position

Integer get_caret_position()

Returns the current caret position.

### get_caret_position_for_index

Rect rect get_caret_position_for_index(%(arg-type)Integer% position)

Returns the caret height and position for the given character position.

### get_command_processor

CommandProcessor get_command_processor()

Gets the command processor associated with the control’s buffer.

### get_delayed_layout_threshold

Integer get_delayed_layout_threshold()

Gets the size of the buffer beyond which layout is delayed during resizing.
This optimizes sizing for large buffers. The default is 20000.

### get_filename

String get_filename()

Gets the current filename associated with the control.

### get_first_visible_position

Integer get_first_visible_position()

Returns the first visible position in the current view.

### get_handler_flags

Integer get_handler_flags()

Returns flags that change the behaviour of loading or saving. See the documentation for each
handler class to see what flags are relevant for each handler.

### get_insertion_point

Integer get_insertion_point()

Returns the current insertion point.

### get_last_position

TextPos get_last_position()

Returns the last position in the buffer.

### get_line_length

Integer get_line_length(%(arg-type)Integer% lineNo)

Returns the length of the specified line in characters.

### get_line_text

String get_line_text(%(arg-type)Integer% lineNo)

Returns the text for the given line.

### get_logical_point

Point get_logical_point(%(arg-type)Point% ptPhysical)

Transforms physical window position to logical (unscrolled) position.

### get_number_of_lines

Integer get_number_of_lines()

Returns the number of lines in the buffer.

### get_physical_point

Point get_physical_point(%(arg-type)Point% ptLogical)

Transforms logical (unscrolled) position to physical window position.

### get_range

String get_range(%(arg-type)Integer% from, Integer to)

Gets the text for the given range.

The end point of range is specified as the last character position of the span of text, plus one.

### get_selection

get_selection(%(arg-type)Integer% from, Integer to)

Returns the range of the current selection.

The end point of range is specified as the last character position of the span of text, plus one.

If the return values from and to are the same, there is no selection.

### get_selection_range

Range get_selection_range()

Returns the selection range in character positions. -1, -1 means no selection.

### get_string_selection

String get_string_selection()

Returns the text within the current selection range, if any.

### get_style

RichTextAttr% get_style(%(arg-type)Integer% position)

Gets the attributes at the given position. This function gets the
combined style – that is, the style you see on the screen as a result of
combining base style, paragraph style and character style attributes. To
get the character or paragraph style alone, use
get_uncombined_style.

### get_style_for_range

RichTextAttr get_style_for_range(%(arg-type)Range% range)

Gets the attributes common to the specified range. Attributes that
differ in value within the range will not be included in _style_’s
flags.

### get_style_sheet

RichTextStyleSheet get_style_sheet()

Returns the style sheet associated with the control, if any. A style
sheet allows named character and paragraph styles to be applied.

### get_uncombined_style

RichTextAttr get_uncombined_style(%(arg-type)Integer% position)

Gets the attributes at the given position.

This function gets the uncombined style – that is, the attributes
associated with the paragraph or character content, and not necessarily
the combined attributes you see on the screen. To get the combined
attributes, use get_style.

### get_value

String get_value()

Returns the content of the entire control as a string.

### get_visible_line_for_caret_position

RichTextLine get_visible_line_for_caret_position(%(arg-type)Integer% caretPosition)

Internal helper function returning the line for the visible caret position. If the caret is
shown at the very end of the line, it means the next character is actually
on the following line. So this function gets the line we’re expecting to find
if this is the case.

### has_character_attributes

Boolean has_character_attributes(%(arg-type)Range% range, RichTextAttr style)

Test if this whole range has character attributes of the specified kind. If any
of the attributes are different within the range, the test fails. You
can use this to implement, for example, bold button updating. style must have
flags indicating which attributes are of interest.

### has_paragraph_attributes

Boolean has_paragraph_attributes(%(arg-type)Range% range, RichTextAttr style)

Test if this whole range has paragraph attributes of the specified kind. If any
of the attributes are different within the range, the test fails. You
can use this to implement, for example, centering button updating. style must have
flags indicating which attributes are of interest.

### has_selection

Boolean has_selection()

Returns if there is a selection.

### hit_test

TextCtrlHitTestResult hit_test(%(arg-type)Point% pt, Integer pos) TextCtrlHitTestResult hit_test(%(arg-type)Point% pt, TextCoord col, TextCoord row)

Finds the character at the given position in pixels.

pt is in device coords (not adjusted for the client area origin nor for scrolling).

### init

init()

Initialises the members of the control.

### init_command_event

init_command_event(%(arg-type)CommandEvent% event)

Initialises the command event.

### is_default_style_showing

Boolean is_default_style_showing()

Returns if the user has recently set the default style without moving
the caret, and therefore the UI needs to reflect the default style and
not the style at the caret.

See also set_and_show_default_style.

### is_editable

Boolean is_editable()

Returns if the control is editable.

### is_frozen

Boolean is_frozen()

Returns if Freeze has been called without a Thaw.

### is_modified

Boolean is_modified()

Returns if the buffer has been modified.

### is_multi_line

Boolean is_multi_line()

Returns if the control is multiline.

### is_position_visible

Boolean is_position_visible(%(arg-type)Integer% pos)

Returns if the given position is visible on the screen.

### is_selection_aligned

Boolean is_selection_aligned(%(arg-type)TextAttrAlignment% alignment)

Returns if all of the selection is aligned according to the specified flag.

### is_selection_bold

Boolean is_selection_bold()

Returns if all of the selection is bold.

### is_selection_italics

Boolean is_selection_italics()

Returns if all of the selection is italic.

### is_selection_underlined

Boolean is_selection_underlined()

Returns if all of the selection is underlined.

### is_single_line

Boolean is_single_line()

Returns if the control is single-line. Currently RichTextCtrl does not
support single-line editing.

### keyboard_navigate

Boolean keyboard_navigate(%(arg-type)Integer% keyCode, Integer flags)

Helper function implementing keyboard navigation.

### layout_content

Boolean layout_content(%(arg-type)Boolean% onlyVisibleRect = false)

Lays out the buffer, which must be done before certain operations, such as
setting the caret position. This function should not normally be required by the
application.

### line_break

Boolean line_break()

Inserts a line break at the current insertion point. A line break forces wrapping within a paragraph, and
can be introduced by using this function, by appending the Char value RichTextLineBreakChar to text content,
or by typing Shift-Return.

### load_file

Boolean load_file(%(arg-type)String% file, Integer type = RICHTEXT_TYPE_ANY)

Loads content into the control’s buffer using the given type. If the specified type
is RICHTEXT_TYPE_ANY, the type is deduced from the filename extension.

This function looks for a suitable RichTextFileHandler object.

### mark_dirty

mark_dirty()

Marks the buffer as modified.

### move_caret

Boolean move_caret(%(arg-type)Integer% pos, Boolean showAtLineStart = false)

Move the caret to the given character position.

### move_caret_back

move_caret_back(%(arg-type)Integer% oldPosition)

Move the caret one visual step forward: this may mean setting a flag
and keeping the same position if we’re going from the end of one line
to the start of the next, which may be the exact same caret position.

### move_caret_forward

move_caret_forward(%(arg-type)Integer% oldPosition)

Move the caret one visual step forward: this may mean setting a flag
and keeping the same position if we’re going from the end of one line
to the start of the next, which may be the exact same caret position.

### move_down

Boolean move_down(%(arg-type)Integer% noLines = 1, Integer flags = 0)

Moves the caret down.

### move_end

Boolean move_end(%(arg-type)Integer% flags = 0)

Moves to the end of the buffer.

### move_home

Boolean move_home(%(arg-type)Integer% flags = 0)

Moves to the start of the buffer.

### move_left

Boolean move_left(%(arg-type)Integer% noPositions = 1, Integer flags = 0)

Moves left.

### move_right

Boolean move_right(%(arg-type)Integer% noPositions = 1, Integer flags = 0)

Moves right.

### move_to_line_end

Boolean move_to_line_end(%(arg-type)Integer% flags = 0)

Moves to the end of the line.

### move_to_line_start

Boolean move_to_line_start(%(arg-type)Integer% flags = 0)

Moves to the start of the line.

### move_to_paragraph_end

Boolean move_to_paragraph_end(%(arg-type)Integer% flags = 0)

Moves to the end of the paragraph.

### move_to_paragraph_start

Boolean move_to_paragraph_start(%(arg-type)Integer% flags = 0)

Moves to the start of the paragraph.

### move_up

Boolean move_up(%(arg-type)Integer% noLines = 1, Integer flags = 0)

Moves up.

### newline

Boolean newline()

Inserts a new paragraph at the current insertion point. See also line_break.

### number_list

Boolean number_list(%(arg-type)Range% range, RichTextListStyleDefinition style, Integer flags $=$ RICHTEXT_SETSTYLE_WITH_UNDO, Integer startFrom = -1, Integer listLevel = -1) Boolean number(%(arg-type)Range% range, String styleName, Integer flags $=$ RICHTEXT_SETSTYLE_WITH_UNDO, Integer startFrom = -1, Integer listLevel = -1)

Numbers the paragraphs in the given range. Pass flags to determine how the attributes are set.
Either the style definition or the name of the style definition (in the current sheet) can be passed.

flags is a bit list of the following:

- RICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
- RICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from startFrom, otherwise existing attributes are used.
- RICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that listLevel should be used as the level for all paragraphs, otherwise the current indentation will be used.

See also set_list_style, promote_list, clear_list_style.

### on_clear

on_clear(%(arg-type)CommandEvent% event)

Standard handler for the ID_CLEAR command.

### on_context_menu

on_context_menu(%(arg-type)ContextMenuEvent% event)

Shows a standard context menu with undo, redo, cut, copy, paste, clear, and select all commands.

### on_copy

on_copy(%(arg-type)CommandEvent% event)

Standard handler for the ID_COPY command.

### on_cut

on_cut(%(arg-type)CommandEvent% event)

Standard handler for the ID_CUT command.

### on_drop_files

on_drop_files(%(arg-type)DropFilesEvent% event)

Loads the first dropped file.

### on_paste

on_paste(%(arg-type)CommandEvent% event)

Standard handler for the ID_PASTE command.

### on_redo

on_redo(%(arg-type)CommandEvent% event)

Standard handler for the ID_REDO command.

### on_select_all

on_select_all(%(arg-type)CommandEvent% event)

Standard handler for the ID_SELECTALL command.

### on_undo

on_undo(%(arg-type)CommandEvent% event)

Standard handler for the ID_PASTE command.

### on_update_clear

on_update_clear(%(arg-type)UpdateUIEvent% event)

Standard update handler for the ID_CLEAR command.

### on_update_copy

on_update_copy(%(arg-type)UpdateUIEvent% event)

Standard update handler for the ID_COPY command.

### on_update_cut

on_update_cut(%(arg-type)UpdateUIEvent% event)

Standard update handler for the ID_CUT command.

### on_update_paste

on_update_paste(%(arg-type)UpdateUIEvent% event)

Standard update handler for the ID_PASTE command.

### on_update_redo

on_update_redo(%(arg-type)UpdateUIEvent% event)

Standard update handler for the ID_REDO command.

### on_update_select_all

on_update_select_all(%(arg-type)UpdateUIEvent% event)

Standard update handler for the ID_SELECTALL command.

### on_update_undo

on_update_undo(%(arg-type)UpdateUIEvent% event)

Standard update handler for the ID_UNDO command.

### page_down

Boolean page_down(%(arg-type)Integer% noPages = 1, Integer flags = 0)

Moves one or more pages down.

### page_up

Boolean page_up(%(arg-type)Integer% noPages = 1, Integer flags = 0)

Moves one or more pages up.

### paint_background

paint_background(%(arg-type)DC% dc)

Paints the background.

### paste

paste()

Pastes content from the clipboard to the buffer.

### position_caret

position_caret()

Internal function to position the visible caret according to the current caret position.

### position_to_xy

Integer, Integer = position_to_xy(%(arg-type)Integer% pos)

Converts a text position to zero-based column and line numbers.

### promote_list

Boolean promote_list(%(arg-type)Integer% promoteBy, Range range, RichTextListStyleDefinition style, Integer flags $=$ RICHTEXT_SETSTYLE_WITH_UNDO, Integer listLevel = -1) Boolean promote_list(%(arg-type)Integer% promoteBy, Range range, String styleName, Integer flags $=$ RICHTEXT_SETSTYLE_WITH_UNDO, Integer listLevel = -1)

Promotes or demotes the paragraphs in the given range. A positive promoteBy produces a smaller indent, and a negative number
produces a larger indent. Pass flags to determine how the attributes are set.
Either the style definition or the name of the style definition (in the current sheet) can be passed.

flags is a bit list of the following:

- RICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
- RICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from startFrom, otherwise existing attributes are used.
- RICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that listLevel should be used as the level for all paragraphs, otherwise the current indentation will be used.

See also set_list_style, See also set_list_style, clear_list_style.

### redo

redo()

Redoes the current command.

### remove

remove(%(arg-type)Integer% from, Integer to)

Removes the content in the specified range.

### replace

replace(%(arg-type)Integer% from, Integer to, String value)

Replaces the content in the specified range with the string specified by value.

### save_file

Boolean save_file(%(arg-type)String% file = ’’, Integer type = RICHTEXT_TYPE_ANY)

Saves the buffer content using the given type. If the specified type
is RICHTEXT_TYPE_ANY, the type is deduced from the filename
extension.

In order to use this method, a
RichTextFileHandler object must have been set previously.

### scroll_into_view

Boolean scroll_into_view(%(arg-type)Integer% position, Integer keyCode)

Scrolls position into view. This function takes a caret position.

### select_all

select_all()

Selects all the text in the buffer.

### select_none

select_none()

Cancels any selection.

### set_and_show_default_style

set_and_show_default_style(%(arg-type)RichTextAttr% attr)

Sets attr as the default style and tells the control that the UI should reflect
this attribute until the user moves the caret.

See also is_default_style_showing.

### set_basic_style

set_basic_style(%(arg-type)RichTextAttr% style)

Sets the basic (overall) style. This is the style of the whole
buffer before further styles are applied, unlike the default style, which
only affects the style currently being applied (for example, setting the default
style to bold will cause subsequently inserted text to be bold).

### set_caret_position

set_caret_position(%(arg-type)Integer% position, Boolean showAtLineStart = false)

The caret position is the character position just before the caret.
A value of -1 means the caret is at the start of the buffer.

### set_default_style

Boolean set_default_style(%(arg-type)RichTextAttr% style)

Sets the current default style, which can be used to change how
subsequently inserted text is displayed.

### set_default_style_to_cursor_style

Boolean set_default_style_to_cursor_style()

Sets the default style to the style under the cursor.

### set_delayed_layout_threshold

set_delayed_layout_threshold(%(arg-type)Integer% threshold)

Sets the size of the buffer beyond which layout is delayed during resizing.
This optimizes sizing for large buffers. The default is 20000.

### set_editable

set_editable(%(arg-type)Boolean% editable)

Makes the control editable, or not.

### set_filename

set_filename(%(arg-type)String% filename)

Sets the current filename.

### set_font

Boolean set_font(%(arg-type)Font% font)

Sets the font, and also the basic and default attributes (see set_default_style).

### set_handler_flags

set_handler_flags(%(arg-type)Integer% flags)

Sets flags that change the behaviour of loading or saving. See the documentation for each
handler class to see what flags are relevant for each handler.

### set_insertion_point

set_insertion_point(%(arg-type)Integer% pos)

Sets the insertion point.

### set_insertion_point_end

set_insertion_point_end()

Sets the insertion point to the end of the text control.

### set_list_style

Boolean set_list_style(%(arg-type)Range% range, RichTextListStyleDefinition style, Integer flags $=$ RICHTEXT_SETSTYLE_WITH_UNDO, Integer startFrom = -1, Integer listLevel = -1) Boolean set_list_style(%(arg-type)Range% range, String styleName, Integer flags $=$ RICHTEXT_SETSTYLE_WITH_UNDO, Integer startFrom = -1, Integer listLevel = -1)

Sets the list attributes for the given range, passing flags to determine how the attributes are set.
Either the style definition or the name of the style definition (in the current sheet) can be passed.

flags is a bit list of the following:

- RICHTEXT_SETSTYLE_WITH_UNDO: specifies that this command will be undoable.
- RICHTEXT_SETSTYLE_RENUMBER: specifies that numbering should start from startFrom, otherwise existing attributes are used.
- RICHTEXT_SETSTYLE_SPECIFY_LEVEL: specifies that listLevel should be used as the level for all paragraphs, otherwise the current indentation will be used.

See also number_list, promote_list, clear_list_style.

### set_selection

set_selection(%(arg-type)Integer% from, Integer to)

Sets the selection to the given range.

The end point of range is specified as the last character position of the span of text, plus one.
So, for example, to set the selection for a character at position 5, use the range (5,6).

### set_selection_range

set_selection_range(%(arg-type)Range% range)

Sets the selection to the given range.

The end point of range is specified as the last character position of the span of text, plus one.
So, for example, to set the selection for a character at position 5, use the range (5,6).

### set_style

Boolean set_style(%(arg-type)Range% range, RichTextAttr style) Boolean set_style(%(arg-type)Integer% start, Integer end, RichTextAttr style)

Sets the attributes for the given range. The end point of range is
specified as the last character position of the span of text, plus one.
So, for example, to set the style for a character at position 5, use the
range (5,6).

### set_style_ex

Boolean set_style_ex(%(arg-type)Range% range, RichTextAttr style, Integer flags = RICHTEXT_SETSTYLE_WITH_UNDO)

Sets the attributes for the given range, passing flags to determine how the attributes are set. The RichTextAttr version is more efficient
because it does not use Font objects.

The end point of range is specified as the last character position of the span of text, plus one.
So, for example, to set the style for a character at position 5, use the range (5,6).

flags may contain a bit list of the following values:

- RICHTEXT_SETSTYLE_NONE: no style flag.
- RICHTEXT_SETSTYLE_WITH_UNDO: specifies that this operation should be undoable.
- RICHTEXT_SETSTYLE_OPTIMIZE: specifies that the style should not be applied if the
  combined style at this point is already the style in question.
- RICHTEXT_SETSTYLE_PARAGRAPHS_ONLY: specifies that the style should only be applied to paragraphs,
  and not the content. This allows content styling to be preserved independently from that of e.g. a named paragraph style.
- RICHTEXT_SETSTYLE_CHARACTERS_ONLY: specifies that the style should only be applied to characters,
  and not the paragraph. This allows content styling to be preserved independently from that of e.g. a named paragraph style.
- RICHTEXT_SETSTYLE_RESET: resets (clears) the existing style before applying the new style.
- RICHTEXT_SETSTYLE_REMOVE: removes the specified style. Only the style flags are used in this operation.

### set_style_sheet

set_style_sheet(%(arg-type)RichTextStyleSheet% styleSheet)

Sets the style sheet associated with the control. A style sheet allows named
character and paragraph styles to be applied.

### set_value

set_value(%(arg-type)String% value)

Replaces existing content with the given text.

### setup_scrollbars

setup_scrollbars(%(arg-type)Boolean% atTop = false)

A helper function setting up scrollbars, for example after a resize.

### show_position

show_position(%(arg-type)Integer% pos)

Scrolls the buffer so that the given position is in view.

### suppressing_undo

Boolean suppressing_undo()

Returns `true` if undo history suppression is on.

### thaw

thaw()

Call this function to end a Freeze and refresh the display.

### undo

undo()

Undoes the command at the top of the command history, if there is one.

### word_left

Boolean word_left(%(arg-type)Integer% noWords = 1, Integer flags = 0)

Moves a number of words to the left.

### word_right

Boolean word_right(%(arg-type)Integer% noWords = 1, Integer flags = 0)

Move a nuber of words to the right.

### write_image

Boolean write_image(%(arg-type)String% filename, Integer bitmapType)

Loads an image from a file and writes it at the current insertion point.

Boolean write_image(%(arg-type)Bitmap% bitmap, Integer bitmapType = BITMAP_TYPE_PNG) Boolean write_image(%(arg-type)Image% image, Integer bitmapType = BITMAP_TYPE_PNG)

Write a bitmap or image at the current insertion point. Supply an
optional type to use for internal and file storage of the raw data.

### write_text

write_text(%(arg-type)String% text)

Writes text at the current position.

### xy_to_position

Integer xy_to_position(%(arg-type)Integer% x, Integer y)

Translates from column and line number to position.

[This page automatically generated from the Textile source at 2023-06-09 00:45:32 +0000]