diff --git a/library/prettyprint/backend.factor b/library/prettyprint/backend.factor index 46ed2b961b..2df69380ba 100644 --- a/library/prettyprint/backend.factor +++ b/library/prettyprint/backend.factor @@ -133,10 +133,9 @@ M: hashtable >pprint-sequence hash>alist \ H{ \ } t ; M: tuple >pprint-sequence tuple>array \ T{ \ } t ; -M: wrapper >pprint-sequence - wrapped dup 1array swap word? [ \ \ f ] [ \ W{ \ } ] if f ; +M: wrapper >pprint-sequence wrapped 1array \ W{ \ } f ; -M: object pprint* +: pprint-object ( obj -- ) [ >pprint-sequence H{ } [ pprint-word ] when* block> ] check-recursion ; + +M: object pprint* pprint-object ; + +M: wrapper pprint* + dup wrapped word? [ + \ \ pprint-word wrapped pprint-word + ] [ + pprint-object + ] if ; diff --git a/library/test/prettyprint.factor b/library/test/prettyprint.factor index e963124754..e585ed7496 100644 --- a/library/test/prettyprint.factor +++ b/library/test/prettyprint.factor @@ -78,3 +78,6 @@ unit-test [ ] [ \ compound see ] unit-test [ ] [ \ duplex-stream see ] unit-test + +[ "[ \\ + ]" ] [ [ \ + ] unparse ] unit-test +[ "[ \\ [ ]" ] [ [ \ [ ] unparse ] unit-test diff --git a/library/tools/completion.factor b/library/tools/completion.factor index f51df00ee8..76455689bc 100644 --- a/library/tools/completion.factor +++ b/library/tools/completion.factor @@ -56,10 +56,14 @@ USING: kernel arrays sequences math namespaces strings io ; : completion ( str quot obj -- pair ) #! pair is { obj score } - [ swap call dup rot fuzzy score ] keep swap 2array ; inline + pick empty? [ + 2nip 1 2array + ] [ + [ swap call dup rot fuzzy score ] keep swap 2array + ] if ; inline : completions ( str candidates quot -- seq ) - pick empty? [ + pick empty? pick length 100 >= and [ 3drop f ] [ [ >r 2dup r> completion ] map 2nip rank-completions diff --git a/library/ui/tools/listener.factor b/library/ui/tools/listener.factor index 9413c7ca12..b97b97c94a 100644 --- a/library/ui/tools/listener.factor +++ b/library/ui/tools/listener.factor @@ -124,26 +124,26 @@ M: listener-gadget tool-help [ set-listener-gadget-minibuffer ] 2keep dupd track-add request-focus ; +: show-titled-minibuffer ( listener gadget title -- ) + swap show-minibuffer ; + : minibuffer-action ( quot -- quot ) [ find-listener hide-minibuffer ] swap append ; : show-word-search ( listener action -- ) minibuffer-action >r dup listener-gadget-input selected-word r> - "Word search" - swap show-minibuffer ; + "Word search" show-titled-minibuffer ; : show-source-files-search ( listener action -- ) minibuffer-action "" swap - "Source file search" - swap show-minibuffer ; + "Source file search" show-titled-minibuffer ; : show-vocabs-search ( listener action -- ) minibuffer-action >r dup listener-gadget-input selected-word r> - "Vocabulary search" - swap show-minibuffer ; + "Vocabulary search" show-titled-minibuffer ; : listener-history ( listener -- seq ) listener-gadget-input interactor-history ; @@ -151,14 +151,10 @@ M: listener-gadget tool-help : history-action ( string -- ) find-listener listener-gadget-input set-editor-text ; -: ( listener -- gadget ) - listener-history - [ [ dup print-input ] make-pane ] - [ history-action ] minibuffer-action - "History" ; - : show-history ( listener -- ) - [ ] keep show-minibuffer ; + dup listener-gadget-input editor-text + over listener-history [ history-action ] minibuffer-action + "History search" show-titled-minibuffer ; : completion-string ( word listener -- string ) >r dup word-name swap word-vocabulary dup vocab r> diff --git a/library/ui/tools/search.factor b/library/ui/tools/search.factor index 997c335346..4251f41099 100644 --- a/library/ui/tools/search.factor +++ b/library/ui/tools/search.factor @@ -81,7 +81,11 @@ M: live-search focusable-child* live-search-field ; ; : ( string action -- gadget ) - vocabs - [ string-completions ] curry + vocabs [ string-completions ] curry [ [ ] string-completion. ] ; + +: ( string seq action -- gadget ) + swap [ string-completions ] curry + [ dup write-object ] + ;