]> gitweb.factorcode.org Git - factor.git/commitdiff
start incremental layout
authorSlava Pestov <slava@factorcode.org>
Wed, 6 Jul 2005 05:57:58 +0000 (05:57 +0000)
committerSlava Pestov <slava@factorcode.org>
Wed, 6 Jul 2005 05:57:58 +0000 (05:57 +0000)
13 files changed:
CHANGES.txt
TODO.FACTOR.txt
library/bootstrap/boot-stage3.factor
library/collections/sequences-epilogue.factor
library/compiler/optimizer.factor
library/inference/branches.factor
library/math/matrices.factor
library/math/more-matrices.factor
library/ui/incremental.factor [new file with mode: 0644]
library/ui/layouts.factor
library/ui/load.factor
library/ui/panes.factor
library/vocabularies.factor

index ad8f08c68d9cb8d378323a870455819e3ae4f110..f5617ae78c0c5d4a46d6b3a562253ed6e4aa781c 100644 (file)
@@ -16,6 +16,8 @@ Factor 0.76:
   new string-in ( string quot -- ) word, calls quot with stdio bound to
   a stream that reads from the given string.
 
+- Improved inspector. Call it with inspect ( obj -- ).
+
 + Framework
 
 - md5 hashing algorithm in contrib/crypto/ (Doug Coleman).
index ad4bed95f0c899f9513a9f520235c95c4ec23226..0b3c1e5cf51041a78ccd291bcfce9284ea5186c7 100644 (file)
@@ -10,6 +10,7 @@
 <magnus--> http://www.caddr.com/macho/archives/sbcl-devel/2005-3/4764.html\r
 <magnus--> http://clozure.com/cgi-bin/viewcvs.cgi/ccl/lisp-kernel/lisp-exceptions.c?rev=1.9&content-type=text/vnd.viewcvs-markup\r
 \r
+- i/o: don't keep creating new sbufs\r
 - set-length should not shorten the underlying sequence\r
 - there is a problem with hashcodes of words and bootstrapping\r
 - http keep alive, and range get\r
index d28cabfad865a5de000251ae8169f951fe779b31..73ed9667217481d525a7177826e5c5cb79bd4d79 100644 (file)
@@ -68,6 +68,7 @@ t [
     "/library/inference/test.factor"
     "/library/tools/walker.factor"
     "/library/tools/annotations.factor"
+    "/library/tools/inspector.factor"
     "/library/bootstrap/image.factor"
     
     "/library/io/logging.factor"
index 8f38f28b029aa926bb9a92b95bf303f795715301..3b27908a34a47cae397c5fb5d64d8d466f743f70 100644 (file)
@@ -181,6 +181,11 @@ TUPLE: repeated length object ;
 M: repeated length repeated-length ;
 M: repeated nth nip repeated-object ;
 
+: seq-transpose ( list -- list )
+    #! An example illustrates this word best:
+    #! [ [ 1 2 3 ] [ 4 5 6 ] ] ==> [ [ 1 2 ] [ 3 4 ] [ 5 6 ] ]
+    0 over nth length [ swap [ nth ] map-with ] project-with ;
+
 IN: kernel
 
 : depth ( -- n )
index e7a27f2bb0d01b13048d6bf799305fb8d6eada0f..da555e4d1136cafd4ad6875f4d463af91022aab6 100644 (file)
@@ -197,7 +197,7 @@ M: #values can-kill* ( literal node -- ? )
 
 : branch-values ( branches -- )
     [ last-node node-in-d >list ] map
-    unify-lengths dual branch-returns set ;
+    unify-lengths seq-transpose branch-returns set ;
 
 : can-kill-branches? ( literal node -- ? )
     #! Check if the literal appears in either branch. This
index 399762c60b58d0c0b3df3341dec882a516c48a4e..e7dfc2d1f8a4ac8664976328dad3c95fed824d5c 100644 (file)
@@ -28,13 +28,10 @@ sequences strings vectors words hashtables prettyprint ;
         [ value-class ] map class-or-list <computed>
     ] ifte ;
 
