1.49 class editor

Class editor describes a graphical object that can be used to edit long textual descriptions. PCE editors have similar design and user-interface as GNU-Emacs. New functionality may added by means of class key_binding.

WHY A PCE EDITOR?

Many applications manipulate large text fields. For many applications, editing text is one of the most important activities. Unfortunately, there is not much of a standard as far as editors is concerned. For this reason, the best option would be to allow the user to run an editor of his/her choice. Unfortunately no good interfacing protocol is available that allows us to manage the text in the editor from inside PCE and read a considerable amount of status information from the editor.

Therefore, PCE defines it's own editor. The basic user interface of the editor is based on the widely accepted GNU-EMACS editor and can be extended and modified to improve compatibility to other editors.

1.49.1 Organisation

Class editor is a subclass of device because it is implemented as a compound graphical object, consisting of the following parts.

text_image objectGraphical that displays the text itself
scroll_bar objectAllows you to scroll the text vertically
text_cursor objectGraphical that displays the caret
text_margin objectOptional annotation margin
text_buffer objectStorage and low-level manipulation

1.49.2 Vocabulary

The editor uses the following vocabulary:

1.49.3 Compatibility

The UI of PCE editors is based on GNU-EMACS. Many of the basic function of GNU-EMACS are available. Like GNU-EMACS, the PCE editors can be programmed. Unlike GNU-EMACS however, this is not done by programming EMACS-LISP, but by adding methods to the editor (or class editor) and linking these methods to key-strokes.

As the basic functionality is rich and can be expanded/redefined, it should not be very difficult to transform the PCE-editor into an editor that is largely compatible to most available editors.

1.49.4 Mouse and keyboard

PCE-editors can be operated both mouse-driven and keyboard-driven, although the latter is the principal way of manipulating a text.

See also
- class key_binding
- class view
- class text
- class text_buffer
- class style
- class fragment
- class font
- tool Card Viewer

1.49.5 Class variables

editor.exact_case: bool = @off
@see editor-exact_case
editor.indent_increment: int = 2
@see editor-indent_increment

1.49.6 Instance variables

editor <-> auto_newline: bool
If @on, a newline is appended automatically after each editor->append. Backward compatibility only.
See also
editor->append
editor <-> bindings: key_binding
Key_binding object used to map typing onto methods defined on the editor. It is filled with an empty key_binding object that has key_binding<-defaults bound to the built-in key_binding object named editor. This implies that bindings created using editor->key_binding are local to the editor.
See also
editor->typed
editor <- caret: int
The editor<-caret is the current insertion point. In ranges from 0 up to and including editor<-size. Zero implies insert at the beginning; editor<-size implies append at the end.

The method editor->caret is invoked explicitly from all internal methods that manipulate the caret and this method may thus be redefined to keep track of the users caret-movements.

The editor<-mark is a mark that moves with inserts and, together with the editor<-caret, defines the region. The region can be in various modes as described by editor<-mark_status.

To get the caret from an event, see text_image<-index. The location of the caret is visualised by a text_cursor object that can be requested using editor<-text_cursor.

See also
editor-mark
editor-dabbrev_origin: int*
Caret index for the beginning of the word on which dynamic expansion was started.
See also
editor->dabbrev_expand
editor-dabbrev_pos: int*
Caret index at which the dynamic expansion was initiated. The string expanded ranges from dabbrev_origin to dabbrev_pos.
See also
editor->dabbrev_expand
editor-dabbrev_reject: chain*
Chain of names of expansion alternatives already rejected by the user.
See also
editor->dabbrev_expand
editor-dabbrev_target: name*
Name, representing the start of the word to be expanded.
See also
editor->dabbrev_expand
editor <-> editable: bool
Boolean that indicates whether or not the text can be edited. If @off, a warning is generated whenever the user attempts to invoke an interactive command that would change the contents of the associated text_buffer.

See also editor->show_caret for hiding the caret on read-only editors.

BUG: In the original design, methods were fixed and methods

either implemented behaviour intended for user interaction or methods intended for program interaction. The editor->editable flag only affected interactive methods. Some of this distinction still remains. It is adviced to set editable to @on before modifying a read-only editor object from the program to avoid confusion.

See also
text_buffer-modified
editor <-> error_message: code*
When an error is trapped in a method, it is reported to the editor using editor->report. When defined, editor->report will execute this message with arguments given below:
@receiver:	The editor (or view)
@arg1		idem
@arg2		The type (status/warning/inform/error)
@arg3		String representing the message itself

See visual->report for a general discussion on the reporting system.

Defaults: @nil

See also
- display->inform
- graphical->alert
editor <-> exact_case: bool
Determines whether or not search and replace is case-sensitive. editor->switch_case_mode sets editor<-exact case according to the argument:
@default toggle editor<-exact_case
> 0editor->exact_case: @on
<= 0editor<-exact_case: @off

