From c4da07c80da84d9087c0113ae84dedc757402843 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 4 Mar 2005 01:43:55 +0000 Subject: [PATCH] halos --- TODO.FACTOR.txt | 2 +- library/tools/interpreter.factor | 59 ++++++++++------------------- library/ui/buttons.factor | 7 ++-- library/ui/dialogs.factor | 1 - library/ui/editors.factor | 2 +- library/ui/events.factor | 12 +++--- library/ui/gadgets.factor | 5 ++- library/ui/halo.factor | 65 +++++++++++++++++++++++++------- library/ui/hand.factor | 41 +++++++++++++++++--- library/ui/inspector.factor | 12 +++--- library/ui/menus.factor | 7 ++++ library/ui/presentations.factor | 5 --- library/ui/root-menu.factor | 2 +- library/ui/scrolling.factor | 4 +- library/ui/world.factor | 23 ++++++++--- native/arithmetic.c | 47 +++++++++-------------- native/array.c | 28 +++----------- native/string.c | 14 +++---- native/string.h | 10 ++--- native/unix/io.c | 2 +- native/unix/write.c | 2 +- native/write.h | 2 +- 22 files changed, 194 insertions(+), 158 deletions(-) diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index 3e37cc6500..bed6d10e20 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -17,7 +17,7 @@ - console: scroll to bottom - split preferred size and layouting - remove shelf/pile duplication -- resizing and moving gadgets +- resizing gadgets - faster layout - faster repaint - closing inspectors diff --git a/library/tools/interpreter.factor b/library/tools/interpreter.factor index 7aa137407b..b14d66ab33 100644 --- a/library/tools/interpreter.factor +++ b/library/tools/interpreter.factor @@ -82,21 +82,11 @@ SYMBOL: meta-cf : do-1 ( obj -- ) dup word? [ meta-word-1 ] [ push-d ] ifte ; -: (interpret) ( quot -- ) +: interpret ( quot -- ) #! The quotation is called with each word as its executed. - done? [ drop ] [ [ next swap call ] keep (interpret) ] ifte ; + done? [ drop ] [ [ next swap call ] keep interpret ] ifte ; -: interpret ( quot quot -- ) - #! The first quotation is meta-interpreted, with each word - #! passed to the second quotation. Pollutes current - #! namespace. - init-interpreter swap meta-cf set (interpret) ; - -: (run) ( -- ) - [ do ] (interpret) ; - -: run ( quot -- ) - [ do ] interpret ; +: run ( -- ) [ do ] interpret ; : set-meta-word ( word quot -- ) "meta-word" set-word-property ; @@ -117,23 +107,6 @@ SYMBOL: meta-cf ! Some useful tools -: report ( obj -- ) - meta-r get vector-length " " fill write . flush ; - -: (trace) ( -- ) - [ dup report do ] (interpret) ; - -: trace ( quot -- ) - #! Trace execution of a quotation by printing each word as - #! its executed, and each literal as its pushed. Each line - #! is indented by the call stack height. - [ - init-interpreter - meta-cf set - (trace) - meta-d get set-datastack - ] with-scope ; - : &s #! Print stepper data stack. meta-d get {.} ; @@ -154,19 +127,27 @@ SYMBOL: meta-cf #! Print stepper variable value. meta-n get (get) ; -: not-done ( quot -- ) - done? [ "Stepper is done." print drop ] [ call ] ifte ; +: stack-report ( -- ) + meta-r get vector-length "=" fill write + meta-d get vector-length "-" fill write ; -: next-report ( -- obj ) - next dup report meta-cf get report ; +: not-done ( quot -- ) + done? [ + stack-report "Stepper is done." print drop + ] [ + call + ] ifte ; + +: report ( -- ) + stack-report meta-cf get . ; : step #! Step into current word. - [ next-report do-1 ] not-done ; + [ next do-1 report ] not-done ; : into #! Step into current word. - [ next-report do ] not-done ; + [ next do report ] not-done ; : walk-banner ( -- ) "The following words control the single-stepper:" print @@ -176,9 +157,9 @@ SYMBOL: meta-cf " ( var -- value ) inspects the stepper namestack." print \ step prettyprint-word " -- single step over" print \ into prettyprint-word " -- single step into" print - \ (trace) prettyprint-word " -- trace until end" print - \ (run) prettyprint-word " -- run until end" print - \ exit prettyprint-word " -- exit single-stepper" print ; + \ run prettyprint-word " -- run until end" print + \ exit prettyprint-word " -- exit single-stepper" print + report ; : walk ( quot -- ) #! Single-step through execution of a quotation. diff --git a/library/ui/buttons.factor b/library/ui/buttons.factor index dd164b1e75..5007c958e6 100644 --- a/library/ui/buttons.factor +++ b/library/ui/buttons.factor @@ -4,17 +4,16 @@ IN: gadgets USING: generic kernel lists math namespaces prettyprint sdl stdio ; -: button-down? ( n -- ? ) - my-hand hand-buttons contains? ; +: button-down? ( n -- ? ) hand hand-buttons contains? ; -: mouse-over? ( gadget -- ? ) my-hand hand-gadget child? ; +: mouse-over? ( gadget -- ? ) hand hand-gadget child? ; : button-pressed? ( button -- ? ) #! Return true if the mouse was clicked on the button, and #! is currently over the button. dup mouse-over? [ 1 button-down? [ - my-hand hand-clicked child? + hand hand-clicked child? ] [ drop f ] ifte diff --git a/library/ui/dialogs.factor b/library/ui/dialogs.factor index edd24680f2..88e59a639f 100644 --- a/library/ui/dialogs.factor +++ b/library/ui/dialogs.factor @@ -20,7 +20,6 @@ TUPLE: dialog continuation delegate ;