fix hang with incremental layout

cvs
Slava Pestov 2005-07-09 20:08:50 +00:00
parent f69e594d90
commit 0a8477701a
6 changed files with 41 additions and 36 deletions

View File

@ -1,7 +1,5 @@
+ bugs to fix soon + bugs to fix soon
<erg> if write returns -1 and errno == EINTR then it's not a real error, you can try again
<magnus--> http://developer.apple.com/technotes/tn2004/tn2123.html#SECLIMITATIONS <magnus--> http://developer.apple.com/technotes/tn2004/tn2123.html#SECLIMITATIONS
<magnus--> http://www.caddr.com/macho/archives/sbcl-devel/2005-3/4742.html <magnus--> http://www.caddr.com/macho/archives/sbcl-devel/2005-3/4742.html
<magnus--> not *too* long <magnus--> not *too* long

View File

@ -5,7 +5,7 @@ USING: alien hashtables io kernel lists namespaces sdl sequences
styles ; styles ;
: ttf-name ( font style -- name ) : ttf-name ( font style -- name )
cons [ cons {{
[[ [[ "Monospaced" plain ]] "VeraMono" ]] [[ [[ "Monospaced" plain ]] "VeraMono" ]]
[[ [[ "Monospaced" bold ]] "VeraMoBd" ]] [[ [[ "Monospaced" bold ]] "VeraMoBd" ]]
[[ [[ "Monospaced" bold-italic ]] "VeraMoBI" ]] [[ [[ "Monospaced" bold-italic ]] "VeraMoBI" ]]
@ -18,7 +18,7 @@ styles ;
[[ [[ "Serif" bold ]] "VeraSeBd" ]] [[ [[ "Serif" bold ]] "VeraSeBd" ]]
[[ [[ "Serif" bold-italic ]] "VeraBI" ]] [[ [[ "Serif" bold-italic ]] "VeraBI" ]]
[[ [[ "Serif" italic ]] "VeraIt" ]] [[ [[ "Serif" italic ]] "VeraIt" ]]
] assoc ; }} hash ;
: ttf-path ( name -- string ) : ttf-path ( name -- string )
[ resource-path % "/fonts/" % % ".ttf" % ] make-string ; [ resource-path % "/fonts/" % % ".ttf" % ] make-string ;
@ -35,7 +35,9 @@ global [ open-fonts nest drop ] bind
: ttf-init ( -- ) : ttf-init ( -- )
TTF_Init TTF_Init
open-fonts [ [ cdr expired? not ] hash-subset ] change ; global [
open-fonts [ [ cdr expired? not ] hash-subset ] change
] bind ;
: gadget-font ( gadget -- font ) : gadget-font ( gadget -- font )
[ font paint-prop ] keep [ font paint-prop ] keep

View File

