Recently Written · git

clic

MIRROR ONLY Gopher client with pretty colours in Common Lisp

git clone https://github.com/equwal/clic

Log | Files | Refs


commit 8e4fb9b8579b02bd71c70cc83492ce2a39f18f54
Solene Rapenne <solene@perso.pw>
2018-05-24 16:04:22 +0200

s command to show a link url

 README.md |  1 +
 clic.1    |  7 ++-----
 clic.lisp | 18 ++++++++++++++++++
 3 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/README.md b/README.md
index 16b093b..98a3a65 100644
--- a/README.md
+++ b/README.md
@@ -51,6 +51,7 @@ Keyboard bindings
 + h : display history
 + r : reload the page
 + x or q or ^D : quit
++ sNUMBER : show the gopher url for link $number
 + / pattern : redisplay the menu only with lines containing string (no regex)
 + d : display the raw response
 
diff --git a/clic.1 b/clic.1
index 86fb8bc..69ff42e 100644
--- a/clic.1
+++ b/clic.1
@@ -30,11 +30,8 @@ Go to previous page.
 .B h
 Display the history.
 .TP
-.B b or -
-Display the bookmarks and choose a link from it.
-.TP
-.B a or +
-Add a bookmark.
+.B sNUMBER
+Show the url of link $NUMBER
 .TP
 .B d
 Dump raw item information.
diff --git a/clic.lisp b/clic.lisp
index 2377d69..8de9a08 100644
--- a/clic.lisp
+++ b/clic.lisp
@@ -361,11 +361,26 @@
   (when (<= 1 (length *history*))
     (visit (pop *history*))))
 
+(defun s(number)
+  "show url for the link $NUMBER"
+  (let ((destination (gethash number *links*)))
+    (if (not destination)
+        (format t "No link ~a~%" number)
+        (format t "gopher://~a~a/~a~a~%"
+                (location-host destination)
+                (let ((port (location-port destination)))
+                  (if (= 70 port)
+                      ""
+                      (format nil ":~a" port)))
+                (location-type destination)
+                (location-uri destination)))))
+
 (defun help-shell()
   "show help for the shell"
   (format t "number            : go to link n~%")
   (format t "p or /            : go to previous page~%")
   (format t "h                 : display history~%")
+  (format t "sNUMBER           : show url for link $NUMBER~%")
   (format t "r or *            : reload the page~%")
   (format t "help              : show this help~%")
   (format t "d                 : dump the raw reponse~%")
@@ -425,6 +440,9 @@
     ((string= "help" input)
      (help-shell))
 
+    ((search "s" input)
+     (s (parse-integer (subseq input 1))))
+
     ((or
       (string= "*" input)
       (string= "ls" input)