]> gitweb.factorcode.org Git - factor.git/commitdiff
fix hang with incremental layout
authorSlava Pestov <slava@factorcode.org>
Sat, 9 Jul 2005 20:08:50 +0000 (20:08 +0000)
committerSlava Pestov <slava@factorcode.org>
Sat, 9 Jul 2005 20:08:50 +0000 (20:08 +0000)
TODO.FACTOR.txt
library/ui/fonts.factor
library/ui/hierarchy.factor
library/ui/incremental.factor
library/ui/init-world.factor
library/ui/panes.factor

index 0b3c1e5cf51041a78ccd291bcfce9284ea5186c7..e3ce6935422cd0e1e28be86209bb55a668a8203c 100644 (file)
@@ -1,7 +1,5 @@
 + bugs to fix soon\r
 \r
-<erg> if write returns -1  and errno == EINTR then it's not a real error, you can try again\r
-\r
 <magnus--> http://developer.apple.com/technotes/tn2004/tn2123.html#SECLIMITATIONS\r
 <magnus--> http://www.caddr.com/macho/archives/sbcl-devel/2005-3/4742.html\r
 <magnus--> not *too* long\r
index e00a683cffde2ddad96caf4a9b1e497667184cfd..8c0c01512d3dd76f1d1c9f029466a7a61aaa26c8 100644 (file)
@@ -5,7 +5,7 @@ USING: alien hashtables io kernel lists namespaces sdl sequences
 styles ;
 
 : ttf-name ( font style -- name )
-    cons [
+    cons {{
         [[ [[ "Monospaced" plain       ]] "VeraMono" ]]
         [[ [[ "Monospaced" bold        ]] "VeraMoBd" ]]
         [[ [[ "Monospaced" bold-italic ]] "VeraMoBI" ]]
@@ -18,7 +18,7 @@ styles ;
         [[ [[ "Serif" bold             ]] "VeraSeBd" ]]
         [[ [[ "Serif" bold-italic      ]] "VeraBI"   ]]
         [[ [[ "Serif" italic           ]] "VeraIt"   ]]
-    ] assoc ;
+    }} hash ;
 
 : ttf-path ( name -- string )
     [ resource-path % "/fonts/" % % ".ttf" % ] make-string ;
@@ -35,7 +35,9 @@ global [ open-fonts nest drop ] bind
 
 : 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 )
     [ font paint-prop ] keep
index f7aeecbcb8dc629c62e13908603509fc2eaecd79..c43512e0ac04ce8cbf55402366fc3c769d403199 100644 (file)
@@ -4,36 +4,34 @@ IN: gadgets
 USING: generic hashtables kernel lists math matrices namespaces
 sequences ;
 
-: remove-gadget ( gadget box -- )
+: remove-gadget ( gadget parent -- )
     [ 2dup gadget-children remq swap set-gadget-children ] keep
     relayout
     f swap set-gadget-parent ;
 
-: (add-gadget) ( gadget box -- )
-    #! This is inefficient.
-    [ gadget-children swap add ] keep
-    set-gadget-children ;
-
 : unparent ( gadget -- )
     [
         dup gadget-parent dup
         [ remove-gadget ] [ 2drop ] ifte
     ] when* ;
 
-: add-gadget ( gadget box -- )
-    #! Add a gadget to a box.
+: (add-gadget) ( gadget box -- )
+    #! This is inefficient.
     over unparent
     dup pick set-gadget-parent
-    tuck (add-gadget)
-    relayout ;
+    [ gadget-children swap add ] keep set-gadget-children ;
+
+: add-gadget ( gadget parent -- )
+    #! Add a gadget to a parent gadget.
+    [ (add-gadget) ] keep relayout ;
 
-: (parent-list) ( gadget -- )
-    [ dup gadget-parent (parent-list) , ] when* ;
+: (parents) ( gadget -- )
+    [ dup gadget-parent (parents) , ] when* ;
 
-: parent-list ( gadget -- list )
+: parents ( gadget -- list )
     #! A list of all parents of the gadget, including the
     #! gadget itself.