@ -4,36 +4,34 @@ IN: gadgets
USING: generic hashtables kernel lists math matrices namespaces USING: generic hashtables kernel lists math matrices namespaces
sequences ; sequences ;
: remove-gadget ( gadget box -- ) : remove-gadget ( gadget parent -- )
[ 2dup gadget-children remq swap set-gadget-children ] keep [ 2dup gadget-children remq swap set-gadget-children ] keep
relayout relayout
f swap set-gadget-parent ; f swap set-gadget-parent ;
: (add-gadget) ( gadget box -- )
#! This is inefficient.
[ gadget-children swap add ] keep
set-gadget-children ;
: unparent ( gadget -- ) : unparent ( gadget -- )
[ [
dup gadget-parent dup dup gadget-parent dup
[ remove-gadget ] [ 2drop ] ifte [ remove-gadget ] [ 2drop ] ifte
] when* ; ] when* ;
: add-gadget ( gadget box -- ) : (add-gadget) ( gadget box -- )
#! Add a gadget to a box. #! This is inefficient.
over unparent over unparent
dup pick set-gadget-parent dup pick set-gadget-parent
tuck (add-gadget) [ gadget-children swap add ] keep set-gadget-children ;
relayout ;
: (parent-list) ( gadget -- ) : add-gadget ( gadget parent -- )
[ dup gadget-parent (parent-list) , ] when* ; #! Add a gadget to a parent gadget.
[ (add-gadget) ] keep relayout ;
: parent-list ( gadget -- list ) : (parents) ( gadget -- )
[ dup gadget-parent (parents) , ] when* ;
: parents ( gadget -- list )
#! A list of all parents of the gadget, including the #! A list of all parents of the gadget, including the
#! gadget itself. #! gadget itself.
[ (parent-list) ] make-list ; [ (parents) ] make-list ;
: (each-parent) ( list quot -- ? ) : (each-parent) ( list quot -- ? )
over [ over [
@ -51,7 +49,7 @@ sequences ;
: each-parent ( gadget quot -- ? ) : each-parent ( gadget quot -- ? )
#! Keep executing the quotation on higher and higher #! Keep executing the quotation on higher and higher
#! parents until it returns f. #! parents until it returns f.
>r parent-list r> (each-parent) ; inline >r parents r> (each-parent) ; inline
: screen-pos ( gadget -- point ) : screen-pos ( gadget -- point )
#! The position of the gadget on the screen. #! The position of the gadget on the screen.

View File

@ -14,12 +14,14 @@ USING: generic kernel matrices ;
TUPLE: incremental cursor ; TUPLE: incremental cursor ;
M: incremental pref-dim incremental-cursor ;
C: incremental ( pack -- incremental ) C: incremental ( pack -- incremental )
[ set-delegate ] keep [ set-delegate ] keep
{ 0 0 0 } over set-incremental-cursor ; { 0 0 0 } over set-incremental-cursor ;
M: incremental pref-dim incremental-cursor ;
M: incremental layout* drop ;
: next-cursor ( gadget incremental -- cursor ) : next-cursor ( gadget incremental -- cursor )
[ [
swap shape-dim swap incremental-cursor swap shape-dim swap incremental-cursor
@ -33,8 +35,12 @@ C: incremental ( pack -- incremental )
dup incremental-cursor dup rot pack-vector v* v- dup incremental-cursor dup rot pack-vector v* v-
swap set-shape-loc ; swap set-shape-loc ;
: prefer-incremental ( gadget -- )
dup pref-dim swap set-shape-dim ;
: add-incremental ( gadget incremental -- ) : add-incremental ( gadget incremental -- )
2dup add-gadget 2dup (add-gadget)
>r dup dup pref-dim swap set-shape-dim r> over prefer-incremental
f over set-gadget-relayout? 2dup incremental-loc
2dup incremental-loc update-cursor ; tuck update-cursor
prefer-incremental ;

View File

@ -1,16 +1,15 @@
! Copyright (C) 2005 Slava Pestov. ! Copyright (C) 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license. ! See http://factor.sf.net/license.txt for BSD license.
IN: gadgets IN: gadgets
USING: generic kernel math namespaces styles ; USING: generic io kernel listener math namespaces styles threads ;
global [ global [
<world> world set <world> world set
{{ {{
[[ background [ 255 255 255 ] ]] [[ background [ 255 255 255 ] ]]
[[ rollover-bg [ 216 216 216 ] ]] [[ rollover-bg [ 255 255 204 ] ]]
[[ foreground [ 0 0 0 ] ]] [[ foreground [ 0 0 0 ] ]]
[[ reverse-video f ]] [[ reverse-video f ]]
[[ font "Sans Serif" ]] [[ font "Sans Serif" ]]
@ -22,9 +21,13 @@ global [
<plain-gadget> add-layer <plain-gadget> add-layer
<console> dup <pane> dup
"Stack display goes here" <label> <y-splitter>
<scroller> "Stack display goes here" <label> <y-splitter>
3/4 over set-splitter-split add-layer 3/4 over set-splitter-split add-layer
dup
[ [ clear print-banner listener ] in-thread ] with-stream
request-focus request-focus
] bind ] bind

View File

@ -51,7 +51,7 @@ TUPLE: pane output active current input continuation ;
C: pane ( -- pane ) C: pane ( -- pane )
<line-pile> over set-delegate <line-pile> over set-delegate
<line-pile> ( <incremental> ) over add-output <line-pile> <incremental> over add-output
<line-shelf> over set-pane-current <line-shelf> over set-pane-current
"" <editor> over set-pane-input "" <editor> over set-pane-input
dup init-active-line dup init-active-line
@ -65,7 +65,7 @@ M: pane focusable-child* ( pane -- editor )
[ <presentation> ] keep pane-current add-gadget ; [ <presentation> ] keep pane-current add-gadget ;
: pane-terpri ( pane -- ) : pane-terpri ( pane -- )
dup pane-current over pane-output ( add-incremental ) add-gadget dup pane-current over pane-output add-incremental
<line-shelf> over set-pane-current init-active-line ; <line-shelf> over set-pane-current init-active-line ;
: pane-write ( style pane list -- ) : pane-write ( style pane list -- )
@ -86,6 +86,4 @@ M: pane stream-write-attr ( string style stream -- )
M: pane stream-close ( stream -- ) drop ; M: pane stream-close ( stream -- ) drop ;
: <console> ( -- pane ) : <console> ( -- pane )
<pane> dup <pane> <scroller> ;
[ [ clear print-banner listener ] in-thread ] with-stream
<scroller> ;