]> gitweb.factorcode.org Git - factor.git/commitdiff
easy-help: use $nl instead of \n.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 14 Dec 2020 22:53:10 +0000 (14:53 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 14 Dec 2020 22:53:10 +0000 (14:53 -0800)
extra/easy-help/easy-help.factor

index 40fa54208473eeea5c3e393c775bcdce9750e8d8..76c4194dd681961c900679c06969d034ca3b2790 100644 (file)
@@ -10,28 +10,27 @@ IN: easy-help
 :: parse-help-token ( end -- str/obj/f )
     ?scan-token dup search {
         { [ dup end eq? ] [ 2drop f ] }
-        { [ dup parsing-word? ] [
-            nip V{ } clone swap execute-parsing first
-            dup wrapper? [ wrapped>> \ $link swap 2array ] when ] }
+        { [ dup parsing-word? ] [ nip V{ } clone swap execute-parsing first ] }
         [ drop ]
     } cond ;
 
+: push-help-text ( accum sbuf obj -- accum sbuf' )
+    [ dup empty? [ >string suffix! SBUF" " clone ] unless ]
+    [ [ suffix! ] curry dip ] bi* ;
+
+: push-help-space ( accum sbuf -- accum sbuf )
+    2dup [ empty? ] both? [ CHAR: \s suffix! ] unless ;
+
 :: parse-help-text ( end -- seq )
     V{ } clone SBUF" " clone [
-        lexer get line>> end parse-help-token
-        [ lexer get line>> swap - 1 > [ CHAR: \n suffix! ] when ] dip
-        [
+        lexer get line>> end parse-help-token [
+            lexer get line>> swap - 1 > [
+                \ $nl push-help-text
+            ] when
+        ] dip [
             [
-                [
-                    2dup [ empty? ] both? not
-                    over ?last CHAR: \n eq? not and
-                    [ CHAR: \s suffix! ] when
-                ] [
-                    dup string? [ append! ] [
-                        [ dup empty? [ >string suffix! SBUF" " clone ] unless ]
-                        [ [ suffix! ] curry dip ] bi*
-                    ] if
-                ] bi*
+                [ push-help-space ] dip
+                dup string? [ append! ] [ push-help-text ] if
             ] when*
         ] keep
     ] loop [ >string suffix! ] unless-empty >array ; inline