Defaults: @off (Resource determined).

See also
- editor->isearch_forward
- editor->isearch_backward
- editor->switch_case_mode
- editor.exact_case
editor <- file: source_sink*
File that is associated with the editor.
See also
- editor->save_buffer
- editor->save
- editor->load
editor <-> fill_mode: bool
If @on, the current paragraph will be automatically reformated if the current line exceeds the editor<->right_margin while inserting text. editor->auto_fill_mode may be used to set editor<-fill_mode interactively:
@default:toggle editor<-fill_mode
> 0editor->fill_mode: @on
<= 0editor->fill_mode: @off
See also
- editor->insert_self_fill
- editor->insert_self
editor <-> focus_function: name*
The editor<->focus_function variable is used to process commands that start a kind of sub-mode, such as entering a numeric argument, doing incremental search, doing a dabbrev expansion, etc.

An interactive behaviour that uses such a sub-loop sets this variable to the selector that handles the loop. As a consequence, editor->typed will invoke this method on each subsequent character typed until

  1. The method fails. In this case the character is handled just as if no focus_function was defined.
  2. The method resets editor<->focus_function to @nil. If the method invoked via editor<->focus_function succeeds, editor->typed assumes the character is handled.

    By convention, the method that is invoked by the focus function has the same name than the method that set the focus preceded by an underscore:

    quoted_insert ->
            _quoted_insert
    

editor <- font: font
Font used to display the contents of the associated text_buffer. Class editor can handle both proportional and non-proportional fonts.
editor <- image: text_image
Text_image object used for actually displaying the text. Direct access to this object may be necessary to exploit the following methods:
text_image->tab_stops Set vector of tab-stops
text_image->wrap Control line-wrapping

Direct access may also be used to attach event-handling to the editor. For example, if a popup is attached to the editor as a whole it might contradict with the editor<-scroll_bar. Associating the popup with the editor<-image ensures it only operates in the text area.

See also
class text_image
editor <-> indent_increment: int
Number of characters with which the indentation is incremented/decremented by the indentation-manipulation commands.

This group of commands is intended for editing source-code.

Defaults: 4 (Resource defined)

See also
- editor->undent_selection
- editor->undent_region
- editor->undent_line
- editor->indent_selection
- editor->indent_region
- editor->indent_line
- editor.indent_increment
editor-internal_mark: alien:int
Additional (floating) mark, used by some internal functions.
editor <- label_text: text*
Text object that displays the label. Initially @nil. A label is associated using editor->label. See also editor<->show_label.
editor <-> left_margin: int
Margins used for filling text. See editor->fill, editor->justify_paragraph, editor->fill_mode, etc. The method editor->set_fill_column may be used to set both methods interactively (Dope compatibility):
@default Report current margins
> 0Set editor->right_margin
< 0Set editor->left_margin to the absolute value.

Defaults: 0

See also
- editor->append
- editor->fill_selection
- editor->fill_region
- editor->fill_paragraph
- editor-right_margin
- editor->set_fill_column
editor <- margin: text_margin*
Margin with icons that indicate the position of fragments. See fragment<-style, and editor->style. When the editor->margin_width is set to a value > 0 and there is no editor<-margin, a margin is created.

Defaults: @nil (no margin)

See also
- class fragment
- editor->margin_width
- class text_margin
editor <- mark: int
Inherits description from: editor-caret
See also
- editor->set_mark
- editor->point_to_mark
- editor->exchange_point_and_mark
- editor-caret
editor <- mark_ring: vector
Ring of old marks. If a new mark is set using editor->mark, the old mark is pushed into the ring. The maximum size of the ring is hard-coded to 16. The command editor->set_mark with a prefix argument cycles throught the saved marks.
editor <- mark_status: {active,inactive,highlight}
Status of the mark/region. Defined values are:
active
The region (selection) is highlighted using editor<-selection_style. Region commands are effective if the mark is in this state.
inactive
The mark is there, but the region is not visible and region commands are not executed. The current region can be made active using editor->exchange_point_and_mark (C-x C-x). The regions is made inactive with the command editor->keyboard_quit (C-g).
highlight
The region is highlighted, but not available for region-commands. This mode is used for highting parts of the text, such as using the comment editor->select_line.

See also editor->caret and editor->selection.

editor <-> modified_message: code*
When the value of the editor<->modified attribute of the associated text_buffer changes and this message is not @nil, this message is executed with the following arguments:
@receiver Editor or view
@arg1 New value of editor<->modified
See also
text_buffer-modified
editor <-> right_margin: int
Defaults: 72 (Resource determined).

Inherits description from: editor-left_margin

