diff --git a/src/misc.c b/src/misc.c index 6471e99..50fb339 100644 --- a/src/misc.c +++ b/src/misc.c @@ -247,3 +247,8 @@ int execute_shell_command(int fd, const char *command) return 0; } + +void clear_line() +{ + print("\r\033[K"); +} diff --git a/src/misc.h b/src/misc.h index 9f8a1d4..8ba8285 100644 --- a/src/misc.h +++ b/src/misc.h @@ -35,3 +35,4 @@ int read_poll(int fd, void *data, size_t len, int timeout); double get_current_time(void); bool match_patterns(const char *string, const char *patterns); int execute_shell_command(int fd, const char *command); +void clear_line(); diff --git a/src/script.c b/src/script.c index 8d68063..a92a4b6 100644 --- a/src/script.c +++ b/src/script.c @@ -513,7 +513,7 @@ void script_file_run(lua_State *L, const char *filename) if (luaL_dofile(L, filename)) { - tio_warning_printf("lua: %s\n", lua_tostring(L, -1)); + tio_warning_printf("lua: %s", lua_tostring(L, -1)); lua_pop(L, 1); /* pop error message from the stack */ return; } diff --git a/src/tty.c b/src/tty.c index 6805fae..8dc4ee6 100644 --- a/src/tty.c +++ b/src/tty.c @@ -1020,9 +1020,15 @@ void handle_command_sequence(char input_char, char *output_char, bool *forward) tio_printf("Run Lua script") tio_printf_raw("Enter file name: "); if (tio_readln()) + { + clear_line(); script_run(device_fd, line); + } else + { + clear_line(); script_run(device_fd, NULL); + } break; case KEY_SHIFT_R: @@ -2201,11 +2207,6 @@ void forward_to_tty(int fd, char output_char) } } -static void clear_line() -{ - print("\r\033[K"); -} - static void print_line(const char *string, int cursor_pos) { clear_line();