diff options
author | Adam Harrison <adamdharrison@gmail.com> | 2024-03-05 12:22:07 -0500 |
---|---|---|
committer | Adam Harrison <adamdharrison@gmail.com> | 2024-03-05 12:22:07 -0500 |
commit | 389fe57a9fcd4c9971bb9cebc8dfeb67cac6498a (patch) | |
tree | 744bbd7f550d175604f64595f89008b7760f686d /src/lpm.c | |
parent | 4ac6bf5a4b4728abfcae7b06b30a0dd17f8735c0 (diff) | |
download | lite-xl-plugin-manager-389fe57a9fcd4c9971bb9cebc8dfeb67cac6498a.tar.gz lite-xl-plugin-manager-389fe57a9fcd4c9971bb9cebc8dfeb67cac6498a.zip |
Flush input buffer before prompt.
Diffstat (limited to 'src/lpm.c')
-rw-r--r-- | src/lpm.c | 11 |
1 files changed, 11 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. |