- new expect file for testing application with coverage report - cleaning whitespace - clic - Clic is an command line interactive client for gopher written in Common LISP
HTML git clone git://bitreich.org/clic/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/clic/
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR README
DIR LICENSE
---
DIR commit 04f5a2a34e4dcd4f26e89de3dc0dd81032eeda10
DIR parent fdffd2e4d1c02050fcf6f441b6e0029d560c1449
HTML Author: Solene Rapenne <solene@perso.pw>
Date: Thu, 16 Nov 2017 12:11:49 +0000
- new expect file for testing application with coverage report
- cleaning whitespace
Diffstat:
M clic.lisp | 51 ++++++++++++++++++-------------
M interactive-test.exp | 26 ++++++++++++++++++--------
2 files changed, 48 insertions(+), 29 deletions(-)
---
DIR diff --git a/clic.lisp b/clic.lisp
@@ -22,7 +22,7 @@
#include <sys/ioctl.h>
#include <limits.h>
unsigned int getTerminalHeight() {
- struct winsize w;
+ struct winsize w;
return ioctl(1,TIOCGWINSZ,&w)<0?UINT_MAX:w.ws_row;}")
(ffi:def-function
("getTerminalHeight" c-termsize)
@@ -155,31 +155,31 @@
(print-with-color "selector 5 not implemented" 'red))
;; 6 Unix uuencoded file
- (check "6"
+ (check "6"
(print-with-color "selector 6 not implemented" 'red))
;; 7 Index search server
- (check "7"
+ (check "7"
(print-with-color "selector 7 not implemented" 'red))
;; 8 Telnet session
- (check "8"
+ (check "8"
(print-with-color "selector 8 not implemented" 'red))
;; 9 Binary
- (check "9"
+ (check "9"
(print-with-color "selector 9 not implemented" 'red))
;; + redundant server
- (check "+"
+ (check "+"
(print-with-color "selector + not implemented" 'red))
;; T text based tn3270 session
- (check "T"
+ (check "T"
(print-with-color "selector T not implemented" 'red))
;; g GIF file
- (check "g"
+ (check "g"
(print-with-color "selector g not implemented" 'red))
;; I image
@@ -373,11 +373,23 @@
(defun display-buffer(type)
"display the buffer"
(let ((rows (c-termsize)))
+
+ ;; we store the user input outside of the loop
+ ;; so if the user doesn't want to scroll
+ ;; we break the loop and then execute the command
(let ((input nil))
(loop for line across *buffer*
counting line into row
do
- (when (= row (- rows 1)) ; -1 for text displayed
+ ;; display lines
+ (cond
+ ((string= "1" type)
+ (formatted-output line))
+ ((string= "0" type)
+ (format t "~a~%" line)))
+
+ ;; split and ask to scroll or to type a command
+ (when (= row rows) ; -1 for text displayed
(setf row 0)
(format t "~a press enter or a shell command ~a : "
(get-color 'cyan)
@@ -386,14 +398,11 @@
(let ((first-input (read-char)))
(when (not (char= #\NewLine first-input))
(unread-char first-input)
- (let ((input-text (format nil "~a" (read))))
+ (let ((input-text (format nil "~a" (read-line nil nil))))
(setf input input-text)
- (loop-finish)))))
- (cond
- ((string= "1" type)
- (formatted-output line))
- ((string= "0" type)
- (format t "~a~%" line))))
+ (loop-finish))))))
+
+ ;; in case of shell command, do it
(when input
(user-input input)))))
@@ -411,9 +420,6 @@
;; goes to the history !
(push destination *history*)
- (display-buffer (location-type destination))
-
-
(when *offline*
(let ((path (concatenate 'string
"history/" (location-host destination)
@@ -427,10 +433,13 @@
:if-does-not-exist :create
:if-exists :supersede)
- (loop for line in *buffer*
+ (loop for line across *buffer*
while line
do
- (format save-offline "~a~%" line))))))
+ (format save-offline "~a~%" line)))))
+
+ (display-buffer (location-type destination)))
+
(defun shell()
"Shell for user interaction"
DIR diff --git a/interactive-test.exp b/interactive-test.exp
@@ -21,9 +21,14 @@ proc user_input {} {
send "19\n"
expect " : "
+ send "\nr\n"
+ expect " : "
send "p\n"
expect "clic => "
+
+ send "r\n"
+ expect "clic => "
send "h\n"
expect "clic => "
@@ -61,35 +66,40 @@ expect "* "
send "(main)\n"
set running [user_input]
-send "quit\n"
+send "(pop *history*) (p) (r)\n"
expect "* "
-send "(main)\n"
-expect "clic => "
-
+send "19\n"
+expect " : "
send "q\n"
expect "* "
-send "(pop *history*) (p) (r)\n"
+send "(main)\n"
+expect "clic => "
+
+send "exit\n"
expect "* "
# add an argv to test argv parsing
-send "(setf *posix-argv* '(\"sbcl\" \"gopher://bitreich.org/0/usr/\"))\n"
+send "(setf *posix-argv* '(\"sbcl\" \"gopher://bitreich.org/0/documents/bitreich-manifesto.md\"))\n"
expect "* "
send "(main)\n"
+expect " : "
+send "q\n"
expect "* "
# add an argv to test argv parsing
-send "(setf *posix-argv* '(\"sbcl\" \"bitreich.org/0/usr/\"))\n"
+send "(setf *posix-argv* '(\"sbcl\" \"bitreich.org/1/usr/solene/\"))\n"
expect "* "
send "(main)\n"
+expect "clic => "
+send "q\n"
expect "* "
-
# add an argv to test argv parsing
send "(setf *posix-argv* '(\"sbcl\" \"bitreich.org:70/\"))\n"
expect "* "