iSupport exit using ^D - clic - Clic is an command line interactive client for gopher written in Common LISP Err bitreich.org 70 hgit clone git://bitreich.org/clic/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/clic/ URL:git://bitreich.org/clic/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/clic/ bitreich.org 70 1Log /scm/clic/log.gph bitreich.org 70 1Files /scm/clic/files.gph bitreich.org 70 1Refs /scm/clic/refs.gph bitreich.org 70 1Tags /scm/clic/tag bitreich.org 70 1README /scm/clic/file/README.md.gph bitreich.org 70 1LICENSE /scm/clic/file/LICENSE.gph bitreich.org 70 i--- Err bitreich.org 70 1commit 8728b1f94663cfc4f8c6eb664263e8b216f8b3e5 /scm/clic/commit/8728b1f94663cfc4f8c6eb664263e8b216f8b3e5.gph bitreich.org 70 1parent 57ee48248441d6a164067c9652f20721a284757a /scm/clic/commit/57ee48248441d6a164067c9652f20721a284757a.gph bitreich.org 70 hAuthor: Solene Rapenne URL:mailto:solene@perso.pw bitreich.org 70 iDate: Sat, 27 Jan 2018 23:36:53 +0100 Err bitreich.org 70 i Err bitreich.org 70 iSupport exit using ^D Err bitreich.org 70 i Err bitreich.org 70 iDiffstat: Err bitreich.org 70 i M README.md | 3 +-- Err bitreich.org 70 i M clic.lisp | 69 +++++++++++++++++-------------- Err bitreich.org 70 i Err bitreich.org 70 i2 files changed, 39 insertions(+), 33 deletions(-) Err bitreich.org 70 i--- Err bitreich.org 70 1diff --git a/README.md b/README.md /scm/clic/file/README.md.gph bitreich.org 70 i@@ -73,8 +73,7 @@ Keyboard bindings Err bitreich.org 70 i + p : previous page Err bitreich.org 70 i + h : display history Err bitreich.org 70 i + r : reload the page Err bitreich.org 70 i-+ x : quit shell mode Err bitreich.org 70 i-+ q : quit shell mode Err bitreich.org 70 i++ x or q or ^D : quit Err bitreich.org 70 i + / pattern : redisplay the menu only with lines containing pattern (no regex) Err bitreich.org 70 i + d : display the raw response Err bitreich.org 70 i Err bitreich.org 70 1diff --git a/clic.lisp b/clic.lisp /scm/clic/file/clic.lisp.gph bitreich.org 70 i@@ -386,16 +386,16 @@ Err bitreich.org 70 i Err bitreich.org 70 i (defun help-shell() Err bitreich.org 70 i "show help for the shell" Err bitreich.org 70 i- (format t "number : go to link n~%") Err bitreich.org 70 i- (format t "p or / : go to previous page~%") Err bitreich.org 70 i- (format t "h : display history~%") Err bitreich.org 70 i- (format t "b or - : display bookmarks and choose a link from it~%") Err bitreich.org 70 i- (format t "a or + : add a bookmark~%") Err bitreich.org 70 i- (format t "r or * : reload the page~%") Err bitreich.org 70 i- (format t "help : show this help~%") Err bitreich.org 70 i- (format t "d : dump the raw reponse~%") Err bitreich.org 70 i- (format t "/ text : display online lines matching text~%") Err bitreich.org 70 i- (format t "x or q or . : exit the shell, go back to REPL~%")) Err bitreich.org 70 i+ (format t "number : go to link n~%") Err bitreich.org 70 i+ (format t "p or / : go to previous page~%") Err bitreich.org 70 i+ (format t "h : display history~%") Err bitreich.org 70 i+ (format t "b or - : display bookmarks and choose a link from it~%") Err bitreich.org 70 i+ (format t "a or + : add a bookmark~%") Err bitreich.org 70 i+ (format t "r or * : reload the page~%") Err bitreich.org 70 i+ (format t "help : show this help~%") Err bitreich.org 70 i+ (format t "d : dump the raw reponse~%") Err bitreich.org 70 i+ (format t "/ text : display online lines matching text~%") Err bitreich.org 70 i+ (format t "^D or x or q or . : quit clic~%")) Err bitreich.org 70 i Err bitreich.org 70 i (defun parse-url(url) Err bitreich.org 70 i "parse a gopher url and return a location" Err bitreich.org 70 i@@ -481,6 +481,7 @@ Err bitreich.org 70 i Err bitreich.org 70 i ;; exit Err bitreich.org 70 i ((or Err bitreich.org 70 i+ (eql nil input) Err bitreich.org 70 i (string= "." input) Err bitreich.org 70 i (string= "exit" input) Err bitreich.org 70 i (string= "x" input) Err bitreich.org 70 i@@ -573,15 +574,20 @@ Err bitreich.org 70 i (get-color 'bg-black) Err bitreich.org 70 i (get-color 'reset)) Err bitreich.org 70 i (force-output) Err bitreich.org 70 i- (let ((first-input (read-char))) Err bitreich.org 70 i- (if (char= #\NewLine first-input) Err bitreich.org 70 i- ;; we hide previous line (prompt) Err bitreich.org 70 i- (format t "'~C[A~C[K~C" #\Escape #\Escape #\return) Err bitreich.org 70 i- (progn Err bitreich.org 70 i- (unread-char first-input) Err bitreich.org 70 i- (let ((input-text (format nil "~a" (read-line nil nil)))) Err bitreich.org 70 i- (setf input input-text) Err bitreich.org 70 i- (loop-finish))))))) Err bitreich.org 70 i+ (let ((first-input (read-char *standard-input* nil nil t))) Err bitreich.org 70 i+ (cond Err bitreich.org 70 i+ ((not first-input) Err bitreich.org 70 i+ (format t "~%") ;; display a newline Err bitreich.org 70 i+ (setf input "x") ;; we exit Err bitreich.org 70 i+ (loop-finish)) Err bitreich.org 70 i+ ((char= #\NewLine first-input) Err bitreich.org 70 i+ ;; we hide previous line (prompt) Err bitreich.org 70 i+ (format t "'~C[A~C[K~C" #\Escape #\Escape #\return)) Err bitreich.org 70 i+ (t Err bitreich.org 70 i+ (unread-char first-input) Err bitreich.org 70 i+ (let ((input-text (format nil "~a" (read-line nil nil)))) Err bitreich.org 70 i+ (setf input input-text) Err bitreich.org 70 i+ (loop-finish))))))) Err bitreich.org 70 i Err bitreich.org 70 i ;; in case of shell command, do it Err bitreich.org 70 i (if input Err bitreich.org 70 i@@ -649,14 +655,15 @@ Err bitreich.org 70 i Err bitreich.org 70 i ;; we loop until X or Q is typed Err bitreich.org 70 i (loop for input = (format nil "~a" (read-line nil nil)) Err bitreich.org 70 i- while (not (or Err bitreich.org 70 i- (string= "exit" input) Err bitreich.org 70 i- (string= "x" input) Err bitreich.org 70 i- (string= "q" input))) Err bitreich.org 70 i- do Err bitreich.org 70 i- (when (eq 'end (user-input input)) Err bitreich.org 70 i- (loop-finish)) Err bitreich.org 70 i- (display-prompt))) Err bitreich.org 70 i+ while (not (or Err bitreich.org 70 i+ (string= "NIL" input) ;; ^D Err bitreich.org 70 i+ (string= "exit" input) Err bitreich.org 70 i+ (string= "x" input) Err bitreich.org 70 i+ (string= "q" input))) Err bitreich.org 70 i+ do Err bitreich.org 70 i+ (when (eq 'end (user-input input)) Err bitreich.org 70 i+ (loop-finish)) Err bitreich.org 70 i+ (display-prompt))) Err bitreich.org 70 i Err bitreich.org 70 i (defun main() Err bitreich.org 70 i "fetch argument, display page and go to shell if type is 1" Err bitreich.org 70 i@@ -675,10 +682,10 @@ Err bitreich.org 70 i Err bitreich.org 70 i ;; if user want to drop from first page we need Err bitreich.org 70 i ;; to look it here Err bitreich.org 70 i- (when (not (eq 'end (visit destination))) Err bitreich.org 70 i- ;; we continue to the shell if we are in a terminal Err bitreich.org 70 i- (when (ttyp) Err bitreich.org 70 i- (shell)))))) Err bitreich.org 70 i+ (when (not (eq 'end (visit destination))) Err bitreich.org 70 i+ ;; we continue to the shell if we are in a terminal Err bitreich.org 70 i+ (when (ttyp) Err bitreich.org 70 i+ (shell)))))) Err bitreich.org 70 i Err bitreich.org 70 i ;; we allow ecl to use a new kind of argument Err bitreich.org 70 i ;; not sure how it works but that works Err bitreich.org 70 .