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