Minor completion UI cleanups

slava 2006-10-06 21:07:13 +00:00
parent c87a34b164
commit 86420977b3
7 changed files with 49 additions and 23 deletions

View File

@ -12,11 +12,6 @@
- minibuffer should show a title
- clean up listener's minibuffer-related code
- help search looks funny
- vocab completer
- vocab operations:
- browse
- insert IN: -- or just 'become in'
- insert USE: -- 'use'
+ ui:

View File

@ -2,7 +2,8 @@
! See http://factorcode.org/license.txt for BSD license.
IN: help
USING: arrays definitions graphs hashtables help io kernel math
namespaces porter-stemmer prettyprint sequences strings words ;
namespaces porter-stemmer prettyprint sequences strings words
completion ;
! Right now this code is specific to the help. It will be
! generalized to an abstract full text search engine later.
@ -46,6 +47,9 @@ SYMBOL: term-index
tokenize [ term-index get hash ] map [ ] subset
count-occurrences hash>alist rank-completions ;
: search-help. ( phrase -- )
search-help [ first ] map help-outliner ;
: index-help ( -- )
term-index get [
dup clear-hash

View File

@ -23,10 +23,6 @@ $terpri
"The " { $link search-help } " word searches the term index and the " { $link index-help } " word updates it." }
{ $see-also help } ;
HELP: discard-irrelevant
{ $values { "results" "a sequence" } { "newresults" "a new sequence" } }
{ $description "Discard search results which rank in the lower 33% compared to the top scoring result, since they are most likely irrelevant." } ;
HELP: count-occurrences
{ $values { "seq" "a sequence of hashtables" } { "hash" "a hashtable" } }
{ $description "Collates all keys from the hashtables in " { $snippet "seq" } " and sums their values, which must be numbers." } ;
@ -36,7 +32,7 @@ HELP: search-help
{ $description "Performs a full-text search in the term index for help topics relating to " { $snippet "phrase" } ". The result is an association list of topic names paired with scores, sorted by decreasing score." } ;
HELP: index-help
{ $description "Updates the full-text search term index for use by " { $link search-help } "." } ;
{ $description "Updates the full-text search term index for use by " { $link search-help. } " and " { $link search-help } "." } ;
HELP: search-help.
{ $values { "phrase" "a string" } }

View File

@ -77,6 +77,7 @@ PROVIDE: library {
"tools/definitions.factor"
"tools/describe.factor"
"tools/completion.factor"
"help/stylesheet.factor"
"help/topics.factor"
@ -94,7 +95,6 @@ PROVIDE: library {
"tools/memory.factor"
"tools/listener.factor"
"tools/inspector.factor"
"tools/completion.factor"
"tools/word-tools.factor"
"tools/test.factor"

View File

@ -114,6 +114,10 @@ M: listener-gadget tool-help
: show-source-files-search ( listener action -- )
"" swap <source-files-search> swap show-minibuffer ;
: show-vocabs-search ( listener action -- )
>r dup listener-gadget-input selected-word r>
<vocabs-search> swap show-minibuffer ;
: show-list ( seq presenter action listener -- )
>r >r >r <model> r> r> <list> <scroller> r>
show-minibuffer ;
@ -168,6 +172,17 @@ listener-gadget "Listener commands" {
show-source-files-search
]
}
{
"Use vocabulary"
T{ key-down f { C+ } "u" }
[
[
find-listener hide-minibuffer
[ use+ ] curry call-listener
]
show-vocabs-search
]
}
{
"Hide minibuffer"
T{ key-down f f "ESCAPE" }

View File

@ -123,6 +123,18 @@ M: operation invoke-command ( target operation -- )
{ +quot+ [ browser call-tool ] }
} define-operation
[ vocab-link? ] H{
{ +mouse+ T{ button-up f f 2 } }
{ +name+ "Enter in" }
{ +quot+ [ [ in set ] curry call-listener ] }
} define-operation
[ vocab-link? ] H{
{ +mouse+ T{ button-up f f 3 } }
{ +name+ "Use" }
{ +quot+ [ [ use+ ] curry call-listener ] }
} define-operation
! Link
[ link? ] H{
{ +mouse+ T{ button-up f f 1 } }

View File

@ -5,7 +5,7 @@ USING: arrays gadgets gadgets-frames gadgets-labels
gadgets-panes gadgets-scrolling gadgets-text gadgets-theme
generic help tools kernel models sequences words
gadgets-borders gadgets-lists namespaces parser hashtables io
completion ;
completion styles ;
TUPLE: live-search field list model producer action presenter ;
@ -34,8 +34,8 @@ search-field H{
: <search-list>
<search-model>
gadget get live-search-presenter
gadget get live-search-action
gadget get live-search-presenter [ make-pane ] curry
gadget get live-search-action \ first add*
<list> ;
C: live-search ( string action producer presenter -- gadget )
@ -60,24 +60,28 @@ C: live-search ( string action producer presenter -- gadget )
M: live-search focusable-child* live-search-field ;
: <word-search> ( string action -- gadget )
\ first add*
all-words
[ word-completions ] curry
[ [ word-completion. ] make-pane ]
[ word-completion. ]
<live-search> ;
: <help-search> ( string action -- gadget )
\ first add*
[ search-help ]
[ [ first ($link) ] make-pane ]
[ first ($link) ]
<live-search> ;
: file-completion. ( pair -- )
first2 over completion>string swap <pathname> write-object ;
: string-completion. ( pair quot -- )
>r first2 over completion>string swap r> write-object ;
inline
: <source-files-search> ( string action -- gadget )
\ first add*
source-files get hash-keys natural-sort
[ string-completions ] curry
[ [ file-completion. ] make-pane ]
[ [ <pathname> ] string-completion. ]
<live-search> ;
: <vocabs-search> ( string action -- gadget )
vocabs
[ string-completions ] curry
[ [ <vocab-link> ] string-completion. ]
<live-search> ;