]> gitweb.factorcode.org Git - factor.git/commitdiff
documents: split-lines is used by ui.gadgets.panes.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 7 Feb 2017 00:06:00 +0000 (16:06 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 7 Feb 2017 00:06:00 +0000 (16:06 -0800)
basis/documents/documents.factor

index b12e93f2519e2a52f563807cd5e7e057d59b1fec..1de79f44742a2977ab4c798aeb00b535ce2893f2 100644 (file)
@@ -110,6 +110,11 @@ CONSTANT: doc-start { 0 0 }
 : with-undo ( ..a document quot: ( ..a document -- ..b ) -- ..b )
     [ t >>inside-undo? ] dip keep f >>inside-undo? drop ; inline
 
+: split-lines ( str -- seq )
+    [ string-lines ] keep ?last
+    [ "\r\n" member? ] [ t ] if*
+    [ "" suffix ] when ;
+
 PRIVATE>
 
 :: doc-range ( from to document -- string )
@@ -124,9 +129,7 @@ PRIVATE>
 
 :: set-doc-range ( string from to document -- )
     from to = string empty? and [
-        string string-lines
-        string ?last [ "\r\n" member? ] [ t ] if*
-        [ "" suffix ] when :> new-lines
+        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