: with-layout ( quot -- )
[ 0 x set 0 y set call ] with-scope ; inline
-: packed-pref-dim ( children gap axis -- dim )
+: pref-dims ( gadget -- list )
+ gadget-children [ pref-dim ] map ;
+
+: packed-pref-dim ( gadget gap axis -- dim )
#! The preferred size of the gadget, if all children are
#! packed in the direction of the given axis.
>r
- over length 0 max v*n >r [ pref-dim ] map r>
+ over length 0 max v*n >r pref-dims r>
2dup [ v+ ] reduce >r [ vmax ] reduce r>
r> set-axis ;
: pop-continuation ( pane -- quot )
dup pane-continuation f rot set-pane-continuation ;
-: pane-return ( pane -- )
- [
- pane-input [
- commit-history line-text get line-clear
- ] with-editor
- ] keep
+: pane-eval ( line pane -- )
2dup stream-write "\n" over stream-write
pop-continuation in-thread drop ;
+
+: pane-return ( pane -- )
+ [
+ pane-input
+ [ commit-history line-text get line-clear ] with-editor
+ ] keep pane-eval ;
: pane-actions ( line -- )
[
dup pane-paint
dup pane-actions ;
-: pane-write-1 ( style pane text -- )
- swap >r <styled-label> r> pane-current add-gadget ;
+: pane-write-1 ( style text pane -- )
+ [ <presentation> ] keep pane-current add-gadget ;
: pane-terpri ( pane -- )
dup pane-current over pane-output add-gadget
<line-shelf> over set-pane-current init-active-line ;
: pane-write ( style pane list -- )
- 3dup car pane-write-1 cdr dup
+ 3dup car swap pane-write-1 cdr dup
[ over pane-terpri pane-write ] [ 3drop ] ifte ;
! Panes are streams.
: <line-pile> 0 { 0 0 0 } 1 <pile> ;
M: pile pref-dim ( pile -- dim )
- dup gadget-children swap pile-gap { 0 1 0 } packed-pref-dim ;
+ dup pile-gap { 0 1 0 } packed-pref-dim ;
: w- swap shape-w swap pref-size drop - ;
: pile-x/y ( pile gadget offset -- )
USING: hashtables io kernel lists namespaces parser prettyprint
sequences ;
-: actions-menu ( -- )
- "actions" get [ uncons [ eval ] append cons ] map
- <menu> show-menu ;
+: actions-menu ( pane actions -- menu )
+ [ uncons rot [ pane-eval ] cons cons cons ] map-with <menu> ;
-: init-actions ( gadget -- )
- [ "actions" get actions-menu ] button-gestures ;
+: init-actions ( gadget pane -- )
+ over "actions" paint-prop dup [
+ actions-menu [ show-menu ] cons button-gestures
+ ] [
+ 3drop
+ ] ifte ;
: <styled-label> ( style text -- label )
- <label> "actions" pick assoc [ dup init-actions ] when
- swap alist>hash over set-gadget-paint ;
+ <label> swap alist>hash over set-gadget-paint ;
+
+: <presentation> ( style text pane -- presentation )
+ >r <styled-label> dup r> init-actions ;
: add-y-slider 2dup set-scroller-y add-right ;
: viewport>bottom ( -- viewport )
- dup viewport-dim vneg over viewport-origin
+ dup viewport-origin over viewport-dim vneg
{ 0 1 0 } set-axis swap scroll ;
: (scroll>bottom) ( scroller -- )
: <y-splitter> { 1 0 0 } <splitter> ;
M: splitter pref-dim
- dup gadget-children swap splitter-vector
- { 0 0 0 } swap packed-pref-dim ;
+ { 0 0 0 } over splitter-vector packed-pref-dim ;
: splitter-part ( splitter -- vec )
dup splitter-split swap shape-dim n*v divider-size 1/2 v*n v- ;
CELL object = dpeek();
if(type_of(object) == ALIEN_TYPE)
+ {
+ ALIEN *alien = untag_alien_fast(object);
drepl(tag_boolean(alien->expired));
+ }
else
drepl(F);
}