On this page:
text: basic<%>
highlight-range
unhighlight-range
get-highlighted-ranges
get-styles-fixed
get-fixed-style
set-styles-fixed
move/ copy-to-edit
initial-autowrap-bitmap
get-port-name
port-name-matches?
text: basic-mixin
on-paint
on-insert
after-insert
put-file
text: first-line<%>
highlight-first-line
first-line-currently-drawn-specially?
get-first-line-height
is-special-first-line?
text: first-line-mixin
on-paint
on-event
scroll-editor-to
text: foreground-color<%>
text: foreground-color-mixin
default-style-name
get-fixed-style
text: hide-caret/ selection<%>
text: hide-caret/ selection-mixin
after-set-position
text: nbsp->space<%>
text: nbsp->space-mixin
on-insert
after-insert
text: normalize-paste<%>
ask-normalize?
string-normalize
text: normalize-paste-mixin
do-paste
on-insert
after-insert
text: searching<%>
set-searching-state
set-search-anchor
get-search-hit-count
set-replace-start
get-search-bubbles
text: searching-mixin
get-keymaps
after-insert
after-delete
on-focus
text: return<%>
text: return-mixin
on-local-char
text: wide-snip<%>
add-wide-snip
add-tall-snip
text: wide-snip-mixin
text: delegate<%>
get-delegate
set-delegate
text: 1-pixel-string-snip%
split
copy
get-extent
insert
draw
text: 1-pixel-tab-snip%
split
copy
get-extent
draw
text: delegate-mixin
highlight-range
unhighlight-range
on-paint
on-edit-sequence
after-edit-sequence
resized
after-insert
after-delete
after-change-style
on-load-file
after-load-file
text: info<%>
text: info-mixin
set-anchor
set-overwrite-mode
after-set-position
after-insert
after-delete
text: clever-file-format<%>
text: clever-file-format-mixin
on-save-file
text: file<%>
get-read-write?
while-unlocked
text: file-mixin
can-insert?
can-delete?
after-save-file
after-load-file
text: ports<%>
delete/ io
get-insertion-point
set-insertion-point
get-unread-start-point
set-unread-start-point
set-allow-edits
get-allow-edits
insert-between
insert-before
submit-to-port?
on-submit
send-eof-to-in-port
send-eof-to-box-in-port
reset-input-box
clear-output-ports
clear-input-port
clear-box-input-port
get-out-style-delta
get-err-style-delta
get-value-style-delta
get-in-port
get-in-box-port
get-out-port
get-err-port
get-value-port
after-io-insertion
get-box-input-editor-snip%
get-box-input-text%
text: ports-mixin
can-insert?
can-delete?
on-local-char
on-display-size
text: input-box<%>
text: input-box-mixin
on-default-char
text: autocomplete<%>
auto-complete
get-autocomplete-border-color
get-autocomplete-background-color
get-autocomplete-selected-color
completion-mode-key-event?
get-all-words
get-word-at
text: autocomplete-mixin
on-paint
on-char
on-event
text: basic%
text: hide-caret/ selection%
text: nbsp->space%
text: delegate%
text: wide-snip%
text: standard-style-list%
text: input-box%
text: keymap%
text: return%
text: autowrap%
text: file%
text: clever-file-format%
text: backup-autosave%
text: searching%
text: info%
text: autocomplete-append-after
text: autocomplete-limit
text: get-completions/ manuals
text: lookup-port-name
Version: 4.1.3.3

27 Text

text:basic<%> : interface?
  implements: editor:basic<%>
 text%

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?)
  argument extends/implements: editor:basic<%>
 text%
  result implements: text:basic<%>

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

Augments on-insert in text%.

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?
  implements: text%

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?)
  argument extends/implements: text%
  result implements: text:first-line<%>

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?
  implements: text:basic<%>
 editor:standard-style-list<%>

text:foreground-color-mixin : (class? . -> . class?)
  argument extends/implements: text:basic<%>
 editor:standard-style-list<%>
  result implements: text:foreground-color<%>

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<%> </