diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lpm.c | 11 | ||||
-rw-r--r-- | src/lpm.lua | 1 |
2 files changed, 12 insertions, 0 deletions
@@ -8,6 +8,7 @@ #include <sys/socket.h> #include <arpa/inet.h> #include <libgen.h> + #include <termios.h> #define MAX_PATH PATH_MAX #endif @@ -155,6 +156,15 @@ static int lpm_hash(lua_State* L) { return 1; } +static int lpm_tcflush(lua_State* L) { + int stream = luaL_checkinteger(L, 1); + #ifndef _WIN32 + if (isatty(stream)) + tcflush(stream, TCIOFLUSH); + #endif + return 0; +} + static int lpm_symlink(lua_State* L) { #ifndef _WIN32 @@ -1279,6 +1289,7 @@ static const luaL_Reg system_lib[] = { { "mkdir", lpm_mkdir }, // Makes a directory. { "rmdir", lpm_rmdir }, // Removes a directory. { "hash", lpm_hash }, // Returns a hex sha256 hash. + { "tcflush", lpm_tcflush }, // Flushes an terminal stream. { "symlink", lpm_symlink }, // Creates a symlink. { "chmod", lpm_chmod }, // Chmod's a file. { "init", lpm_init }, // Initializes a git repository with the specified remote. diff --git a/src/lpm.lua b/src/lpm.lua index 5307a0a..c990407 100644 --- a/src/lpm.lua +++ b/src/lpm.lua @@ -524,6 +524,7 @@ local function log_progress_action(message) end end local function prompt(message) + system.tcflush(0) if not ASSUME_YES or not JSON then io.stderr:write(colorize(message .. " [Y/n]: ", "cyan")) if ASSUME_YES then io.stderr:write("Y\n") end |