! Copyright (C) 2005 Slava Pestov. ! See http://factor.sf.net/license.txt for BSD license. IN: gadgets-presentations DEFER: DEFER: gadget. IN: gadgets-panes USING: arrays gadgets gadgets-buttons gadgets-editors gadgets-labels gadgets-layouts gadgets-scrolling gadgets-theme generic hashtables io kernel line-editor lists math namespaces prettyprint sequences strings styles threads ; ! A pane is an area that can display text. ! output: pile ! current: shelf ! input: editor TUPLE: pane output active current input continuation scrolls? ; : add-output 2dup set-pane-output add-gadget ; : ( current input -- line ) [ 2array ] [ 1array ] if* make-shelf ; : init-active-line ( pane -- ) dup pane-active unparent [ dup pane-current swap pane-input ] keep 2dup set-pane-active add-gadget ; : pop-continuation ( pane -- quot ) dup pane-continuation f rot set-pane-continuation ; : pane-eval ( string pane -- ) pop-continuation dup [ [ continue-with ] in-thread ] when 2drop ; SYMBOL: structured-input : elements. ( quot -- ) [ 2 nesting-limit set 5 length-limit set newline ] with-pprint ; : pane-call ( quot pane -- ) 2dup [ elements. ] with-stream* >r structured-input global set-hash "\"structured-input\" \"gadgets-panes\" lookup global hash call" r> pane-eval ; : editor-commit ( editor -- line ) #! Add current line to the history, and clear the editor. [ commit-history line-text get line-clear ] with-editor ; : replace-input ( string pane -- ) pane-input set-editor-text ; : ( string -- button ) dup