]> gitweb.factorcode.org Git - factor.git/commitdiff
prettyprint.sections: add default long-section implementation
authorAlexander Ilin <alex.ilin@protonmail.com>
Sun, 13 Aug 2023 19:21:54 +0000 (21:21 +0200)
committerAlexander Ilin <alex.ilin@protonmail.com>
Sun, 13 Aug 2023 23:33:45 +0000 (01:33 +0200)
Make all section descendants call short-section in the default
implementation of the long-section. This removes some redundant
definitions.

basis/prettyprint/sections/sections-docs.factor
basis/prettyprint/sections/sections.factor
extra/images/viewer/prettyprint/prettyprint.factor

index f6b51216e09ed87c9b7204d6be91245cad477a92..7a78cf93374f93a17d46e35d693e92472c04feba 100644 (file)
@@ -37,7 +37,7 @@ HELP: short-section
 
 HELP: long-section
 { $values { "section" section } }
-{ $contract "Prints a section which spans multiple lines. This should use a layout strategy maximizing readability and minimizing line length." } ;
+{ $contract "Prints a section which spans multiple lines. This should use a layout strategy maximizing readability and minimizing line length. Default implementation calls " { $link short-section } "." } ;
 
 HELP: indent-section?
 { $values { "section" section } { "?" boolean } }
index d86ffe67fc425787cbb5ff1eb800e11816dc8547..694d6fc2c413c352e09399f3c310aabb1c979d31 100644 (file)
@@ -110,6 +110,8 @@ M: section unindent-first-line? drop f ;
 
 M: section newline-after? drop f ;
 
+M: section long-section short-section ;
+
 M: object short-section? section-fits? ;
 
 : indent+ ( section n -- )
@@ -153,8 +155,6 @@ TUPLE: line-break < section type ;
 
 M: line-break short-section drop ;
 
-M: line-break long-section drop ;
-
 ! Block sections
 TUPLE: block < section sections ;
 
@@ -229,8 +229,6 @@ TUPLE: text-section < section string ;
 
 M: text-section short-section string>> write ;
 
-M: text-section long-section short-section ;
-
 : styled-text ( string style -- ) <text> add-section ;
 
 : text ( string -- ) f styled-text ;
@@ -279,8 +277,6 @@ TUPLE: colon < block ;
 : <colon> ( -- block )
     colon new-block ;
 
-M: colon long-section short-section ;
-
 M: colon indent-section? drop t ;
 
 M: colon unindent-first-line? drop t ;
index af20c4840afd7136b38fc04aa6dcc4b06ca3a2db..a70d6440d346b0dcfecc21843e30e76ce12faf5c 100644 (file)
@@ -12,9 +12,6 @@ CONSTANT: approx-pixels-per-cell 8
         over >>image
         swap presented associate >>style ;
 
-M: image-section long-section
-    short-section ;
-
 M: image-section short-section
     image>> <image-gadget> output-stream get write-gadget ;