From 4a85644f585d00f20e8af06a4f4c4a5115c69fcc Mon Sep 17 00:00:00 2001 From: eknauel Date: Fri, 27 May 2005 16:02:39 +0000 Subject: [PATCH] Add a "result screen" for showing the output of external programs. --- scheme/nuit-engine.scm | 22 +++++++++++++++++++--- scheme/nuit-packages.scm | 7 ++++++- scheme/std-command.scm | 36 +++++++++++++++++++++++++++++++++++- 3 files changed, 60 insertions(+), 5 deletions(-) diff --git a/scheme/nuit-engine.scm b/scheme/nuit-engine.scm index a5f9d4f..eb8618e 100644 --- a/scheme/nuit-engine.scm +++ b/scheme/nuit-engine.scm @@ -132,7 +132,6 @@ (current-history-entry-selector-maker history-entry-result)) (define (update-current-result! new-value) - (debug-message "update-current-result! " new-value) (cond ((current-history-item) => (lambda (entry) @@ -295,11 +294,27 @@ (toggle-command/scheme-mode) (loop (wait-for-input) #f)) + ((= ch key-f8) + (show-shell-screen) + (paint) + (loop (wait-for-input) #f)) + ;; C-x o --- toggle buffer focus ((and c-x-pressed? (= ch key-o)) (toggle-buffer-focus) (loop (wait-for-input) #f)) + ;; C-x p --- insert selection + ((and c-x-pressed? + (focus-on-command-buffer?) + (current-history-item) + (= ch 112)) + (add-string-to-command-buffer + (post-message + (history-entry-plugin (entry-data (current-history-item))) + (make-selection-message (active-command) (current-result)))) + (loop (wait-for-input) #f)) + ((and c-x-pressed? (focus-on-result-buffer?)) (let ((key-message (make-key-pressed-message @@ -493,7 +508,6 @@ (refresh-command-window)) (define (paint) - (debug-message "paint") (paint-bar-1) (paint-command-frame-window) (paint-command-window-contents) @@ -672,9 +686,11 @@ (wrefresh win))) (define (paint-result-buffer paint-proc) + (debug-message "paint-result-buffer before") (paint-proc (app-window-curses-win result-window) result-buffer - (focus-on-result-buffer?))) + (focus-on-result-buffer?)) + (debug-message "paint-result-buffer after")) ;;Cursor ;;move cursor to the corrct position diff --git a/scheme/nuit-packages.scm b/scheme/nuit-packages.scm index 67e71b2..191817f 100644 --- a/scheme/nuit-packages.scm +++ b/scheme/nuit-packages.scm @@ -106,8 +106,12 @@ ;;; standard command plugin (define-structure standard-command-plugin - (export standard-command-plugin) + (export standard-command-plugin show-shell-screen) (open nuit-eval + let-opt + pps + ncurses + signals plugin) (files std-command)) @@ -175,6 +179,7 @@ srfi-1 srfi-6 display-conditions + signals ncurses layout diff --git a/scheme/std-command.scm b/scheme/std-command.scm index fda621b..e186a6b 100644 --- a/scheme/std-command.scm +++ b/scheme/std-command.scm @@ -1,8 +1,36 @@ +;; ,open let-opt +(define (wait-for-key . optionals) + (let-optionals optionals + ((tty-port (current-input-port))) + (let* ((old (tty-info tty-port)) + (copy (copy-tty-info old))) + (set-tty-info:local-flags + copy + (bitwise-and (tty-info:local-flags copy) + (bitwise-not ttyl/canonical))) + (set-tty-info:min copy 1) + (set-tty-info:time copy 0) + (set-tty-info/now tty-port copy) + (let ((c (read-char tty-port))) + (set-tty-info/now tty-port old) + c)))) + (define (standard-command-plugin-completer command args) #f) +(define (show-shell-screen) + (def-prog-mode) + (endwin) + (display "Press any key to return to scsh-nuit...") + (wait-for-key)) + (define (standard-command-plugin-evaluater command args) - (run/strings (,command ,@args))) + (def-prog-mode) + (endwin) + (let ((status (run (,command ,@args)))) + (display "Press any key to return to scsh-nuit...") + (wait-for-key) + status)) (define standard-command-plugin (make-command-plugin #f @@ -19,6 +47,12 @@ (lambda (command args) (directory-files)))) +(register-plugin! + (make-command-plugin "ps" + no-completer + (lambda (command args) + (pps)))) + (register-plugin! (make-command-plugin "pwd" no-completer