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:
parent
2b9854c8ff
commit
a354a75345
|
@ -161,6 +161,19 @@
|
|||
(move-cursor (command-buffer) (result-buffer))
|
||||
(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)
|
||||
(cond
|
||||
((command-buffer-in-command-mode?)
|
||||
|
@ -172,6 +185,28 @@
|
|||
(move-cursor (command-buffer) (result-buffer))
|
||||
(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)
|
||||
(let ((command-line (cadr (reverse (buffer-text (command-buffer))))))
|
||||
(debug-message "command-line " command-line)
|
||||
|
@ -401,7 +436,13 @@
|
|||
(offer-completions (last (buffer-text (command-buffer))))))
|
||||
(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))
|
||||
(toggle-command/scheme-mode)
|
||||
(loop (wait-for-input) #f #f))
|
||||
|
|
|
@ -896,6 +896,8 @@
|
|||
|
||||
configuration
|
||||
command-line-parser
|
||||
command-line-compiler
|
||||
utils
|
||||
focus-table
|
||||
result-buffer-changes
|
||||
nuit-eval/focus-table
|
||||
|
|
Loading…
Reference in New Issue