{ $notes "The range is created by calling " { $link <slice> } "." }
{ $errors "Throws an error if " { $snippet "from" } " or " { $snippet "to" } " is out of bounds." } ;
-HELP: each-line
+HELP: each-doc-line
{ $values { "from" "a non-negative integer" } { "to" "a non-negative integer" } { "quot" { $quotation ( ... line -- ... ) } } }
{ $description "Applies the quotation to each line in the range." }
{ $notes "The range is created by calling " { $link <slice> } "." }
remove-doc-range
}
"A combinator:"
-{ $subsections each-line }
+{ $subsections
+ each-doc-line
+ map-doc-lines
+}
"More info:"
{ $subsections
"document-locs"
to first line# =
[ to second ] [ line# document doc-line length ] if ;
-: each-line ( ... from to quot: ( ... line -- ... ) -- ... )
+: each-doc-line ( ... from to quot: ( ... line -- ... ) -- ... )
2over = [ 3drop ] [
[ [ first ] bi@ [a..b] ] dip each
] if ; inline
-: map-lines ( ... from to quot: ( ... line -- ... result ) -- ... results )
- collector [ each-line ] dip ; inline
+: map-doc-lines ( ... from to quot: ( ... line -- ... result ) -- ... results )
+ collector [ each-doc-line ] dip ; inline
: start/end-on-line ( from to line# document -- n1 n2 )
[ start-on-line ] [ end-on-line ] bi-curry bi-curry bi* ;
PRIVATE>
:: doc-range ( from to document -- string )
- from to [ [ from to ] dip document (doc-range) ] map-lines
+ from to [ [ from to ] dip document (doc-range) ] map-doc-lines
join-lines ;
: add-undo ( edit document -- )