Compare commits
8
Commits
56d2f9d5d0
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
267518fe3a | ||
|
|
89c3f88a34 | ||
|
|
6d1c9c95ac | ||
|
|
06c00a0924 | ||
|
|
b30229b770 | ||
|
|
f7589dbe2b | ||
|
|
25c912069a | ||
|
|
24fe4a4aa4 |
@@ -129,6 +129,7 @@ static const char ui_rename_text[] = "rename "SETTINGS_COMMAND_REPLACE_STR" to:"
|
|||||||
static const char ui_makefile_text[] = "makedir:";
|
static const char ui_makefile_text[] = "makedir:";
|
||||||
static const char ui_makedir_text[] = "makefile:";
|
static const char ui_makedir_text[] = "makefile:";
|
||||||
static const char ui_delete_text[] = "delete:";
|
static const char ui_delete_text[] = "delete:";
|
||||||
|
static const char ui_search_text[] = "/"; /*unlike the other ui, this one doesnt automatically add a space*/
|
||||||
|
|
||||||
/* {{{ */
|
/* {{{ */
|
||||||
static const unsigned long binding_count = sizeof(key_binding) / sizeof(binding);
|
static const unsigned long binding_count = sizeof(key_binding) / sizeof(binding);
|
||||||
@@ -156,6 +157,7 @@ static const char ui_delete_text[];
|
|||||||
static const char copy_cmd[];
|
static const char copy_cmd[];
|
||||||
static const char cut_cmd[];
|
static const char cut_cmd[];
|
||||||
static const char del_cmd[];
|
static const char del_cmd[];
|
||||||
|
static const char ui_search_text[];
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|||||||
+3
-3
@@ -12,6 +12,7 @@ static FILE *ueberzug = NULL;
|
|||||||
#endif
|
#endif
|
||||||
extern unsigned int terminal_height;
|
extern unsigned int terminal_height;
|
||||||
extern unsigned int terminal_width;
|
extern unsigned int terminal_width;
|
||||||
|
extern char *global_path;
|
||||||
char previewd;
|
char previewd;
|
||||||
magic_t cookie_type;
|
magic_t cookie_type;
|
||||||
magic_t cookie_description;
|
magic_t cookie_description;
|
||||||
@@ -89,17 +90,16 @@ void images_clear(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void images_print(char *file_name){
|
void images_print(char *file_name){
|
||||||
char *path=getcwd(NULL, 0);
|
|
||||||
|
|
||||||
fprintf(ueberzug, "{\"action\":\"add\", \
|
fprintf(ueberzug, "{\"action\":\"add\", \
|
||||||
\"identifier\":\"preview\", \
|
\"identifier\":\"preview\", \
|
||||||
|
\"scaler\":\"fit_contain\", \
|
||||||
\"max_height\":%d, \
|
\"max_height\":%d, \
|
||||||
\"max_width\":%d, \
|
\"max_width\":%d, \
|
||||||
\"y\":0, \
|
\"y\":0, \
|
||||||
\"x\":%d, \
|
\"x\":%d, \
|
||||||
\"path\":\"%s/%s\"}\n", terminal_height, terminal_width/2, terminal_width/2, path, file_name);
|
\"path\":\"%s/%s\"}\n", terminal_height, terminal_width/2, terminal_width/2, global_path, file_name);
|
||||||
fflush(ueberzug);
|
fflush(ueberzug);
|
||||||
free(path);
|
|
||||||
}
|
}
|
||||||
void ueberzug_init(){
|
void ueberzug_init(){
|
||||||
#if SETTINGS_UEBERZUG_IMAGE_PREVIEW == 2
|
#if SETTINGS_UEBERZUG_IMAGE_PREVIEW == 2
|
||||||
|
|||||||
+70
-64
@@ -53,13 +53,16 @@ void user_interactions() {
|
|||||||
|
|
||||||
|
|
||||||
ch = getch();
|
ch = getch();
|
||||||
if(ch != ERR) {
|
if(ch != (char)ERR) {
|
||||||
input[input_pass] = ch;
|
input[input_pass] = ch;
|
||||||
input_pass++;
|
input_pass++;
|
||||||
if (ch == 27) { /* esc key */
|
if (ch == 27) { /* esc key */
|
||||||
memset(input, 0, INPUT_BUFFER_SIZE);
|
memset(input, 0, INPUT_BUFFER_SIZE);
|
||||||
input_pass = 0;
|
input_pass = 0;
|
||||||
}
|
}
|
||||||
|
if (input_pass >= INPUT_BUFFER_SIZE) {
|
||||||
|
input_pass = INPUT_BUFFER_SIZE - 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -119,43 +122,50 @@ void user_interactions() {
|
|||||||
binding_matches = 0;
|
binding_matches = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int read_string(WINDOW *win, int y, int x, char *str){
|
char read_string_loop(WINDOW *win, char *buffer, char *nullable_return_char, unsigned long *pass, unsigned long y, unsigned long x) {
|
||||||
curs_set(1);
|
char ch = wgetch(win_b);
|
||||||
|
|
||||||
timeout(-1); /* negative numbers block until enter is pressed */
|
if (nullable_return_char != NULL) {
|
||||||
|
*nullable_return_char = 0;
|
||||||
unsigned int pass = 0;
|
}
|
||||||
char ch;
|
if (ch == '\n' ) {
|
||||||
char err = 0;
|
buffer[*pass] = 0;
|
||||||
|
return 1;
|
||||||
wmove(win, y, x);
|
} else if ( ch == 27 /* esc key */) {
|
||||||
while(1) {
|
buffer[*pass] = 0;
|
||||||
ch = wgetch(win);
|
return 2;
|
||||||
if (ch == '\n') {
|
|
||||||
break;
|
|
||||||
} else if (ch == 27) { /* esc key */
|
|
||||||
err = 1;
|
|
||||||
break;
|
|
||||||
} else if (ch == '\t') { /* tab */
|
} else if (ch == '\t') { /* tab */
|
||||||
memcpy(str + pass, mid_dir.current_file->file_name, strlen(mid_dir.current_file->file_name));
|
memcpy(buffer + *pass, mid_dir.current_file->file_name, strlen(mid_dir.current_file->file_name));
|
||||||
mvwaddstr(win, y, x + pass, mid_dir.current_file->file_name);
|
mvwaddstr(win_b, 0, x+ *pass, mid_dir.current_file->file_name);
|
||||||
pass += strlen(mid_dir.current_file->file_name);
|
*pass += strlen(mid_dir.current_file->file_name);
|
||||||
} else if (ch == 127) { /* backspace */
|
} else if (ch == 127) { /* backspace */
|
||||||
if (pass > 0) {
|
if (*pass > 0) {
|
||||||
pass--;
|
unsigned long i = x;
|
||||||
mvwdelch(win, y, x + pass);
|
while (i < terminal_width) {
|
||||||
|
mvwaddch(win, y, i, ' ');
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
} else {
|
*pass -= 1;
|
||||||
mvwaddch(win, y, x + pass, ch);
|
buffer[*pass] = 0;
|
||||||
str[pass] = ch;
|
mvwaddstr(win, y, x, buffer);
|
||||||
pass++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
str[pass] = '\0';
|
|
||||||
|
|
||||||
curs_set(0);
|
}
|
||||||
|
} else if (ch) {
|
||||||
|
if (nullable_return_char != NULL) {
|
||||||
|
*nullable_return_char = ch;
|
||||||
|
}
|
||||||
|
|
||||||
return err;
|
mvwaddch(win_b, 0, x + *pass, ch);
|
||||||
|
buffer[*pass] = ch;
|
||||||
|
*pass += 1;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
if (*pass >= INPUT_BUFFER_SIZE) {
|
||||||
|
*pass = INPUT_BUFFER_SIZE - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
void quit_program(){
|
void quit_program(){
|
||||||
status = STATUS_QUIT_PROGRAM;
|
status = STATUS_QUIT_PROGRAM;
|
||||||
@@ -320,8 +330,13 @@ void open_with(){
|
|||||||
char *str = malloc(INPUT_BUFFER_SIZE);
|
char *str = malloc(INPUT_BUFFER_SIZE);
|
||||||
char *parsed_ui_text = parse_cmd(ui_open_with_text, mid_dir.current_file->file_name);
|
char *parsed_ui_text = parse_cmd(ui_open_with_text, mid_dir.current_file->file_name);
|
||||||
mvwprintw(win_b, 0, 0, parsed_ui_text);
|
mvwprintw(win_b, 0, 0, parsed_ui_text);
|
||||||
|
unsigned long pass = 0;
|
||||||
|
char ret;
|
||||||
|
|
||||||
if (read_string(win_b, 0, strlen(parsed_ui_text)+1, str) == 0) {
|
while ((ret = read_string_loop(win_b, str, NULL, &pass, 0, strlen(parsed_ui_text)+1)) == 0) {
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret == 1) {
|
||||||
if (str[0] == SETTINGS_COMMAND_FORK) {
|
if (str[0] == SETTINGS_COMMAND_FORK) {
|
||||||
cmd = parse_cmd(str+1, mid_dir.current_file->file_name);
|
cmd = parse_cmd(str+1, mid_dir.current_file->file_name);
|
||||||
pid_t pid = fork();
|
pid_t pid = fork();
|
||||||
@@ -336,6 +351,7 @@ void open_with(){
|
|||||||
}
|
}
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(parsed_ui_text);
|
free(parsed_ui_text);
|
||||||
free(str);
|
free(str);
|
||||||
|
|
||||||
@@ -346,8 +362,12 @@ void rename_hovered(){
|
|||||||
char *new_file_name = malloc(INPUT_BUFFER_SIZE);
|
char *new_file_name = malloc(INPUT_BUFFER_SIZE);
|
||||||
char *parsed_ui_text = parse_cmd(ui_rename_text, mid_dir.current_file->file_name);
|
char *parsed_ui_text = parse_cmd(ui_rename_text, mid_dir.current_file->file_name);
|
||||||
mvwprintw(win_b, 0, 0, parsed_ui_text);
|
mvwprintw(win_b, 0, 0, parsed_ui_text);
|
||||||
|
unsigned long pass = 0;
|
||||||
|
char ret;
|
||||||
|
|
||||||
if (read_string(win_b, 0, strlen(parsed_ui_text)+1, new_file_name) == 0) {
|
while ((ret = read_string_loop(win_b, new_file_name, NULL, &pass, 0, strlen(parsed_ui_text)+1)) == 0) {
|
||||||
|
}
|
||||||
|
if (ret == 1) {
|
||||||
char *cmd0 = parse_cmd(rename_cmd, mid_dir.current_file->file_name);
|
char *cmd0 = parse_cmd(rename_cmd, mid_dir.current_file->file_name);
|
||||||
char *cmd1 = parse_cmd(cmd0, new_file_name);
|
char *cmd1 = parse_cmd(cmd0, new_file_name);
|
||||||
ignore_return(system(cmd1));
|
ignore_return(system(cmd1));
|
||||||
@@ -393,7 +413,11 @@ void makedir(){
|
|||||||
wclear(win_b);
|
wclear(win_b);
|
||||||
char *file_name = malloc(INPUT_BUFFER_SIZE);
|
char *file_name = malloc(INPUT_BUFFER_SIZE);
|
||||||
mvwprintw(win_b, 0, 0, ui_makedir_text);
|
mvwprintw(win_b, 0, 0, ui_makedir_text);
|
||||||
if (read_string(win_b, 0, strlen(ui_makedir_text)+1, file_name) == 0) {
|
unsigned long pass = 0;
|
||||||
|
char ret;
|
||||||
|
while ((ret = read_string_loop(win_b, file_name, NULL, &pass, 0, strlen(ui_makedir_text)+1)) == 0) {
|
||||||
|
}
|
||||||
|
if (ret == 1) {
|
||||||
char *cmd = parse_cmd(makedir_cmd, file_name);
|
char *cmd = parse_cmd(makedir_cmd, file_name);
|
||||||
ignore_return(system(cmd));
|
ignore_return(system(cmd));
|
||||||
free(cmd);
|
free(cmd);
|
||||||
@@ -406,7 +430,11 @@ void makefile(){
|
|||||||
wclear(win_b);
|
wclear(win_b);
|
||||||
char *file_name = malloc(INPUT_BUFFER_SIZE);
|
char *file_name = malloc(INPUT_BUFFER_SIZE);
|
||||||
mvwprintw(win_b, 0, 0, ui_makefile_text);
|
mvwprintw(win_b, 0, 0, ui_makefile_text);
|
||||||
if (read_string(win_b, 0, strlen(ui_makefile_text)+1, file_name) == 0) {
|
unsigned long pass = 0;
|
||||||
|
char ret;
|
||||||
|
while ((ret = read_string_loop(win_b, file_name, NULL, &pass, 0, strlen(ui_makefile_text)+1)) == 0) {
|
||||||
|
}
|
||||||
|
if (ret == 1) {
|
||||||
char *cmd = parse_cmd(makefile_cmd, file_name);
|
char *cmd = parse_cmd(makefile_cmd, file_name);
|
||||||
ignore_return(system(cmd));
|
ignore_return(system(cmd));
|
||||||
free(cmd);
|
free(cmd);
|
||||||
@@ -596,7 +624,7 @@ void search(){
|
|||||||
for (i = 0; i < terminal_width -1; i++) {
|
for (i = 0; i < terminal_width -1; i++) {
|
||||||
mvwaddch(win_b, 0, i, ' ');
|
mvwaddch(win_b, 0, i, ' ');
|
||||||
}
|
}
|
||||||
mvwaddch(win_b, 0, 0, '/');
|
mvwaddstr(win_b, 0, 0, ui_search_text);
|
||||||
memset(search_buffer, 0, INPUT_BUFFER_SIZE);
|
memset(search_buffer, 0, INPUT_BUFFER_SIZE);
|
||||||
|
|
||||||
curs_set(1);
|
curs_set(1);
|
||||||
@@ -604,33 +632,12 @@ void search(){
|
|||||||
|
|
||||||
timeout(-1); /* negative numbers block until enter is pressed */
|
timeout(-1); /* negative numbers block until enter is pressed */
|
||||||
|
|
||||||
unsigned int pass = 0;
|
unsigned long pass = 0;
|
||||||
char ch;
|
char ch;
|
||||||
|
|
||||||
wmove(win_b, 0, 1);
|
while (read_string_loop(win_b, search_buffer, &ch, &pass, 0, strlen(ui_search_text)) == 0) {
|
||||||
while(1) {
|
|
||||||
ch = wgetch(win_b);
|
|
||||||
if (ch == '\n' || ch == 27 /* esc key */) {
|
|
||||||
/* unlike the other uses of a read string reimplementation,
|
|
||||||
* here we do not differentiate between accepting and cancle.
|
|
||||||
* this is intentional */
|
|
||||||
break;
|
|
||||||
} else if (ch == '\t') { /* tab */
|
|
||||||
memcpy(search_buffer + pass, mid_dir.current_file->file_name, strlen(mid_dir.current_file->file_name));
|
|
||||||
mvwaddstr(win_b, 0, pass+1, mid_dir.current_file->file_name);
|
|
||||||
pass += strlen(mid_dir.current_file->file_name);
|
|
||||||
} else if (ch == 127) { /* backspace */
|
|
||||||
if (pass > 0) {
|
|
||||||
pass--;
|
|
||||||
mvwdelch(win_b, 0, pass+1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ch) {
|
if (ch) {
|
||||||
mvwaddch(win_b, 0, pass+1, ch);
|
unsigned long index = 0;
|
||||||
search_buffer[pass] = ch;
|
|
||||||
pass++;
|
|
||||||
|
|
||||||
unsigned long index = (mid_dir.current_file - mid_dir.file_list);
|
|
||||||
for (; &mid_dir.file_list[index] < mid_dir.file_list + mid_dir.file_count; index++) {
|
for (; &mid_dir.file_list[index] < mid_dir.file_list + mid_dir.file_count; index++) {
|
||||||
if (smartstrcasestr(mid_dir.file_list[index].file_name, search_buffer)) {
|
if (smartstrcasestr(mid_dir.file_list[index].file_name, search_buffer)) {
|
||||||
mid_dir.current_file = &mid_dir.file_list[index];
|
mid_dir.current_file = &mid_dir.file_list[index];
|
||||||
@@ -641,15 +648,14 @@ void search(){
|
|||||||
werase(win_m);
|
werase(win_m);
|
||||||
print_dir(win_m, 1, &mid_dir);
|
print_dir(win_m, 1, &mid_dir);
|
||||||
|
|
||||||
wnoutrefresh(win_m);
|
wrefresh(win_m);
|
||||||
|
|
||||||
pthread_mutex_unlock(&mutex_render);
|
pthread_mutex_unlock(&mutex_render);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
search_buffer[pass] = '\0';
|
|
||||||
|
|
||||||
noecho();
|
noecho();
|
||||||
curs_set(0);
|
curs_set(0);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ int sort_natural(const void *file0, const void *file1){
|
|||||||
long parsed_number0 = 0;
|
long parsed_number0 = 0;
|
||||||
long parsed_number1 = 0;
|
long parsed_number1 = 0;
|
||||||
char is_num = 0;
|
char is_num = 0;
|
||||||
char result = 0;
|
signed char result = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
|
||||||
|
|||||||
+38
-46
@@ -31,7 +31,6 @@ dir mid_dir;
|
|||||||
dir lft_dir;
|
dir lft_dir;
|
||||||
char *rgt_buffer; /* used for file previews, unlike rgt_content, which is used for directory previews */
|
char *rgt_buffer; /* used for file previews, unlike rgt_content, which is used for directory previews */
|
||||||
char *btm_buffer;
|
char *btm_buffer;
|
||||||
char *top_buffer; /* current path */
|
|
||||||
|
|
||||||
extern WINDOW *win_t;
|
extern WINDOW *win_t;
|
||||||
extern WINDOW *win_b;
|
extern WINDOW *win_b;
|
||||||
@@ -52,10 +51,7 @@ unsigned int btm_status;
|
|||||||
|
|
||||||
|
|
||||||
void *thread_mid(){
|
void *thread_mid(){
|
||||||
dir tmp;
|
dir previous_dir_state = { 0 };
|
||||||
tmp.current_file = NULL;
|
|
||||||
tmp.file_list = NULL;
|
|
||||||
tmp.file_count = 0;
|
|
||||||
|
|
||||||
while(!(status & STATUS_QUIT_PROGRAM)){
|
while(!(status & STATUS_QUIT_PROGRAM)){
|
||||||
|
|
||||||
@@ -75,7 +71,7 @@ void *thread_mid(){
|
|||||||
if (status & STATUS_RELOAD_DIRECTORY) {
|
if (status & STATUS_RELOAD_DIRECTORY) {
|
||||||
long index = mid_dir.current_file - mid_dir.file_list;
|
long index = mid_dir.current_file - mid_dir.file_list;
|
||||||
|
|
||||||
tmp = mid_dir;
|
previous_dir_state = mid_dir;
|
||||||
|
|
||||||
mid_dir.file_count = get_dir_size(path);
|
mid_dir.file_count = get_dir_size(path);
|
||||||
mid_dir.file_list = malloc(mid_dir.file_count * sizeof(file));
|
mid_dir.file_list = malloc(mid_dir.file_count * sizeof(file));
|
||||||
@@ -89,8 +85,21 @@ void *thread_mid(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned long i;
|
unsigned long i;
|
||||||
for(i = 0; i < mid_dir.file_count && i < tmp.file_count; i++) {
|
for(i = 0; i < mid_dir.file_count && i < previous_dir_state.file_count; i++) {
|
||||||
mid_dir.file_list[i].status = tmp.file_list[i].status;
|
mid_dir.file_list[i].status = previous_dir_state.file_list[i].status;
|
||||||
|
}
|
||||||
|
/* youd think that after the above previous_dir_state = mid_dir previous_dir_state.current_file is always within the bounds of the file_list,
|
||||||
|
* but no, it fucking is not for some reason
|
||||||
|
* however for some mysterious reason this condition doesnt fail. well it probably does,
|
||||||
|
* but that doesnt matter as it does what its supposed to do:
|
||||||
|
* keep the current file selected after a reload even if the dir contents change like a new file being added */
|
||||||
|
if (previous_dir_state.current_file != NULL && previous_dir_state.current_file < previous_dir_state.file_list + previous_dir_state.file_count) {
|
||||||
|
for (i = 0; i < mid_dir.file_count; i++) {
|
||||||
|
if (strcmp(mid_dir.file_list[i].file_name, previous_dir_state.file_list[index].file_name) == 0) {
|
||||||
|
mid_dir.current_file = &mid_dir.file_list[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -125,17 +134,15 @@ void *thread_mid(){
|
|||||||
pthread_mutex_unlock(&mutex_render);
|
pthread_mutex_unlock(&mutex_render);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
unsigned long i;
|
unsigned long i;
|
||||||
for (i = 0; i < tmp.file_count; i++) {
|
for (i = 0; i < previous_dir_state.file_count; i++) {
|
||||||
free(tmp.file_list[i].file_name);
|
free(previous_dir_state.file_list[i].file_name);
|
||||||
}
|
}
|
||||||
free(tmp.file_list);
|
free(previous_dir_state.file_list);
|
||||||
tmp.current_file = NULL;
|
previous_dir_state.current_file = NULL;
|
||||||
tmp.file_list = NULL;
|
previous_dir_state.file_list = NULL;
|
||||||
tmp.file_count = 0;
|
previous_dir_state.file_count = 0;
|
||||||
|
free(path);
|
||||||
}
|
}
|
||||||
pthread_exit(0);
|
pthread_exit(0);
|
||||||
}
|
}
|
||||||
@@ -289,34 +296,20 @@ void *thread_top(){
|
|||||||
pthread_cond_wait(&cond_top, &mutex_top);
|
pthread_cond_wait(&cond_top, &mutex_top);
|
||||||
|
|
||||||
|
|
||||||
free(top_buffer);
|
pthread_mutex_lock(&mutex_mid);
|
||||||
|
|
||||||
if(global_path == NULL) {
|
if(global_path == NULL) {
|
||||||
top_buffer = malloc(sizeof("cannot open directory"));
|
mvwaddstr(win_t, 0, 0, "cannot open directory");
|
||||||
top_width = sizeof("cannot open directory");
|
|
||||||
top_buffer = "cannot open directory";
|
|
||||||
pthread_mutex_unlock(&mutex_top);
|
pthread_mutex_unlock(&mutex_top);
|
||||||
|
pthread_mutex_unlock(&mutex_mid);
|
||||||
|
continue;
|
||||||
|
} else if (mid_dir.current_file == NULL) {
|
||||||
|
mvwaddstr(win_t, 0, 0, "cannot open file");
|
||||||
|
pthread_mutex_unlock(&mutex_top);
|
||||||
|
pthread_mutex_unlock(&mutex_mid);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&mutex_mid);
|
|
||||||
|
|
||||||
if (mid_dir.current_file != NULL) {
|
|
||||||
top_buffer = malloc(strlen(global_path)+1 + strlen(mid_dir.current_file->file_name)+1);
|
|
||||||
memcpy(top_buffer, global_path, strlen(global_path));
|
|
||||||
if (strlen(global_path) != 1) {
|
|
||||||
memcpy(top_buffer + strlen(global_path) + 1, mid_dir.current_file->file_name, strlen(mid_dir.current_file->file_name)+1);
|
|
||||||
top_buffer[strlen(global_path)] = '/';
|
|
||||||
} else { /* dir '/' */
|
|
||||||
memcpy(top_buffer + 1, mid_dir.current_file->file_name, strlen(mid_dir.current_file->file_name)+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
top_width = strlen(top_buffer);
|
|
||||||
} else {
|
|
||||||
top_buffer = malloc(strlen(global_path)+1);
|
|
||||||
memcpy(top_buffer, global_path, strlen(global_path)+1);
|
|
||||||
}
|
|
||||||
pthread_mutex_unlock(&mutex_mid);
|
|
||||||
|
|
||||||
|
|
||||||
/* rendering */
|
/* rendering */
|
||||||
@@ -324,20 +317,21 @@ void *thread_top(){
|
|||||||
werase(win_t);
|
werase(win_t);
|
||||||
if (strlen(global_path) != 1) {
|
if (strlen(global_path) != 1) {
|
||||||
wattron(win_t, COLOR_PAIR(COLOR_PATH));
|
wattron(win_t, COLOR_PAIR(COLOR_PATH));
|
||||||
mvwaddnstr(win_t, 0, 0, top_buffer, strlen(global_path)+1);
|
mvwaddnstr(win_t, 0, 0, global_path, strlen(global_path)+1);
|
||||||
|
mvwaddch(win_t, 0, strlen(global_path), '/');
|
||||||
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, mid_dir.current_file->file_name);
|
||||||
} else { /* dir '/' */
|
} else { /* dir '/' */
|
||||||
wattron(win_t, COLOR_PAIR(COLOR_PATH));
|
wattron(win_t, COLOR_PAIR(COLOR_PATH));
|
||||||
mvwaddnstr(win_t, 0, 0, top_buffer, 1);
|
mvwaddnstr(win_t, 0, 0, global_path, 1);
|
||||||
wattroff(win_t, COLOR_PAIR(COLOR_PATH));
|
wattroff(win_t, COLOR_PAIR(COLOR_PATH));
|
||||||
mvwaddstr(win_t, 0, 1, top_buffer+1);
|
mvwaddstr(win_t, 0, 1, mid_dir.current_file->file_name);
|
||||||
}
|
}
|
||||||
/*wnoutrefresh(win_t);*/
|
/*wnoutrefresh(win_t);*/
|
||||||
wrefresh(win_t);
|
wrefresh(win_t);
|
||||||
pthread_mutex_unlock(&mutex_render);
|
pthread_mutex_unlock(&mutex_render);
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&mutex_mid);
|
||||||
pthread_mutex_unlock(&mutex_top);
|
pthread_mutex_unlock(&mutex_top);
|
||||||
}
|
}
|
||||||
pthread_exit(0);
|
pthread_exit(0);
|
||||||
@@ -476,7 +470,6 @@ void *thread_btm(){
|
|||||||
|
|
||||||
void threading_init(){
|
void threading_init(){
|
||||||
|
|
||||||
top_buffer = NULL;
|
|
||||||
rgt_buffer = NULL;
|
rgt_buffer = NULL;
|
||||||
btm_buffer = NULL;
|
btm_buffer = NULL;
|
||||||
|
|
||||||
@@ -494,7 +487,6 @@ void threading_init(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
void threading_free(){
|
void threading_free(){
|
||||||
free(top_buffer);
|
|
||||||
|
|
||||||
pthread_mutex_destroy(&mutex_top);
|
pthread_mutex_destroy(&mutex_top);
|
||||||
pthread_mutex_destroy(&mutex_mid);
|
pthread_mutex_destroy(&mutex_mid);
|
||||||
|
|||||||
Reference in New Issue
Block a user