restored word completion for the full languages (not teaching languages yet)
svn: r8018 original commit: f790d7e10ed5314a651a3a2b28439912c97a9ec7
This commit is contained in:
parent
7fb2184475
commit
effaca815d
|
@ -82,11 +82,12 @@
|
||||||
""
|
""
|
||||||
"Defaults to 15.")
|
"Defaults to 15.")
|
||||||
(text:get-completions/manuals
|
(text:get-completions/manuals
|
||||||
(-> (listof string?) (listof string?))
|
(-> (or/c false/c (listof symbol?)) (listof string?))
|
||||||
(manuals)
|
(manuals)
|
||||||
"Returns the list of keywords for the manuals from \\var{manuals}"
|
"Returns the list of keywords for the manuals from \\var{manuals}"
|
||||||
"by reading them from the \\texttt{keywords}"
|
"by extracting all of the documented exports of the manuals."
|
||||||
"files in the corresponding manuals' directories")
|
"The symbols are meant to be module paths."
|
||||||
|
"If \\var{manuals} is false, then all of the documented names are used.")
|
||||||
|
|
||||||
(number-snip:make-repeating-decimal-snip
|
(number-snip:make-repeating-decimal-snip
|
||||||
(number? boolean? . -> . (is-a?/c snip%))
|
(number? boolean? . -> . (is-a?/c snip%))
|
||||||
|
|
|
@ -20,6 +20,12 @@ WARNING: printf is rebound in the body of the unit to always
|
||||||
(lib "dirs.ss" "setup")
|
(lib "dirs.ss" "setup")
|
||||||
(lib "string.ss")
|
(lib "string.ss")
|
||||||
(prefix-in srfi1: (lib "1.ss" "srfi")))
|
(prefix-in srfi1: (lib "1.ss" "srfi")))
|
||||||
|
(require setup/scribble-index
|
||||||
|
scribble/struct
|
||||||
|
scribble/manual-struct
|
||||||
|
scribble/decode
|
||||||
|
scribble/basic
|
||||||
|
(prefix-in s/m: scribble/manual))
|
||||||
|
|
||||||
(import mred^
|
(import mred^
|
||||||
[prefix icon: framework:icon^]
|
[prefix icon: framework:icon^]
|
||||||
|
@ -2239,9 +2245,7 @@ designates the character that triggers autocompletion
|
||||||
[else
|
[else
|
||||||
#f]))
|
#f]))
|
||||||
|
|
||||||
(define/public (get-all-words)
|
(define/public (get-all-words) (get-completions/manuals #f))
|
||||||
(get-completions/manuals
|
|
||||||
'("framework" "foreign" "scribble" "mzlib" "mrlib" "mzscheme" "mred" "r5rs")))
|
|
||||||
|
|
||||||
(define completions-box #f) ; completions-box% or #f if no completions box is active right now
|
(define completions-box #f) ; completions-box% or #f if no completions box is active right now
|
||||||
(define word-start-pos #f) ; start pos of that word, or #f if no autocompletion
|
(define word-start-pos #f) ; start pos of that word, or #f if no autocompletion
|
||||||
|
@ -2801,32 +2805,35 @@ designates the character that triggers autocompletion
|
||||||
;; ============================================================
|
;; ============================================================
|
||||||
;; read keywords from manuals
|
;; read keywords from manuals
|
||||||
|
|
||||||
(define (get-completions/manuals manuals)
|
(define xref #f)
|
||||||
(define (read-keywords dir)
|
|
||||||
(let ([ddir (find-doc-dir)])
|
|
||||||
(if ddir
|
|
||||||
(let ([keywords (build-path ddir dir "keywords")])
|
|
||||||
(if (file-exists? keywords)
|
|
||||||
(map (λ (x) (string->symbol (car x)))
|
|
||||||
(call-with-input-file keywords
|
|
||||||
read))
|
|
||||||
'()))
|
|
||||||
'())))
|
|
||||||
|
|
||||||
(let ([ht (make-hash-table)])
|
(define (get-completions/manuals manuals)
|
||||||
(for-each (λ (x) (hash-table-put! ht x #t))
|
(let* ([sym->mpi (λ (mp) (module-path-index-resolve (module-path-index-join mp #f)))]
|
||||||
(apply append (map read-keywords manuals)))
|
[manual-mpis (and manuals (map sym->mpi manuals))])
|
||||||
(sort
|
|
||||||
(hash-table-map ht (λ (x y) (symbol->string x)))
|
(unless xref
|
||||||
string<=?)))
|
(set! xref (load-xref)))
|
||||||
|
|
||||||
|
(let ([ht (make-hash-table 'equal)])
|
||||||
|
(for-each
|
||||||
|
(λ (entry)
|
||||||
|
(let ([desc (entry-desc entry)])
|
||||||
|
(when (exported-index-desc? desc)
|
||||||
|
(let ([name (exported-index-desc-name desc)])
|
||||||
|
(when name
|
||||||
|
(when (or (not manual-mpis)
|
||||||
|
(ormap (λ (from-lib) (memq from-lib manual-mpis))
|
||||||
|
(map sym->mpi (exported-index-desc-from-libs desc))))
|
||||||
|
(hash-table-put! ht (symbol->string name) #t)))))))
|
||||||
|
(xref-index xref))
|
||||||
|
(sort (hash-table-map ht (λ (x y) x)) string<=?))))
|
||||||
|
|
||||||
;; ============================================================
|
;; ============================================================
|
||||||
;; auto complete example code
|
;; auto complete example code
|
||||||
|
|
||||||
#;
|
#;
|
||||||
(begin
|
(begin
|
||||||
(define all-words (get-completions/manuals
|
(define all-words (get-completions/manuals #f))
|
||||||
'("framework" "foreign" "scribble" "mzlib" "mrlib" "mzscheme" "mred" "r5rs")))
|
|
||||||
|
|
||||||
(let* ([f (new frame% (label "Test") (height 400) (width 400))]
|
(let* ([f (new frame% (label "Test") (height 400) (width 400))]
|
||||||
[e (new (autocomplete-mixin text%))]
|
[e (new (autocomplete-mixin text%))]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user