Compare commits
4
Commits
e65a2ecdb6
...
c68b872d1e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c68b872d1e | ||
|
|
c6ec8c1199 | ||
|
|
230bac4d75 | ||
|
|
e898ec3ba5 |
@@ -84,7 +84,7 @@ static const binding key_binding[] = {
|
||||
{ "G", jump_bottom, NULL, "jump to last file in dir" },
|
||||
{ "gg", jump_top, NULL, "jump to first file in dir" },
|
||||
{ "gh", jump_to_dir, "$HOME", "jump to $HOME" },
|
||||
{ "gs", jump_to_dir, "$START_PATH", "jump to $START_PATH" }, /* the path you started th in */
|
||||
{ "gs", jump_to_dir, "$TH_START_PATH", "jump to $TH_START_PATH" }, /* the path you started th in */
|
||||
{ "gD", jump_to_dir, "$HOME/Downloads", "jump to $HOME/Downloads" },
|
||||
{ "gC", jump_to_dir, "$HOME/Documents", "jump to $HOME/Documents" },
|
||||
{ "gP", jump_to_dir, "$HOME/Pictures", "jump to $HOME/Pictures" },
|
||||
|
||||
+5
-5
@@ -108,14 +108,14 @@ void ueberzug_init(){
|
||||
ueberzug = popen("ueberzug layer -s --no-cache ", "w");
|
||||
#endif
|
||||
}
|
||||
void ueberzug_close(){
|
||||
images_clear();
|
||||
pclose(ueberzug);
|
||||
}
|
||||
#endif
|
||||
void file_preview_init(){
|
||||
cookie_type = magic_open(MAGIC_MIME_TYPE);
|
||||
cookie_description = magic_open(MAGIC_NONE);
|
||||
magic_load(cookie_type, NULL);
|
||||
magic_load(cookie_description, NULL);
|
||||
}
|
||||
void ueberzug_close(){
|
||||
images_clear();
|
||||
pclose(ueberzug);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -133,10 +133,6 @@ int main(){
|
||||
|
||||
void render_pass(){
|
||||
|
||||
if (status & STATUS_UPDATE_SCREEN_CLEAR) {
|
||||
clear();
|
||||
status &= ~STATUS_UPDATE_SCREEN_CLEAR;
|
||||
}
|
||||
if (status & STATUS_UPDATE_SCREEN_RESIZE) {
|
||||
|
||||
wresize(win_t, 1, terminal_width);
|
||||
@@ -151,12 +147,23 @@ void render_pass(){
|
||||
mvwin(win_m, 1, (terminal_width/8));
|
||||
mvwin(win_r, 1, ((terminal_width/2)));
|
||||
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();
|
||||
pthread_mutex_unlock(&mutex_render);
|
||||
}
|
||||
*/
|
||||
}
|
||||
/*this function exists for things done at startup (initialization, reading config, etc)*/
|
||||
void init() {
|
||||
@@ -188,7 +195,7 @@ void init() {
|
||||
ESCDELAY = 10;
|
||||
global_path = getcwd(NULL, 0);
|
||||
char *start_path = getcwd(NULL, 0);
|
||||
setenv("START_PATH", start_path, 0);
|
||||
setenv("TH_START_PATH", start_path, 0);
|
||||
free(start_path);
|
||||
|
||||
seed = time(NULL);
|
||||
|
||||
+32
-23
@@ -120,7 +120,8 @@ void *thread_mid(){
|
||||
} else {
|
||||
print_dir(win_m, 1, &mid_dir);
|
||||
}
|
||||
wnoutrefresh(win_m);
|
||||
/*wnoutrefresh(win_m);*/
|
||||
wrefresh(win_m);
|
||||
pthread_mutex_unlock(&mutex_render);
|
||||
|
||||
|
||||
@@ -182,7 +183,8 @@ void *thread_lft(){
|
||||
pthread_mutex_lock(&mutex_render);
|
||||
werase(win_l);
|
||||
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_lft);
|
||||
@@ -244,7 +246,8 @@ void *thread_rgt(){
|
||||
pthread_mutex_lock(&mutex_render);
|
||||
werase(win_r);
|
||||
print_dir(win_r, 0, &rgt_dir);
|
||||
wnoutrefresh(win_r);
|
||||
/*wnoutrefresh(win_r);*/
|
||||
wrefresh(win_r);
|
||||
pthread_mutex_unlock(&mutex_render);
|
||||
|
||||
} 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) {
|
||||
mvwaddstr(win_r, 0, 0, "not accessible");
|
||||
}
|
||||
wnoutrefresh(win_r);
|
||||
/*wnoutrefresh(win_r);*/
|
||||
wrefresh(win_r);
|
||||
pthread_mutex_unlock(&mutex_render);
|
||||
}
|
||||
}
|
||||
@@ -318,7 +322,8 @@ void *thread_top(){
|
||||
mvwaddnstr(win_t, 0, 0, top_buffer, strlen(global_path)+1);
|
||||
wattroff(win_t, COLOR_PAIR(COLOR_PATH));
|
||||
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);
|
||||
|
||||
|
||||
@@ -332,10 +337,20 @@ void *thread_btm(){
|
||||
unsigned int ui_btm_right_block_size = 0;
|
||||
unsigned int buffer_width = 0;
|
||||
|
||||
|
||||
while(!(status & STATUS_QUIT_PROGRAM)){
|
||||
pthread_mutex_lock(&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)) {
|
||||
/*{{{ 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);
|
||||
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) {
|
||||
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[buffer_width] = '\0';
|
||||
|
||||
|
||||
/* rendering */
|
||||
pthread_mutex_lock(&mutex_render);
|
||||
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);
|
||||
}
|
||||
wnoutrefresh(win_b);
|
||||
|
||||
mvwprintw(win_b, 0, 0, "%s", btm_buffer);
|
||||
|
||||
/*wnoutrefresh(win_b);*/
|
||||
wrefresh(win_b);
|
||||
pthread_mutex_unlock(&mutex_render);
|
||||
pthread_mutex_unlock(&mutex_btm);
|
||||
/*the printing of all possible inputs are done in user_interactions */
|
||||
@@ -453,13 +466,9 @@ void *thread_btm(){
|
||||
|
||||
void threading_init(){
|
||||
|
||||
top_buffer = malloc(sizeof(char));
|
||||
rgt_buffer = malloc(sizeof(char));
|
||||
btm_buffer = malloc(sizeof(char));
|
||||
memset(top_buffer, '\0', sizeof(char));
|
||||
memset(rgt_buffer, '\0', sizeof(char));
|
||||
memset(btm_buffer, '\0', sizeof(char));
|
||||
|
||||
top_buffer = NULL;
|
||||
rgt_buffer = NULL;
|
||||
btm_buffer = NULL;
|
||||
|
||||
pthread_mutex_init(&mutex_top, NULL);
|
||||
pthread_mutex_init(&mutex_mid, NULL);
|
||||
|
||||
Reference in New Issue
Block a user