diff --git a/library/help/tutorial.factor b/library/help/tutorial.factor index 36751ba9e0..94d33fc1da 100644 --- a/library/help/tutorial.factor +++ b/library/help/tutorial.factor @@ -39,7 +39,7 @@ M: string tutorial-line : ( list -- gadget ) [ tutorial-line ] map make-pile 1 over set-pack-fill - dup page-theme ; + dup page-theme ; : tutorial-pages { diff --git a/library/styles.factor b/library/styles.factor index 447feacb9e..3dae31179c 100644 --- a/library/styles.factor +++ b/library/styles.factor @@ -37,4 +37,4 @@ SYMBOL: outline ! Paragraph styles SYMBOL: border-color SYMBOL: border-width -SYMBOL: word-wrap +SYMBOL: wrap-margin diff --git a/library/ui/borders.factor b/library/ui/borders.factor index dc4b82d345..9bc00b53e1 100644 --- a/library/ui/borders.factor +++ b/library/ui/borders.factor @@ -1,16 +1,19 @@ ! Copyright (C) 2005 Slava Pestov. ! See http://factor.sf.net/license.txt for BSD license. IN: gadgets-borders -USING: errors gadgets gadgets-layouts gadgets-theme generic -hashtables kernel math namespaces vectors ; +USING: arrays errors gadgets gadgets-layouts gadgets-theme +generic hashtables kernel math namespaces vectors ; TUPLE: border size ; -C: border ( child -- border ) +C: border ( child gap -- border ) dup delegate>gadget - { 5 5 0 } over set-border-size + [ >r dup 0 3array r> set-border-size ] keep [ add-gadget ] keep ; +: ( child -- border ) + 5 ; + : layout-border-loc ( border -- ) dup border-size swap gadget-child set-rect-loc ; diff --git a/library/ui/buttons.factor b/library/ui/buttons.factor index ec88f3313e..dc974bd383 100644 --- a/library/ui/buttons.factor +++ b/library/ui/buttons.factor @@ -36,7 +36,7 @@ TUPLE: button rollover? pressed? ; [ button-update ] [ mouse-enter ] set-action ; C: button ( gadget quot -- button ) - rot over set-gadget-delegate + rot over set-gadget-delegate [ swap button-gestures ] keep ; : ( gadget quot -- button ) diff --git a/library/ui/commands.factor b/library/ui/commands.factor index 57c8a70005..95e5ebdd24 100644 --- a/library/ui/commands.factor +++ b/library/ui/commands.factor @@ -80,9 +80,4 @@ M: command-button gadget-help ( button -- string ) "Compile" [ word? ] [ recompile ] define-command "Infer stack effect" [ word? ] [ unit infer . ] define-command -: gadget. ( gadget -- ) - gadget associate - "This stream does not support live gadgets" - swap format terpri ; - "Display gadget" [ [ gadget? ] is? ] [ gadget. ] define-command diff --git a/library/ui/menus.factor b/library/ui/menus.factor index 9580ccc777..883ad365e5 100644 --- a/library/ui/menus.factor +++ b/library/ui/menus.factor @@ -39,4 +39,4 @@ namespaces sequences ; : ( assoc -- gadget ) #! Given an association list mapping labels to quotations. - menu-items dup menu-theme ; + menu-items dup menu-theme ; diff --git a/library/ui/outliner.factor b/library/ui/outliner.factor index 3cb44821f1..8defdda316 100644 --- a/library/ui/outliner.factor +++ b/library/ui/outliner.factor @@ -24,7 +24,8 @@ DEFER: [ outliner? ] find-parent ; : ( ? -- gadget ) - arrow-right arrow-down ? gray swap ; + arrow-right arrow-down ? gray swap + ; : ( ? -- gadget ) #! If true, the button expands, otherwise it collapses. diff --git a/library/ui/panes.factor b/library/ui/panes.factor index 1c73bf422c..5f51ab46e1 100644 --- a/library/ui/panes.factor +++ b/library/ui/panes.factor @@ -112,6 +112,14 @@ M: pane stream-terpri ( pane -- ) 3dup car -rot pane-current stream-format cdr dup [ over stream-terpri pane-format ] [ 3drop ] if ; +: write-gadget ( gadget pane -- ) + #! Print a gadget to the given pane. + pane-current add-gadget ; + +: gadget. ( gadget -- ) + #! Print a gadget to the current pane. + stdio get write-gadget terpri ; + ! Panes are streams. M: pane stream-flush ( pane -- ) drop ; @@ -138,12 +146,12 @@ M: pane stream-close ( pane -- ) drop ; dup pane-current gadget-children empty? [ dup stream-terpri ] unless drop ; -: make-pane ( quot -- pane ) - #! Execute the quotation with output to an output-only pane. - [ swap with-stream ] keep - dup ?pane-terpri pane-output ; inline - : with-pane ( pane quot -- ) #! Clear the pane and run the quotation in a scope with #! stdio set to the pane. - >r dup pane-clear r> with-stream* ; inline + over pane-clear over >r with-stream* + r> ?pane-terpri ; inline + +: make-pane ( quot -- pane ) + #! Execute the quotation with output to an output-only pane. + [ with-pane ] keep ; inline diff --git a/library/ui/presentations.factor b/library/ui/presentations.factor index da36f35a91..08df83da62 100644 --- a/library/ui/presentations.factor +++ b/library/ui/presentations.factor @@ -5,48 +5,83 @@ USING: arrays gadgets gadgets-borders gadgets-labels gadgets-layouts gadgets-outliner gadgets-panes hashtables io kernel sequences strings styles ; -: init-commands ( style gadget -- gadget ) - presented rot hash [ ] when* ; - -: style-font ( style -- font ) - [ font swap hash [ "Monospaced" ] unless* ] keep - [ font-style swap hash [ plain ] unless* ] keep - font-size swap hash [ 12 ] unless* 3array ; - -: ( style text -- label ) -