-    [ (parent-list) ] make-list ;
+    [ (parents) ] make-list ;
 
 : (each-parent) ( list quot -- ? )
     over [
@@ -51,7 +49,7 @@ sequences ;
 : each-parent ( gadget quot -- ? )
     #! Keep executing the quotation on higher and higher
     #! parents until it returns f.
-    >r parent-list r> (each-parent) ; inline
+    >r parents r> (each-parent) ; inline
 
 : screen-pos ( gadget -- point )
     #! The position of the gadget on the screen.
index e5c42a08a2f5723dd8c64fb002f2441abf8daa0b..f92ee39bd27090f186b975fcd2707773227c962d 100644 (file)
@@ -14,12 +14,14 @@ USING: generic kernel matrices ;
 
 TUPLE: incremental cursor ;
 
-M: incremental pref-dim incremental-cursor ;
-
 C: incremental ( pack -- incremental )
     [ set-delegate ] keep
     { 0 0 0 } over set-incremental-cursor ;
 
+M: incremental pref-dim incremental-cursor ;
+
+M: incremental layout* drop ;
+
 : next-cursor ( gadget 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-
     swap set-shape-loc ;
 
+: prefer-incremental ( gadget -- )
+    dup pref-dim swap set-shape-dim ;
+
 : add-incremental ( gadget incremental -- )
-    2dup add-gadget
-    >r dup dup pref-dim swap set-shape-dim r>
-    f over set-gadget-relayout?
-    2dup incremental-loc update-cursor ;
+    2dup (add-gadget)
+    over prefer-incremental
+    2dup incremental-loc
+    tuck update-cursor
+    prefer-incremental ;
index 10791ef1eb6ebaf5731a86a05ece91447163adad..61177c2ff535ce98c9a30c88f35a7d8aa4e6fde4 100644 (file)
@@ -1,16 +1,15 @@
 ! Copyright (C) 2005 Slava Pestov.
 ! See http://factor.sf.net/license.txt for BSD license.
 IN: gadgets
-USING: generic kernel math namespaces styles ;
+USING: generic io kernel listener math namespaces styles threads ;
 
 
 global [
     <world> world set
     
     {{
-
         [[ background [ 255 255 255 ] ]]
-        [[ rollover-bg [ 216 216 216 ] ]]
+        [[ rollover-bg [ 255 255 204 ] ]]
         [[ foreground [ 0 0 0 ] ]]
         [[ reverse-video f ]]
         [[ font "Sans Serif" ]]
@@ -22,9 +21,13 @@ global [
     
     <plain-gadget> add-layer
 
-    <console> dup
-    "Stack display goes here" <label> <y-splitter>
+    <pane> dup
+    
+    <scroller> "Stack display goes here" <label> <y-splitter>
     3/4 over set-splitter-split add-layer
     
+    dup
+    [ [ clear  print-banner listener ] in-thread ] with-stream
+    
     request-focus
 ] bind
index 12e170e52ea5dd01901ab540126978de63f0bad0..671fb0d0d823a5061b9f1a50022f18d30eef18d5 100644 (file)
@@ -51,7 +51,7 @@ TUPLE: pane output active current input continuation ;
 
 C: pane ( -- pane )
     <line-pile> over set-delegate
-    <line-pile> ( <incremental> ) over add-output
+    <line-pile> <incremental> over add-output
     <line-shelf> over set-pane-current
     "" <editor> over set-pane-input
     dup init-active-line
@@ -65,7 +65,7 @@ M: pane focusable-child* ( pane -- editor )
     [ <presentation> ] keep pane-current add-gadget ;
 
 : 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 ;
 
 : pane-write ( style pane list -- )
@@ -86,6 +86,4 @@ M: pane stream-write-attr ( string style stream -- )
 M: pane stream-close ( stream -- ) drop ;
 
 : <console> ( -- pane )
-    <pane> dup
-    [ [ clear  print-banner listener ] in-thread ] with-stream
-    <scroller> ;
+    <pane> <scroller> ;