Fix tables and word wrap
parent
5564691c27
commit
409f9030d4
|
@ -6,7 +6,6 @@
|
||||||
- outliners don't work
|
- outliners don't work
|
||||||
- browser responder doesn't work
|
- browser responder doesn't work
|
||||||
- tests in a loop runs out of memory eventually
|
- tests in a loop runs out of memory eventually
|
||||||
- fix word wrap with tables in panes
|
|
||||||
|
|
||||||
- fix this:
|
- fix this:
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
USING: help inspector parser prettyprint ;
|
USING: help inspector parser prettyprint ;
|
||||||
|
|
||||||
ARTICLE: "handbook" "Factor documentation"
|
ARTICLE: "handbook" "Factor documentation"
|
||||||
"Factor is a dynamically-typed stack based language. I hope you like it."
|
|
||||||
{ $subsection "changes" }
|
{ $subsection "changes" }
|
||||||
{ $heading "Survival guide" }
|
{ $heading "Survival guide" }
|
||||||
{ $list
|
{ $list
|
||||||
{ "Load source files using " { $link run-file } ":" }
|
{ "Load source files using " { $link run-file } ":"
|
||||||
{ $code "\"contrib/httpd/load.factor\" run-file" }
|
{ $code "\"contrib/httpd/load.factor\" run-file" } }
|
||||||
{ { $link .s } " prints the contents of the stack." }
|
{ { $link .s } " prints the contents of the stack." }
|
||||||
{ { $link . } " prints the object at the top of the stack." }
|
{ { $link . } " prints the object at the top of the stack." }
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,8 @@ M: f >link <link> ;
|
||||||
: $see-also ( content -- )
|
: $see-also ( content -- )
|
||||||
"See also" $heading $links ;
|
"See also" $heading $links ;
|
||||||
|
|
||||||
: $table ( content -- ) [ print-element ] tabular-output ;
|
: $table ( content -- )
|
||||||
|
[ [ print-element ] tabular-output ] ($block) ;
|
||||||
|
|
||||||
: $values ( content -- )
|
: $values ( content -- )
|
||||||
"Arguments and values" $heading
|
"Arguments and values" $heading
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
! Copyright (C) 2005, 2006 Slava Pestov
|
! Copyright (C) 2005, 2006 Slava Pestov
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
IN: gadgets
|
IN: gadgets-paragraphs
|
||||||
USING: arrays gadgets-labels generic kernel math
|
USING: arrays gadgets gadgets-labels generic kernel math
|
||||||
namespaces sequences ;
|
namespaces sequences ;
|
||||||
|
|
||||||
! A word break gadget
|
! A word break gadget
|
||||||
|
@ -20,22 +20,30 @@ SYMBOL: x SYMBOL: max-x
|
||||||
|
|
||||||
SYMBOL: y SYMBOL: max-y
|
SYMBOL: y SYMBOL: max-y
|
||||||
|
|
||||||
|
SYMBOL: line-height
|
||||||
|
|
||||||
SYMBOL: margin
|
SYMBOL: margin
|
||||||
|
|
||||||
: overrun? ( width -- ? ) x get + margin get >= ;
|
: overrun? ( width -- ? ) x get + margin get >= ;
|
||||||
|
|
||||||
: wrap-line ( height -- ) 0 x set y [ + ] change ;
|
: wrap-line ( -- )
|
||||||
|
line-height get y +@
|
||||||
|
0 { x line-height } [ set ] each-with ;
|
||||||
|
|
||||||
: wrap-pos ( -- pos ) x get y get 0 3array ;
|
: wrap-pos ( -- pos ) x get y get 0 3array ;
|
||||||
|
|
||||||
: advance-x ( x -- ) x [ + dup ] change max-x [ max ] change ;
|
: advance-x ( x -- )
|
||||||
|
x +@
|
||||||
|
x get max-x [ max ] change ;
|
||||||
|
|
||||||
: advance-y ( y -- ) y get + max-y [ max ] change ;
|
: advance-y ( y -- )
|
||||||
|
dup line-height [ max ] change
|
||||||
|
y get + max-y [ max ] change ;
|
||||||
|
|
||||||
: wrap-step ( quot child -- | quot: pos child -- )
|
: wrap-step ( quot child -- | quot: pos child -- )
|
||||||
dup pref-dim [
|
dup pref-dim [
|
||||||
over word-break-gadget? [
|
over word-break-gadget? [
|
||||||
dup first overrun? [ dup second wrap-line ] when
|
dup first overrun? [ wrap-line ] when
|
||||||
] unless drop wrap-pos rot call
|
] unless drop wrap-pos rot call
|
||||||
] keep first2 advance-y advance-x ; inline
|
] keep first2 advance-y advance-x ; inline
|
||||||
|
|
||||||
|
@ -43,7 +51,7 @@ SYMBOL: margin
|
||||||
|
|
||||||
: init-wrap ( paragraph -- )
|
: init-wrap ( paragraph -- )
|
||||||
paragraph-margin margin set
|
paragraph-margin margin set
|
||||||
0 { x max-x y max-y } [ set ] each-with ;
|
0 { x max-x y max-y line-height } [ set ] each-with ;
|
||||||
|
|
||||||
: do-wrap ( paragraph quot -- dim | quot: pos child -- )
|
: do-wrap ( paragraph quot -- dim | quot: pos child -- )
|
||||||
[
|
[
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
! Copyright (C) 2005, 2006 Slava Pestov.
|
! Copyright (C) 2005, 2006 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
IN: gadgets-presentations
|
IN: gadgets-presentations
|
||||||
USING: arrays gadgets gadgets-borders
|
USING: arrays gadgets gadgets-borders gadgets-buttons
|
||||||
gadgets-buttons gadgets-labels gadgets-outliner
|
gadgets-labels gadgets-outliner gadgets-panes gadgets-paragraphs
|
||||||
gadgets-panes generic hashtables inspector io kernel prettyprint
|
generic hashtables inspector io kernel prettyprint sequences
|
||||||
sequences strings styles words ;
|
strings styles words ;
|
||||||
|
|
||||||
! Clickable objects
|
! Clickable objects
|
||||||
TUPLE: object-button object ;
|
TUPLE: object-button object ;
|
||||||
|
|
|
@ -27,11 +27,8 @@ GENERIC: tick ( ms object -- )
|
||||||
[ timer-last [-] ] 2keep set-timer-last ;
|
[ timer-last [-] ] 2keep set-timer-last ;
|
||||||
|
|
||||||
: do-timer ( ms timer -- )
|
: do-timer ( ms timer -- )
|
||||||
dup next-time pick <= [
|
dup next-time pick <=
|
||||||
[ advance-timer ] keep timer-object tick
|
[ [ advance-timer ] keep timer-object tick ] [ 2drop ] if ;
|
||||||
] [
|
|
||||||
2drop
|
|
||||||
] if ;
|
|
||||||
|
|
||||||
: do-timers ( -- )
|
: do-timers ( -- )
|
||||||
millis timers hash-values [ do-timer ] each-with ;
|
millis timers hash-values [ do-timer ] each-with ;
|
||||||
|
|
Loading…
Reference in New Issue