On this page:
text:  basic<%>
highlight-range
unhighlight-range
unhighlight-ranges/  key
unhighlight-ranges
get-highlighted-ranges
get-styles-fixed
get-fixed-style
set-styles-fixed
move/  copy-to-edit
move-to
copy-to
initial-autowrap-bitmap
get-port-name
port-name-matches?
set-port-unsaved-name
after-set-port-unsaved-name
get-edition-number
get-start-of-line
text:  basic-mixin
on-paint
on-insert
after-insert
put-file
text:  inline-overview<%>
get-inline-overview-enabled?
set-inline-overview-enabled?
text:  inline-overview-mixin
text:  line-spacing<%>
text:  line-spacing-mixin
text:  ascii-art-enlarge-boxes<%>
set-ascii-art-enlarge
get-ascii-art-enlarge
text:  ascii-art-enlarge-boxes-mixin
on-local-char
on-default-char
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:  column-guide<%>
text:  column-guide-mixin
on-paint
on-change
text:  normalize-paste<%>
ask-normalize?
string-normalize
text:  normalize-paste-mixin
do-paste
on-insert
after-insert
text:  all-string-snips<%>
all-string-snips?
text:  all-string-snips-mixin
on-insert
after-delete
text:  searching<%>
set-searching-state
set-search-anchor
get-search-hit-count
get-replace-search-hit
set-replace-start
finish-pending-search-work
get-search-bubbles
text:  searching-mixin
get-keymaps
after-insert
after-delete
on-focus
text:  return<%>
text:  return-mixin
new
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:  crlf-line-endings<%>
text:  crlf-line-endings-mixin
after-load-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
insert/  io
do-submission
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
default-style-name
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:  overwrite-disable<%>
text:  overwrite-disable-mixin
text:  basic%
text:  line-spacing%
text:  hide-caret/  selection%
text:  nbsp->space%
text:  normalize-paste%
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:  line-numbers<%>
show-line-numbers!
show-line-numbers?
set-line-numbers-color
text:  line-numbers-mixin
on-paint
show-line-numbers!
show-line-numbers?
set-line-numbers-color
text:  range?
text:  range-start
text:  range-end
text:  range-caret-space?
text:  range-style
text:  range-color
text:  autocomplete-append-after
text:  autocomplete-limit
text:  get-completions/  manuals
text:  lookup-port-name
text:  make-snip-special
text:  snip-special?
text:  send-snip-to-port

31 Text

interface

text:basic<%> : interface?

  implements: editor:basic<%>
 text%
Classes matching this interface are expected to implement the basic functionality needed by the framework.

method