See also
- editor->fill_selection
- editor->fill_region
- editor->fill_paragraph
- editor->set_fill_column
- editor->insert_self_fill
- editor-left_margin
editor <- scroll_bar: scroll_bar
Scroll_bar object attached to the editor. In the current implementation it is not possible to remove the scrollbar or place it at the right-side of the editor. However, setting the graphical->width to 0 before the editor is displayed effectively removes it.
See also
class scroll_bar
editor-search_base: int
Character index from which the last search was started.
See also
editor->isearch_forward
editor-search_direction: {forward,backward}
Current direction of the search. Set by editor->isearch_forward and editor->isearch_backward to resp. forward and backward.
See also
- editor->isearch_backward
- editor->isearch_forward
editor-search_origin: int
Place where the search was initiated. Set by editor->isearch_forward and editor->isearch_backward. Used to return when the search is canceled.
See also
editor->isearch_forward
editor <-> search_string: string*
Current target string for incremental search.
See also
editor->isearch_forward
editor <- selected_fragment: fragment*
Currently selected fragment. The visual appearance of this fragment is determined by editor<-selected_fragment_style. There is no default user-interface for selecting fragments. text_buffer<-find_fragment and text_margin<-fragment may be useful methods for defining a user-interface.
See also
- editor-selected_fragment_style
- class fragment
editor <- selected_fragment_style: style
@see class style @see editor-selected_fragment @see text_margin-styles @see class fragment
editor <- size: size
Size management of class editor has been redefined to communicate in character units rather then in pixel units. Width is expressed in font<-ex of the current editor<-font., height in font<-height.

The methods editor->_size, graphical->area and graphical->set may still be used to handle the pixel size directly.

editor <- styles: sheet
Mapping from style names as stored in fragment<-style onto style objects that determine the actual appearance of a fragment. This separates semantical information represented by the fragment from visualisation as achieved in the editor. Setting the style to @nil deletes the visual appearance of fragments with this name.

The following skeleton illustrates this. E is an editor. The final code fragment creates a fragment to turn the current selection into a title.

:- pce_global(@title_style,
                          new(style(font :=
                                                font(helvetica, bold, 16)))).

        ...
        send(E, style, title, @title_style),
        ...

        ...
        get(E, selection, point(Start, End)),
        Length is End - Start,
        new(F, fragment(E, Start, Length, title)),
        ...
See also
- text_margin-styles
- class fragment
editor <- tab_distance: characters=int
Distance between tab-stops in font<-ex units of the current editor<-font. Mainly used for handling source-code. When editor->tab_stops is defined the value of this variable is ignored.
editor <- text_buffer: text_buffer
The editor<-text_buffer stores the text. Class editor delegates messages not understood to the editor<-text_buffer. A text_buffer can have multiple editors operating on it simultaneously. The text_buffer object associated to an editor may be changed anytime.
editor <- text_cursor: text_cursor
Visualisation of the caret. It may be displayed in various styles. See class text_cursor. The default caret is a static inverting block for fixed-width fonts and a line with triangle for proportional fonts.

1.49.7 Send methods

editor ->_dabbrev_expand: event_id
@see editor->dabbrev_expand
editor ->align: column=int, index=[int]
Insert/delete spaces and tab characters such that the character at index [editor<-caret] will have editor<-indentation column. When layout characters are deleted, at least a single space remains.

Useful for realising automatic indentation and alignment of comments in syntax driven editors.

editor ->align_line: column=[int]
Align the line holding the caret such that the first non-layout character is at the indicated column. When columns is omitted, editor<-left_margin is used. See also editor->align, align_region and editor->indent_line.
editor ->align_region: column=[int]
Apply editor->align_line to all lines in the current region (mark, caret).
editor ->append: text=char_array
Append the specified text. If editor<-left_margin is not zero, editor->align the last line to editor<-left_margin. Then append the text. If editor<-auto_newline is @on, append a newline too. Set the editor->caret at the end of the buffer.

editor->print editor->insert’s the text at the editor<-caret, followed by a newline character if editor<-auto_newline equals @on.

Bugs: Messy. New code should use the editor->align and editor->format methods.

