diff --git a/core/prettyprint/backend/backend.factor b/core/prettyprint/backend/backend.factor index 1a376ef0e1..363071ccbd 100644 --- a/core/prettyprint/backend/backend.factor +++ b/core/prettyprint/backend/backend.factor @@ -44,10 +44,10 @@ M: word pprint* dup parsing? [ \ POSTPONE: [ pprint-word ] pprint-prefix ] [ - dup "break-before" word-prop break + dup "break-before" word-prop line-break dup pprint-word dup ?start-group dup ?end-group - "break-after" word-prop break + "break-after" word-prop line-break ] if ; M: real pprint* number>string text ; diff --git a/core/prettyprint/prettyprint-docs.factor b/core/prettyprint/prettyprint-docs.factor index 8467391d6d..2b01df8faa 100644 --- a/core/prettyprint/prettyprint-docs.factor +++ b/core/prettyprint/prettyprint-docs.factor @@ -72,7 +72,7 @@ $nl "Once the output sections have been generated, the tree of sections is traversed and intelligent decisions are made about indentation and line breaks. Finally, text is output." { $subsection section } "Adding leaf sections:" -{ $subsection break } +{ $subsection line-break } { $subsection text } { $subsection styled-text } "Nesting and denesting sections:" diff --git a/core/prettyprint/prettyprint.factor b/core/prettyprint/prettyprint.factor index 011a8cc851..ce54bc6b9b 100644 --- a/core/prettyprint/prettyprint.factor +++ b/core/prettyprint/prettyprint.factor @@ -227,7 +227,7 @@ M: mixin-class see-class* \ MIXIN: pprint-word dup pprint-word ; diff --git a/core/prettyprint/sections/sections-docs.factor b/core/prettyprint/sections/sections-docs.factor index d55ec36bbd..ad47dc0664 100644 --- a/core/prettyprint/sections/sections-docs.factor +++ b/core/prettyprint/sections/sections-docs.factor @@ -30,10 +30,10 @@ HELP: fresh-line { $description "Advances the prettyprinter by one line unless the current line is empty. If the line limit is exceeded, escapes the prettyprinter by restoring a continuation captured in " { $link do-pprint } "." } ; HELP: soft -{ $description "Possible input parameter to " { $link break } "." } ; +{ $description "Possible input parameter to " { $link line-break } "." } ; HELP: hard -{ $description "Possible input parameter to " { $link break } "." } ; +{ $description "Possible input parameter to " { $link line-break } "." } ; { soft hard } related-words @@ -70,7 +70,7 @@ HELP: section { $class-description "A piece of prettyprinter output. Instances of this class are not used directly, instead one instantiates various classes which delegate to this class:" { $list { $link text } - { $link break } + { $link line-break } { $link block } { $link inset } { $link flow } @@ -123,7 +123,7 @@ HELP: pprint-section { $contract "Prints a section, performing wrapping and indentation using available formatting information." } $prettyprinting-note ; -HELP: break +HELP: line-break { $values { "type" { $link soft } " or " { $link hard } } } { $description "Adds a section introducing a line break to the current block. If the block is output as a " { $link short-section } ", all breaks are ignored. Otherwise, hard breaks introduce unconditional newlines, and soft breaks introduce a newline if the position is more than half of the " { $link margin } "." } $prettyprinting-note ; @@ -158,11 +158,11 @@ HELP: save-end-position HELP: pprint-sections { $values { "block" block } { "advancer" "a quotation with stack effect " { $snippet "( block -- )" } } } -{ $description "Prints child sections of a block, ignoring any " { $link break } " sections. The " { $snippet "advancer" } " quotation is called between every pair of sections." } ; +{ $description "Prints child sections of a block, ignoring any " { $link line-break } " sections. The " { $snippet "advancer" } " quotation is called between every pair of sections." } ; HELP: do-break -{ $values { "break" break } } -{ $description "Prints a break section as per the policy outlined in " { $link break } "." } ; +{ $values { "break" line-break } } +{ $description "Prints a break section as per the policy outlined in " { $link line-break } "." } ; HELP: empty-block? { $values { "block" block } { "?" "a boolean" } } diff --git a/core/prettyprint/sections/sections.factor b/core/prettyprint/sections/sections.factor index ff8e8b297d..063dcb7fd4 100644 --- a/core/prettyprint/sections/sections.factor +++ b/core/prettyprint/sections/sections.factor @@ -124,15 +124,16 @@ M: object short-section? section-fits? ; ] if ; ! Break section -TUPLE: break type ; +TUPLE: line-break type ; -: ( type -- section ) +: ( type -- section ) H{ } 0
- { set-break-type set-delegate } \ break construct ; + { set-line-break-type set-delegate } + \ line-break construct ; -M: break short-section drop ; +M: line-break short-section drop ; -M: break long-section drop ; +M: line-break long-section drop ; ! Block sections TUPLE: block sections ; @@ -149,7 +150,8 @@ TUPLE: block sections ; pprinter-block block-sections push ; : last-section ( -- section ) - pprinter-block block-sections [ break? not ] find-last nip ; + pprinter-block block-sections + [ line-break? not ] find-last nip ; : start-group ( -- ) t last-section set-section-start-group? ; @@ -162,13 +164,13 @@ TUPLE: block sections ; swap short-section? and [ bl ] when ; -: break ( type -- ) [ add-section ] when* ; +: line-break ( type -- ) [ add-section ] when* ; M: block section-fits? ( section -- ? ) line-limit? [ drop t ] [ delegate section-fits? ] if ; : pprint-sections ( block advancer -- ) - swap block-sections [ break? not ] subset + swap block-sections [ line-break? not ] subset unclip pprint-section [ dup rot call pprint-section ] curry* each ; inline @@ -177,7 +179,7 @@ M: block short-section ( block -- ) [ advance ] pprint-sections ; : do-break ( break -- ) - dup break-type hard eq? + dup line-break-type hard eq? over section-end last-newline get - margin get 2/ > or [