27 Text
Classes matching this interface are expected to implement the basic
functionality needed by the framework.
This function highlights a region of text in the buffer.
The range between start and end will
be highlighted with the color in color, if the style is
'rectangle (the default).
If the style is 'ellipse, then an ellipse is drawn
around the range in the editor, using the color.
If the style is
'hollow-ellipse, then the outline of an ellipse is
drawn around the range in the editor, using the color.
If the style is 'dot, then start and
end must be the same, and a dot is drawn at the bottom of
that position in the editor.
If caret-space? is not #f, the left
edge of the range will be one pixel short, to leave
space for the caret. The caret does not interfere with
the right hand side of the range. Note that under some
platforms, the caret is drawn with XOR, which means
almost anything can happen. So if the caret is in the
middle of the range it may be hard to see, or if it is
on the left of the range and caret-space? is
#f it may also be hard to see.
The priority argument indicates the relative
priority for drawing overlapping regions. If two regions
overlap and have different priorities, the region with
'high priority will be drawn second and only it
will be visible in the overlapping region.
This method returns a thunk, which, when invoked, will turn off
the highlighting from this range.
This method removes the highlight from a region of text in
the buffer.
The region must match up to a region specified
from an earlier call to
highlight-range.
Returns a list of (opaque) values representing the active
ranges in the editor.
If the result of this function is
#t, the styles in this
text:basic<%>
will be fixed. This means
that any text inserted to this editor
has its style set to this editor’s
style-list%’s
"Standard" style.
See also
set-styles-fixed.
|
dest-text : (instance text%) |
start : exact-integer |
end : exact-integer |
dest-pos : exact-integer |
This moves or copies text and snips to another edit.
Moves or copies from the edit starting at start and ending at
end. It puts the copied text and snips in dest-text
starting at location dest-pos.
If a snip refused to be moved, it will be copied, otherwise it will be
moved. A snip may refuse to be moved by returning
#f from
release-from-owner.
The result of this method is used as the initial autowrap
bitmap. Override this method to change the initial
bitmap%. See also
set-autowrap-bitmapThe result of this method is a symbol that identifies this
editor and that is used as the port-name of a port that is
read from this editor if this editor is used in DrRacket.
See also
port-name-matches?.
Indicates if
id matches the port name of this file. If
the file is saved, the port name matches when the save file
is the path as
id. If the file has not been saved, the
port name matches if the symbol is the same as the result of
port-name-matches?.
Returns a number that increments everytime something in
the editor changes.
The number is updated in after-insert in text% and
after-delete in text%.
This method is used by
keymap:setup-global to implement
a keybinding for the
"home" key and for
"c:a".
This mixin implements the basic functionality needed for
text%
objects in the framework.
The class that this mixin produces uses the same initialization
arguments as it’s input.
|
directory : path |
default-name : path |
Call this method to enable special treatment of the first line in the editor.
Returns
#t if
is-special-first-line?
returned
#t for the current first line
and if the buffer is scrolled down so that the first
line would not (ordinarily) be visible.
Returns the height, in pixels, of the first line.
Override this method to control when the first line is always
visible. The argument is the first line, as a string.
Provides the implementation of
text:first-line<%>.
Does so by just painting the text of the first
line over top of what is already there and overriding
scroll-editor-to to patch
up scrolling and
on-event to patch up
mouse handling.
Based on the various return values of the methods in text:first-line,
draws the first actual line of the editor over top of the first
visible line in the editor.
Clicks in the first line cause the editor to scroll to the
actual first line.
Scrolls a little bit more, when a scroll would be requested
that scrolls something so that it is line underneath the first line.
This class hides the caret, except when the selection is active.
Instances of this class are useful for editors that used for
displaying purposes, but still allow users to copy their text.
Calls
hide-caret
to hide the caret when there is only a caret and no selection.
Classes that implement this interface silently change
non-breaking spaces, ie the character
(integer->char 160), to regular spaces when inserted into the editor.
|
start : exact-int |
end : exact-int |
Replaces all non-breaking space characters
(integer->char 160)
by
#\space characters.
Prompts the user if the pasted text should be normalized
(and updates various preferences based on the response).
Override this method in the mixin to avoid all GUI and preferences interactions.
Overridden to detect when insertions are due to pasting. Sets some internal state and calls the super.
Any object matching this interface can be searched.
Searches using this class has a non-traditional feature
for performance reasons. Specifically, multiple adjacent
hits are coalesced into a single search results when
bubbles are drawn. This means, for example, that searching
for a space in a file with 80,000 spaces (as one file in
the Racket code base has) is still tractable, since
many of those spaces will be next to each other and thus
there will be far fewer bubbles (the file in question has
only 20,000 such bubbles).
If str is not #f, then this method highlights
every occurrence of str in the editor. If str is
#f, then it clears all of the highlighting in the buffer.
If cs? is #f, the search is case-insensitive, and
otherwise it is case-sensitive.
If the replace-start argument is #f,
then the search is not in replacement mode. If it is a
number, then the first search hit after that position in
the editor is where the next replacement will take place.
Sets the anchor’s position in the editor. Only takes effect if
the 'framework:anchored-search preference is on.
Returns the number of hits for the search in the buffer, based on the
count found last time that a search happened.
Sets the position where replacement next occurs. This is equivalent
to calling
set-searching-state with
a new
replace-start argument, but the other arguments the same
as the last call to
set-searching-state,
but is more efficient (since
set-searching-state
will search the entire buffer and re-build all of the bubbles).
Returns information about the search bubbles in the editor. Each
item in the outermost list corresponds to a single bubble. The pair
of numbers is the range of the bubble and the triple of numbers is
the color of the bubble, in RGB coordinates.
If replace-start has been set (via
set-replace-start) and the
closest search hit following replace-start does not
collapse with an adjacent bubble,the result will include
that bubble. If the closest search hit after
replace-start is collpased with another bubble, then
the search hit is not reflected in the result.
This method is intended for use in test suites.
This
text%
can be searched.
The result of this mixin uses the same initialization arguments as the
mixin’s argument.
This returns a list containing the super-class’s keymaps, plus the
result of
keymap:get-searchRe-does any search now that the contents of the window have changed.
Re-does any search now that the contents of the window have changed.
Tells the frame containing the editor to search based on this editor via
the
set-text-to-search method.
Use this buffer to perform some special action when return is typed.
If key is either return or newline, only invoke the return
thunk (initialization argument) and do nothing else.
Registers a snip in this editor to be resized when its viewing area
changes. Ensures the snip is as wide as the viewing area.
This method should only be called by
add-wide-snip in canvas:wide-snip<%>.
Registers a snip in this editor. It is resized when the
viewing area of the editor changes.
The contents of the two
editor are kept in sync, as modifications
to this object happen.
The result of this method is the
text% object
that the contents of this editor are being delegated to, or
#f, if there is none.
This method sets the current delegate.
When it is set, all of the snips are copied from this object
to
delegate. Additionally, if this object implements
scheme:text<%>
the tab settings of
delegate are updated to match this
objects.
This class re-uses the implementation of
string-snip%
to implement a string snip that just draws
a single pixel for each character in the string.
(send a-text:1-pixel-string-snip split | | position | | | | | | | first | | | | | | | second) | | → | | void |
|
position : exact |
first : (box (instanceof snip%)) |
second : (box (instanceof snip%)) |
(send a-text:1-pixel-string-snip get-extent | | dc | | | | | | | x | | | | | | | y | | | | | | [ | w | | | | | | | h | | | | | | | descent | | | | | | | space | | | | | | | lspace | | | | | | | rspace]) | | → | | void |
|
dc : (instanceof dc<%>) |
x : real |
y : real |
w : (box (union non-negative-real-number |#f|)) = |#f| |
h : (box (union non-negative-real-number |#f|)) = |#f| |
descent : (box (union non-negative-real-number |#f|)) = |#f| |
space : (box (union non-negative-real-number |#f|)) = |#f| |
lspace : (box (union non-negative-real-number |#f|)) = |#f| |
rspace : (box (union non-negative-real-number |#f|)) = |#f| |
Sets the descent, space, lspace, and rspace to zero. Sets
the height to 1. Sets the width to the number of characters
in the string.
|
s : string |
len : exact |
pos : exact = 0 |
(send a-text:1-pixel-string-snip draw | | dc | | | | | | | x | | | | | | | y | | | | | | | left | | | | | | | top | | | | | | | right | | | | | | | bottom | | | | | | | dx | | | | | | | dy | | | | | | | draw-caret) | | → | | void |
|
dc : (instanceof dc<%>) |
x : real |
y : real |
left : real |
top : real |
right : real |
bottom : real |
dx : real |
dy : real |
draw-caret : (union 'no-caret 'show-inactive-caret 'show-caret) |
Draws black pixels for non-whitespace characters and draws
nothing for whitespace characters.
This class re-uses the implementation of
tab-snip%
to implement a string snip that is always one pixel
high.
(send a-text:1-pixel-tab-snip split | | position | | | | | | | first | | | | | | | second) | | → | | void |
|
position : exact |
first : (box (instanceof snip%)) |
second : (box (instanceof snip%)) |
|
dc : (instanceof dc<%>) |
x : real |
y : real |
w : (box (union non-negative-real-number |#f|)) = |#f| |
h : (box (union non-negative-real-number |#f|)) = |#f| |
descent : (box (union non-negative-real-number |#f|)) = |#f| |
space : (box (union non-negative-real-number |#f|)) = |#f| |
lspace : (box (union non-negative-real-number |#f|)) = |#f| |
rspace : (box (union non-negative-real-number |#f|)) = |#f| |
Sets the descent, space, lspace, and rspace to zero. Sets
the height to 1. Sets the width to the width of tabs as
returned in the
tab-width parameter of the
get-tabs
method.
(send a-text:1-pixel-tab-snip draw | | dc | | | | | | | x | | | | | | | y | | | | | | | left | | | | | | | top | | | | | | | right | | | | | | | bottom | | | | | | | dx | | | | | | | dy | | | | | | | draw-caret) | | → | | void |
|
dc : (instanceof dc<%>) |
x : real |
y : real |
left : real |
top : real |
right : real |
bottom : real |
dx : real |
dy : real |
draw-caret : (union 'no-caret 'show-inactive-caret 'show-caret) |
Draws nothing.
In addition to calling the super method,
highlight-range, this method forwards the highlighting to
the delegatee.
This method propagates the call to the delegate and calls the super method.
Draws a blue region in the delegatee editor that shows where
the visible region of the delegate editor is.
starts an edit sequence in the delegate.
ends an edit sequence in the delegate.
Sends a message to the delegate to update the size of the
copied snip, if there is one.
|
start : number |
len : number |
forwards the change to the delegate
|
start : number |
len : number |
forwards the change to the delegate.
|
start : number |
len : number |
forwards the changed style to the delegate.
updates the delegate with the new contents of the text.
Objects supporting this interface are expected to send information
about themselves to the frame that is displaying them.
Objects supporting this interface are expected to support a clever
file format when saving.
The result of this mixin uses the same initialization arguments as the
mixin’s argument.
When files are saved from this
text%, a check is made to see if there are any non-
string-snip%
objects in the
text%. If so, it is saved using the file format
'std. (see
set-file-format
for more information. If not, the file format passed to
save-file
is used.
|
filename : path? |
format : (one-of/c 'guess 'standard 'text 'text-force-cr 'same 'copy) |
If the method
get-file-format
returns 'text and the text has some non
string-snip%s, the file format is set to 'standard.
Depending on the user’s preferences, the user may also be queried.
Also, the changes to the file format only happen if the argument
file-format is 'copy or 'same.
Mixins that implement this interface lock themselves when
the file they are editing is read only.
Indicates whether or not this editor is in read-write mode.
Unlocks the editor, calls the thunk, and then relocks the
editor, all using a
dynamic-wind.
Returns false if the result of
get-read-write?
is true, otherwise returns the
result of calling
inner.
Returns false if the result of
get-read-write?
is true, otherwise returns the
result of calling
inner.
Checks if the newly saved file is write-only in the filesystem. If
so, locks the editor with the
lock
method. Otherwise unlocks the buffer
Checks if the newly loaded file is write-only in the filesystem. If
so, locks the editor with the
lock
method. Otherwise unlocks the buffer
Classes implementing this interface (via the associated
mixin) support input and output ports that read from the
editor.
There are two input ports: the normal input port just reads
from the editor’s contents directly and the box input port
inserts an editor snip into this text and uses input typed
into the box as input into the port.
They create three threads to mediate access to the input and
output ports (one for each input port and one for all of the
output ports).
(send a-text:ports delete/io start end) → void |
start : exact-integer |
end : exact-integer |
Deletes the text between start and end without
changing the behavior of the ports (otherwise, deleting the
text would break internal invariants of the port).
Both start and end must be less than
get-insertion-point
(or else it is safe to delete them so you don’t need this
method).
Returns the position where characters put into the output
port will appear.
Returns the position where input will be taken into the
input port (after the next time return is typed).
Sets the position where input will be taken into the
input port (after the next time return is typed).
See also
get-unread-start-point.
Indicates if editing is allowed in the buffer at this point.
Inserts some text between the unread start point and the
insertion point (and updates them properly). To insert
before the two points, see
insert-before.
See also
set-unread-start-point
and
set-insertion-point.
Inserts some text before the unread start point and updates
it and the insertion point properly. To insert between
the two points, see
insert-between.
See also
set-unread-start-point
and
set-insertion-point.
Augment this method to help control when characters should
be submitted to the input port.
Return
#t or the result of calling
inner.
This method is called when text is sent into the input port.
Does nothing.
This method puts an eof into the input port.
This method puts an eof into the box input port.
This method removes the current input box from the editor
(and all input in it is lost).
Flushes all of the data in all of the output ports that
hasn’t appeared in the editor yet.
Flushes all of the data in the input port that hasn’t yet
been read. Reading will now block.
Flushes all of the data in the box input port that hasn’t
yet been read. Reading will now block.
The result of this method is the style that is used to color
text submitted to the result of
get-out-port.
If the result is a string that is not mapped in the editor’s
style list, the style named "Standard" is used and
if that isn’t mapped, the style named "Basic" is used.
This method is called during the initialization of the class.
The result of this method is the style that is used to color
text submitted to the result of
get-err-port.
If the result is a string that is not mapped in the editor’s
style list, the style named "Standard" is used and
if that isn’t mapped, the style named "Basic" is used.
This method is called during the initialization of the class.
The result of this method is the style (or the name of the
style) that is used to color text submitted to the result of
get-value-port.
If the result is a string that is not mapped in the editor’s
style list, the style named "Standard" is used and
if that isn’t mapped, the style named "Basic" is used.
This method is called during the initialization of the class.
Defaultly returns "text:ports value" which is mapped
to a blue style in the style list returned by
editor:get-standard-style-list.
Returns the input port that data in this editor is sent to.
Returns the box input port that data in this editor is sent to.
Returns an output port that writes into this editor. The
only difference between this port and the ports returned by
get-err-port
and
get-value-port
is the font style and color.
Returns an output port that writes into this editor. The
only difference between this port and the ports returned by
get-err-port
and
get-out-port
is the font style and color.
Returns an output port that writes into this editor. The
only difference between this port and the ports returned by
get-err-port
and
get-out-port
is the font style and color.
This method is called after an insertion due to IO occurs.
The result of this method is used as the class of editor
snips that is inserted by the box port in this editor.
Adjusts the embedded editor-snip (used for reading input to the
get-in-box-port) to match the width of the editor.
Classes that implement this interface are used as the
editors for the box input port in
text:ports%.
Notifies the
text:ports<%>
enclosing this editor that a new line of input has been provided.
The mixin implementing this interface provides an
unintrusive autocompletion menu when a particular
(configurable) keystroke is pressed.
Starts a completion.
The border color for the autocomplete menu. Defaults to
"black".
The background color for the non-selected menu
items. Defaults to "lavender".
The background color for the selected menu item. Defaults to
(make-object color% 204 153 255).
Returns true when the key event passed to it should initiate
the completions menu.
Returns the list of the words that autocompletion should
choose from.
Given an editor location, returns the prefix ending at that location
that autocompletion should try to complete.
Draws the completion menu (when it is popped up).
Takes over the handling of key events when the completions
menu is visible. Also, when the completions menu is not
visible, it calls the
completion-mode-key-event?
method to see if it should start completing.
This method is overridden to allow mouse access of the
completions menu. It only handles events when there is a
menu open and the mouse is in the menu, in which case it
makes the menu trace the mouse.
The only time it does not call the super method is when
the mouse is button is pushed.
Enables or disables line number drawing.
Returns whether or not line drawing is enabled.
Sets the color of the line numbers.
Draws the line numbers.
Enables or disables line number drawing.
Returns whether or not line drawing is enabled.
Sets the color of the line numbers.
Determines if arg is an instance of the range struct.
Returns the start position of the range.
Returns the end position of the range.
Returns a boolean indicating where the caret-space in the range goes.
See also
highlight-range.
Returns the color of the highlighted range.
A string that is inserted after a completion is inserted by a
text:autocomplete instance.
Defaults to "".
Controls the number of completions visible at a time in the menu produced
by text:autocomplete instances.
Defaults to 15.
Returns the list of keywords for the manuals from
manuals by
extracting all of the documented exports of the manuals. The symbols are
meant to be module paths, e.g., the quoted form of the argument to
require.
If manuals is false, then all of the documented names are used.
Returns the editor instance whose port-name matches the given symbol.
If no editor can be found, then returns
false.