add support for terminal size for ecl Thanks to pjb on #ecl that wrote the ffi … | |
git clone git://bitreich.org/clic/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
LICENSE | |
--- | |
commit ba86c5e114249375116d7d40a5b66bc2e2baa4ce | |
parent c6ebdeef05fc755afb9f9506445026dded37a077 | |
Author: Solene Rapenne <[email protected]> | |
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(-) | |
--- | |
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 |