From aedfdd1ed58d7ca82643753cd147e5da9fdd3969 Mon Sep 17 00:00:00 2001 From: nova Date: Thu, 26 Jun 2025 23:52:04 +0200 Subject: [PATCH] window sizing now possible in interaction functions --- defines.h | 3 --- interactions.c | 17 +++++++++++++---- main.c | 14 +++----------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/defines.h b/defines.h index e132635..bdca937 100644 --- a/defines.h +++ b/defines.h @@ -7,9 +7,6 @@ #define STATUS_UPDATE_SCREEN_RESIZE 16 #define STATUS_UPDATE_SCREEN_RELOAD_FULL 32 #define STATUS_USER_ROOT 64 -#define STATUS_INTERACTIONS_MASK 384 -#define STATUS_INTERACTIONS_OPEN_WITH 128 -#define STATUS_INTERACTIONS_RENAME 256 #define SETTINGS_HAS_COLOR 1 diff --git a/interactions.c b/interactions.c index 694da7b..de9e2b5 100644 --- a/interactions.c +++ b/interactions.c @@ -19,6 +19,9 @@ extern file *lft_content; extern file *rgt_content; extern file file_current; +extern unsigned int terminal_height; +extern unsigned int terminal_width; + extern WINDOW *win_b; extern char *rgt_buffer; @@ -145,7 +148,11 @@ int read_string(WINDOW *win, int y, int x, char *str){ void open_with(){ btm_buffer = concat("open \"", file_current.file_name); btm_buffer = concat(btm_buffer, "\" with:"); - status |= (STATUS_UPDATE_SCREEN_0 | STATUS_INTERACTIONS_OPEN_WITH); + + status = STATUS_UPDATE_SCREEN_0; + werase(win_b); + mvwin(win_b, terminal_height-6, 0); + wresize(win_b, 5, terminal_width/3); /*the div3 just looks cool*/ render_pass(); unsigned long local_width; @@ -171,7 +178,6 @@ void open_with(){ } - status &= ~(STATUS_INTERACTIONS_MASK); status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL); free(str); @@ -181,7 +187,11 @@ void rename_hovered(){ btm_buffer = concat("rename \"", file_current.file_name); btm_buffer = concat(btm_buffer, "\" to:"); - status |= (STATUS_UPDATE_SCREEN_0 | STATUS_INTERACTIONS_RENAME); + + status = STATUS_UPDATE_SCREEN_0; + werase(win_b); + mvwin(win_b, terminal_height-6, 0); + wresize(win_b, 5, terminal_width/3); /*the div3 just looks cool*/ render_pass(); @@ -205,7 +215,6 @@ void rename_hovered(){ btm_buffer = cmd; } - status &= ~(STATUS_INTERACTIONS_MASK); status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL); free(btm_buffer); diff --git a/main.c b/main.c index 3d9b2e0..00684d0 100644 --- a/main.c +++ b/main.c @@ -119,7 +119,7 @@ int main(){ void render_pass(){ - if (status & (STATUS_UPDATE_SCREEN_RESIZE | STATUS_INTERACTIONS_MASK)) { + if (status & STATUS_UPDATE_SCREEN_RESIZE) { if (status & STATUS_UPDATE_SCREEN_RELOAD_FULL) { clear(); status &= ~STATUS_UPDATE_SCREEN_RELOAD_FULL; @@ -137,22 +137,14 @@ void render_pass(){ wresize(win_l, terminal_height-2, terminal_width/8); wresize(win_m, terminal_height-2, (terminal_width/2)-(terminal_width/8)); wresize(win_r, terminal_height-2, terminal_width/2); - if(status & STATUS_INTERACTIONS_MASK) { - wresize(win_b, 5, terminal_width/3); /*the div3 just looks cool*/ - } else { - wresize(win_b, 1, terminal_width); - } + wresize(win_b, 1, terminal_width); mvwin(win_t, 0, 0); mvwin(win_l, 1, 0); mvwin(win_m, 1, (terminal_width/8)); mvwin(win_r, 1, ((terminal_width/2))); - if(status & STATUS_INTERACTIONS_MASK) { - mvwin(win_b, terminal_height-6, 0); - } else { - mvwin(win_b, terminal_height-1, 0); - } + mvwin(win_b, terminal_height-1, 0); status |= STATUS_UPDATE_SCREEN_0;