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 ; : select-word ( editor -- ) one-word-elt select-elt ;
: selected-word ( editor -- string ) : selected-token ( editor -- string )
dup gadget-selection? dup gadget-selection?
[ dup select-word ] unless [ dup select-word ] unless
gadget-selection ; gadget-selection ;

View File

@ -81,10 +81,10 @@ M: interactor ungraft*
[ dup help>> remove-connection ] [ call-next-method ] bi ; [ dup help>> remove-connection ] [ call-next-method ] bi ;
M: interactor model-changed M: interactor model-changed
2dup [ help>> eq? ] [ nip completion-popup>> not ] 2bi and 2dup help>> eq? [
[ [ value>> ] dip show-summary ] dup completion-popup>>
[ call-next-method ] [ 2drop ] [ [ value>> ] dip show-summary ] if
if ; ] [ call-next-method ] if ;
GENERIC: (print-input) ( object -- ) GENERIC: (print-input) ( object -- )
@ -532,7 +532,7 @@ CONSTANT: completion-popup-offset { -4 0 }
: word-completion-popup ( interactor -- ) : word-completion-popup ( interactor -- )
dup vocab-completion? dup vocab-completion?
[ vocabs-matching ] [ words-matching ] ? [ vocabs-matching ] [ words-matching ] ? '[ [ { } ] _ if-empty ]
one-word-elt show-completion-popup ; one-word-elt show-completion-popup ;
: history-matching ( interactor -- alist ) : history-matching ( interactor -- alist )
@ -555,6 +555,13 @@ M: interactor handle-gesture
[ call-next-method ] [ 2drop f ] if [ call-next-method ] [ 2drop f ] if
] [ call-next-method ] 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 { interactor "completion" f {
{ T{ key-down f f "TAB" } word-completion-popup } { T{ key-down f f "TAB" } word-completion-popup }
{ T{ key-down f { C+ } "p" } history-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 } { +listener+ t }
} define-operation } define-operation
USE: ui.gadgets.tables
! Operations -> commands ! Operations -> commands
source-editor source-editor
"word" "word"
"These commands operate on the Factor word named by the token at the caret position." "These commands operate on the Factor word named by the token at the caret position."
\ selected-word \ selected-word
[ selected-word ] [ selected-word ]
[ dup search [ ] [ no-word ] ?if ] [ ]
define-operation-map define-operation-map
interactor interactor