rendering improvements
This commit is contained in:
@@ -133,10 +133,6 @@ int main(){
|
|||||||
|
|
||||||
void render_pass(){
|
void render_pass(){
|
||||||
|
|
||||||
if (status & STATUS_UPDATE_SCREEN_CLEAR) {
|
|
||||||
clear();
|
|
||||||
status &= ~STATUS_UPDATE_SCREEN_CLEAR;
|
|
||||||
}
|
|
||||||
if (status & STATUS_UPDATE_SCREEN_RESIZE) {
|
if (status & STATUS_UPDATE_SCREEN_RESIZE) {
|
||||||
|
|
||||||
wresize(win_t, 1, terminal_width);
|
wresize(win_t, 1, terminal_width);
|
||||||
@@ -151,12 +147,23 @@ void render_pass(){
|
|||||||
mvwin(win_m, 1, (terminal_width/8));
|
mvwin(win_m, 1, (terminal_width/8));
|
||||||
mvwin(win_r, 1, ((terminal_width/2)));
|
mvwin(win_r, 1, ((terminal_width/2)));
|
||||||
mvwin(win_b, terminal_height-1, 0);
|
mvwin(win_b, terminal_height-1, 0);
|
||||||
|
status |= STATUS_UPDATE_SCREEN_CLEAR;
|
||||||
|
status &= ~STATUS_UPDATE_SCREEN_RESIZE;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (pthread_mutex_lock(&mutex_render) == 0) {
|
if (status & STATUS_UPDATE_SCREEN_CLEAR) {
|
||||||
|
clear();
|
||||||
|
pthread_mutex_lock(&mutex_render);
|
||||||
|
refresh();
|
||||||
|
status &= ~STATUS_UPDATE_SCREEN_CLEAR;
|
||||||
|
pthread_mutex_unlock(&mutex_render);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
if (pthread_mutex_trylock(&mutex_render) == 0) {
|
||||||
doupdate();
|
doupdate();
|
||||||
pthread_mutex_unlock(&mutex_render);
|
pthread_mutex_unlock(&mutex_render);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
/*this function exists for things done at startup (initialization, reading config, etc)*/
|
/*this function exists for things done at startup (initialization, reading config, etc)*/
|
||||||
void init() {
|
void init() {
|
||||||
|
|||||||
+29
-16
@@ -120,7 +120,8 @@ void *thread_mid(){
|
|||||||
} else {
|
} else {
|
||||||
print_dir(win_m, 1, &mid_dir);
|
print_dir(win_m, 1, &mid_dir);
|
||||||
}
|
}
|
||||||
wnoutrefresh(win_m);
|
/*wnoutrefresh(win_m);*/
|
||||||
|
wrefresh(win_m);
|
||||||
pthread_mutex_unlock(&mutex_render);
|
pthread_mutex_unlock(&mutex_render);
|
||||||
|
|
||||||
|
|
||||||
@@ -182,7 +183,8 @@ void *thread_lft(){
|
|||||||
pthread_mutex_lock(&mutex_render);
|
pthread_mutex_lock(&mutex_render);
|
||||||
werase(win_l);
|
werase(win_l);
|
||||||
print_dir(win_l, 0, &lft_dir);
|
print_dir(win_l, 0, &lft_dir);
|
||||||
wnoutrefresh(win_l);
|
/*wnoutrefresh(win_l);*/
|
||||||
|
wrefresh(win_l);
|
||||||
pthread_mutex_unlock(&mutex_render);
|
pthread_mutex_unlock(&mutex_render);
|
||||||
|
|
||||||
pthread_mutex_unlock(&mutex_lft);
|
pthread_mutex_unlock(&mutex_lft);
|
||||||
@@ -244,7 +246,8 @@ void *thread_rgt(){
|
|||||||
pthread_mutex_lock(&mutex_render);
|
pthread_mutex_lock(&mutex_render);
|
||||||
werase(win_r);
|
werase(win_r);
|
||||||
print_dir(win_r, 0, &rgt_dir);
|
print_dir(win_r, 0, &rgt_dir);
|
||||||
wnoutrefresh(win_r);
|
/*wnoutrefresh(win_r);*/
|
||||||
|
wrefresh(win_r);
|
||||||
pthread_mutex_unlock(&mutex_render);
|
pthread_mutex_unlock(&mutex_render);
|
||||||
|
|
||||||
} else if ((status & STATUS_DELTA_TIME) != STATUS_DELTA_TIME && rgt_dir.file_count > 0) {
|
} else if ((status & STATUS_DELTA_TIME) != STATUS_DELTA_TIME && rgt_dir.file_count > 0) {
|
||||||
@@ -259,7 +262,8 @@ void *thread_rgt(){
|
|||||||
} else if ((rgt_dir.current_file->permissions & S_IRUSR) == 0) {
|
} else if ((rgt_dir.current_file->permissions & S_IRUSR) == 0) {
|
||||||
mvwaddstr(win_r, 0, 0, "not accessible");
|
mvwaddstr(win_r, 0, 0, "not accessible");
|
||||||
}
|
}
|
||||||
wnoutrefresh(win_r);
|
/*wnoutrefresh(win_r);*/
|
||||||
|
wrefresh(win_r);
|
||||||
pthread_mutex_unlock(&mutex_render);
|
pthread_mutex_unlock(&mutex_render);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -318,7 +322,8 @@ void *thread_top(){
|
|||||||
mvwaddnstr(win_t, 0, 0, top_buffer, strlen(global_path)+1);
|
mvwaddnstr(win_t, 0, 0, top_buffer, strlen(global_path)+1);
|
||||||
wattroff(win_t, COLOR_PAIR(COLOR_PATH));
|
wattroff(win_t, COLOR_PAIR(COLOR_PATH));
|
||||||
mvwaddstr(win_t, 0, strlen(global_path)+1, top_buffer+strlen(global_path)+1);
|
mvwaddstr(win_t, 0, strlen(global_path)+1, top_buffer+strlen(global_path)+1);
|
||||||
wnoutrefresh(win_t);
|
/*wnoutrefresh(win_t);*/
|
||||||
|
wrefresh(win_t);
|
||||||
pthread_mutex_unlock(&mutex_render);
|
pthread_mutex_unlock(&mutex_render);
|
||||||
|
|
||||||
|
|
||||||
@@ -332,10 +337,20 @@ void *thread_btm(){
|
|||||||
unsigned int ui_btm_right_block_size = 0;
|
unsigned int ui_btm_right_block_size = 0;
|
||||||
unsigned int buffer_width = 0;
|
unsigned int buffer_width = 0;
|
||||||
|
|
||||||
|
|
||||||
while(!(status & STATUS_QUIT_PROGRAM)){
|
while(!(status & STATUS_QUIT_PROGRAM)){
|
||||||
pthread_mutex_lock(&mutex_btm);
|
pthread_mutex_lock(&mutex_btm);
|
||||||
pthread_cond_wait(&cond_btm, &mutex_btm);
|
pthread_cond_wait(&cond_btm, &mutex_btm);
|
||||||
|
|
||||||
|
if (buffer_width != terminal_width) {
|
||||||
|
buffer_width = terminal_width;
|
||||||
|
if (terminal_width < 10) { buffer_width = 10; }
|
||||||
|
|
||||||
|
free(btm_buffer);
|
||||||
|
btm_buffer = malloc(buffer_width+1);
|
||||||
|
/*in this case STATUS_RUN_BACKEND should be true as defined in the main loop resize check*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (status & (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY)) {
|
if (status & (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY)) {
|
||||||
/*{{{ parse storage info; the fold of shame*/
|
/*{{{ parse storage info; the fold of shame*/
|
||||||
@@ -408,15 +423,11 @@ void *thread_btm(){
|
|||||||
/*}}}*/
|
/*}}}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer_width != terminal_width) {
|
|
||||||
buffer_width = terminal_width;
|
|
||||||
free(btm_buffer);
|
|
||||||
btm_buffer = malloc(buffer_width+1);
|
|
||||||
}
|
|
||||||
memset(btm_buffer, ' ', buffer_width);
|
memset(btm_buffer, ' ', buffer_width);
|
||||||
btm_buffer[buffer_width] = '\0';
|
|
||||||
|
|
||||||
memcpy(btm_buffer + buffer_width - ui_btm_right_block_size, ui_btm_right_block, ui_btm_right_block_size);
|
if (ui_btm_right_block_size + 9 < buffer_width) {
|
||||||
|
memcpy(btm_buffer + buffer_width - ui_btm_right_block_size, ui_btm_right_block, ui_btm_right_block_size);
|
||||||
|
}
|
||||||
|
|
||||||
if (mid_dir.current_file != NULL) {
|
if (mid_dir.current_file != NULL) {
|
||||||
btm_buffer[0] = (S_ISLNK(mid_dir.current_file->permissions)) ? 'l':
|
btm_buffer[0] = (S_ISLNK(mid_dir.current_file->permissions)) ? 'l':
|
||||||
@@ -432,15 +443,17 @@ void *thread_btm(){
|
|||||||
btm_buffer[9] = (mid_dir.current_file->permissions & S_IXOTH) ? 'x' : '-';
|
btm_buffer[9] = (mid_dir.current_file->permissions & S_IXOTH) ? 'x' : '-';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
btm_buffer[buffer_width] = '\0';
|
||||||
|
|
||||||
|
|
||||||
/* rendering */
|
/* rendering */
|
||||||
pthread_mutex_lock(&mutex_render);
|
pthread_mutex_lock(&mutex_render);
|
||||||
werase(win_b);
|
werase(win_b);
|
||||||
if (*top_buffer != ' ') { /*printing ' ' (standard initialized value, see threading_init) makes valgrind throw a fuss*/
|
|
||||||
mvwprintw(win_b, 0, 0, "%s", btm_buffer);
|
mvwprintw(win_b, 0, 0, "%s", btm_buffer);
|
||||||
}
|
|
||||||
wnoutrefresh(win_b);
|
/*wnoutrefresh(win_b);*/
|
||||||
|
wrefresh(win_b);
|
||||||
pthread_mutex_unlock(&mutex_render);
|
pthread_mutex_unlock(&mutex_render);
|
||||||
pthread_mutex_unlock(&mutex_btm);
|
pthread_mutex_unlock(&mutex_btm);
|
||||||
/*the printing of all possible inputs are done in user_interactions */
|
/*the printing of all possible inputs are done in user_interactions */
|
||||||
|
|||||||
Reference in New Issue
Block a user