add support for terminal size for ecl Thanks to pjb on #ecl that wrote the ffi code - 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 ba86c5e114249375116d7d40a5b66bc2e2baa4ce
DIR parent c6ebdeef05fc755afb9f9506445026dded37a077
HTML Author: Solene Rapenne <solene@perso.pw>
Date: Sat, 11 Nov 2017 22:06:08 +0000
add support for terminal size for ecl
Thanks to pjb on #ecl that wrote the ffi code
Diffstat:
M clic.lisp | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
---
DIR diff --git a/clic.lisp b/clic.lisp
@@ -9,7 +9,7 @@
;;;; SBCL only
#+sbcl
(progn
- (load-shared-object "./extension.so")
+ (load-shared-object #p"./extension.so")
(declaim (inline getTerminalHeight))
(sb-alien:define-alien-routine "getTerminalHeight" unsigned-int)
(defun c-termsize ()
@@ -18,9 +18,15 @@
#+ecl
(progn
- "we don't do C binding with ecl"
- (defun c-termsize()
- 40))
+ (ffi:clines "
+ #include <sys/ioctl.h>
+ #include <limits.h>
+ unsigned int getTerminalHeight() {
+ struct winsize w;
+ return ioctl(1,TIOCGWINSZ,&w)<0?UINT_MAX:w.ws_row;}")
+ (ffi:def-function
+ ("getTerminalHeight" c-termsize)
+ () :returning :unsigned-int))
;;;; END C binding
;; structure to store links