simplification of thread_top
This commit is contained in:
25
threading.c
25
threading.c
@@ -214,7 +214,6 @@ void *thread_rgt(){
|
||||
|
||||
pthread_mutex_unlock(&mutex_mid);
|
||||
|
||||
werase(win_r);
|
||||
if (rgt_dir.current_file->permissions & S_IRUSR) {
|
||||
if (rgt_dir.current_file->file_type &= FILE_TYPE_DIR) {
|
||||
#if SETTINGS_UEBERZUG_IMAGE_PREVIEW != 0
|
||||
@@ -231,6 +230,7 @@ void *thread_rgt(){
|
||||
rgt_dir.current_file = NULL;
|
||||
}
|
||||
pthread_mutex_lock(&mutex_render);
|
||||
werase(win_r);
|
||||
print_dir(win_r, 0, &rgt_dir);
|
||||
wnoutrefresh(win_r);
|
||||
pthread_mutex_unlock(&mutex_render);
|
||||
@@ -241,6 +241,7 @@ void *thread_rgt(){
|
||||
rgt_buffer = preview_file(rgt_dir.current_file);
|
||||
rgt_dir.current_file->file_type |= FILE_TYPE_OPEN_FILE;
|
||||
pthread_mutex_lock(&mutex_render);
|
||||
werase(win_r);
|
||||
if (rgt_dir.current_file->file_type == FILE_TYPE_OPEN_FILE) {
|
||||
mvwaddnstr(win_r, 0, 0, rgt_buffer, (terminal_width/2) * terminal_width);
|
||||
} else if ((rgt_dir.current_file->permissions & S_IRUSR) == 0) {
|
||||
@@ -281,27 +282,27 @@ void *thread_top(){
|
||||
pthread_mutex_unlock(&mutex_top);
|
||||
continue;
|
||||
}
|
||||
top_buffer = malloc(strlen(global_path)+1);
|
||||
memcpy(top_buffer, global_path, strlen(global_path)+1);
|
||||
|
||||
pthread_mutex_lock(&mutex_mid);
|
||||
|
||||
top_buffer = malloc(strlen(global_path)+1 + strlen(mid_dir.current_file->file_name)+1);
|
||||
memcpy(top_buffer, global_path, strlen(global_path));
|
||||
memcpy(top_buffer + strlen(global_path) + 1, mid_dir.current_file->file_name, strlen(mid_dir.current_file->file_name)+1);
|
||||
|
||||
pthread_mutex_unlock(&mutex_mid);
|
||||
top_buffer[strlen(global_path)] = '/';
|
||||
top_width = strlen(top_buffer);
|
||||
|
||||
|
||||
/* rendering */
|
||||
pthread_mutex_lock(&mutex_mid);
|
||||
pthread_mutex_lock(&mutex_render);
|
||||
werase(win_t);
|
||||
if (*top_buffer != ' ') { /*printing ' ' (standard initialized value, see threading_init) makes valgrind throw a fuss*/
|
||||
wattron(win_t, COLOR_PAIR(COLOR_PATH));
|
||||
mvwaddstr(win_t, 0, 0, top_buffer);
|
||||
mvwaddch(win_t, 0, strlen(top_buffer), '/');
|
||||
mvwaddnstr(win_t, 0, 0, top_buffer, strlen(global_path)+1);
|
||||
wattroff(win_t, COLOR_PAIR(COLOR_PATH));
|
||||
if (mid_dir.file_count != 0 && !(mid_dir.current_file == NULL)) {
|
||||
mvwaddstr(win_t, 0, strlen(top_buffer)+1, mid_dir.current_file->file_name);
|
||||
}
|
||||
}
|
||||
mvwaddstr(win_t, 0, strlen(global_path)+1, top_buffer+strlen(global_path)+1);
|
||||
wnoutrefresh(win_t);
|
||||
pthread_mutex_unlock(&mutex_render);
|
||||
pthread_mutex_unlock(&mutex_mid);
|
||||
|
||||
|
||||
pthread_mutex_unlock(&mutex_top);
|
||||
|
||||
Reference in New Issue
Block a user