! Copyright (C) 2005 Slava Pestov. ! See http://factor.sf.net/license.txt for BSD license. IN: gadgets USING: generic kernel line-editor listener lists namespaces stdio streams strings threads ; ! A pane is an area that can display text. ! output: pile ! current: label ! input: editor TUPLE: pane output current input continuation ; : add-output 2dup set-pane-output add-gadget ; : add-input 2dup set-pane-input add-gadget ; : ( current input -- line ) [ tuck add-gadget add-gadget ] keep ; : pane-paint ( pane -- ) [[ "Monospaced" 12 ]] font set-paint-prop ; : pane-return ( pane -- ) [ pane-input [ commit-history line-text get line-clear ] with-editor ] keep 2dup stream-write "\n" over stream-write pane-continuation call ; : pane-actions ( line -- ) [ [[ [ button-down 1 ] [ pane-input click-editor ] ]] [[ [ "RETURN" ] [ pane-return ] ]] [[ [ "UP" ] [ pane-input [ history-prev ] with-editor ] ]] [[ [ "DOWN" ] [ pane-input [ history-next ] with-editor ] ]] ] swap add-actions ; C: pane ( -- pane ) over set-delegate over add-output ""