set-doc-range ( string from to document -- )
Factor handbook » UI framework » Building user interfaces » Pre-made UI gadgets » Editor gadgets » Documents

Prev:doc-range ( from to document -- string )
Next:remove-doc-range ( from to document -- )


Vocabulary
documents

Inputs
stringa string
froma pair of integers
toa pair of integers
documenta document


Outputs
None

Word description
Replaces all text between two line/column number pairs with string. The string may use either \n, \r\n or \r line separators.

Errors
Throws an error if from or to is out of bounds.

Side effects
Modifies document

Definition


:: set-doc-range ( string from to document -- )
from to = string empty? and [
string ?split-lines :> new-lines new-lines from text+loc
:> new-to from to document doc-range
:> old-string old-string string from to new-to <edit>
document add-undo new-lines from to document
[ (set-doc-range) ] change-model
new-to document update-locs
] unless ;