From 016a1ed817bb813c343a9adc590071ad64bbb41c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 27 Sep 2008 13:47:31 -0500 Subject: [PATCH 01/10] Fix usability issue found by prunedtree --- basis/prettyprint/prettyprint.factor | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/basis/prettyprint/prettyprint.factor b/basis/prettyprint/prettyprint.factor index 149ecde447..d41a68f0c4 100755 --- a/basis/prettyprint/prettyprint.factor +++ b/basis/prettyprint/prettyprint.factor @@ -123,7 +123,11 @@ PRIVATE> : callstack. ( callstack -- ) callstack>array 2 [ remove-breakpoints - 3 nesting-limit [ . ] with-variable + [ + 3 nesting-limit set + 100 length-limit set + . + ] with-scope ] assoc-each ; : .c ( -- ) callstack callstack. ; From b7610e0bf7b8c36c775ebe9434dbe7d7e25edc46 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 27 Sep 2008 14:36:04 -0500 Subject: [PATCH 02/10] Fix ridiculous indentation, over (>>foo), and other crap in UI --- basis/ui/gadgets/books/books.factor | 8 +- basis/ui/gadgets/borders/borders.factor | 2 +- basis/ui/gadgets/buttons/buttons.factor | 57 ++++++------- basis/ui/gadgets/editors/editors.factor | 4 +- basis/ui/gadgets/gadgets-tests.factor | 16 ++-- basis/ui/gadgets/gadgets.factor | 17 ++-- basis/ui/gadgets/grids/grids.factor | 18 ++-- .../ui/gadgets/incremental/incremental.factor | 4 +- basis/ui/gadgets/labelled/labelled.factor | 32 +++---- basis/ui/gadgets/labels/labels.factor | 14 ++-- basis/ui/gadgets/lists/lists.factor | 6 +- basis/ui/gadgets/menus/menus.factor | 20 ++--- basis/ui/gadgets/packs/packs.factor | 8 +- basis/ui/gadgets/panes/panes.factor | 84 ++++++++++--------- basis/ui/gadgets/paragraphs/paragraphs.factor | 4 +- .../gadgets/scrollers/scrollers-tests.factor | 2 +- basis/ui/gadgets/scrollers/scrollers.factor | 26 +++--- basis/ui/gadgets/sliders/sliders.factor | 28 +++---- basis/ui/gadgets/slots/slots.factor | 12 +-- basis/ui/gadgets/tracks/tracks-tests.factor | 14 ++-- basis/ui/gadgets/tracks/tracks.factor | 41 +++++---- basis/ui/gadgets/viewports/viewports.factor | 2 +- basis/ui/gadgets/worlds/worlds-tests.factor | 8 +- basis/ui/operations/operations.factor | 13 ++- basis/ui/render/render.factor | 2 +- basis/ui/tools/browser/browser.factor | 10 +-- basis/ui/tools/deploy/deploy.factor | 6 +- basis/ui/tools/inspector/inspector.factor | 10 +-- basis/ui/tools/listener/listener-tests.factor | 2 +- basis/ui/tools/listener/listener.factor | 31 ++++--- basis/ui/tools/profiler/profiler.factor | 10 +-- basis/ui/tools/search/search.factor | 17 ++-- basis/ui/tools/tools-tests.factor | 2 +- basis/ui/tools/tools.factor | 43 +++++----- basis/ui/tools/traceback/traceback.factor | 12 +-- basis/ui/tools/workspace/workspace.factor | 16 ++-- basis/ui/ui.factor | 15 ++-- basis/ui/x11/x11.factor | 4 +- 38 files changed, 299 insertions(+), 321 deletions(-) diff --git a/basis/ui/gadgets/books/books.factor b/basis/ui/gadgets/books/books.factor index 161677b56a..1c6e4c8331 100755 --- a/basis/ui/gadgets/books/books.factor +++ b/basis/ui/gadgets/books/books.factor @@ -16,15 +16,15 @@ M: book model-changed ( model book -- ) relayout ; : new-book ( pages model class -- book ) - new-gadget - swap >>model - swap add-gadgets ; inline + new-gadget + swap >>model + swap add-gadgets ; inline : ( pages model -- book ) book new-book ; M: book pref-dim* ( book -- dim ) children>> pref-dims max-dim ; M: book layout* ( book -- ) - [ dim>> ] [ children>> ] bi [ (>>dim) ] with each ; + [ children>> ] [ dim>> ] bi [ >>dim drop ] curry each ; M: book focusable-child* ( book -- child/t ) current-page ; diff --git a/basis/ui/gadgets/borders/borders.factor b/basis/ui/gadgets/borders/borders.factor index 4609562af4..0dd11eca70 100644 --- a/basis/ui/gadgets/borders/borders.factor +++ b/basis/ui/gadgets/borders/borders.factor @@ -10,7 +10,7 @@ TUPLE: border < gadget { align initial: { 1/2 1/2 } } ; : new-border ( child class -- border ) - new-gadget [ swap add-gadget drop ] keep ; inline + new-gadget swap add-gadget ; inline : ( child gap -- border ) swap border new-border diff --git a/basis/ui/gadgets/buttons/buttons.factor b/basis/ui/gadgets/buttons/buttons.factor index e04e385a23..4ad9e14874 100755 --- a/basis/ui/gadgets/buttons/buttons.factor +++ b/basis/ui/gadgets/buttons/buttons.factor @@ -25,7 +25,7 @@ TUPLE: button < border pressed? selected? quot ; dup mouse-clicked? over button-rollover? and buttons-down? and - over (>>pressed?) + >>pressed? relayout-1 ; : if-clicked ( button quot -- ) @@ -115,20 +115,18 @@ M: checkmark-paint draw-interior dup { 0 1 } v* swap { 1 0 } v* gl-line ] with-translation ; -: checkmark-theme ( gadget -- ) +: checkmark-theme ( gadget -- gadget ) f f black black - - over (>>interior) - black - swap (>>boundary) ; + >>interior + black >>boundary ; : ( -- gadget ) - dup checkmark-theme - { 14 14 } over (>>dim) ; + checkmark-theme + { 14 14 } >>dim ; : toggle-model ( model -- ) [ not ] change-model ; @@ -148,7 +146,7 @@ TUPLE: checkbox < button ; align-left ; M: checkbox model-changed - swap value>> over (>>selected?) relayout-1 ; + swap value>> >>selected? relayout-1 ; TUPLE: radio-paint color ; @@ -162,20 +160,18 @@ M: radio-paint draw-boundary color>> set-color origin get { 1 1 } v+ swap rect-dim { 2 2 } v- 12 gl-circle ; -: radio-knob-theme ( gadget -- ) +: radio-knob-theme ( gadget -- gadget ) f f black black - - over (>>interior) - black - swap (>>boundary) ; + >>interior + black >>boundary ; : ( -- gadget ) - dup radio-knob-theme - { 16 16 } over (>>dim) ; + radio-knob-theme + { 16 16 } >>dim ; TUPLE: radio-control < button value ; @@ -188,13 +184,12 @@ TUPLE: radio-control < button value ; M: radio-control model-changed swap value>> - over value>> = - over (>>selected?) + over value>> = >>selected? relayout-1 ; : ( parent model assoc quot -- parent ) - #! quot has stack effect ( value model label -- ) - swapd [ swapd call add-gadget ] 2curry assoc-each ; inline + #! quot has stack effect ( value model label -- ) + swapd [ swapd call add-gadget ] 2curry assoc-each ; inline : radio-button-theme ( gadget -- gadget ) { 5 5 } >>gap @@ -204,18 +199,18 @@ M: radio-control model-changed label-on-right radio-button-theme ; : ( model assoc -- gadget ) - - -rot - [ ] - { 5 5 } >>gap ; + + -rot + [ ] + { 5 5 } >>gap ; : ( value model label -- gadget ) bevel-button-theme ; : ( model assoc -- gadget ) - - -rot - [ ] ; + + -rot + [ ] ; : command-button-quot ( target command -- quot ) [ invoke-command drop ] 2curry ; @@ -227,7 +222,7 @@ M: radio-control model-changed ; : ( target -- toolbar ) - - swap - "toolbar" over class command-map commands>> swap - [ -rot add-gadget ] curry assoc-each ; + + swap + "toolbar" over class command-map commands>> swap + [ -rot add-gadget ] curry assoc-each ; diff --git a/basis/ui/gadgets/editors/editors.factor b/basis/ui/gadgets/editors/editors.factor index 888716b364..a1026ef35a 100755 --- a/basis/ui/gadgets/editors/editors.factor +++ b/basis/ui/gadgets/editors/editors.factor @@ -96,9 +96,9 @@ M: editor ungraft* : click-loc ( editor model -- ) >r clicked-loc r> set-model ; -: focus-editor ( editor -- ) t over (>>focused?) relayout-1 ; +: focus-editor ( editor -- ) t >>focused? relayout-1 ; -: unfocus-editor ( editor -- ) f over (>>focused?) relayout-1 ; +: unfocus-editor ( editor -- ) f >>focused? relayout-1 ; : (offset>x) ( font col# str -- x ) swap head-slice string-width ; diff --git a/basis/ui/gadgets/gadgets-tests.factor b/basis/ui/gadgets/gadgets-tests.factor index a1602effe9..877d4ad145 100755 --- a/basis/ui/gadgets/gadgets-tests.factor +++ b/basis/ui/gadgets/gadgets-tests.factor @@ -9,9 +9,9 @@ IN: ui.gadgets.tests ! c contains b contains a "a" set "b" set - "a" get "b" get swap add-gadget drop + "b" get "a" get add-gadget drop "c" set - "b" get "c" get swap add-gadget drop + "c" get "b" get add-gadget drop ! position a and b "a" get { 100 200 } >>loc drop @@ -33,8 +33,8 @@ IN: ui.gadgets.tests "g3" set "g3" get { 100 200 } >>dim drop -"g1" get "g2" get swap add-gadget drop -"g2" get "g3" get swap add-gadget drop +"g2" get "g1" get add-gadget drop +"g3" get "g2" get add-gadget drop [ { 30 30 } ] [ "g1" get screen-loc ] unit-test [ { 30 30 } ] [ "g1" get screen-rect rect-loc ] unit-test @@ -49,11 +49,11 @@ IN: ui.gadgets.tests "g1" set "g1" get { 300 300 } >>dim drop "g2" set -"g2" get "g1" get swap add-gadget drop +"g1" get "g2" get add-gadget drop "g2" get { 20 20 } >>loc { 20 20 } >>dim drop "g3" set -"g3" get "g1" get swap add-gadget drop +"g1" get "g3" get add-gadget drop "g3" get { 100 100 } >>loc { 20 20 } >>dim drop @@ -66,7 +66,7 @@ IN: ui.gadgets.tests [ t ] [ { 110 110 } "g1" get pick-up "g3" get eq? ] unit-test "g4" set -"g4" get "g2" get swap add-gadget drop +"g2" get "g4" get add-gadget drop "g4" get { 5 5 } >>loc { 1 1 } >>dim drop @@ -121,7 +121,7 @@ M: mock-gadget ungraft* : add-some-children 3 [ over >>model - dup "g" get swap add-gadget drop + "g" get over add-gadget drop swap 1+ number>string set ] each ; diff --git a/basis/ui/gadgets/gadgets.factor b/basis/ui/gadgets/gadgets.factor index 05764d5b84..b082c11c0b 100755 --- a/basis/ui/gadgets/gadgets.factor +++ b/basis/ui/gadgets/gadgets.factor @@ -27,10 +27,10 @@ M: gadget model-changed 2drop ; : nth-gadget ( n gadget -- child ) children>> nth ; : init-gadget ( gadget -- gadget ) - init-rect - { 0 1 } >>orientation - t >>visible? - { f f } >>graft-state ; inline + init-rect + { 0 1 } >>orientation + t >>visible? + { f f } >>graft-state ; inline : new-gadget ( class -- gadget ) new init-gadget ; inline @@ -147,7 +147,7 @@ M: array gadget-text* DEFER: relayout : invalidate* ( gadget -- ) - \ invalidate* over (>>layout-state) + \ invalidate* >>layout-state dup forget-pref-dim dup root?>> [ layout-later ] [ parent>> [ relayout ] when* ] if ; @@ -167,7 +167,7 @@ DEFER: relayout DEFER: in-layout? : do-invalidate ( gadget -- gadget ) - in-layout? get [ dup invalidate ] [ dup invalidate* ] if ; + in-layout? get [ dup invalidate ] [ dup invalidate* ] if ; M: gadget (>>dim) ( dim gadget -- ) 2dup dim>> = @@ -282,8 +282,7 @@ SYMBOL: in-layout? : (clear-gadget) ( gadget -- ) dup [ (unparent) ] each-child - f over (>>focus) - f swap (>>children) ; + f >>focus f >>children drop ; : clear-gadget ( gadget -- ) not-in-layout @@ -305,7 +304,7 @@ SYMBOL: in-layout? not-in-layout (add-gadget) dup relayout ; - + : add-gadgets ( parent children -- parent ) not-in-layout [ (add-gadget) ] each diff --git a/basis/ui/gadgets/grids/grids.factor b/basis/ui/gadgets/grids/grids.factor index f14ccf1cca..3e91e0ceb6 100644 --- a/basis/ui/gadgets/grids/grids.factor +++ b/basis/ui/gadgets/grids/grids.factor @@ -2,7 +2,7 @@ ! See http://factorcode.org/license.txt for BSD license. USING: arrays kernel math namespaces make sequences words io io.streams.string math.vectors ui.gadgets columns accessors -math.geometry.rect ; +math.geometry.rect locals ; IN: ui.gadgets.grids TUPLE: grid < gadget @@ -12,18 +12,18 @@ grid : new-grid ( children class -- grid ) new-gadget - [ (>>grid) ] [ >r concat r> swap add-gadgets drop ] [ nip ] 2tri ; - inline + swap >>grid + dup grid>> concat add-gadgets ; inline : ( children -- grid ) grid new-grid ; : grid-child ( grid i j -- gadget ) rot grid>> nth nth ; -: grid-add ( grid child i j -- grid ) - >r >r dupd swap r> r> - >r >r 2dup swap add-gadget drop r> r> - 3dup grid-child unparent rot grid>> nth set-nth ; +:: grid-add ( grid child i j -- grid ) + grid i j grid-child unparent + grid child add-gadget + child i j grid grid>> nth set-nth ; : grid-remove ( grid i j -- grid ) -rot grid-add ; @@ -33,10 +33,10 @@ grid : (compute-grid) ( grid -- seq ) [ max-dim ] map ; : compute-grid ( grid -- horiz vert ) - pref-dim-grid dup flip (compute-grid) swap (compute-grid) ; + pref-dim-grid [ flip (compute-grid) ] [ (compute-grid) ] bi ; : (pair-up) ( horiz vert -- dim ) - >r first r> second 2array ; + [ first ] [ second ] bi* 2array ; : pair-up ( horiz vert -- dims ) [ [ (pair-up) ] curry map ] with map ; diff --git a/basis/ui/gadgets/incremental/incremental.factor b/basis/ui/gadgets/incremental/incremental.factor index 4d67080775..ffc05ec24b 100755 --- a/basis/ui/gadgets/incremental/incremental.factor +++ b/basis/ui/gadgets/incremental/incremental.factor @@ -24,7 +24,7 @@ TUPLE: incremental < pack cursor ; M: incremental pref-dim* dup layout-state>> [ - dup call-next-method over (>>cursor) + dup call-next-method >>cursor ] when cursor>> ; : next-cursor ( gadget incremental -- cursor ) @@ -57,5 +57,5 @@ M: incremental pref-dim* not-in-layout dup (clear-gadget) dup forget-pref-dim - { 0 0 } over (>>cursor) + { 0 0 } >>cursor parent>> [ relayout ] when* ; diff --git a/basis/ui/gadgets/labelled/labelled.factor b/basis/ui/gadgets/labelled/labelled.factor index 64020c7626..8cf13c8367 100755 --- a/basis/ui/gadgets/labelled/labelled.factor +++ b/basis/ui/gadgets/labelled/labelled.factor @@ -11,10 +11,10 @@ IN: ui.gadgets.labelled TUPLE: labelled-gadget < track content ; : ( gadget title -- newgadget ) - { 0 1 } labelled-gadget new-track - swap