Introduce toggle-cmd/scm-mode-with-conversion

part of darcs patch Wed Sep 21 20:25:07 EEST 2005  Eric Knauel <knauel@informatik.uni-tuebingen.de>
This commit is contained in:
eknauel 2005-09-27 16:31:07 +00:00
parent 2b9854c8ff
commit a354a75345
2 changed files with 44 additions and 1 deletions

View File

@ -161,6 +161,19 @@
(move-cursor (command-buffer) (result-buffer)) (move-cursor (command-buffer) (result-buffer))
(refresh-command-window)))) (refresh-command-window))))
(define (current-command-line)
(let ((entered (last (buffer-text (command-buffer)))))
(if (string=? entered "")
#f
entered)))
(define (replace-current-command-line! text)
(set-buffer-text!
(command-buffer)
(reverse
(cons text
(cdr (reverse (buffer-text (command-buffer))))))))
(define (toggle-command/scheme-mode) (define (toggle-command/scheme-mode)
(cond (cond
((command-buffer-in-command-mode?) ((command-buffer-in-command-mode?)
@ -172,6 +185,28 @@
(move-cursor (command-buffer) (result-buffer)) (move-cursor (command-buffer) (result-buffer))
(refresh-command-window)) (refresh-command-window))
;; assumes we are in command mode
(define (toggle-command/scheme-mode-with-conversion)
(cond
((current-command-line)
=> (lambda (cmdln)
(cond
((lex/parse-partial-command-line cmdln #f)
=> (lambda (parsed)
(let ((scheme-str
(write-to-string
(compile-command-line parsed))))
(replace-current-command-line! scheme-str)
(enter-scheme-mode!)
(set-buffer-pos-col! (command-buffer)
(+ 2 (string-length scheme-str)))
(paint-command-frame-window)
(paint-command-window-contents)
(move-cursor (command-buffer) (result-buffer))
(refresh-command-window))))
(else (values)))))
(else (values))))
(define (handle-return-key) (define (handle-return-key)
(let ((command-line (cadr (reverse (buffer-text (command-buffer)))))) (let ((command-line (cadr (reverse (buffer-text (command-buffer))))))
(debug-message "command-line " command-line) (debug-message "command-line " command-line)
@ -401,7 +436,13 @@
(offer-completions (last (buffer-text (command-buffer)))))) (offer-completions (last (buffer-text (command-buffer))))))
(loop (wait-for-input) #f maybe-selector))) (loop (wait-for-input) #f maybe-selector)))
;; F7 toggle scheme-mode / command-mode (FIXME: find a better key) ((and (focus-on-command-buffer?)
(command-buffer-in-command-mode?)
c-x-pressed?
(= ch (config 'main 'switch-command-buffer-mode-key)))
(toggle-command/scheme-mode-with-conversion)
(loop (wait-for-input) #f #f))
((= ch (config 'main 'switch-command-buffer-mode-key)) ((= ch (config 'main 'switch-command-buffer-mode-key))
(toggle-command/scheme-mode) (toggle-command/scheme-mode)
(loop (wait-for-input) #f #f)) (loop (wait-for-input) #f #f))

View File

@ -896,6 +896,8 @@
configuration configuration
command-line-parser command-line-parser
command-line-compiler
utils
focus-table focus-table
result-buffer-changes result-buffer-changes
nuit-eval/focus-table nuit-eval/focus-table