This manual is for text.editing version 0.1.0.
The text.editing library provides manipulation functions for the contents of text buffers that are required by, for example, commandline processors, input editors and text editors.
text.editing does not provide
A buffer is conceptually a sequence of lines, each of which contains a sequence of items and zero or more attached cursors.
text.editing does not provide an implementation of the buffer concept or associated protocols. Instead, it uses the protocols and classes provided by the cluffer library.
A cursor is an object that is attached to a buffer line before this first item, after the last item or between to adjacent items.
text.editing does not provide an implementation of the cursor concept or associated protocols. Instead, it uses the protocols and classes provided by the cluffer library.
The point is a distinguished cursor which specifies the buffer location at which the next editing operation issued by a user will be performed.
The mark is a distinguished cursor
TODO
Unit are a way to designate particular sub-sequences of the sequence of
all items in a buffer, often relative to the point cursor. For example,
the :word
unit refers to a sequence of non-whitespace,
non-punctuation characters that follow (or precede depending on the
specified direction) the mark cursor.
A “site” ties together pieces of data that are required for performing consecutive editing operations around a specific “location”, or site, in a buffer. The most important piece of data is the point cursor which makes precise the notion of a buffer “location”. Other pieces of data include a mark, a mark stack and an insertion stack.
The main reason for storing this data in a dedicated site object instead of directly in a buffer is the possibility of allowing simultaneous editing at multiple sites in a buffer. From the perspective of an editor user, each site would typically appear as a cursor (with its own point, mark, insertion stack, etc.) which would generally act as if it were the only cursor in the buffer (disregarding effects that arise from sites being too close together or overlapping).
Mention primary site, adding/removing sites, cycling through primary sites
TODO preferred column of a cursor could also be stored in site
The insertion stack is a stack the elements of which are recently copied or killed sequences of buffer items which can be inserted into a buffer. “Kill” and “yank” operations push and pop this stack.
This concept is similar to the “Kill Ring” in Emacs with the following differences:
The following figure illustrates important concepts and their relations:
Sites, units and operations are the basic concepts from which most desired behaviors can be constructed. Here are a few examples:
Operation | Unit | Direction | Equivalent Emacs command |
---|---|---|---|
move | item | forward | forward-char (C-f) |
move | item | backward | backward-char (C-b) |
move | word | forward | forward-word (M-f) |
move | word | backward | backward-word (M-b) |
move | line | forward | next-line (C-n) |
move | line | backward | previous-line (C-p) |
delete | item | forward | delete-char (C-d) |
delete | item | backward | delete-backward-char (<backspace>) |
delete | word | forward | kill-word (M-d) |
delete | word | backward | backward-kill-word (M-<backspace>) |
delete | line | forward | kill-line (C-n) |
delete | line | backward | kill-line with 0 prefix (C-0 C-n) |
Unit | Description |
---|---|
:word | Word |
:line | Line |
:paragraph | Paragraph |
:expression | Expression |
:buffer-boundary | Start or end of buffer |
:buffer | Whole buffer |
This chapter describes the external protocols provided by the text.editing library.
This protocol allows querying and manipulating the entries of an insertion stack. This protocol is not concerned with buffers, sites or cursors. See Copy and Yank Protocol for a higher-level protocol on top of this one.
Return the sequence of items that have been added to
insertion-entry by forward deletion operations such as
cluffer:delete-item
and cluffer:join-line
.
Return the sequence of items that have been added to
insertion-entry by backward deletion operations such as
cluffer:erase-item
.
Return a sequence of items that should be inserted into a buffer to conceptually insert insertion-entry into that buffer.
The returned sequence is the concatenation of the items of the “forward” and “backward” sequences of insertion-entry in the appropriate order.
Return the point cursor of site.
The returned object is a cluffer cursor
Return the column number in which the point of site should reside by default.
The point cursor should be placed in that column or the closest existing column of the current line when the point cursor moves between lines without moving within any line.
Return the mark cursor of site.
The returned object is a cluffer cursor
Indicate whether the mark cursor of site is active.
Change whether the mark cursor of site is active.
new-value is a generalized Boolean.
Set the mark cursor of site to the position of the point cursor.
TODO describe other effects
TODO
Return the insertion stack of site.
The returned object implements the Insertion Stack Protocol.
Detach object from any buffer or line it is currently attached to
TODO
The following convenience function allow easy retrieval and mutation of sub-sequences of buffer items:
Call function with each item in the sub-sequence of buffer items indicated by cursor, unit and direction.
Return a cl:sequence
containing the sub-sequence of buffer items
indicated by cursor, unit and direction.
Replace the sub-sequence of buffer items indicated by cursor,
unit and direction by the items in the cl:sequence
new-value.
Return the sequence of all sites which are attached to buffer except the primary site.
Return the number of sites that are attached to buffer.
Call function with each site that is attached to buffer.
Return the sequence of all sites which are attached to buffer.
TODO
TODO
TODO
TODO
TODO
TODO
&rest
operation-arguments ¶TODO
note: The operations described in this section can be invoked by calling the respective generic function. However, a more flexible way which, for example, handles multiple sites correctly is the Operation Protocol. The following code invokes an operation operation via that protocol
(text.editing:perform buffer 'operation unit direction other-arguments)
Move cursor to the beginning or end of the sub-sequence of buffer items indicated by unit.
If direction is :forward
, cursor moves to the end of the
sub-sequence. If direction is :backward
, cursor moves to
the beginning of the sub-sequence.
Move cursor to the first column of the current line that contains a non-whitespace item.
Delete the sub-sequence of buffer items indicated by cursor, unit and direction.
TODO
Change the case of the sub-sequence of buffer items indicated by cursor, unit and direction according to case.
case has to be one of :down
, :up
or :capitalize
.
TODO
TODO fill operation
The copy and yank protocol offers higher-level functions that implement typical copy and yank operations which abstract from the details of the lower-level Insertion Stack Protocol.
Copy items indicated by the point cursor of site, unit and direction into a new top entry of the insertion stack of site.
&key
direction ¶Insert the items from the top entry of the insertion stack of site at the point cursor of site.
TODO there is no actual generic function at the moment
Jump to: | B C I M P R S U |
---|
Index Entry | Section | ||
---|---|---|---|
| |||
B | |||
buffer: | Concepts | ||
| |||
C | |||
cursor: | Concepts | ||
| |||
I | |||
insertion stack: | Concepts | ||
insertion stack: | Insertion Stack Protocol | ||
| |||
M | |||
mark: | Concepts | ||
mark stack: | Concepts | ||
| |||
P | |||
point: | Concepts | ||
| |||
R | |||
region: | Concepts | ||
| |||
S | |||
site: | Concepts | ||
site: | Site Protocol | ||
| |||
U | |||
unit: | Concepts | ||
|
Jump to: | B C I M P R S U |
---|
Jump to: | (
A B C D E F G I M O P R S T Y |
---|
Jump to: | (
A B C D E F G I M O P R S T Y |
---|
No change history yet