From 8d8580089f177192b895b302275677d25af4e629 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 22 Oct 2021 21:22:27 -0700 Subject: print's newline now returns to column 0 At this point I'm done making this repo ncurses-ready. Remaining files that allude to stdin/stdout/stderr: lauxlib.c - unclear how these primitives should work; may kill them ldblib.c - unclear what debug experience should be liolib.c - might kill or simulate these luac.c - let the compiler continue to be a terminal program --- src/lbaselib.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/lbaselib.c b/src/lbaselib.c index 2ab550b..fa597eb 100644 --- a/src/lbaselib.c +++ b/src/lbaselib.c @@ -7,6 +7,7 @@ #include +#include #include #include #include @@ -22,15 +23,9 @@ -/* -** If your system does not support `stdout', you can just remove this function. -** If you need, you can define your own `print' function, following this -** model but changing `fputs' to put the strings at a proper place -** (a console window or a log file, for instance). -*/ static int luaB_print (lua_State *L) { int n = lua_gettop(L); /* number of arguments */ - int i; + int i, y, x; lua_getglobal(L, "tostring"); for (i=1; i<=n; i++) { const char *s; @@ -41,11 +36,13 @@ static int luaB_print (lua_State *L) { if (s == NULL) return luaL_error(L, LUA_QL("tostring") " must return a string to " LUA_QL("print")); - if (i>1) fputs("\t", stdout); - fputs(s, stdout); + if (i>1) addstr("\t"); + addstr(s); lua_pop(L, 1); /* pop result */ } - fputs("\n", stdout); + getyx(stdscr, y, x); + mvprintw(y+1, x=0, ""); + refresh(); return 0; } -- cgit 1.4.1-2-gfad0