removed the need for a second input pass by making window global
This commit is contained in:
@ -19,26 +19,17 @@ extern file *lft_content;
|
|||||||
extern file *rgt_content;
|
extern file *rgt_content;
|
||||||
extern file file_current;
|
extern file file_current;
|
||||||
|
|
||||||
|
extern WINDOW *win_b;
|
||||||
|
|
||||||
extern char *rgt_buffer;
|
extern char *rgt_buffer;
|
||||||
extern char *btm_buffer;
|
extern char *btm_buffer;
|
||||||
|
|
||||||
extern unsigned int status;
|
extern unsigned int status;
|
||||||
void open_with_pass_2();
|
|
||||||
void rename_hovered_pass_2();
|
|
||||||
int read_string(WINDOW *win, int y, int x, char *str);
|
int read_string(WINDOW *win, int y, int x, char *str);
|
||||||
|
|
||||||
void user_interactions(char *input, WINDOW *win_b) {
|
void user_interactions(char *input, WINDOW *win_b) {
|
||||||
void (*func_ptr)();
|
void (*func_ptr)();
|
||||||
unsigned long i = 0;
|
unsigned long i = 0;
|
||||||
if (status & STATUS_INTERACTIONS_MASK) {
|
|
||||||
if (status & STATUS_INTERACTIONS_OPEN_WITH) {
|
|
||||||
open_with_pass_2(win_b);
|
|
||||||
} else if (status & STATUS_INTERACTIONS_RENAME) {
|
|
||||||
rename_hovered_pass_2(win_b);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
for (i = 0; i < binding_count; i++) {
|
for (i = 0; i < binding_count; i++) {
|
||||||
if (*input == key_binding[i].key[0]) {
|
if (*input == key_binding[i].key[0]) {
|
||||||
func_ptr = key_binding[i].func;
|
func_ptr = key_binding[i].func;
|
||||||
@ -156,9 +147,7 @@ void open_with(){
|
|||||||
btm_buffer = concat(btm_buffer, "\" with:");
|
btm_buffer = concat(btm_buffer, "\" with:");
|
||||||
status |= (STATUS_UPDATE_SCREEN_0 | STATUS_INTERACTIONS_OPEN_WITH);
|
status |= (STATUS_UPDATE_SCREEN_0 | STATUS_INTERACTIONS_OPEN_WITH);
|
||||||
|
|
||||||
}
|
render_pass();
|
||||||
void open_with_pass_2(WINDOW *win_b){
|
|
||||||
|
|
||||||
unsigned long local_width;
|
unsigned long local_width;
|
||||||
unsigned long local_height;
|
unsigned long local_height;
|
||||||
getmaxyx(win_b, local_height, local_width);
|
getmaxyx(win_b, local_height, local_width);
|
||||||
@ -194,9 +183,7 @@ void rename_hovered(){
|
|||||||
btm_buffer = concat(btm_buffer, "\" to:");
|
btm_buffer = concat(btm_buffer, "\" to:");
|
||||||
status |= (STATUS_UPDATE_SCREEN_0 | STATUS_INTERACTIONS_RENAME);
|
status |= (STATUS_UPDATE_SCREEN_0 | STATUS_INTERACTIONS_RENAME);
|
||||||
|
|
||||||
}
|
render_pass();
|
||||||
|
|
||||||
void rename_hovered_pass_2(WINDOW *win_b){
|
|
||||||
|
|
||||||
unsigned long local_width;
|
unsigned long local_width;
|
||||||
unsigned long local_height;
|
unsigned long local_height;
|
||||||
@ -225,3 +212,4 @@ void rename_hovered_pass_2(WINDOW *win_b){
|
|||||||
|
|
||||||
free(str);
|
free(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
27
main.c
27
main.c
@ -20,8 +20,14 @@ unsigned int status;
|
|||||||
unsigned int timeout_time = 0;
|
unsigned int timeout_time = 0;
|
||||||
char input = 0;
|
char input = 0;
|
||||||
|
|
||||||
|
WINDOW *win_t;
|
||||||
|
WINDOW *win_b;
|
||||||
|
WINDOW *win_l;
|
||||||
|
WINDOW *win_m;
|
||||||
|
WINDOW *win_r;
|
||||||
|
|
||||||
void render_pass(WINDOW *wint, WINDOW *winb, WINDOW *winl, WINDOW *winm, WINDOW *winr);
|
|
||||||
|
void render_pass();
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
|
|
||||||
@ -30,11 +36,16 @@ int main(){
|
|||||||
init();
|
init();
|
||||||
|
|
||||||
getmaxyx(stdscr, terminal_height, terminal_width);
|
getmaxyx(stdscr, terminal_height, terminal_width);
|
||||||
WINDOW *win_t = newwin(1, terminal_width, 0, 0);
|
WINDOW *wint = newwin(1, terminal_width, 0, 0);
|
||||||
WINDOW *win_b = newwin(1, terminal_width, terminal_height-1, 0);
|
WINDOW *winb = newwin(1, terminal_width, terminal_height-1, 0);
|
||||||
WINDOW *win_l = newwin(terminal_height-2, terminal_width/8, 1, 0);
|
WINDOW *winl = newwin(terminal_height-2, terminal_width/8, 1, 0);
|
||||||
WINDOW *win_m = newwin(terminal_height-2, terminal_width/3, 1, (terminal_width/8));
|
WINDOW *winm = newwin(terminal_height-2, terminal_width/3, 1, (terminal_width/8));
|
||||||
WINDOW *win_r = newwin(terminal_height-2, terminal_width/3, 1, ((terminal_width/2)));
|
WINDOW *winr = newwin(terminal_height-2, terminal_width/3, 1, ((terminal_width/2)));
|
||||||
|
win_t = wint;
|
||||||
|
win_b = winb;
|
||||||
|
win_r = winr;
|
||||||
|
win_m = winm;
|
||||||
|
win_l = winl;
|
||||||
|
|
||||||
pthread_t thread_b;
|
pthread_t thread_b;
|
||||||
pthread_t thread_t;
|
pthread_t thread_t;
|
||||||
@ -80,7 +91,7 @@ int main(){
|
|||||||
timeout(timeout_time); /* blocking timeout of getch() */
|
timeout(timeout_time); /* blocking timeout of getch() */
|
||||||
|
|
||||||
|
|
||||||
render_pass(win_t, win_b, win_l, win_m, win_r);
|
render_pass();
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -106,7 +117,7 @@ int main(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void render_pass(WINDOW *win_t, WINDOW *win_b, WINDOW *win_l, WINDOW *win_m, WINDOW *win_r){
|
void render_pass(){
|
||||||
|
|
||||||
if (status & (STATUS_UPDATE_SCREEN_RESIZE | STATUS_INTERACTIONS_MASK)) {
|
if (status & (STATUS_UPDATE_SCREEN_RESIZE | STATUS_INTERACTIONS_MASK)) {
|
||||||
if (status & STATUS_UPDATE_SCREEN_RELOAD_FULL) {
|
if (status & STATUS_UPDATE_SCREEN_RELOAD_FULL) {
|
||||||
|
Reference in New Issue
Block a user