- 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:
! 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.
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
"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." } ;
{ $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" } }
"tools/definitions.factor"
"tools/describe.factor"
+ "tools/completion.factor"
"help/stylesheet.factor"
"help/topics.factor"
"tools/memory.factor"
"tools/listener.factor"
"tools/inspector.factor"
- "tools/completion.factor"
"tools/word-tools.factor"
"tools/test.factor"
: 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 ;
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" }
{ +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 } }
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 ;
: <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 )
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> ;