]> gitweb.factorcode.org Git - factor.git/commitdiff
ui.gadgets.editors: make editors pref-dim respect min/max rows/cols.
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 25 Feb 2021 23:51:22 +0000 (17:51 -0600)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 25 Feb 2021 23:51:22 +0000 (17:51 -0600)
basis/ui/gadgets/editors/editors.factor
basis/ui/gadgets/line-support/line-support.factor

index c045a91aed1352cc9876ce103a93ee0dce288fd4..6a2405bd6e1fb6e59fa5d6d7a9e3078212acb54d 100644 (file)
@@ -248,10 +248,11 @@ M: editor draw-gadget*
     ] if ;
 
 M: editor pref-dim*
+    [ call-next-method ] keep ! at least as big as our min-rows/min-cols
     ! Add some space for the caret.
     [ font>> ] keep dup draw-default-text?
     [ default-text>> ] [ control-value ] if
-    text-dim { 1 0 } v+ ;
+    text-dim { 1 0 } v+ vmax ;
 
 M: editor baseline font>> font-metrics ascent>> ;
 
index da60a2023efc6ec40cc2954afeed3879eec952fa..9fb28fa84676a7be159041a3ff9422e4c3a1923b 100644 (file)
@@ -87,7 +87,7 @@ GENERIC: draw-line ( line index gadget -- )
 <PRIVATE
 
 : clamp ( dim unit min max -- dim' )
-    [ -1/0. or * ] [ 1/0. or * ] bi-curry* bi
+    [ -1/0. or 1 max * ] [ 1/0. or 1 max * ] bi-curry* bi
     [ max ] [ min ] bi* ;
 
 : em ( font -- x ) "m" text-width ;
@@ -113,5 +113,7 @@ M: line-gadget pref-viewport-dim
         [ drop ] [ dupd pref-viewport-dim<< ] if
     ] ?if ;
 
+M: line-gadget pref-dim* pref-viewport-dim ;
+
 : visible-lines ( gadget -- n )
     [ visible-dim second ] [ line-height ] bi /i ;