resizing code which does not work

This commit is contained in:
anon 2024-09-22 00:11:50 +02:00
parent 8e40ed1445
commit 37fda5ceb4
3 changed files with 43 additions and 10 deletions

View File

@ -1,2 +1,4 @@
+ refreshing can go wrong, characters being left over in what should be open space,
i have no clue how, when or why it happens; seems like something i can live with
+ readline calling `return_input_available()` will SIGILL in debug builds;
as far as im aware, its gcc 13 being retarded on nested functions

View File

@ -1,2 +1,4 @@
+ resizing
+ resizing -- i added the code, the case seem to never execute;
i have no clue why, and not being able to create debug builds is not helping,
this will have to wait until gcc gets fixed
+ unicode support in the tui

View File

@ -52,6 +52,9 @@ static int input;
//
static inline void update_input(void);
static void full_redraw(void);
static void resize(void);
static inline void init_windows();
static inline void deinit_windows();
static bool do_fullredraw = true;
@ -64,13 +67,7 @@ int init_tui(void) {
curs_set(0);
keypad(stdscr, TRUE);
entry_lines = LINES-3;
main_window = newwin(LINES-1, COLS, 0, 0);
input_window = newwin( 1, COLS, LINES-1, 0);
entry_window = subwin(main_window, entry_lines, COLS-2, 1, 1);
version_window = subwin(main_window, 1, strlen(version_string), 0, 5);
refresh();
init_windows();
// Readline
rl_bind_key('\t', rl_insert);
@ -108,6 +105,7 @@ int init_tui(void) {
}
int deinit_tui(void) {
deinit_windows();
endwin();
return 0;
}
@ -145,6 +143,25 @@ void tui_append_back(const entry_t entry) {
++entry_line_index;
}
static inline
void init_windows() {
entry_lines = LINES-3;
main_window = newwin(LINES-1, COLS, 0, 0);
input_window = newwin( 1, COLS, LINES-1, 0);
entry_window = subwin(main_window, entry_lines, COLS-2, 1, 1);
version_window = subwin(main_window, 1, strlen(version_string), 0, 5);
refresh();
}
static inline
void deinit_windows() {
delwin(entry_window);
delwin(version_window);
delwin(main_window);
delwin(input_window);
}
static
void full_redraw(void) {
box(main_window, 0, 0);
@ -157,8 +174,11 @@ void full_redraw(void) {
doupdate();
}
void tui_rearm() {
entry_line_index = 0;
static
void resize(void) {
deinit_windows();
init_windows();
full_redraw();
}
static inline
@ -184,6 +204,10 @@ void update_input() {
wnoutrefresh(input_window);
}
void tui_rearm() {
entry_line_index = 0;
}
void tui_refresh(void) {
// XXX: this is dirty
if (selection_relative > last_entry_line_index-1) {
@ -212,6 +236,7 @@ void tui_refresh(void) {
doupdate();
}
#include <stdlib.h>
void tui_take_input(void) {
extern bool do_run;
@ -286,6 +311,10 @@ void tui_take_input(void) {
case '\r': {
do_run = false;
} break;
case KEY_RESIZE: {
//flushinp();
resize();
} break;
case ERR: break;
default: {
input_available = true;