cleaning up some ui code

db4
Doug Coleman 2009-10-04 16:43:00 -05:00
parent 1ca81c3130
commit 41e6c8f3be
2 changed files with 14 additions and 14 deletions

View File

@ -86,8 +86,7 @@ M: editor ungraft*
: editor-mark ( editor -- loc ) mark>> value>> ; : editor-mark ( editor -- loc ) mark>> value>> ;
: set-caret ( loc editor -- ) : set-caret ( loc editor -- )
[ model>> validate-loc ] keep [ model>> validate-loc ] [ caret>> ] bi set-model ;
caret>> set-model ;
: change-caret ( editor quot -- ) : change-caret ( editor quot -- )
[ [ [ editor-caret ] [ model>> ] bi ] dip call ] [ drop ] 2bi [ [ [ editor-caret ] [ model>> ] bi ] dip call ] [ drop ] 2bi
@ -136,7 +135,7 @@ M: editor ungraft*
[ editor-caret ] keep loc>point ; [ editor-caret ] keep loc>point ;
: caret-dim ( editor -- dim ) : caret-dim ( editor -- dim )
line-height 0 swap 2array ; [ 0 ] dip line-height 2array ;
: scroll>caret ( editor -- ) : scroll>caret ( editor -- )
dup graft-state>> second [ dup graft-state>> second [
@ -228,13 +227,13 @@ M: editor gadget-selection?
selection-start/end = not ; selection-start/end = not ;
M: editor gadget-selection M: editor gadget-selection
[ selection-start/end ] keep model>> doc-range ; [ selection-start/end ] [ model>> ] bi doc-range ;
: remove-selection ( editor -- ) : remove-selection ( editor -- )
[ selection-start/end ] keep model>> remove-doc-range ; [ selection-start/end ] [ model>> ] bi remove-doc-range ;
M: editor user-input* M: editor user-input*
[ selection-start/end ] keep model>> set-doc-range t ; [ selection-start/end ] [ model>> ] bi set-doc-range t ;
: editor-string ( editor -- string ) : editor-string ( editor -- string )
model>> doc-string ; model>> doc-string ;
@ -265,14 +264,15 @@ M: editor gadget-text* editor-string % ;
: drag-selection-mark ( loc editor element -- loc ) : drag-selection-mark ( loc editor element -- loc )
[ [
[ drag-direction? not ] keep [ drag-direction? not ]
[ editor-mark ] [ model>> ] bi [ editor-mark ]
[ model>> ] tri
] dip prev/next-elt ? ; ] dip prev/next-elt ? ;
: drag-caret&mark ( editor -- caret mark ) : drag-caret&mark ( editor -- caret mark )
dup clicked-loc swap mouse-elt [ clicked-loc ] [ mouse-elt ] bi
[ drag-selection-caret ] 3keep [ drag-selection-caret ]
drag-selection-mark ; [ drag-selection-mark ] 3bi ;
: drag-selection ( editor -- ) : drag-selection ( editor -- )
dup drag-caret&mark dup drag-caret&mark

View File

@ -150,11 +150,11 @@ M: interactor stream-readln
] if ; ] if ;
M: interactor stream-read M: interactor stream-read
swap dup zero? [ swap [
2drop "" drop ""
] [ ] [
[ interactor-read dup [ "\n" join ] when ] dip short head [ interactor-read dup [ "\n" join ] when ] dip short head
] if ; ] if-zero ;
M: interactor stream-read-partial M: interactor stream-read-partial
stream-read ; stream-read ;