27 Text
| text:basic<%> : interface? | ||||
|
Classes matching this interface are expected to implement the basic functionality needed by the framework.
(send a-text:basic highlight-range start end color [ caret-space priority style]) → (-> void) start : exact-nonnegative-integer? end : exact-nonnegative-integer? color : (or/c string? (is-a?/c color%)) caret-space : boolean? = #f priority : (symbols 'high 'low) = 'low
style : (symbols 'rectangle 'ellipse 'hollow-ellipse 'dot) = 'rectangle 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.
See also unhighlight-range.
(send a-text:basic unhighlight-range start end color [ caret-space style]) → void? start : exact-nonnegative-integer? end : exact-nonnegative-integer? color : (or/c string? (is-a?/c color%)) caret-space : boolean? = #f
style : (symbols 'rectangle 'ellipse 'hollow-ellipse) = 'rectangle 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.
(send a-text:basic get-highlighted-ranges) → (listof range) Returns a list of (opaque) values representing the active ranges in the editor.
(send a-text:basic get-styles-fixed) → boolean? 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.
(send a-text:basic get-fixed-style) → (is-a?/c style<%>) Returns the style used by set-styles-fixedwhen setting the styles.
(send a-text:basic set-styles-fixed fixed?) → void fixed? : boolean? Sets the styles fixed parameter of this text%. See also get-styles-fixed and get-fixed-style.
(send a-text:basic move/copy-to-edit dest-text start end dest-pos) → void 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.
(send a-text:basic initial-autowrap-bitmap) → (union |#f| (instance bitmap%)) The result of this method is used as the initial autowrap bitmap. Override this method to change the initial bitmap%. See also set-autowrap-bitmap
Defaultly returns the result of icon:get-autowrap-bitmap
(send a-text:basic get-port-name) → symbol? The 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 DrScheme. See also port-name-matches?.
(send a-text:basic port-name-matches? id) → boolean? id : (or/c path? symbol?) 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?.
| text:basic-mixin : (class? . -> . class?) | ||||
| ||||
|
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.
(send a-text:basic on-paint before? dc left top right bottom dx dy draw-caret) → void before? : any/c dc : (is-a?/c dc<%>) left : real? top : real? right : real? bottom : real? dx : real? dy : real? draw-caret : (one-of/c 'no-caret 'show-inactive-caret 'show-caret) Overrides on-paint in editor<%>.
Draws the rectangles installed by highlight-range.
(send a-text:basic on-insert start end) → void start : exact-int end : exact-int See set-styles-fixed.
(send a-text:basic after-insert start len) → void start : exact-nonnegative-integer? len : exact-nonnegative-integer? Augments after-insert in text%.
See set-styles-fixed.
(send a-text:basic put-file directory default-name) → void directory : path default-name : path Overrides put-file in editor<%>.
Like put-file but uses finder:put-file instead of put-file.
| text:first-line<%> : interface? | ||
|
Objects implementing this interface, when highlight-first-line is invoked with #t, always show their first line, even with scrolled (as long as first-line-currently-drawn-specially? returns #t).
(send a-text:first-line highlight-first-line on?) → void? on? : boolean? Call this method to enable special treatment of the first line in the editor.
(send a-text:first-line first-line-currently-drawn-specially?) → boolean? 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.
(send a-text:first-line get-first-line-height) → number? Returns the height, in pixels, of the first line.
(send a-text:first-line is-special-first-line? line) → boolean? line : string? Override this method to control when the first line is always visible. The argument is the first line, as a string.
| text:first-line-mixin : (class? . -> . class?) | ||
| ||
|
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.
(send a-text:first-line on-paint before? dc left top right bottom dx dy draw-caret) → void? before? : any/c dc : (is-a?/c dc<%>) left : real? top : real? right : real? bottom : real? dx : real? dy : real? draw-caret : (one-of/c 'no-caret 'show-inactive-caret 'show-caret) Overrides on-paint in editor<%>.
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.
(send a-text:first-line on-event event) → void? event : (is-a?/c mouse-event%) Overrides on-event in editor<%>.
Clicks in the first line cause the editor to scroll to the actual first line.
(send a-text:first-line scroll-editor-to localx localy width height refresh? bias) → void? localx : real? localy : real? width : (and/c real? (not/c negative?)) height : (and/c real? (not/c negative?)) refresh? : any/c bias : (one-of/c 'start 'end 'none) Overrides scroll-editor-to in editor<%>.
Scrolls a little bit more, when a scroll would be requested that scrolls something so that it is line underneath the first line.
| text:foreground-color<%> : interface? | ||||
|
| text:foreground-color-mixin : (class? . -> . class?) | ||||
| ||||
|
This mixin changes the default text style to have the foreground color controlled by editor:set-default-font-color.
(send a-text:foreground-color default-style-name) → string Overrides default-style-name in editor<%>.
Returns the result of editor:get-default-color-style-name.
(send a-text:foreground-color get-fixed-style) → (is-a?/c style<%>) Overrides get-fixed-style in text:basic<%>.
Returns the style named by editor:get-default-color-style-name.
| text:hide-caret/selection<%> |