Word operations now DTRT if the completion popup is visible

db4
Slava Pestov 2009-01-15 01:33:35 -06:00
parent ecd2f75808
commit d1c84783f1
3 changed files with 16 additions and 7 deletions

View File

@ -462,7 +462,7 @@ editor "caret-motion" f {
: select-word ( editor -- ) one-word-elt select-elt ;
: selected-word ( editor -- string )
: selected-token ( editor -- string )
dup gadget-selection?
[ dup select-word ] unless
gadget-selection ;

View File

@ -81,10 +81,10 @@ M: interactor ungraft*
[ dup help>> remove-connection ] [ call-next-method ] bi ;
M: interactor model-changed
2dup [ help>> eq? ] [ nip completion-popup>> not ] 2bi and
[ [ value>> ] dip show-summary ]
[ call-next-method ]
if ;
2dup help>> eq? [
dup completion-popup>>
[ 2drop ] [ [ value>> ] dip show-summary ] if
] [ call-next-method ] if ;
GENERIC: (print-input) ( object -- )
@ -532,7 +532,7 @@ CONSTANT: completion-popup-offset { -4 0 }
: word-completion-popup ( interactor -- )
dup vocab-completion?
[ vocabs-matching ] [ words-matching ] ?
[ vocabs-matching ] [ words-matching ] ? '[ [ { } ] _ if-empty ]
one-word-elt show-completion-popup ;
: history-matching ( interactor -- alist )
@ -555,6 +555,13 @@ M: interactor handle-gesture
[ call-next-method ] [ 2drop f ] if
] [ call-next-method ] if ;
: selected-word ( editor -- word )
dup completion-popup>> [
[ table>> selected-row drop ] [ hide-completion-popup ] bi
] [
selected-token dup search [ ] [ no-word ] ?if
] ?if ;
interactor "completion" f {
{ T{ key-down f f "TAB" } word-completion-popup }
{ T{ key-down f { C+ } "p" } history-completion-popup }

View File

@ -174,13 +174,15 @@ M: word com-stack-effect def>> com-stack-effect ;
{ +listener+ t }
} define-operation
USE: ui.gadgets.tables
! Operations -> commands
source-editor
"word"
"These commands operate on the Factor word named by the token at the caret position."
\ selected-word
[ selected-word ]
[ dup search [ ] [ no-word ] ?if ]
[ ]
define-operation-map
interactor