\r
+ ui:\r
\r
+- off-by-one error in pickup?\r
+- closing ui does not stop timers\r
- adding/removing timers automatically for animated gadgets\r
- fix listener prompt display after presentation commands invoked\r
- theme abstraction in ui\r
- gaps in pack layout\r
- find out why so many small bignums get consed\r
- faster mouse tracking\r
-- binary search to locate visible children of packs\r
- rewrite frame layout for new style\r
- an interior paint that is only painted on rollover and mouse press;\r
use it for menu items. give menus a gradient background\r
#! Compute a quotation into an uninterned word, for testing
#! purposes.
gensym [ swap define-compound ] keep dup compile execute ;
+
+\ optimize profile
+\ linearize profile
+\ simplify profile
: short. ( object -- )
dup unparse-short swap write-object terpri ;
-: [.] ( sequence -- ) [ unparse-short. ] each ;
+: [.] ( sequence -- ) [ short. ] each ;
: stack. reverse-slice [.] ;
! Copyright (C) 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license.
IN: words
+USING: interpreter io kernel lists math namespaces prettyprint
+sequences strings test ;
! The annotation words let you flag a word for either tracing
! or single-stepping. Note that currently, words referring to
-! annotated words cannot be compiled; and annotating a word has
-! no effect of compiled calls to that word.
-USING: interpreter io kernel lists namespaces prettyprint
-sequences strings test ;
-
+! annotated words cannot be compiled.
: annotate ( word quot -- | quot: word def -- def )
over >r >r dup word-def r> call r> swap define-compound ;
inline
: (watch) ( word def -- def )
[
- "===> Entering: " pick word-name append , \ print ,
- \ .s ,
+ "===> Entering: " pick word-name append ,
+ [ print .s ] %
%
- "===> Leaving: " swap word-name append , \ print ,
- \ .s ,
+ "===> Leaving: " swap word-name append ,
+ [ print .s ] %
] make-list ;
: watch ( word -- )
#! Cause the word to start the code walker when executed.
[ nip [ walk ] cons ] annotate ;
-: timer ( word -- )
- #! Print the time taken to execute the word when it's called.
- [ nip [ time ] cons ] annotate ;
+: +@ ( n var -- ) dup get [ swap >r + r> ] when* set ;
+
+: with-profile ( quot word -- )
+ millis >r >r call r> millis r> - swap global [ +@ ] bind ;
+ inline
+
+: (profile) ( word def -- def )
+ [ , literalize , \ with-profile , ] make-list ;
+
+: profile ( word -- )
+ #! When the word is called, time it, and add the time to
+ #! the value in a global variable named by the word.
+ [ (profile) ] annotate ;
: &r
#! Print stepper call stack, as well as the currently
#! executing quotation.
- meta-cf get unparse-short.
- meta-executing get . meta-r get stack. ;
+ meta-cf get short. meta-executing get . meta-r get stack. ;
: &get ( var -- value )
#! Get stepper variable value.
: pane-clear ( pane -- )
dup pane-output clear-incremental pane-current clear-gadget ;
-: pane-ignore? ( style text pane -- ? )
- #! If we already have stuff in the current pack, and there
- #! is no style information or text to write, ignore it.
- #! Otherwise, we either have a fancy style (like an icon
- #! or gadget being output), or we want the current pack to
- #! have a minimal height so we put the empty label there.
- pane-current gadget-children empty? not
- rot not and swap empty? and ;
-
: pane-write-1 ( style text pane -- )
- 3dup pane-ignore? [
+ pick not pick empty? and [
3drop
] [
>r <presentation> r> pane-current add-gadget
] ifte ;
+: prepare-print ( current -- gadget )
+ #! Optimization: if line has 1 child, add the child.
+ dup gadget-children {
+ { [ dup empty? ] [ 2drop "" <label> ] }
+ { [ dup length 1 = ] [ nip first ] }
+ { [ t ] [ drop ] }
+ } cond ;
+
+: pane-print-1 ( current pane -- )
+ >r prepare-print r> pane-output add-incremental ;
+
: pane-terpri ( pane -- )
- dup pane-current over pane-output add-incremental
+ dup pane-current over pane-print-1
<line-shelf> over set-pane-current init-active-line ;
: pane-write ( style pane list -- )