! Copyright (C) 2005 Slava Pestov. ! See http://factor.sf.net/license.txt for BSD license. IN: gadgets USING: generic kernel line-editor listener lists math namespaces sequences io strings threads styles ; ! A pane is an area that can display text. ! output: pile ! current: shelf ! input: editor TUPLE: pane output active current input continuation ; : add-output 2dup set-pane-output add-gadget ; : add-input 2dup set-pane-input add-gadget ; : ( input current -- line ) [ add-gadget ] keep [ add-gadget ] keep ; : init-active-line ( pane -- ) dup pane-active [ unparent ] when* [ dup pane-input swap pane-current ] keep 2dup set-pane-active add-gadget ; : pane-paint ( pane -- ) "Monospaced" font set-paint-prop ; : pop-continuation ( pane -- quot ) dup pane-continuation f rot set-pane-continuation ; : pane-return ( pane -- ) [ pane-input [ commit-history line-text get line-clear ] with-editor ] keep 2dup stream-write "\n" over stream-write pop-continuation in-thread drop ; : 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 ""