See also
- editor-left_margin
- editor-auto_newline
editor ->print: text=string
Insert text at caret (auto_newline).
editor ->appendf: format=char_array, argument=any ...
Formatted append (see editor->format and string->format (argument specification).
editor ->auto_fill: from=[int], skip=[regex]
Fill after editor->insert_self_fill detected a long line. The default implementation fills from the start of the current line to the end of the paragraph, using the left-margin from the current indentation.

This method is intended for redefinition in language mode to perform more mode-dependent filling such as breaking long comments, log argument lists, etc.

editor ->auto_fill_mode: [int]
Inherits description from: editor-fill_mode
editor ->backward_paragraph: [int]
Move paragraphs backward.
editor ->backward_sentence: [int]
Move sentences backward.
editor ->backward_term: [int]
Move Prolog terms backward.
editor ->backward_word: [int]
Move words backward.
editor ->backward_char: [int]
Move the caret the times the indicated unit backwards. The definition of words, sentences and paragraphs depends on the syntax_table object associate to the editor<-text_buffer. See also text_buffer<-scan.
editor ->delete_char: [int]
Delete characters forward.
editor ->backward_delete_char: [int]
Delete characters from the caret. By default deletes a single character.
editor ->kill_line: [int]
Kill lines forward.
editor ->kill_paragraph: [int]
Kill paragraphs.
editor ->kill_sentence: [int]
Kill sentences forward.
editor ->kill_term: [int]
Kill Prolog terms.
editor ->kill_word: [int]
Kill words forward.
editor ->backward_kill_word: [int]
Kill the specified (default 1) number of units in the specified direction. See editor->kill and editor->yank for details on killing and yanking (cut/copy) text.
editor ->beginning_of_line: [int]
Move lines backward, default is to the start of the current line.
editor ->downcase_previous_word: [int]
Lower-case n words before caret.
editor ->upcase_previous_word: [int]
Uppercase n words before caret.
editor ->capitalise_previous_word: [int]
Similar to the editor->capitalise_word/editor->upcase_word and editor->downcase_word group, but affects the word before rather than after the editor<-caret. Saves keystrokes when used to correct typos while entering text.
editor ->downcase_word: [int]
Loser-case n words after caret.
editor ->upcase_word: [int]
Uppercase n words after caret.
editor ->capitalise_word: [int]
Change the case of the word, starting at the first letter scanning forwards from the editor<-caret up to the end of this word. editor->capitalise_word maps the first letter to uppercase and the remainder to lowercase.
editor ->clear:
Remove all text and fragments using text_buffer->clear. Deletes the selection and sets the editor<-caret to 0.
editor ->column: column=int
Inherits description from: editor<-column
editor ->compute:
Invoke text_image->compute. Next verifies that the editor<-caret is in the window and moves the window if necessary. Finally update the editor<-text_cursor, editor<-margin and editor<-scroll_bar.
editor ->cua_key_as_prefix: event|event_id
Test whether to use the keys \C-x or \C-c as Emacs prefix keys or CUA-mode Cut/Copy commands. The rules for this are based on cua.el, a GNU-Emacs mode merging CUA and Emacs by Kim F. Storm (storm@cua.dk):

editor ->dabbrev_expand:
Expand the word before the caret. This is achieved by scanning the current buffer backwards for words that start the same way as the partial current word. Successive execution of this method will try alternative completions.
See also
- editor-dabbrev_target
- editor-dabbrev_reject
- editor-dabbrev_pos
- editor-dabbrev_origin
- editor->_dabbrev_expand
editor ->delete: from=int, to=int
Each of the commands editor->delete, editor->grab and editor->kill operate on characters in the range [from, to) (i.e. to minus from characters). If to < from, the arguments are first swapped. The commands may or may not delete the range and may or may not add the deleted text to the kill-buffer @text_kill_ring:
editor->delete Just deletes the text
editor->kill editor->delete and add the deleted text to the kill ring
editor->grab Add the text to the kill-ring without deleting it.

See also @text_kill_ring and editor->yank.

editor ->delete_blank_lines:
GNU-Emacs compatible command. See also editor->delete_horizontal_space and editor->just_one_space.
editor ->grab: from=int, to=int
Add text to the kill-buffer.
editor ->kill: from=int, to=int
Delete text and add it to the kill-buffer.
editor ->delete_horizontal_space: [int]
Delete all white space (no newlines) around caret and reinsert the specified number of spaces. Default is to insert 0 spaces. See also editor->just_one_space.
editor ->capitalise_region:
Capitalise words in region.
editor ->downcase_region:
Map all characters in the region [editor<-mark ... editor<-caret) to the specified case. editor->capitalise_region will map any first letter of a word to uppercase and any other letter to lowercase.
See also
editor->upcase_region
editor ->electric_caret: index=int, seconds=[real]
Temporary display the caret at the indicated position. The caret is restored to the insertion-point after the indicated time (in seconds) or after the user has typed in the editor.

This method may be used to indicate a related position. For example if the user types a closing-bracket this method may be used to indicate the matching opening bracket.

Defaults: The default time to restore the caret is 0.5 seconds.

See also
editor->show_caret_at
editor ->event: event
Process an event:

  1. Succeed if device->event succeeds. This allows for redefining event-handling on any of the parts of the editor.
  2. If the event is a keyboard event, invoke editor->typed.
  3. If the event is an area event, update the graphical->active status.
  4. If the recogniser object @editor_recogniser exists, invoke recogniser->event to this object and return the result thereof.
editor ->exchange_point_and_mark:
Exchange the location of editor<-mark with editor<-caret. Note that commands operating on the region (the text between the two) do not care which of the two has the lowest index.
See also
editor-mark
editor ->fill: from=int, to=int, left_margin=[int], right_margin=[int], justify=[bool]
Fill paragraphs in the range [from, to). The specified margins default to editor<-left_margin and editor<-right_margin. If justify equals @on, editor->fill inserts spaces such that the right_margin will be straight.

Bugs: Only works properly with fixed-width fonts,

editor ->fill_region:
Fill paragraphs in region.
editor ->fill_selection:
Compat: editor->fill_region.
editor ->fill_paragraph: justify=[int]
Frontend methods to editor->fill the specified text. The margins default to editor<-left_margin and editor<-right_margin.
See also
- editor-right_margin
- editor-left_margin
editor ->find_cut_buffer: [int]
Find the value of the indicated display<-cut_buffer as a plain string. Respects editor<-exact_case. If the string is found it is selected, otherwise a warning is editor->report’ed.
editor ->format: format=char_array, argument=any ...
Inserts formatted text at the editor<-caret location. See string->format for a description on the format specification. See also editor->appendf.
editor ->forward_paragraph: [int]
Move paragraphs forward.
editor ->forward_sentence: [int]
Move sentences forward.
editor ->forward_term: [int]
Move Prolog terms forward.
editor ->forward_word: [int]
Move words forward.
editor ->forward_char: [int]
Move the caret the times the indicated unit forwards. The definition of words, sentences and paragraphs depends on the syntax_table object associate to the editor<-text_buffer. See also text_buffer<-scan.
editor ->geometry: x=[int], y=[int], width=[int], height=[int]
Handle geometry requests to the editor. Properly resizes and positions the editor<-scroll_bar, editor<-image and editor<-margin. The minimum size is defined to be 50x20 pixels.
editor ->gosmacs_transpose:
Transpose characters compatible to the GosMacs editor: transposes the character before the caret with the one before that one. The advantage lies in correcting character transposition typos. Using editor->gosmacs_transpose this requires a single keystroke. Using editor->transpose_chars this requires 3 keystrokes.
graphical ->height: int
Inherits description from: editor-size
editor ->hover_fragment_icon: fragment=fragment*, icon_area=[area]
Virtual method. Called from the text_margin object when the mouse enters and exits the area of an icon. On enter the fragment object and the area where the fragment is painted relative to the margin is passed. On exit, the fragment is @nil and the argument @default.
editor ->indent_region: [int]
Indent lines in region by editor<-indent_increment.
editor ->indent_selection: [int]
Compat: editor->indent_region.
editor ->undent_line: [int]
Unindent line by editor<-indent_increment.
editor ->undent_region: [int]
Unindent lines in region by editor<-indent_increment.
editor ->undent_selection: [int]
Compat: editor->undent_region.
editor ->indent_line: [int]
Increase (undent: decrease) the indentation of the current line by arg times editor<-indent_increment. This group of methods is compatible to the Dope editor and allows for manipulating the indentation when editing source-code. See also editor->align_line.
See also
editor-indent_increment
editor ->initialise: text=[text_buffer], width=[int], height=[int], margin=[int]
Create an editor object from the specified arguments. If no text_buffer is specified, a default empty text_buffer object is used. The width and height arguments are interpreted in terms of character units.

The margin specifies the with of the text_margin object attached to the right side used for annotations. The default is 0, attaching no annotation margin. See also editor->margin.

Class view encapsulates an editor object in a window.

editor ->insert: text=char_array
Insert the given text at the caret and move the caret to point just after the inserted text.
editor ->insert_cut_buffer: [int]
Insert the text from the display<-cut_buffer. Move caret to the end.
editor ->insert_self_fill: times=[int], character=[char]
Insert char n times; adjust margins.
editor ->insert_self: times=[int], character=[char]
Insert the argument character times times.

The editor->insert method calls editor->insert_self_fill if editor<-auto_fill_mode equals @on.

The editor->insert_self_fill calls editor->auto_fill if -after the insertion-, the text extends the editor<-right_margin. Normally this fills the remainder of the paragraph. By redefining editor->auto_fill, more specialised handling of long lines can be implemented.

See also
editor-fill_mode
editor ->isearch_backward:
Start incremental search backward.
editor ->isearch_forward:
Start an incremental search. The editor will search for the typed plain text (respecting editor<-exact_case) and indicate the first hit using the selection on each subsequent letter typed by the user. While searching, the following keys have special meaning:
keyboard_quit			Abort and revert to where search started
isearch_backward
isearch_forward			Revert direction or search for next
backward_delete_char	Remove the last character from the target
ESCAPE					Terminate search
\C-w					Extend target to current word
See also
- editor->isearch_backward
- editor-search_string
- editor-search_origin
- editor-search_direction
- editor-search_base
- editor-exact_case
editor ->just_one_space:
Replace all white-space (tab, space, not newline) surrounding the caret by a single space.
editor ->justify_region:
Justify region.
editor ->justify_paragraph:
Front-end to editor->fill the specified unit of text. The justify argument of editor->fill is set to @on, creating a straight right margin.
editor ->key_binding: key=name, action=name|code
Add a new binding to editor<-bindings using key_binding->function to this object. The key_binding remains local to the receiving editor. The method editor<-key_binding requests the current binding (local or global) using key_binding<-function.
editor ->kill_or_grab_region: [int]
Without an argument, editor->kill the current region. Otherwise editor->grab the region.
editor ->label: name
Associate a label with the editor and set the string of the label. The label is displayed by editor<-label_text. The font of the label is dictated by editor.label_font. See also editor<->show_label.
editor ->line_number: line=int
Position the caret at the start of nth (1-based) line.
editor ->line_to_top_of_window: [int]
Scroll such that the current line is the nth (1 based, default = 1) line of the window. See also editor->normalise.
editor ->load: file=source_sink
Load the contents of the specified file object. Performs the following steps:
->clear						Clear the editor
`text_buffer ->insert_file`	Insert the file contents
<-file						Assign the file variable
->caret: 0					Put the caret `home`
`text_buffer ->modified: @off`	Clear modified
`text_buffer ->reset_undo`	Clear undo info
->editable: Bool

If file->access succeeds, editor->editable: @on is invoked on the editor, otherwise editor->editable: @off.

See also
editor-file
editor ->lost_text_buffer:
Invoked by the associated editor<-text_buffer if it is being freed. By default, this method will simply send object->free to the editor, or its associated view object.

This method may be redefined, but should either free the editor, or associate another (new) text_buffer object with the editor.

See also text_buffer->unlink.

editor ->margin_width: pixels=int
Inherits description from: editor-margin, editor<-margin_width
See also
- style-icon
- editor-margin
- class text_margin
editor ->mark: mark=[int], status=[{active,inactive,highlight}]
Set mark and region-status. The region (selection) is defined by the characters in the range [editor<-mark ... editor<-caret) or [editor<-caret .. editor<-mark) if the caret is before the mark. The old position of the mark is pushed in editor<-mark_ring. If the mark is active, it can be used for region-commands.

See also editor->set_mark, editor<-mark_ring and editor->selection.

editor ->newline: [int]
Insert times newline characters. editor->newline inserts before the caret, editor->open_line after the caret, so the caret remains at the same line.
editor ->open_line: [int]
Insert newlines after caret.
editor ->newline_and_indent: [int]
Start a new line and copy the indentation from the previous line. The argument defines the number of lines inserted.
editor ->next_line: lines=[int], column=[int]
Move lines downward; place caret at column. If columns is omitted, editor<-column is used. Normally the column is maintained by class key_binding.
See also
editor-save_column
editor ->normalise: from=[int], to=[int]
Try to make the range [from,to) visible. If this range is too big to fit on a screenful, the line on which from resides will be the first line displayed. See also editor->line_to_top_of_window and editor->recenter.

Defaults: Both arguments default to editor<-caret

See also
editor->selection
editor ->point_to_bottom_of_window: [int]
Scroll caret to bottom of window.
editor ->point_to_bottom_of_file: [int]
Place the caret at the nth-line from the end of the file/window. Without an argument, the caret is placed at the end of the file/window.
editor ->point_to_mark:
Move editor<-caret to the editor<-mark. In most cases editor->exchange_point_and_mark is to be preferred. See also editor->set_mark.
See also
editor-mark
editor ->point_to_top_of_window: [int]
Move to 1st character of window.
editor ->point_to_top_of_file: [int]
Move caret to the nth-line from the top of the file/window. Default is the start of the file/window. See also editor->line_number.
editor ->previous_line: lines=[int], column=[int]
@see editor-save_column
editor ->recenter: [int]
Same as editor->line_to_top_of_window, but centers the current line on the window rather than making it the first line.
editor ->report: kind={status,inform,progress,done,warning,error,fatal}, format=[char_array], argument=any ...
If editor<-error_message is not @nil, execute it using the following arguments:
@receiver The editor<-master of the editor
@arg1 The editor
@arg2 the kind
@arg3 The message

See visual->report for a discussion on the reporting mechanism.

editor ->save: file=[file]
Save to editor<-file or named file. If no file is specified and editor<-file is @nil, this method fails. If the file to save in exists, a backup is created using file->backup. Next, the contents of the editor is saved into the named file. If a file was specified, editor<-file will be filled with the argument file.
See also
editor-file
editor ->save_buffer: always=[int]
Save the editor to editor<-file if it is editor<-modified or the argument is not @default. If the operation succeeds, the editor<-modified flag is cleared. Diagnostics are reported using editor->report.
See also
editor-file
editor ->scroll_one_line_down: [int]
Scroll lines (1 line) downward.
editor ->scroll_one_line_up: [int]
Scroll lines (1 line) upward.
editor ->scroll_up: [int]
Scroll lines (1 screen) upward.
editor ->scroll_down: [int]
Scroll forwards or backwards by the specified number of lines. For the one_line versions of this method, the default is to scroll a single line. For editor->scroll_up/editor->scroll_down the default is a screenful minus a line.
editor ->scroll_to: index=[int], screenline=[int]
Set start of screenline-th line of window to index (character based). Index should be the start of a physical line, though this is not actively enforced. If screenline is @default, the given position is centered in the window. The first screenline is line 1.

See text_buffer<-scan.

editor ->scroll_vertical: direction={forwards,backwards,goto}, unit={file,page,line}, amount=int
Handle requests from the editor<-scroll_bar. Normally there is no reason to deal with this method yourself. We document it here to explain the three scrolling models used by the editor.

If the text_buffer<-size (i.e. the number of characters held by the editor) is large, It determines the position and size of the scrollbar based on character offsets.

If the size gets medium, it counts physical lines, i.e. the number of newline characters.

If the size gets small, it computes the line-layout, including line-heigth using the current editor<-wrap setting. This mode provides relyable precise scrolling, but quickly gets too costly for real-time usage.

Inherits description from: editor<-length

editor ->select_line: line=[int], newline=[bool]
Select the line with given number. Numbering lines starts at 1.
editor ->selected_fragment: fragment*
@see class fragment
editor ->selected_fragment_style: style
Style for the currently editor<-selected_fragment.

See also editor->margin_width, editor->selection_style and class style.

editor ->selection: mark=[int], caret=[int], status=[{active,inactive,highlight}]
Make characters in the range [from,to) the selection and invoke editor->normalise on the same range to make the selection or as much as possible thereof visible. If to is equal to from, no selection is visible and the editor is not normalised.

The selection is determined by editor<-mark and editor<-caret. It can be in three modes as described with editor<->mark_status.

See also editor<-selected, editor<-selection, editor<-selection_start and editor<-selection_end.

Defaults: The first argument (from) defaults to the current start of the selection; the second (to) to the current end of the selection.

See also
editor->normalise
editor ->selection_extend: to=int
Extend the selection to include the specified index. This method is used when defining the selection with the pointer. This method respects -selection_unit.
editor ->set_fill_column: [int]
Inherits description from: editor-left_margin
See also
- editor-right_margin
- editor-left_margin
editor ->set_mark: [int]
Interactive command to set editor<-mark at editor<-caret, starting an active selection, also called region. With an argument this command cycles through the list marks in the editor<-mark_ring.

Programmatic access to the mark is provided by editor->mark.

See also
editor-mark
editor ->show_caret: show=bool
Controls the visibility of the caret. In addition, if the caret is not visible, the cursor up/down keys scroll the editor rather than moving the (invisible) caret. See also editor->editable.
editor ->show_caret_at: index=[int]
Display the caret at the indicated location without moving the insertion-point. The indicated position must be inside the visible range of the editor (see editor<-start and editor<-view). This method is used by editor->electric_caret..
See also
editor->electric_caret
editor ->show_label: show=bool
Show/unshow the label. If the editor has no editor<-label_text, one is created. Otherwise the graphical<->displayed attribute of the label_text is used to control the visibility of the label. The method editor->geometry is invoked to realise the proper layout of the components of the editor object.
editor ->show_matching_bracket: index=[int]
Indicate the bracket matching the bracket at index (default editor<-caret) using editor->electric_caret.
graphical ->size: size
Inherits description from: editor-size
editor ->sort: from=[int], to=[int]
Inherits description from: text_buffer->sort
editor ->style: fragment=name, style=style*
Inherits description from: editor-styles
See also
class style
editor ->switch_case_mode: [int]
Inherits description from: editor-exact_case
See also
editor-exact_case
editor ->tab_stops: vector*
Set/query tab-stops at the indicated (pixel) positions. This method is commonly used to display tabular information.
See also
editor<-tab_stops
editor ->transpose_lines:
Transpose line with line above.
editor ->transpose_terms:
Transpose Prolog terms around point.
editor ->transpose_word:
Transpose words around caret.
editor ->transpose_chars:
Transpose the unit before the caret with the one after the caret. The exact definition of the unit depends on the syntax_table object associated to the editor<-text_buffer
editor ->typed: event|event_id
Normally called from editor->event to handle typing. Handles editor<-focus_function and/or invokes key_binding->typed on editor<-bindings.
See also
editor-bindings
editor ->undo:
Undo the last interactively given command. Marking the undo-log is achieved by editor->event.
editor ->upcase_region:
@see editor->downcase_region
graphical ->width: int
Inherits description from: editor-size
editor ->wrap: {none,character,word}
Inherits description from: editor<-wrap
editor ->yank: [int]
Insert the text from the nth (default 0) vector<-element of @text_kill_ring. Text is inserted in the kill-ring using editor->kill or editor->grab.

1.49.8 Get methods

editor <-column: index=[int] -> column=0..
Determine the column for index. Interprets editor<-tab_stops. When set, the editor<-caret is moved as close as possible to the indicated column. See also editor->align.
editor <-contains: -> visual
Fails (hiding the internal structure of the editor for the visual hierarchy).
editor <-convert: view -> editor
Convert a view object into its view<-editor. Improves the transparency between class editor and class view.
editor <-dabbrev_candidates: mode={user0,user1,user2,user3}, target=char_array -> chain*
Helper called by editor->dabbrev_expand. The mode argument describes the stage of the expansion:

This method should return a list if candidates, each starting with target.

editor <-height: -> character=int
Inherits description from: editor-size
editor <-indentation: index=[int], skip=[regex] -> column=int
Column for first non-blank character of line holding index. The default index is editor<-caret. If regex is specified, regex->match is executed from the start of the line and the column for the end of the match is returned. If the regex does not match at all, 0 is returned.

This method is commonly used in combination with editor->align for language dependent automatic indentation and alignment.

editor <-key_binding: key=name|event_id -> action=name|code
Inherits description from: editor->key_binding
editor <-start: [int] -> int
editor <-view: -> int
editor <-length: -> int
The methods editor<-length, editor<-start and editor<-view are used by the related scroll_bar object to determine the visible part of the text. The method editor->scroll_vertical is called from the editor<-scroll_bar.
editor <-line: index=[int] -> line=string
New string with text of the line holding index. When omitted, the line holding the editor<-caret is returned.
editor <-line_number: index=[int] -> line=int
1-based line-number of index. If index is omitted, editor<-caret is used as default. The line-numbers returned refers to the physical line number. In other words, the returned number is the number of LF (Line-Feed) characters from the start of the buffer to index plus one.

This numbering is conventionally used by programming languages.

editor <-margin_width: -> pixels=int
Inherits description from: editor-margin
editor <-master: -> editor|view
Return the view object if graphical<-device yields an instance of class view. Otherwise return the editor itself. Used when the editor executes a code object. See editor<-error_message and editor<-modified_message.

See also visual<-master.

editor <-read_line: -> line=string
As editor<-line, moves caret to next line. Fails after reading the last line of text. When reading the whole buffer in this fashion, don't forget to set editor->caret: 0 before starting. See also file<-read_line.
editor <-selection: -> point
Returns a new point object whose device<-x is the start of the selection and device<-y is the end of the selection (not including: 50,51 represents a selection holding one characters). The device<-x is guaranteed to be smaller than device<-y.

The selection is determined by the editor<-mark and editor<-caret.

editor <-selection_end: -> int
Index for end of selection. This message is a backward compatible method for editor<-caret. See also editor<-mark and editor<-selection.
editor <-selection_start: -> int
Index for start of selection. This is a backward compatibility method for editor<-mark. See also editor<-caret and editor<-selection.

Inherits description from: editor-selection_end

editor <-size: -> characters=size
Inherits description from: editor-size
editor <-tab_stops: -> vector*
Inherits description from: editor->tab_stops
See also
editor->tab_stops
editor <-width: -> characters=int
Inherits description from: editor-size
editor <-wrap: -> {none,character,word}
How to display handle long lines. The default is character, breaking long-lines at the character level. If none is used, text exceeding the left-margin is simply discarded. Finally, word makes the editor break lines at the start of a word. See also text_image->wrap.

editor->wrap chooses between the two views on a text-file realised by class editor. The default mode is intended for editing source code or other traditional line-based text documents, generally using a fixed-width font object. Using‘editor->wrap: word’, the editor treats the file as a sequence of paragraphs separated by newlines. The latter is the common view for most modern GUIs for textareas.

In addition to wrapping, a number of commands are influenced by editor<-wrap to use screen-lines rather then physical lines if editor<-wrap = word. This is only the case if the method is not passed a numerical argument.