-: dual ( list -- list )
-    0 over nth length [ swap [ nth ] map-with ] project-with ;
-
 : unify-stacks ( list -- stack )
     #! Replace differing literals in stacks with unknown
     #! results.
-    unify-lengths dual [ unify-results ] map >vector ; 
+    unify-lengths seq-transpose [ unify-results ] map >vector ; 
 
 : balanced? ( list -- ? )
     #! Check if a list of [[ instack outstack ]] pairs is
index d9c451c221972bcf43f495ce3a0ada998e6802f1..f5898bf8170feb3f432477628bc5b6452b2dbc8b 100644 (file)
@@ -30,7 +30,6 @@ vectors ;
 : v. ( v v -- x ) v** sum ;
 
 : norm-sq ( v -- n ) 0 [ absq + ] reduce ;
-: norm ( v -- n ) norm-sq sqrt ;
 
 : proj ( u v -- w )
     #! Orthogonal projection of u onto v.
index b3343ad93e0821f92b50ec69971f66b198839b94..5f0b229eb871bd6f648d23082c610ef66db18cd5 100644 (file)
@@ -3,5 +3,5 @@
 IN: matrices
 USING: kernel math ;
 
-: norm ( vec -- n ) dup v. sqrt ;
+: norm ( vec -- n ) norm-sq sqrt ;
 : normalize ( vec -- vec ) [ norm recip ] keep n*v ;
diff --git a/library/ui/incremental.factor b/library/ui/incremental.factor
new file mode 100644 (file)
index 0000000..f9ebd47
--- /dev/null
@@ -0,0 +1,38 @@
+! Copyright (C) 2005 Slava Pestov.
+! See http://factor.sf.net/license.txt for BSD license.
+IN: gadgets
+USING: generic kernel matrices ;
+
+! Incremental layout allows adding lines to panes to be O(1).
+! Note that incremental packs are distinct from ordinary packs
+! defined in layouts.factor, since you don't want all packs to
+! be incremental. In particular, if the children of the pack
+! change size, the incremental strategy does not work.
+
+! The cursor is the current size of the incremental pack.
+! New gadgets are added at cursor-cursor*pack-vector.
+
+TUPLE: incremental cursor ;
+
+M: incremental pref-dim incremental-cursor ;
+
+C: incremental ( pack -- incremental )
+    [ set-delegate ] keep
+    { 0 0 0 } over set-incremental-cursor ;
+
+: next-cursor ( gadget incremental -- cursor )
+    [
+        swap shape-dim swap incremental-cursor
+        2dup v+ >r vmax r>
+    ] keep  pack-vector set-axis ;
+
+: update-cursor ( gadget incremental -- )
+    [ next-cursor ] keep set-incremental-cursor ;
+
+: incremental-loc ( gadget incremental -- )
+    dup incremental-cursor dup rot pack-vector v* v-
+    swap set-gadget-loc ;
+
+: add-incremental ( gadget incremental -- )
+    ( 2dup add-gadget ) (  over prefer )  f over set-gadget-relayout?
+    ( 2dup incremental-loc ) ( update-cursor ) 2drop ;
index f6aa142855617c5aaf16056ad5d39e5ef4a52c1c..9a6193252a9a718c43689652fd914ea784b6e74b 100644 (file)
@@ -19,18 +19,17 @@ namespaces sdl sequences ;
         drop
     ] ifte ;
 
-GENERIC: alignment
-GENERIC: filling
-GENERIC: orientation
-
 : pref-dims ( gadget -- list )
     gadget-children [ pref-dim ] map ;
 
 : orient ( gadget list1 list2 -- list )
-    zip >r orientation r> [ uncons rot set-axis ] map-with ;
+    zip >r pack-vector r> [ uncons rot set-axis ] map-with ;
 
 : packed-dim-2 ( gadget sizes -- list )
-    [ over shape-dim { 1 1 1 } vmax over v- rot filling v*n v+ ] map-with ;
+    [
+        over shape-dim { 1 1 1 } vmax over v-
+        rot pack-fill v*n v+
+    ] map-with ;
 
 : (packed-dims) ( gadget sizes -- list )
     2dup packed-dim-2 swap orient ;
