# HG changeset patch # User Steve Losh # Date 1525820030 14400 # Node ID e4640f290f7be009e1a56bbeab1744fb99113722 # Parent d0a70b5614591075b2b91374424d47327feeb284 Switch to a good regex, add version number, remove log line diff -r d0a70b561459 -r e4640f290f7b brows.asd --- a/brows.asd Tue May 08 18:19:05 2018 -0400 +++ b/brows.asd Tue May 08 18:53:50 2018 -0400 @@ -4,6 +4,8 @@ :author "Steve Losh " :license "MIT" + :version "0.0.0" + :depends-on ( :boots diff -r d0a70b561459 -r e4640f290f7b src/main.lisp --- a/src/main.lisp Tue May 08 18:19:05 2018 -0400 +++ b/src/main.lisp Tue May 08 18:53:50 2018 -0400 @@ -2,13 +2,12 @@ (defparameter *regex* (ppcre:create-scanner - ; the regex in urlview's docs, with added [] exclusion - "(((http|https|ftp|gopher)|mailto):(//)?[^ \\[\\]<>\"\\t]*|(www|ftp)[0-9]?\\.[-a-z0-9.]+)[^ .,;\\[\\]\\t\\n\\r<\">\\):]?[^, <>\\[\\]\"\\t]*[^ .,;\\[\\]\\t\\n\\r<\">\\):]" + ;; https://gist.github.com/gruber/249502 + "(?i)\\b((?:[a-z][\\w-]+:(?:/{1,3}|[a-z0-9%])|www\\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:'\".,<>?«»“”‘’]))" :case-insensitive-mode t)) - +(defparameter *version* (asdf:component-version (asdf:find-system :brows))) (defparameter *urls* nil) -(defparameter *log* nil) (defparameter *pos* 0) (defparameter *actions* (make-hash-table)) @@ -60,12 +59,11 @@ (defun draw (canvas) (boots:clear canvas) - (boots:draw canvas 0 0 (structural-string *log*)) + (boots:draw canvas 0 0 (format nil "brows v~A" *version*)) (iterate - (with selected = (1+ *pos*)) - (for row :from 1 :below (boots:height canvas)) - (for url :in-vector *urls*) - (when (= row selected) + (for row :from 2 :below (boots:height canvas)) + (for url :in-vector *urls* :with-index i) + (when (= i *pos*) (boots:draw canvas row 0 "-> ")) (boots:draw canvas row 3 url))) @@ -86,7 +84,7 @@ ((#\Q #\q) (return-from main)) ((#\k :up) (incf-pos -1)) ((#\j :down) (incf-pos 1)) - (t (setf *log* event)))))) + (t nil))))) (defmacro catch-and-spew-errors (&body body) `(handler-case (progn ,@body)