]> gitweb.factorcode.org Git - factor.git/commitdiff
Minor completion UI cleanups
authorslava <slava@factorcode.org>
Fri, 6 Oct 2006 21:07:13 +0000 (21:07 +0000)
committerslava <slava@factorcode.org>
Fri, 6 Oct 2006 21:07:13 +0000 (21:07 +0000)
TODO.FACTOR.txt
library/help/search.factor
library/help/search.facts
library/load.factor
library/ui/tools/listener.factor
library/ui/tools/operations.factor
library/ui/tools/search.factor

index 2fc37b933cdc21e940b150472aa9a1b37fd25b36..1e2299056e62c761b23450af5955157b810a41f4 100644 (file)
 - 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:
 
index 1c9179e78a09f96cb832f258474166b61107a649..fbf300c968c76b24f35b25a3837c1e4ff2750025 100644 (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
index 87c978ae5067631ab0368e9cba6631938ee18735..14513ec41f838479fde360b6e800a0c35d91bd8a 100644 (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" } }
index 2054a4d7bd919178759eae9cd95e8fa096f50df5..235d0ee138188eb6b3b87c49ab8d33bd08d4facf 100644 (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"
 
index 5386ebf72f314812449ac318fdc2962ab68e8162..c30749e7c9187b6a2ed0246135c26059499b91ff 100644 (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" }
index 91fbde372ba5a0879b8f765360f54c916e2d7461..a09183790fac549e2c44b4fbde441aac326aa434 100644 (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 } }
index d826c887deb9887481af76554791df4072e84531..5e8166526a054f38ba63c8d448016e3ce7a9e7e4 100644 (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> ;