@@ -43,8 +42,9 @@ GENERIC: orientation
     { 0 0 0 } [ v+ ] accumulate ;
 
 : packed-loc-2 ( gadget sizes -- list )
-    >r dup shape-dim { 1 1 1 } vmax over r> packed-dim-2 [ v- ] map-with
-    >r dup alignment swap shape-dim { 1 1 1 } vmax r>
+    >r dup shape-dim { 1 1 1 } vmax over r>
+    packed-dim-2 [ v- ] map-with
+    >r dup pack-align swap shape-dim { 1 1 1 } vmax r>
     [ >r 2dup r> v- n*v ] map 2nip ;
 
 : (packed-locs) ( gadget sizes -- list )
@@ -76,21 +76,14 @@ C: pack ( align fill vector -- pack )
 
 : <line-shelf> 0 0 <shelf> ;
 
-M: pack orientation pack-vector ;
-
-M: pack filling pack-fill ;
-
-M: pack alignment pack-align ;
-
 M: pack pref-dim ( pack -- dim )
     [
         pref-dims
         [ { 0 0 0 } [ vmax ] reduce ] keep
         { 0 0 0 } [ v+ ] reduce
-    ] keep orientation set-axis ;
+    ] keep pack-vector set-axis ;
 
-M: pack layout* ( pack -- )
-    dup pref-dims packed-layout ;
+M: pack layout* ( pack -- ) dup pref-dims packed-layout ;
 
 : <stack> ( list -- gadget )
     #! A stack lays out all its children on top of each other.
index 89638b49321bb89a026fa8a2242690a632797538..91dfa7ae39dbb34f2b4f09e73c1971e4af9a069a 100644 (file)
@@ -24,6 +24,7 @@ USING: kernel parser sequences io ;
     "/library/ui/menus.factor"
     "/library/ui/splitters.factor"
     "/library/ui/presentations.factor"
+    "/library/ui/incremental.factor"
     "/library/ui/panes.factor"
     "/library/ui/init-world.factor"
     "/library/ui/ui.factor"
index 4d994f0dd6d6ede568d728488df25ce6516c1082..2fc02ce4601d135231e4c61bf8ab21a6000575ec 100644 (file)
@@ -49,7 +49,7 @@ TUPLE: pane output active current input continuation ;
 
 C: pane ( -- pane )
     <line-pile> over set-delegate
-    <line-pile> over add-output
+    <line-pile> <incremental> over add-output
     <line-shelf> over set-pane-current
     "" <editor> over set-pane-input
     dup init-active-line
@@ -60,10 +60,10 @@ M: pane focusable-child* ( pane -- editor )
     pane-input ;
 
 : pane-write-1 ( style text pane -- )
-    [ <presentation> ] keep pane-current add-gadget ;
+    [ <presentation> ] keep pane-current add-incremental ;
 
 : pane-terpri ( pane -- )
-    dup pane-current over pane-output add-gadget
+    dup pane-current over pane-output add-incremental
     <line-shelf> over set-pane-current init-active-line ;
 
 : pane-write ( style pane list -- )
index 0286eaed6a2cebb41152d9090286ca338d94109a..7f145703aec84a566f82ddf3ae1049591248450a 100644 (file)
@@ -94,9 +94,9 @@ SYMBOL: vocabularies
     "scratchpad" "in" set
     [
         "compiler" "debugger" "errors" "generic"
-        "hashtables" "inference" "interpreter" "jedit" "kernel"
-        "listener" "lists" "math" "matrices" "memory"
-        "namespaces" "parser" "prettyprint" "processes"
+        "hashtables" "inference" "inspector" "interpreter"
+        "jedit" "kernel" "listener" "lists" "math" "matrices"
+        "memory" "namespaces" "parser" "prettyprint" "processes"
         "sequences" "io" "strings" "styles" "syntax" "test"
         "threads" "unparser" "vectors" "words" "scratchpad"
     ] "use" set ;