flashing drastically descreased

This commit is contained in:
anon 2024-08-17 01:15:06 +02:00
parent df061c1f36
commit 43db0ce7df
4 changed files with 27 additions and 15 deletions

View File

@ -1,3 +1,2 @@
+ scroll flashes
+ technical dept in tui.cpp -
+ resizing
+ unicode support in the tui

View File

@ -86,8 +86,8 @@ signed main(const int argc, const char * const * const argv) {
pthread_t query_thread;
pthread_create(&query_thread, NULL, async_input, NULL);
while (do_run) {
loop_start:
entry_t entry;
loop_start:
if (do_redisplay) {
do_redisplay = false;
if (is_input_changed) {
@ -97,7 +97,7 @@ signed main(const int argc, const char * const * const argv) {
requery();
}
while (entry = get_entry(), entry.command != NULL) {
if (is_input_changed) { goto loop_start; }
if (is_input_changed) { tui_rearm(); goto loop_start; }
tui_append_back(entry);
}
tui_refresh();

View File

@ -39,7 +39,7 @@ static int input_available = false;
static int input;
//
static void refresh_input(void);
static inline void update_input(void);
static void full_redraw(void);
static bool do_fullredraw = true;
@ -73,7 +73,13 @@ int init_tui(void) {
int return_input_available(void) { return input_available; }
rl_getc_function = getc_function;
rl_input_available_hook = return_input_available;
rl_redisplay_function = refresh_input;
/* Due to this bug: https://mail.gnu.org/archive/html/bug-readline/2013-09/msg00021.html ;
* we cannot null this function.
* Im seriously questioning why readline is still the """default""" library in the wild
* and whether i should participate.
*/
int redisplay_nop(void) { return; }
rl_redisplay_function = redisplay_nop;
/* We must specify an input handler or readline chimps out,
* but we dont want the line to be actually submittable,
* (search is continous and that would delete what the user
@ -131,19 +137,25 @@ void full_redraw(void) {
box(main_window, 0, 0);
waddstr(version_window, version_string);
wrefresh(version_window);
refresh_input();
update_input();
wnoutrefresh(version_window);
doupdate();
}
static
void refresh_input(void) {
void tui_rearm() {
entry_line_index = 0;
}
static inline
void update_input() {
wmove(input_window, 0, 0);
wclrtoeol(input_window);
waddstr(input_window, "$ ");
waddstr(input_window, rl_line_buffer);
waddch(input_window, ACS_BLOCK);
wrefresh(input_window);
wnoutrefresh(input_window);
}
void tui_refresh(void) {
@ -160,11 +172,11 @@ void tui_refresh(void) {
}
entry_line_index = 0;
refresh_input();
update_input();
wrefresh(entry_window);
wmove(entry_window, 0, 0);
wrefresh(main_window);
wnoutrefresh(entry_window);
wnoutrefresh(main_window);
doupdate();
}

View File

@ -19,6 +19,7 @@ extern int deinit_tui(void);
extern void tui_append_back(const entry_t entry);
extern void tui_refresh(void);
extern void tui_rearm(void);
extern void tui_take_input(void);