(send a-text:basic highlight-range 
  start 
  end 
  color 
  [caret-space 
  priority 
  style 
  #:adjust-on-insert/delete adjust-on-insert/delete 
  #:key key]) 
  
(if adjust-on-insert/delete
    void?
    (-> void?))
  start : exact-nonnegative-integer?
  end : exact-nonnegative-integer?
  color : (or/c string? (is-a?/c color%))
  caret-space : boolean? = #f
  priority : (or/c 'high 'low) = 'low
  style : (or/c 'rectangle 'ellipse 'hollow-ellipse 'dot)
   = 'rectangle
  adjust-on-insert/delete : boolean? = #f
  key : any/c = #f
This function highlights a region of text in the buffer.

The range between start and end will be highlighted with the given 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.

If adjust-on-insert/delete? is #t, then insertions and deletions to the text will adjust the start and end of the range. Insertions and deletions before the range move the range forward and backward; insertions and deletions after the range will be ignored. An insertion in the middle of the range will enlarge the range and a deletion that overlaps the range adjusts the range to reflect the deleted portion of the range and its new position.

The key argument can be used with unhighlight-ranges/key and unhighlight-ranges to identify ranges whose start and end positions may have changed. Symbols whose names begin with plt: are reserved for internal use.

If this method returns a thunk, invoking the thunk will turn off the highlighting from this range.

Note that if adjust-on-insert/delete is a true value, then the result is not a thunk and instead unhighlight-range, unhighlight-ranges/key, or unhighlight-ranges must be called directly to remove the highlighting.

method

(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 : (or/c '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.

This method does a linear scan over all of the regions currently set. If you expect to call this method many times (when there are many ranges set) consider instead calling unhighlight-ranges.

method

(send a-text:basic unhighlight-ranges/key key)  void?

  key : any/c
This method removes the highlight from regions in the buffer that have the key key (as passed to highlight-range).

method

(send a-text:basic unhighlight-ranges pred?)  void?

  pred? : 
(-> exact-nonnegative-integer?
    exact-nonnegative-integer?
    (is-a?/c color%)
    boolean?
    (or/c 'rectangle 'ellipse 'hollow-ellipse)
    (or/c boolean? exact-nonnegative-integer?)
    any/c
    boolean?)
This method removes the highlight from regions in the buffer as selected by pred?. The arguments to pred? are the same as the arguments to highlight-range when it was originally called, unless the adjust-on-insert/delete argument was a true value, in which case the first two arguments to the predicate will reflect the current state of the bubble, if it is changed.

method

(send a-text:basic get-highlighted-ranges)

  (listof text:range?)
Returns a list of (opaque) values representing the active ranges in the editor.

method

(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.

method

(send a-text:basic get-fixed-style)  (is-a?/c style<%>)

Returns the style used by set-styles-fixedwhen setting the styles.

method

(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.

method

(send a-text:basic move/copy-to-edit 
  dest-text 
  start 
  end 
  dest-pos 
  [#:try-to-move? try-to-move?]) 
  void?
  dest-text : (is-a?/c text%)
  start : natural?
  end : (and/c natural? (>=/c start))
  dest-pos : natural?
  try-to-move? : boolean? = #t
This moves or copies text and snips to dest-text.

Moves or copies from this starting at start and ending at end. It puts the copied text and snips in dest-text starting at location dest-pos. If start and end are equal then nothing is moved or copied.

If try-to-move? is #t, then the snips are removed; and if it is #f, then they are copied. If try-to-move? is #t and dest-pos is between start and end then this is unchanged.

If a snip refuses to be moved, it will be copied and deleted from the editor, otherwise it will be moved. A snip may refuse to be moved by returning #f from release-from-owner.

method

(send a-text:basic move-to dest-text    
  start    
  end    
  dest-pos)  void?
  dest-text : (is-a?/c text%)
  start : natural?
  end : (and/c natural? (>=/c start))
  dest-pos : natural?
Like move/copy-to-edit when the #:try-to-move? argument is #t.

method

(send a-text:basic copy-to dest-text    
  start    
  end    
  dest-pos)  void?
  dest-text : (is-a?/c text%)
  start : natural?
  end : (and/c natural? (>=/c start))
  dest-pos : natural?
Like move/copy-to-edit when the #:try-to-move? argument is #f.

method

(send a-text:basic initial-autowrap-bitmap)

  (or/c #f (is-a?/c 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

Returns the result of icon:get-autowrap-bitmap by default.

method

(send a-text:basic get-port-name)

  (or/c path-string? symbol? #f)
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 DrRacket. See also port-name-matches?.

method

(send a-text:basic port-name-matches? id)  boolean?

  id : any/c
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 get-port-name.

This method calls normalize-path and thus can be very expensive on some filesystems. If it is called many times in a loop, cache the results to avoid calling it too often.

method

(send a-text:basic set-port-unsaved-name name)  void?

  name : string?
When get-port-name returns a symbol, the printed representation of the symbol will be the same as name.

method

(send a-text:basic after-set-port-unsaved-name)  any/c

This method is called after set-port-unsaved-name is called. Override it to detect changes in what get-port-name returns.

Returns a number that increments every time 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".

Its default implementation is (line-start-position (position-line pos)).

mixin

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 its input.

method

(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 : 
(or/c 'no-caret
      'show-inactive-caret
      'show-caret)
Overrides on-paint in editor<%>.
Draws the rectangles installed by highlight-range.

method

(send a-text:basic on-insert start end)  void?

  start : exact-nonnegative-integer?
  end : exact-nonnegative-integer?
Augments on-insert in text%.

method

(send a-text:basic after-insert start len)  void?

  start : exact-nonnegative-integer?
  len : exact-nonnegative-integer?
Augments after-insert in text%.

method

(send a-text:basic put-file directory    
  default-name)  (or/c path? #f)
  directory : (or/c path? #f)
  default-name : string?
Overrides put-file in editor<%>.
Like put-file but uses finder:put-file instead of put-file.

interface

text:inline-overview<%> : interface?

  implements: text%
Classes implementing this interface provide an overview along the right-hand side of the text%’s view, showing one pixel per character in the editor. Clicking on the editor moves the insertion point to the corresponding place in the text% object.
This effect is similar to text:delegate<%>, but much more efficient.

Added in version 1.32 of package gui-lib.

method

(send a-text:inline-overview get-inline-overview-enabled?)

  boolean?
This method is final, so it cannot be overridden.
Returns a boolean indicating if inline-overview mode is turned on for this text% object.

method

(send a-text:inline-overview set-inline-overview-enabled? on?)

  void?
  on? : any/c
This method is final, so it cannot be overridden.
Enables or disables inline-overview mode for this text% object.

mixin

text:inline-overview-mixin : (class? . -> . class?)

  argument extends/implements: text%
  result implements: text:inline-overview<%>

interface

text:line-spacing<%> : interface?

  implements: text:basic<%>
Objects implementing this interface adjust their spacing based on the 'framework:line-spacing-add-gap? preference.

mixin

text:line-spacing-mixin : (class? . -> . class?)

  argument extends/implements: text:basic<%>
  result implements: text:line-spacing<%>
Calls set-line-spacing to either 0 or 1 when an object is created, based on the 'framework:line-spacing-add-gap? preference.
Also registers a callback (via preferences:add-callback) to call set-line-spacing when the 'framework:line-spacing-add-gap? preference changes.

method

(send a-text:ascii-art-enlarge-boxes set-ascii-art-enlarge e?)

  void?
  e? : any/c
Enables or disables the ascii art box enlarging mode based on e?’s true value.

method

(send a-text:ascii-art-enlarge-boxes get-ascii-art-enlarge)

  boolean?
Returns #t if ascii art box enlarging mode is enabled and #f otherwise.

mixin

text:ascii-art-enlarge-boxes-mixin : (class? . -> . class?)

  argument extends/implements: text%
  result implements: text:ascii-art-enlarge-boxes<%>

method

(send a-text:ascii-art-enlarge-boxes on-local-char event)

  void?
  event : (is-a?/c key-event%)
Overrides on-local-char in editor<%>.
When the get-key-code method of event returns either 'numpad-enter or #\return and get-ascii-art-enlarge returns #t, this method handles the return key by adding an additional line in the containing unicode ascii art box and moving the insertion point to the first character on the new line that is in the containing cell.

It does not call the super method (in that case).

method

(send a-text:ascii-art-enlarge-boxes on-default-char event)

  void?
  event : (is-a?/c key-event%)
Overrides on-default-char in text%.
When the get-key-code method of event returns either a character or symbol that corresponds to the insertion of a single character get-ascii-art-enlarge returns #t, this method first makes room in the box and then calls the super method. If the get-overwrite-mode returns #f, then it always opens up a column in the box. If get-overwrite-mode returns #t, then it opens up a column only when the character to be inserted would overwrite one of the walls.

interface

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).

method

(send a-text:first-line highlight-first-line on?)  void?

  on? : boolean?
This method is final, so it cannot be overridden.
Call this method to enable special treatment of the first line in the editor.

method

(send a-text:first-line first-line-currently-drawn-specially?)

  boolean?
This method is final, so it cannot be overridden.
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.

method

(send a-text:first-line get-first-line-height)  number?

This method is final, so it cannot be overridden.
Returns the height, in pixels, of the first line.

method

(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.

mixin

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.

method

(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.

method

(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.

method

(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)
Scrolls a little bit more, when a scroll would be requested that scrolls something so that it is line underneath the first line.

mixin

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.

method

(send a-text:foreground-color default-style-name)  string?

method

(send a-text:foreground-color get-fixed-style)

  (is-a?/c style<%>)
Returns the style named by editor:get-default-color-style-name.

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.

mixin

text:hide-caret/selection-mixin : (class? . -> . class?)

  argument extends/implements: text:basic<%>
  result implements: text:hide-caret/selection<%>

method

(send a-text:hide-caret/selection after-set-position)  void?

Calls hide-caret to hide the caret when there is only a caret and no selection.

interface

text:nbsp->space<%> : interface?

  implements: text%
Classes that implement this interface silently change non-breaking spaces, ie the character (integer->char 160), to regular spaces when inserted into the editor.

mixin

text:nbsp->space-mixin : (class? . -> . class?)

  argument extends/implements: text%
  result implements: text:nbsp->space<%>

method

(send a-text:nbsp->space on-insert start    
  end)  void?
  start : exact-nonnegative-integer?
  end : exact-nonnegative-integer?
Augments on-insert in text%.
Starts an edit-sequence by calling begin-edit-sequence.

method

(send a-text:nbsp->space after-insert start    
  len)  void?
  start : exact-nonnegative-integer?
  len : exact-nonnegative-integer?
Augments after-insert in text%.
Replaces all non-breaking space characters (integer->char 160) by #\space characters.

Ends the edit sequence (by calling end-edit-sequence) started in on-insert.

interface

text:column-guide<%> : interface?

  implements: text%
Classes that implement this interface show a vertical line at a specified column width (when the content in the text has any lines wider than that column width).
The column width is determined by the 'framework:column-guide-width preference; that preference is a list of length two where the first element is a boolean indicating if the line should be visible at all, and the second is the width where the line would be visible (if the first is #t).
The position of the line is determined by taking the width of the x character in the "Standard" style (or, if there is no "Standard" style, then the "Basic" style) and multiplying that by the preference value.

mixin

text:column-guide-mixin : (class? . -> . class?)

  argument extends/implements: text%
  result implements: text:column-guide<%>

method

(send a-text:column-guide on-paint before?    
  dc    
  left    
  top    
  right    
  bottom    
  dx    
  dy    
  draw-caret)  void?
  before? : any/
  dc : (is-a?/c dc<%>)
  left : real?
  top : real?
  right : real?
  bottom : real?
  dx : real?
  dy : real?
  draw-caret : 
(or/c 'no-caret 'show-inactive-caret 'show-caret
      (cons/c exact-nonnegative-integer?
              exact-nonnegative-integer?))
Extends on-paint in editor<%>.
Draws the column guide (if appropriate; see text:column-guide<%>).

method

(send a-text:column-guide on-change)  void?

Augments on-change in editor<%>.
Checks to see if any of the state that would cause the line to draw in a different place has changed (via calls to get-extent and get-padding; if so makes (up to) two calls to invalidate-bitmap-cache with rectangles that cover the old and new locations of the line.

interface

text:normalize-paste<%> : interface?

  implements: text:basic<%>

method

(send a-text:normalize-paste ask-normalize?)  boolean?

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.

method

(send a-text:normalize-paste string-normalize s)  string?

  s : string?
Normalizes s. Defaults to:
(regexp-replace*
 #rx"\u200B"
 (regexp-replace*
  #rx"−"
  (string-normalize-nfkc s)
  "-")
 "")

mixin

text:normalize-paste-mixin : (class? . -> . class?)

  argument extends/implements: text:basic<%>
  result implements: text:normalize-paste<%>

method

(send a-text:normalize-paste do-paste start    
  time)  void?
  start : exact-nonnegative-integer?
  time : exact-integer?
Overrides do-paste in text%.
Overridden to detect when insertions are due to pasting. Sets some internal state and calls the super.

method

(send a-text:normalize-paste on-insert start    
  len)  void?
  start : exact-nonnegative-integer?
  len : exact-nonnegative-integer?
Augments on-insert in text%.

method

(send a-text:normalize-paste after-insert start    
  len)  void?
  start : exact-nonnegative-integer?
  len : exact-nonnegative-integer?
Augments after-insert in text%.
Normalizes any next text and calls end-edit-sequence.

method

(send a-text:all-string-snips all-string-snips?)  boolean?

Returns #t if all of the snips in the text% object are string-snip%s.

This method usually returns quickly, tracking changes to the editor to update internal state. But if a non-string-snip% is deleted, then the next call to all-string-snips? traverses the entire content to search to see if there are other non-string-snip%s.

mixin

text:all-string-snips-mixin : (class? . -> . class?)

  argument extends/implements: text%
  result implements: text:all-string-snips<%>

method

(send a-text:all-string-snips on-insert start    
  len)  void?
  start : exact-nonnegative-integer?
  len : exact-nonnegative-integer?
Augments on-insert in text%.
Checks to see if there were any non-string-snip%s inserted in the given range and, if so, updates the internal state.

method

(send a-text:all-string-snips after-delete start    
  len)  void?
  start : exact-nonnegative-integer?
  len : exact-nonnegative-integer?
Augments after-delete in text%.
Checks to see if there were any non-string-snip%s deleted in the given range and, if so, updates the internal state.

Any object matching this interface can be searched.

method

(send a-text:searching set-searching-state str 
  cs? 
  replace-mode? 
  notify-frame?) 
  void?
  str : (or/c #f non-empty-string?)
  cs? : boolean?
  replace-mode? : boolean?
  notify-frame? : boolean?
If str is not #f, then this method initiates a search for every occurrence of str in the editor. If str is #f, then it clears all of the search highlighting in the buffer.

If cs? is #f, the search is case-insensitive, and otherwise it is case-sensitive.

The replace-mode? boolean determines if the resulting search should be tracking the next-to-replace search hit as the insertion point moves around in the editor. Also, when replace-mode? is #f, then the bubbles are are uniform medium purple color ("plum" in the-color-database) and otherwise they are either a lighter purple or a darker purple, with every bubble except the one just following the insertion the lighter color.

The search does not complete before set-searching-state returns. Accordingly, get-search-hit-count may have out-of-date results for a while, until the search process is finished. If notify-frame? is #t then search-hits-changed is called when the search completes.

method

(send a-text:searching set-search-anchor position)  void?

  position : (or/c #f number?)
Sets the anchor’s position in the editor. Only takes effect if the 'framework:anchored-search preference is on.

method

(send a-text:searching get-search-hit-count)  
number? number?
Returns the number of hits for the search in the buffer before the insertion point and the total number of hits. Both are based on the count found last time that a search completed.

A search initiated by some earlier change to the editor or to the string to search for may make the results of this method obsolete. To force those changes to complete (and thus get an accurate result from this method) call finish-pending-search-work.

method

(send a-text:searching get-replace-search-hit)

  (or/c number? #f)
Returns the position of the nearest search hit that comes after the insertion point.

A search initiated by some earlier change to the editor or to the string to search for may make the results of this method obsolete. To force those changes to complete (and thus get an accurate result from this method) call finish-pending-search-work.

method

(send a-text:searching set-replace-start pos)  void?

  pos : (or/c number? #f)
This method is ignored. (The next replacement start is now tracked via the after-set-position method.)

method

(send a-text:searching finish-pending-search-work)  void?

Finishes any pending work in computing and drawing the search bubbles.

Call this method to ensure that the results from any of get-search-hit-count, get-replace-search-hit, or get-search-bubbles are correct.

method

(send a-text:searching get-search-bubbles)

  
(listof (list/c (cons/c number? number?)
                (or/c 'normal-search-color
                      'dark-search-color
                      'light-search-color)))
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 symbol is the color of the bubble.

A search initiated by some earlier change to the editor or to the string to search for may make the results of this method obsolete. To force those changes to complete (and thus get an accurate result from this method) call finish-pending-search-work.

This method is intended for use in test suites.

mixin

text:searching-mixin : (class? . -> . class?)

  argument extends/implements: editor:keymap<%>
 text:basic<%>
  result implements: text:searching<%>
This text% can be searched.
The result of this mixin uses the same initialization arguments as the mixin’s argument.

method

(send a-text:searching get-keymaps)

  (listof (is-a?/c keymap%))
This returns a list containing the super-class’s keymaps, plus the result of keymap:get-search.

method

(send a-text:searching after-insert start    
  len)  void?
  start : exact-nonnegative-integer?
  len : exact-nonnegative-integer?
Augments after-insert in text%.
Re-does any search now that the contents of the window have changed.

method

(send a-text:searching after-delete start    
  len)  void?
  start : exact-nonnegative-integer?
  len : exact-nonnegative-integer?
Augments after-delete in text%.
Re-does any search now that the contents of the window have changed.

method

(send a-text:searching on-focus on?)  void?

  on? : boolean?
Overrides on-focus in editor<%>.
Tells the frame containing the editor to search based on this editor via the set-text-to-search method.

interface

text:return<%> : interface?

  implements: text%
Objects supporting this interface were created by text:return-mixin.

mixin

text:return-mixin : (class? . -> . class?)

  argument extends/implements: text%
  result implements: text:return<%>
Use this buffer to perform some special action when return is typed.

constructor

(new text:return-mixin [return return])

  (is-a?/c text:return-mixin)
  return : (-> boolean?)

method

(send a-text:return on-local-char event)  void?

  event : (is-a?/c key-event%)
Overrides on-local-char in editor<%>.
If key is either return or newline, only invoke the return thunk (initialization argument) and do nothing else.

interface

text:wide-snip<%> : interface?

  implements: text:basic<%>

method

(send a-text:wide-snip add-wide-snip snip)  void?

  snip : (is-a?/c snip%)
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<%>.

method

(send a-text:wide-snip add-tall-snip snip)  void?

  snip : (is-a?/c snip%)
Registers a snip in this editor. It is resized when the viewing area of the editor changes.

This method should only be called by add-tall-snip in canvas:wide-snip<%>.

mixin

text:wide-snip-mixin : (class? . -> . class?)

  argument extends/implements: text:basic<%>
  result implements: text:wide-snip<%>

interface

text:delegate<%> : interface?

  implements: text:basic<%>
Implementations of this interface copy all of the changes to this editor to the result of get-delegate except instead of regular string and tab snips, instead instances of text:1-pixel-string-snip% and text:1-pixel-tab-snip% are created.
The contents of the two editor are kept in sync, as modifications to this object happen.
This effect is similar to that achieved by text:inline-overview<%>, but this implementation has significant performance overheads that affect interactivity. Use text:inline-overview<%> instead.

method

(send a-text:delegate get-delegate)

  (or/c #f (is-a?/c text%))
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.

method

(send a-text:delegate set-delegate delegate)  void?

  delegate : (or/c #f (is-a?/c text%))
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 racket: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.
See also text:1-pixel-tab-snip% for a similar extension to the tab-snip% class.
This snip is used in conjunction with the frame:delegate<%> and text:delegate<%> interfaces.

method

(send a-text:1-pixel-string-snip split position    
  first    
  second)  void?
  position : exact-nonnegative-integer?
  first : (box/c (is-a?/c snip%))
  second : (box/c (is-a?/c snip%))
Overrides split in snip%.
Fills the boxes with instance of text:1-pixel-string-snip%s.

method

(send a-text:1-pixel-string-snip copy)  (is-a?/c snip%)

Overrides copy in snip%.
Creates and returns an instance of text:1-pixel-string-snip%.

method

(send a-text:1-pixel-string-snip get-extent dc    
  x    
  y    
  [w    
  h    
  descent    
  space    
  lspace    
  rspace])  void?
  dc : (is-a?/c dc<%>)
  x : real?
  y : real?
  w : (or/c (box/c (and/c real? (not/c negative?))) #f) = #f
  h : (or/c (box/c (and/c real? (not/c negative?))) #f) = #f
  descent : (or/c (box/c (and/c real? (not/c negative?))) #f)
   = #f
  space : (or/c (box/c (and/c real? (not/c negative?))) #f) = #f
  lspace : (or/c (box/c (and/c real? (not/c negative?))) #f)
   = #f
  rspace : (or/c (box/c (and/c real? (not/c negative?))) #f)
   = #f
Overrides get-extent in snip%.
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.

method

(send a-text:1-pixel-string-snip insert s    
  len    
  [pos])  void?
  s : string?
  len : exact-nonnegative-integer?
  pos : exact-nonnegative-integer? = 0
Overrides insert in string-snip%.

method

(send a-text:1-pixel-string-snip draw dc    
  x    
  y    
  left    
  top    
  right    
  bottom    
  dx    
  dy    
  draw-caret)  void?
  dc : (is-a?/c dc<%>)
  x : real?
  y : real?
  left : real?
  top : real?
  right : real?
  bottom : real?
  dx : real?
  dy : real?
  draw-caret : (or/c 'no-caret 'show-inactive-caret 'show-caret)
Overrides draw in snip%.
Draws black pixels for non-whitespace characters and draws nothing for whitespace characters.

class

text:1-pixel-tab-snip% : class?

  superclass: tab-snip%

This class re-uses the implementation of tab-snip% to implement a string snip that is always one pixel high.
See also text:1-pixel-string-snip% for a similar extension to the string-snip% class.
This snip is used in conjunction with the frame:delegate<%> and text:delegate<%> interfaces.

method

(send a-text:1-pixel-tab-snip split position    
  first    
  second)  void?
  position : exact-nonnegative-integer?
  first : (box/c (is-a?/c snip%))
  second : (box/c (is-a?/c snip%))
Overrides split in snip%.
Fills the boxes with instance of text:1-pixel-tab-snip%s.

method

(send a-text:1-pixel-tab-snip copy)  (is-a?/c snip%)

Overrides copy in snip%.
Creates and returns an instance of text:1-pixel-tab-snip%.

method

(send a-text:1-pixel-tab-snip get-extent dc    
  x    
  y    
  [w    
  h    
  descent    
  space    
  lspace    
  rspace])  void?
  dc : (is-a?/c dc<%>)
  x : real?
  y : real?
  w : (or/c (box/c (and/c real? (not/c negative?)) #f)) = #f
  h : (or/c (box/c (and/c real? (not/c negative?)) #f)) = #f
  descent : (or/c (box/c (and/c real? (not/c negative?)) #f))
   = #f
  space : (or/c (box/c (and/c real? (not/c negative?)) #f)) = #f
  lspace : (or/c (box/c (and/c real? (not/c negative?)) #f))
   = #f
  rspace : (or/c (box/c (and/c real? (not/c negative?)) #f))
   = #f
Overrides get-extent in snip%.
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.

method

(send a-text:1-pixel-tab-snip draw dc    
  x    
  y    
  left    
  top    
  right    
  bottom    
  dx    
  dy    
  draw-caret)  void?
  dc : (is-a?/c dc<%>)
  x : real?
  y : real?
  left : real?
  top : real?
  right : real?
  bottom : real?
  dx : real?
  dy : real?
  draw-caret : (or/c 'no-caret 'show-inactive-caret 'show-caret)
Overrides draw in snip%.
Draws nothing.

mixin

text:delegate-mixin : (class? . -> . class?)

  argument extends/implements: text:basic<%>
  result implements: text:delegate<%>
This mixin provides an implementation of the text:delegate<%> interface.
This effect is similar to that achieved by text:inline-overview-mixin, but this implementation has significant performance overheads that affect interactivity. Use text:inline-overview-mixin instead.

method

(send a-text:delegate highlight-range start    
  end    
  color    
  [caret-space    
  priority    
  style])  (-> void?)
  start : exact-integer?
  end : exact-nonnegative-integer?
  color : (or/c string? (is-a?/c color%))
  caret-space : boolean? = #f
  priority : (or/c 'high 'low) = 'low
  style : (or/c 'rectangle 'ellipse 'hollow-ellipse 'dot)
   = 'rectangle
In addition to calling the super method, highlight-range, this method forwards the highlighting to the delegatee.

method

(send a-text:delegate 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 : (or/c 'rectangle 'ellipse 'hollow-ellipse)
   = 'rectangle
This method propagates the call to the delegate and calls the super method.

method

(send a-text:delegate 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 a blue region in the delegatee editor that shows where the visible region of the delegate editor is.

method

(send a-text:delegate on-edit-sequence)  void?

starts an edit sequence in the delegate.

method

(send a-text:delegate after-edit-sequence)  void?

ends an edit sequence in the delegate.

method

(send a-text:delegate resized snip    
  redraw-now?)  void?
  snip : (is-a?/c snip%)
  redraw-now? : boolean?
Overrides resized in editor<%>.
Sends a message to the delegate to update the size of the copied snip, if there is one.

method

(send a-text:delegate after-insert start    
  len)  void?
  start : exact-nonnegative-integer?
  len : exact-nonnegative-integer?
Augments after-insert in text%.
forwards the change to the delegate

method

(send a-text:delegate after-delete start    
  len)  void?
  start : exact-nonnegative-integer?
  len : exact-nonnegative-integer?
Augments after-delete in text%.
forwards the change to the delegate.

method

(send a-text:delegate after-change-style start    
  len)  void?
  start : exact-nonnegative-integer?
  len : exact-nonnegative-integer?
forwards the changed style to the delegate.

method

(send a-text:delegate on-load-file filename    
  format)  void?
  filename : string?
  format : symbol?
Augments on-load-file in editor<%>.
remembers the filename, for use in after-load-file.

method

(send a-text:delegate after-load-file success?)  void?

  success? : boolean?
updates the delegate with the new contents of the text.

interface

text:info<%> : interface?

  implements: text:basic<%>
Objects supporting this interface are expected to send information about themselves to the frame that is displaying them.

mixin

text:info-mixin : (class? . -> . class?)

  argument extends/implements: editor:keymap<%>
 text:basic<%>
  result implements: text:info<%>
This mixin adds support for supplying information to objects created with frame:info-mixin. When this editor:basic<%> is displayed in a frame, that frame must have been created with frame:info-mixin.

method

(send a-text:info set-anchor on?)  void?

  on? : any/c
Overrides set-anchor in text%.
Calls the anchor-status-changed method of the frame that is viewing this object. It uses get-canvas to get the canvas for this frame, and uses that canvas’s top-level-window<%> as the frame.

method

(send a-text:info set-overwrite-mode on?)  void?

  on? : any/c
Calls the overwrite-status-changedmethod of the frame that is viewing this object. It uses get-canvas to get the canvas for this frame, and uses that canvas’s top-level-window<%> as the frame.

method

(send a-text:info after-set-position)  void?

Calls the editor-position-changed method of the frame that is viewing this object. It uses get-canvas to get the canvas for this frame, and uses that canvas’s top-level-window<%> as the frame.

method

(send a-text:info after-insert start len)  void?

  start : exact-nonnegative-integer?
  len : exact-nonnegative-integer?
Augments after-insert in text%.
Calls the editor-position-changed method of the frame that is viewing this object. It uses get-canvas to get the canvas for this frame, and uses that canvas’s top-level-window<%> as the frame.

method

(send a-text:info after-delete start len)  void?

  start : exact-nonnegative-integer?
  len : exact-nonnegative-integer?
Augments after-delete in text%.
Calls the editor-position-changed method of the frame that is viewing this object. It uses get-canvas to get the canvas for this frame, and uses that canvas’s top-level-window<%> as the frame.

interface

text:clever-file-format<%> : interface?

  implements: text%
Objects supporting this interface are expected to support a clever file format when saving.

mixin

text:clever-file-format-mixin : (class? . -> . class?)

  argument extends/implements: text%
  result implements: text:clever-file-format<%>
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.

method

(send a-text:clever-file-format on-save-file filename    
  format)  void?
  filename : path?
  format : 
(or/c 'guess 'standard 'text
      'text-force-cr 'same 'copy)
Augments on-save-file in editor<%>.
If the method get-file-format returns 'standard and the text has only string-snip%s, the file format is set to 'text.

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.

interface

text:crlf-line-endings<%> : interface?

  implements: text%
Objects supporting this interface use use-file-text-mode to change the line ending style under windows. See after-load-file for more information.

mixin

text:crlf-line-endings-mixin : (class? . -> . class?)

  argument extends/implements: text%
  result implements: text:crlf-line-endings<%>

method

(send a-text:crlf-line-endings after-load-file success?)

  void?
  success? : any/c
Checks to see if the newly loaded file has any lines terminated with "\n" (i.e., not "\r\n") or if the file is empty. If so, and if the system-type returns 'windows, then this method calls use-file-text-mode, passing #f.

Otherwise, calls use-file-text-mode with #t.

interface

text:file<%> : interface?

  implements: editor:file<%>
 text:basic<%>
Mixins that implement this interface lock themselves when the file they are editing is read only.

method

(send a-text:file get-read-write?)  boolean?

Indicates whether or not this editor is in read-write mode.

method

(send a-text:file while-unlocked thunk)  any/c

  thunk : (-> any/c)
Unlocks the editor, calls the thunk, and then relocks the editor, all using a dynamic-wind.

mixin

text:file-mixin : (class? . -> . class?)

  argument extends/implements: editor:file<%>
 text:basic<%>
  result implements: text:file<%>

method

(send a-text:file can-insert? start len)  boolean?

  start : exact-nonnegative-integer?
  len : exact-nonnegative-integer?
Augments can-insert? in text%.
Returns false if the result of get-read-write? is true, otherwise returns the result of calling inner.

method

(send a-text:file can-delete? start len)  boolean?

  start : exact-nonnegative-integer?
  len : exact-nonnegative-integer?
Augments can-delete? in text%.
Returns false if the result of get-read-write? is true, otherwise returns the result of calling inner.

method

(send a-text:file after-save-file)  void?

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

For each canvas returned from get-canvases it checks to see if the canvas%’s get-top-level-window matches the frame:editor<%> interface. If so, it calls set-label with the last part of the filename (ie, the name of the file, not the directory the file is in).

method

(send a-text:file after-load-file)  void?

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

For each canvas returned from get-canvases it checks to see if the canvas%’s get-top-level-window matches the frame:editor<%> interface. If so, it calls set-label with the last part of the filename (ie, the name of the file, not the directory the file is in).

Classes implementing this interface (via the associated mixin) support input and output ports that read from and to 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.
There are three output ports, designed to match stdout, stderr, and a special port for printing values. The only difference between them is the output is rendered in different colors when it comes in via the different ports.
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).

method

(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 via delete, so you don’t need this method).

method

(send a-text:ports insert/io str pos)  void?

  str : string?
  pos : exact-integer?
Inserts str at the position start without changing the behavior of the ports (otherwise, inserting the text would break internal invariants of the port).

The pos argument must be less than get-insertion-point (or else it is safe to insert the string via insert, so you don’t need this method).

Added in version 1.2 of package gui-lib.

method

(send a-text:ports do-submission)  void?

Triggers a submission to the input port with what is currently pending in the editor.

method

(send a-text:ports get-insertion-point)  exact-integer?

Returns the position where characters put into the output port will appear.

method

(send a-text:ports set-insertion-point ip)  void?

  ip : exact-integer?
Sets the position where the output port will insert characters. See also get-insertion-point.

method

(send a-text:ports get-unread-start-point)  exact-integer?

Returns the position where input will be taken into the input port (after the next time return is typed).

method

(send a-text:ports set-unread-start-point usp)  void?

  usp : exact-integer?
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.

method

(send a-text:ports set-allow-edits allow-edits?)  void?

  allow-edits? : boolean?
Enables or disables editing in the buffer. Be sure to update the unread start point (via set-unread-start-point) and the insertion point (via set-insertion-point) after making changes to the buffer.

method

(send a-text:ports get-allow-edits)  boolean?

Indicates if editing is allowed in the buffer at this point.

method

(send a-text:ports insert-between str)  void?

  str : (or/c (is-a?/c snip%) string?)
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.

method

(send a-text:ports insert-before str)  void?

  str : (or/c (is-a?/c snip%) string?)
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.

method

(send a-text:ports submit-to-port? key)  boolean?

  key : (is-a?/c key-event%)
Augment this method to help control when characters should be submitted to the input port.

Return #t or the result of calling inner.

method

(send a-text:ports on-submit)  void?

This method is called when text is sent into the input port.

Does nothing.

method

(send a-text:ports send-eof-to-in-port)  void?

This method puts an eof into the input port.

method

(send a-text:ports send-eof-to-box-in-port)  void?

This method puts an eof into the box input port.

method

(send a-text:ports reset-input-box)  void?

This method removes the current input box from the editor (and all input in it is lost).

method

(send a-text:ports clear-output-ports)  void?

Flushes all of the data in all of the output ports that hasn’t appeared in the editor yet.

method

(send a-text:ports clear-input-port)  void?

Flushes all of the data in the input port that hasn’t yet been read. Reading will now block.

method

(send a-text:ports clear-box-input-port)  void?

Flushes all of the data in the box input port that hasn’t yet been read. Reading will now block.

method

(send a-text:ports get-out-style-delta)

  (or/c (is-a?/c style-delta%) string?)
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.

By default, returns "text:ports out" which is mapped to a blue style in the style list returned by editor:get-standard-style-list.

method

(send a-text:ports get-err-style-delta)

  (or/c (is-a?/c style-delta%) string?)
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.

By default, returns "text:ports err" which is mapped to a red italic style in the style list returned by editor:get-standard-style-list.

method

(send a-text:ports get-value-style-delta)

  (or/c (is-a?/c style-delta%) string?)
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.

By default, returns "text:ports value" which is mapped to a blue style in the style list returned by editor:get-standard-style-list.

method

(send a-text:ports get-in-port)  input-port?

Returns the input port that data in this editor is sent to.

method

(send a-text:ports get-in-box-port)  input-port?

Returns the box input port that data in this editor is sent to.

method

(send a-text:ports get-out-port)  output-port?

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.

method

(send a-text:ports get-err-port)  output-port?

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.

method

(send a-text:ports get-value-port)  output-port?

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.

method

(send a-text:ports after-io-insertion)  void?

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.

The default result is a subclass of editor-snip% that calls use-style-background with #t during initialization.

method

(send a-text:ports get-box-input-text%)

  (is-a?/c text:input-box<%>)
The result of this method is instantiated and placed inside the result of get-box-input-editor-snip%.

mixin

text:ports-mixin : (class? . -> . class?)

  argument extends/implements: text:wide-snip<%>
  result implements: text:ports<%>
The ports from this mixin accepts as special values (see port-writes-special?) markup from the simple-tree-text-markup/data module, and renders them with graphical boxes and clickable srcloc links.

method

(send a-text:ports can-insert? start len)  boolean?

  start : exact-integer?
  len : exact-integer?
Augments can-insert? in text%.
Returns the results of the inner call, unless get-allow-edits returns #f.

method

(send a-text:ports can-delete? start len)  boolean?

  start : exact-integer?
  len : exact-integer?
Augments can-delete? in text%.
Returns the results of the inner call, unless get-allow-edits returns #f.

method

(send a-text:ports on-local-char event)  void?

  event : (is-a?/c key-event%)
Overrides on-local-char in editor<%>.
Sends the data between the last position and the result of get-unread-start-point to the input port, unless submit-to-port? returns #f.

Also calls on-submit.

method

(send a-text:ports on-display-size)  void?

Adjusts the embedded editor-snip (used for reading input to the get-in-box-port) to match the width of the editor.

interface

text:input-box<%> : interface?

  implements: text%
Classes that implement this interface are used as the editors for the box input port in text:ports%.

mixin

text:input-box-mixin : (class? . -> . class?)

  argument extends/implements: text%
  result implements: text:input-box<%>
This mixin provides an implementation of text:input-box<%> for use with text:ports<%>.

method

(send a-text:input-box on-default-char event)  void?

  event : (is-a?/c key-event%)
Overrides on-default-char in text%.
Notifies the text:ports<%> enclosing this editor that a new line of input has been provided.

method

(send a-text:input-box default-style-name)  string?

interface

text:autocomplete<%> : interface?

  implements: text%
The mixin implementing this interface provides an unintrusive autocompletion menu when a particular (configurable) keystroke is pressed.

method

(send a-text:autocomplete auto-complete)  void?

Starts a completion.

method

(send a-text:autocomplete get-autocomplete-border-color)

  (or/c string? (is-a?/c color%))
The border color for the autocomplete menu. Defaults to "black".

method

(send a-text:autocomplete get-autocomplete-background-color)

  (or/c string? (is-a?/c color%))
The background color for the non-selected menu items. Defaults to "lavender".

method

(send a-text:autocomplete get-autocomplete-selected-color)

  (or/c string? (is-a?/c color%))
The background color for the selected menu item. Defaults to (make-object color% 204 153 255).

method

(send a-text:autocomplete completion-mode-key-event? key-event)

  boolean?
  key-event : (is-a?/c key-event%)
Returns true when the key event passed to it should initiate the completions menu.

method

(send a-text:autocomplete get-all-words)  (listof string?)

Returns the list of the words that autocompletion should choose from.

method

(send a-text:autocomplete get-word-at pos)  string?

  pos : exact-positive-integer?
Given an editor location, returns the prefix ending at that location that autocompletion should try to complete.

mixin

text:autocomplete-mixin : (class? . -> . class?)

  argument extends/implements: text%
  result implements: text:autocomplete<%>

method

(send a-text:autocomplete on-paint)  void?

Overrides on-paint in editor<%>.
Draws the completion menu (when it is popped up).

method

(send a-text:autocomplete on-char)  void?

Overrides on-char in editor<%>.
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.

method

(send a-text:autocomplete on-event)  void?

Overrides on-event in editor<%>.
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.

Classes implementing this interface disable overwrite mode when the overwrite mode keybindings are turned off.

mixin

text:overwrite-disable-mixin : (class? . -> . class?)

  argument extends/implements: text%
  result implements: text:set-overwrite-mode<%>
This mixin adds a callback for 'framework:overwrite-mode-keybindings via preferences:add-callback that calls set-overwrite-mode with #f when the preference is set to #f.

method

(send a-text:line-numbers show-line-numbers! show)  void?

  show : boolean?
Enables or disables line number drawing.

method

(send a-text:line-numbers show-line-numbers?)  boolean?

Returns whether or not line drawing is enabled.

method

(send a-text:line-numbers set-line-numbers-color color)  void?

  color : string?
Sets the color of the line numbers.

mixin

text:line-numbers-mixin : (class? . -> . class?)

  argument extends/implements: text%
 editor:standard-style-list<%>
  result implements: text:line-numbers<%>

method

(send a-text:line-numbers on-paint)  void?

Overrides on-paint in editor<%>.
Draws the line numbers.

method

(send a-text:line-numbers show-line-numbers! show)  void?

  show : boolean?
Enables or disables line number drawing.

method

(send a-text:line-numbers show-line-numbers?)  boolean?

Returns whether or not line drawing is enabled.

method

(send a-text:line-numbers set-line-numbers-color color)  void?

  color : string?
Sets the color of the line numbers.

procedure

(text:range? arg)  boolean?

  arg : any/c
Determines if arg is an instance of the range struct.

procedure

(text:range-start range)  exact-nonnegative-integer?

  range : text:range?
Returns the start position of the range.

procedure

(text:range-end range)  exact-nonnegative-integer?

  range : text:range?
Returns the end position of the range.

procedure

(text:range-caret-space? range)  boolean?

  range : text:range?
Returns a boolean indicating where the caret-space in the range goes. See also highlight-range.

procedure

(text:range-style range)

  (or/c 'rectangle 'hollow-ellipse 'ellipse 'dot)
  range : text:range?
Returns the style of the range. See also highlight-range.

procedure

(text:range-color range)  (or/c string? (is-a?/c color%))

  range : text: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.

procedure

(text:get-completions/manuals manuals)  (listof string?)

  manuals : (or/c false/c (listof symbol?))
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.

procedure

(text:lookup-port-name manuals)

  (or/c (is-a?/c editor:basic<%>) false/c)
  manuals : symbol?
Returns the editor instance whose port-name matches the given symbol. If no editor can be found, then returns false.

procedure

(text:make-snip-special snip)  text:snip-special?

  snip : (is-a?/c snip%)
Returns a snip-special to be used as a special with the ports in text:ports<%>.

When a snip is sent as a special, if it has a snip-class% from a different eventspace, it may not work properly in the text% object connected to the ports in a text:port<%> object. This function, when it is called, constructs the bytes corresponding to the result of using the snip’s write method and saves them in its result. Then, when the result is used as a special, the snip will rebuild from the bytes, but now using the snip-class% from the eventspace where the text:ports<%> operates.

procedure

(text:snip-special? v)  boolean?

  v : any/c
Recognizes the result of text:make-snip-special.

procedure

(text:send-snip-to-port snip port)  void?

  snip : (is-a?/c snip%)
  port : output-port?
Sends snip to port by using text:make-snip-special, handling a few special cases for performance and backwards compatibility reasons.