method
(send a-snip adjust-cursor dc x y editorx editory event) → (or/c (is-a?/c cursor%) #f) dc : (is-a?/c dc<%>) x : real? y : real? editorx : real? editory : real? event : (is-a?/c mouse-event%)
Default implementation: Returns #f.
The drawing context and snip’s locations in drawing context coordinates are provided.
method
(send a-snip can-do-edit-operation? op [ recursive?]) → boolean?
op :
(or/c 'undo 'redo 'clear 'cut 'copy 'paste 'kill 'select-all 'insert-text-box 'insert-pasteboard-box 'insert-image) recursive? : any/c = #t
Called when the snip’s editor’s method is called, recursive? is not #f, and this snip owns the caret.
method
(send a-snip do-edit-operation op [ recursive? time]) → void?
op :
(or/c 'undo 'redo 'clear 'cut 'copy 'paste 'kill 'select-all 'insert-text-box 'insert-pasteboard-box 'insert-image) recursive? : any/c = #t time : exact-integer? = 0
Called when the snip’s editor’s method is called, recursive? is not #f, and this snip owns the caret.
method
(send a-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 (cons/c exact-nonnegative-integer? exact-nonnegative-integer?))
The arguments left, top, right, and bottom define a clipping region (in DC coordinates) that the snip can use to optimize drawing, but it can also ignore these arguments.
The dx and dy argument provide numbers that can be subtracted from x and y to obtain the snip’s location in editor coordinates (as opposed to DC coordinates, which are used for drawing).
See Caret Ownership for information about draw-caret. When draw-caret is a pair, refrain from drawing a background for the selected region, and if (get-highlight-text-color) returns a color (instead of #f), use that color for drawing selected text and other selected foreground elements.
Before this method is called, the font, text color, and pen color for the snip’s style will have been set in the drawing context. (The drawing context is not so configured for get-extent or partial-offset.) The draw method must not make any other assumptions about the state of the drawing context, except that the clipping region is already set to something appropriate. Before draw returns, it must restore any drawing context settings that it changes.
See also on-paint in editor<%>.
The snip’s editor is usually internally locked for writing and reflowing when this method is called (see also Internal Editor Locks), and it is normally in a refresh (see Editors and Threads).
Default implementation: Draws nothing.
Default implementation: Calls the other-equal-to? method of snip (to simulate multi-method dispatch) in case snip provides a more specific equivalence comparison.
method
(send a-snip other-equal-to? that equal?) → boolean?
that : (is-a?/c snip%) equal? : (-> any/c any/c boolean?)
method
(send a-snip equal-hash-code-of hash-code) → exact-integer?
hash-code : (any/c . -> . exact-integer?)
Default implementation: Returns (eq-hash-code a-snip).
method
(send a-snip equal-secondary-hash-code-of hash-code)
→ exact-integer? hash-code : (any/c . -> . exact-integer?)
Default implementation: Returns 1.
method
(send a-snip find-scroll-step y) → exact-nonnegative-integer?
y : real?
Default implementation: Returns 0.
method
(send a-snip get-admin) → (or/c (is-a?/c snip-admin%) #f)
method
(send a-snip get-count) → exact-nonnegative-integer?
method
(send a-snip get-grapheme-count) → exact-nonnegative-integer?
Added in version 1.4 of package snip-lib.
method
(send a-snip grapheme-position n) → exact-nonnegative-integer?
n : exact-nonnegative-integer?
When get-count is the same as get-grapheme-count, this method returns n.
Added in version 1.4 of package snip-lib.
method
(send a-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
This method is called by the snip’s administrator; it is not normally called directly by others. To get the extent of a snip, use get-snip-location in editor<%> .
A drawing context is provided for the purpose of finding font sizes, but no drawing should occur. The get-extent and partial-offset methods must not make any assumptions about the state of the drawing context, except that it is scaled properly. In particular, the font for the snip’s style is not automatically set in the drawing context before the method is called. (Many snips cache their size information, so automatically setting the font would be wasteful.) If get-extent or partial-offset changes the drawing context’s setting, it must restore them before returning. However, the methods should not need to change the drawing context; only font settings can affect measurement results from a device context, and get-text-extent in dc<%> accepts a font% argument for sizing that overrides that device context’s current font.
The snip’s left and top locations are provided as x and y in editor coordinates, in case the snip’s size depends on its location; the x and y arguments are usually ignored. In a text editor, the y-coordinate is the line’s top location; the snip’s actual top location is potentially undetermined until its height is known.
If a snip caches the result size for future replies, it should invalidate its cached size when size-cache-invalid is called (especially if the snip’s size depends on any device context properties).
If a snip’s size changes after receiving a call to get-extent and before receiving a call to size-cache-invalid, then the snip must notify its administrator of the size change, so that the administrator can recompute its derived size information. Notify the administrator of a size change by call its resized method.
The snip’s editor is usually internally locked for writing and reflowing when this method is called (see also Internal Editor Locks).
Default implementation: Fills in all boxes with 0.0.
'is-text —
this is a text snip derived from string-snip%; do not set this flag 'can-append —
this snip can be merged with another snip of the same type 'invisible —
an invisible snip that the user doesn’t see, such as a newline 'newline —
a newline currently follows the snip; only an owning editor should set this flag 'handles-events —
this snip can handle keyboard and mouse events when it has the keyboard focus 'handles-all-mouse-events —
this snip can handle mouse events that touch the snip or that immediately follow an event that touches the snip, even if the snip does not have the keyboard focus (see also on-goodbye-event) 'handles-between-events —
this snip handles mouse events that are between items in the snip (instead of defaulting to treating mouse clicks as setting the position or other event handling that happens at the text% or pasteboard% level) 'width-depends-on-x —
this snip’s display width depends on the snip’s x-location within the editor; e.g.: tab 'height-depends-on-y —
this snip’s display height depends on the snip’s y-location within the editor 'width-depends-on-y —
this snip’s display width depends on the snip’s y-location within the editor 'height-depends-on-x —
this snip’s display height depends on the snip’s x-location within the editor 'uses-editor-path —
this snip uses its editor’s pathname and should be notified when the name changes; notification is given as a redundant call to set-admin
method
(send a-snip get-num-scroll-steps)
→ exact-nonnegative-integer?
Default implementation: Returns 1.
method
(send a-snip get-scroll-step-offset offset)
→ (and/c real? (not/c negative?)) offset : exact-nonnegative-integer?
Default implementation: Returns 0.0.
method
(send a-snip get-snipclass) → (or/c #f (is-a?/c snip-class%))
Since this method returns the snip class stored by set-snipclass, it is not meant to be overridden.
method
offset : exact-nonnegative-integer? num : exact-nonnegative-integer? flattened? : any/c = #f
If flattened? is not #f, then flattened text is returned. See Flattened Text for a discussion of flattened vs. non-flattened text.
Default implementation: Returns "".
method
(send a-snip get-text! buffer offset num buffer-offset) → void? buffer : (and/c string? (not/c immutable?)) offset : exact-nonnegative-integer? num : exact-nonnegative-integer? buffer-offset : exact-nonnegative-integer?
The buffer string is filled starting at position buffer-offset. The buffer string must be at least num+buffer-offset characters long.
Default implementation: Calls get-text, except in the case of a string-snip%, in which case buffer is filled directly.
Default implementation: Returns #t if the snip and a-snip are from the same class and have the same length.
If the returned snip does not have the expected count, its count is forcibly modified. If the returned snip is already owned by another administrator, a surrogate snip is created.
The snip’s editor is usually internally locked for reading when this method is called (see also Internal Editor Locks).
Default implementation: Returns #f.
In a text editor, the next snip is the snip at the position following this snip’s (last) position. In a pasteboard, the next snip is the one immediately behind this snip. (See Editor Structure and Terminology for information about snip order in pasteboards.)
method
(send a-snip on-char dc x y editorx editory event) → void? dc : (is-a?/c dc<%>) x : real? y : real? editorx : real? editory : real? event : (is-a?/c key-event%)
The x and y arguments are the snip’s location in display coordinates. The editorx and editory arguments are the snip’s location in editor coordinates. To get event’s x location in snip coordinates, subtract x from (send event get-x).
See also 'handles-events in get-flags.
Default implementation: Does nothing.
method
(send a-snip on-event dc x y editorx editory event) → void? dc : (is-a?/c dc<%>) x : real? y : real? editorx : real? editory : real? event : (is-a?/c mouse-event%)
The x and y arguments are the snip’s location in display coordinates. The editorx and editory arguments are the snip’s location in editor coordinates. To get event’s x location in snip coordinates, subtract x from (send event get-x).
See also 'handles-events in get-flags.
Default implementation: Does nothing.
method
(send a-snip on-goodbye-event dc x y editorx editory event) → void? dc : (is-a?/c dc<%>) x : real? y : real? editorx : real? editory : real? event : (is-a?/c mouse-event%)
This method is called only when the snip has the 'handles-all-mouse-events flag set (see get-flags and set-flags).
Default implementation: Calls this object’s on-event method
Added in version 1.1 of package snip-lib.
The own-it? argument is #t if the snip owns the keyboard focus or #f otherwise.
Default implementation: Does nothing.
method
(send a-snip position-grapheme n) → exact-nonnegative-integer?
n : exact-nonnegative-integer?
When get-count is the same as get-grapheme-count, this method returns n.
Added in version 1.4 of package snip-lib.
method
(send a-snip partial-offset dc x y len) → real?
dc : (is-a?/c dc<%>) x : real? y : real? len : exact-nonnegative-integer?
The snip’s editor is usually internally locked for writing and reflowing when this method is called (see also Internal Editor Locks).
Default implementation: Returns 0.0.
method
(send a-snip release-from-owner) → boolean?
Use this method for moving a snip from one editor to another. This method notifies the snip’s owning editor that someone else really wants control of the snip. It is not necessary to use this method for "cleaning up" a snip when it is deleted from an editor.
Default implementation: Requests a low-level release from the snip’s owning administrator.
See also on-interactive-resize in pasteboard%.
Default implementation: Returns #f.
The default method sets the internal state of a snip to record its administrator. It will not modify this state if the snip is already owned by an administrator and the administrator has not blessed the transition. If the administrator state of a snip is not modified as expected during a sensitive call to this method by an instance of text% or pasteboard%, the internal state may be forcibly modified (if the new administrator was #f) or a surrogate snip may be created (if the snip was expected to receive a new administrator).
The snip’s (new) editor is usually internally locked for reading when this method is called (see also Internal Editor Locks).
method
c : (integer-in 1 100000)
The snip’s count may be changed by the system (in extreme cases to maintain consistency) without calling this method or set-char-and-grapheme-count.
Default implementation: Sets the snip’s count and notifies the snip’s administrator that the snip’s size has changed.
method
(send a-snip set-char-and-grapheme-count char-c grapheme-c) → void? char-c : exact-nonnegative-integer? grapheme-c : exact-nonnegative-integer?
The snip’s count may be changed by the system (in extreme cases to maintain consistency) without calling this method or set-count.
Default implementation: Sets the snip’s count and notifies the snip’s administrator that the snip’s size has changed.
Added in version 1.4 of package snip-lib.
Default implementation: Sets the snip flags and notifies the snip’s editor that its flags have changed.
method
(send a-snip set-snipclass class) → void?
class : (is-a?/c snip-class%)
This method stores the snip class internally; other editor objects may access the snip class directly, instead of through the get-snipclass method.
The snip’s style may be changed by the system without calling this method.
method
(send a-snip set-unmodified) → void?
Default implementation: Does nothing.
method
(send a-snip size-cache-invalid) → void?
The snip’s (new) editor is usually internally locked for reflowing when this method is called (see also Internal Editor Locks).
Default implementation: Does nothing.
method
position : exact-nonnegative-integer? first : (box/c (is-a?/c snip%)) second : (box/c (is-a?/c snip%))
The arguments are a relative position integer and two boxes. The position integer specifies how many items should be given to the new first snip; the rest go to the new second snip. The two boxes must be filled with two new snips. (The old snip is no longer used, so it can be recycled as a new snip.)
If the returned snips do not have the expected counts, their counts are forcibly modified. If either returned snip is already owned by another administrator, a surrogate snip is created.
The snip’s editor is usually internally locked for reading when this method is called (see also Internal Editor Locks).
Default implementation: Creates a new snip% instance with position elements, and modifies a-snip to decrement its count by position. The nest snip is installed into first and a-snip is installed into second.
method
f : (is-a?/c editor-stream-out%)