Store the cursor position in TO-COMPLETE tokens in order to restore

the cursor position after completion.
This commit is contained in:
eknauel 2005-08-17 13:29:55 +00:00
parent f71f975e6d
commit 41b8e1dde9
1 changed files with 11 additions and 10 deletions

View File

@ -59,19 +59,20 @@
(integer? (token-cursor-pos token)))) (integer? (token-cursor-pos token))))
(define-record-type to-complete :to-complete (define-record-type to-complete :to-complete
(make-to-complete prefix) (make-to-complete prefix pos)
to-complete? to-complete?
(prefix to-complete-prefix)) (prefix to-complete-prefix)
(pos to-complete-pos))
(define-record-discloser :to-complete (define-record-discloser :to-complete
(lambda (r) (lambda (r)
`(to-complete ,(to-complete-prefix r)))) `(to-complete ,(to-complete-prefix r) ,(to-complete-pos r))))
(define to-complete-without-prefix? (define to-complete-without-prefix?
to-complete-prefix) to-complete-prefix)
(define (make-empty-to-complete) (define (make-empty-to-complete pos)
(make-to-complete #f)) (make-to-complete #f pos))
(define operator-chars (char-set #\& #\| #\< #\> #\, #\;)) (define operator-chars (char-set #\& #\| #\< #\> #\, #\;))
@ -117,8 +118,6 @@
(define (lex-port cursor-index port) (define (lex-port cursor-index port)
(let lp ((c (peek-char port)) (tokens '())) (let lp ((c (peek-char port)) (tokens '()))
(display (list c (current-column port)))
(newline)
(cond (cond
((eof-object? c) ((eof-object? c)
(reverse tokens)) (reverse tokens))
@ -137,7 +136,7 @@
(read-char port) (read-char port)
(lp (peek-char port) (lp (peek-char port)
(if (and cursor-index (= cursor-index pos)) (if (and cursor-index (= cursor-index pos))
(cons (make-empty-to-complete) tokens) (cons (make-empty-to-complete pos) tokens)
tokens)))) tokens))))
(else (else
(let ((token (lex-token cursor-index port))) (let ((token (lex-token cursor-index port)))
@ -214,7 +213,7 @@
((to-complete? t) ((to-complete? t)
t) t)
((cursor-on-token? t) ((cursor-on-token? t)
(make-to-complete (token-token t))) (make-to-complete (token-token t) (token-start-pos t)))
(else (else
(token-token t)))) (token-token t))))
@ -344,7 +343,9 @@
(let lp ((tokens tokens)) (let lp ((tokens tokens))
(cond (cond
((null? tokens) ((null? tokens)
#f) (make-command-line
(make-command (make-to-complete #f 0) '() '())
'() #f))
((parse-command-line-carefully tokens) ((parse-command-line-carefully tokens)
=> (lambda (v) v)) => (lambda (v) v))
(else (else