diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-03-12 19:06:54 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2019-03-12 19:06:54 +0100 |
commit | 5bf50b03a3d5a5d8888021b4f3722031958367d3 (patch) | |
tree | 8ae79d1e8751a7f74d51869df38a93c609579fb5 /terminal/util.scm | |
parent | Add some more time utils. (diff) | |
download | calp-5bf50b03a3d5a5d8888021b4f3722031958367d3.tar.gz calp-5bf50b03a3d5a5d8888021b4f3722031958367d3.tar.xz |
Add a bunch of terminal control modules.
Diffstat (limited to 'terminal/util.scm')
-rw-r--r-- | terminal/util.scm | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/terminal/util.scm b/terminal/util.scm new file mode 100644 index 00000000..5b454769 --- /dev/null +++ b/terminal/util.scm @@ -0,0 +1,30 @@ +(define-module (terminal util) + #:use-module (srfi srfi-19) + #:use-module (srfi srfi-60) + #:export (line ctrl color-escape)) + +(define* (line #:optional (width 64)) + (display (make-string width #\_)) + (newline)) + +(define (ctrl char) + (integer->char (bitwise-and #b00011111 (char->integer char)))) + +(define-public (display-calendar-header! date) + (let* ((day (number->string (date-day date))) + (month (number->string (date-month date))) + (year (number->string (date-year date)))) + (system* "cal" "-3" day month year))) + + +(define (color-escape n) + (cond ((not n) "") + ((char=? #\# (string-ref n 0)) + (let* ((str (string-drop n 1)) + (rs (substring str 0 2)) + (gs (substring str 2 4)) + (bs (substring str 4 6))) + (format #f "\x1b[38;2;~a;~a;~am" + (string->number rs 16) + (string->number gs 16) + (string->number bs 16)))))) |