propper input handling
This commit is contained in:
15
main.c
15
main.c
@ -17,8 +17,6 @@ unsigned int temp_width = 0;
|
||||
unsigned int settings;
|
||||
unsigned int file_modifiers;
|
||||
unsigned int status;
|
||||
unsigned int timeout_time = 0;
|
||||
char input = 0;
|
||||
|
||||
WINDOW *win_t;
|
||||
WINDOW *win_b;
|
||||
@ -26,6 +24,7 @@ WINDOW *win_l;
|
||||
WINDOW *win_m;
|
||||
WINDOW *win_r;
|
||||
|
||||
char *input; /*used in user_interactions*/
|
||||
|
||||
void render_pass();
|
||||
void init();
|
||||
@ -82,13 +81,7 @@ int main(){
|
||||
status &= ~(STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||
status |= STATUS_UPDATE_SCREEN_0;
|
||||
}
|
||||
if ((input = getch())) {
|
||||
user_interactions(&input, win_b);
|
||||
timeout_time = 5;
|
||||
} else {
|
||||
timeout_time += 10;
|
||||
}
|
||||
timeout(timeout_time); /* blocking timeout of getch() */
|
||||
user_interactions();
|
||||
|
||||
|
||||
render_pass();
|
||||
@ -169,11 +162,13 @@ void init() {
|
||||
|
||||
initscr(); /* start ncurses */
|
||||
noecho(); /* hide keyboard input */
|
||||
timeout(timeout_time); /* blocking timeout of getch() */
|
||||
timeout(0); /* blocking timeout of getch() */
|
||||
keypad(stdscr, TRUE);
|
||||
curs_set(0);
|
||||
|
||||
/*file_modifiers = (FILE_MODIFIERS_HIDDEN_FILES | FILE_MODIFIERS_SORT_BITMASK);*/
|
||||
input = malloc(sizeof(char)*255); /* size of input buffer, out of bounds access will not be accounted for */
|
||||
memset(input, 0, 255);
|
||||
status = (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY);
|
||||
if (getuid() == 0) {
|
||||
status += STATUS_USER_ROOT;
|
||||
|
Reference in New Issue
Block a user