make repl tty sensitive
This commit is contained in:
parent
b7fca32f61
commit
2e0fab5a26
|
@ -1 +1,3 @@
|
|||
list(APPEND PICLIB_CONTRIB_LIBS ${PROJECT_SOURCE_DIR}/contrib/20.repl/repl.scm)
|
||||
list(APPEND PICRIN_CONTRIB_SOURCES ${PROJECT_SOURCE_DIR}/contrib/20.repl/repl.c)
|
||||
list(APPEND PICRIN_CONTRIB_INITS repl)
|
|
@ -0,0 +1,25 @@
|
|||
#include "picrin.h"
|
||||
#include "picrin/data.h"
|
||||
#include "picrin/pair.h"
|
||||
#include "picrin/string.h"
|
||||
#include "picrin/cont.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
static pic_value
|
||||
pic_repl_tty_p(pic_state *pic)
|
||||
{
|
||||
|
||||
pic_get_args(pic, "");
|
||||
|
||||
return pic_bool_value((isatty(STDIN_FILENO)));
|
||||
}
|
||||
|
||||
void
|
||||
pic_init_repl(pic_state *pic)
|
||||
{
|
||||
pic_deflibrary (pic, "(picrin repl)") {
|
||||
pic_defun(pic, "tty?", pic_repl_tty_p);
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@
|
|||
(else
|
||||
(begin
|
||||
(define (readline str)
|
||||
(display str)
|
||||
(if (tty?) (display str))
|
||||
(read-line))
|
||||
(define (add-history str)
|
||||
#f))))
|
||||
|
|
Loading…
Reference in New Issue