mirror of
https://gittea.dev/nova/th.git
synced 2026-01-30 16:50:10 -05:00
Compare commits
3 Commits
66f3f3bef6
...
1f1de78283
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1f1de78283 | ||
|
|
f3a39b0df0 | ||
|
|
8734fa6ae4 |
2
config.h
2
config.h
@@ -39,7 +39,7 @@ static const extension file_extension_default_cmd[] = {
|
||||
{ ".csv", "$EDITOR"},
|
||||
};
|
||||
static const binding key_binding[] = {
|
||||
/*key action blackmagic comment*/
|
||||
/*key action blackmagic comment*/
|
||||
/*you cannot add bindings that include other bindings in its entirety
|
||||
* possible: mk, mf
|
||||
* not possible: gg, ggg
|
||||
|
||||
6
dir.c
6
dir.c
@@ -254,7 +254,7 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file
|
||||
file_name[printable_size + strlen(extension)-1] = '\0';
|
||||
file_name[printable_size - 2] = '~';
|
||||
} else {
|
||||
file_name = malloc(printable_size-1);
|
||||
file_name = malloc(printable_size);
|
||||
memcpy(file_name, dir_content[i].file_name, printable_size);
|
||||
file_name[printable_size-2] = '~';
|
||||
file_name[printable_size-1] = '\0';
|
||||
@@ -315,6 +315,7 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file
|
||||
} else {
|
||||
wattroff(win, COLOR_PAIR(dir_content[i].color_pair));
|
||||
}
|
||||
free(file_name);
|
||||
|
||||
}
|
||||
free(bg);
|
||||
@@ -322,10 +323,11 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file
|
||||
|
||||
char update_selected_file(){
|
||||
char ret = -1; /* -1 on empty or inaccessible file, 0 on unchanged file, 1 on changed file */
|
||||
|
||||
if (selected_file_current >= mid_file_count) {
|
||||
selected_file_current = mid_file_count-1;
|
||||
}
|
||||
if (selected_file_current != selected_file_last) {
|
||||
if (selected_file_current != selected_file_last && selected_file_last <= mid_file_count) {
|
||||
mid_content[selected_file_last].status &= ~FILE_STATUS_HOVER;
|
||||
ret = 1;
|
||||
} else {
|
||||
|
||||
@@ -33,6 +33,7 @@ char* get_mimetype(char *path){
|
||||
FILE *cmd_open = popen(cmd, "r");
|
||||
char *line = NULL;
|
||||
size_t size = 0;
|
||||
free(cmd);
|
||||
if (getline(&line, &size, cmd_open) != -1){
|
||||
pclose(cmd_open);
|
||||
return line;
|
||||
|
||||
@@ -201,7 +201,7 @@ void move_up(unsigned long passes){
|
||||
current_dir->selected_file_current = selected_file_current;
|
||||
|
||||
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK);
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_0);
|
||||
pthread_mutex_unlock(&mutex_selection);
|
||||
}
|
||||
void move_left(unsigned long passes){
|
||||
@@ -217,7 +217,9 @@ void move_left(unsigned long passes){
|
||||
selected_file_current = dir_get_selected_file_current();
|
||||
}
|
||||
}
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY);
|
||||
update_selected_file();
|
||||
current_dir->selected_file_current = selected_file_current;
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_RELOAD_FULL | STATUS_RELOAD_DIRECTORY);
|
||||
}
|
||||
void move_right(){
|
||||
if (mid_content->file_name[0] == '\0') {
|
||||
@@ -248,7 +250,7 @@ void move_right(){
|
||||
}
|
||||
curs_set(1); /*for some reason, 1 here turns it invisible once again */
|
||||
match = 1;
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_RELOAD_FULL | STATUS_RELOAD_DIRECTORY);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -262,7 +264,7 @@ void move_right(){
|
||||
/*do nothing*/
|
||||
}
|
||||
curs_set(1); /*for some reason, 1 here turns it invisible once again */
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_RELOAD_FULL);
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_RELOAD_FULL | STATUS_RELOAD_DIRECTORY);
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -271,11 +273,11 @@ void move_right(){
|
||||
free(mime);
|
||||
}
|
||||
update_selected_file();
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY);
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_RELOAD_FULL | STATUS_RELOAD_DIRECTORY);
|
||||
}
|
||||
void toggle_hidden_files(){
|
||||
file_modifiers ^= FILE_MODIFIERS_HIDDEN_FILES;
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY);
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_RELOAD_FULL | STATUS_RELOAD_DIRECTORY);
|
||||
}
|
||||
void toggle_selection(){
|
||||
pthread_mutex_lock(&mutex_selection);
|
||||
@@ -291,7 +293,7 @@ void jump_bottom(){
|
||||
selected_file_current = 0 - 1;
|
||||
update_selected_file();
|
||||
current_dir->selected_file_current = selected_file_current;
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK);
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_0);
|
||||
pthread_mutex_unlock(&mutex_selection);
|
||||
}
|
||||
void jump_top(){
|
||||
@@ -415,41 +417,21 @@ void delete(){
|
||||
|
||||
werase(win_b);
|
||||
mvwin(win_b, terminal_height-6, 0);
|
||||
if (strlen(file_str) < (BTM_WINDOW_HEIGHT_ON_STR_INTERACTION-1) * (terminal_width/3)) {
|
||||
wresize(win_b, BTM_WINDOW_HEIGHT_ON_STR_INTERACTION, terminal_width/3); /*the div3 just looks cool*/
|
||||
btm_buffer = malloc(BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * (terminal_width/3));
|
||||
memset(btm_buffer, ' ', (BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * (terminal_width/3)));
|
||||
wresize(win_b, BTM_WINDOW_HEIGHT_ON_STR_INTERACTION, terminal_width);
|
||||
btm_buffer = malloc(BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width);
|
||||
memset(btm_buffer, ' ', BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width);
|
||||
|
||||
memcpy(btm_buffer, ui_delete_text ,strlen(ui_delete_text));
|
||||
if (hits) {
|
||||
memcpy(btm_buffer + strlen(ui_delete_text)+1, file_str, strlen(file_str));
|
||||
} else {
|
||||
btm_buffer[strlen(ui_delete_text)+1] = '"';
|
||||
memcpy(btm_buffer + strlen(ui_delete_text) +1 + sizeof(char), mid_content[selected_file_current].file_name, strlen(mid_content[selected_file_current].file_name));
|
||||
btm_buffer[strlen(ui_delete_text)+1 + sizeof(char) + strlen(mid_content[selected_file_current].file_name)] = '"';
|
||||
}
|
||||
memcpy(btm_buffer, ui_delete_text ,strlen(ui_delete_text));
|
||||
|
||||
memcpy(btm_buffer + (BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * (terminal_width/3) - (terminal_width/3)) , "(y/N)", strlen("(y/N)"));
|
||||
btm_buffer[BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * (terminal_width/3)] = '\0';
|
||||
/*this horrendous check tries to copy everything until the last line, while keeping said last line unwritten*/
|
||||
/*lets hope im never gonna need to format something like this ever again*/
|
||||
memcpy(btm_buffer + strlen(ui_delete_text)+1, file_str,
|
||||
(strlen(file_str) > ((BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width) - terminal_width) ?
|
||||
((BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width) - terminal_width) :
|
||||
strlen(file_str)));
|
||||
|
||||
} else {
|
||||
/*since more data is present than can be represented using div3, we do the uncool thing*/
|
||||
wresize(win_b, BTM_WINDOW_HEIGHT_ON_STR_INTERACTION, terminal_width);
|
||||
btm_buffer = malloc(BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width);
|
||||
memset(btm_buffer, ' ', BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width);
|
||||
|
||||
memcpy(btm_buffer, ui_delete_text ,strlen(ui_delete_text));
|
||||
|
||||
/*this horrendous check tries to copy everything until the last line, while keeping said last line unwritten*/
|
||||
/*lets hope im never gonna need to format something like this ever again*/
|
||||
memcpy(btm_buffer + strlen(ui_delete_text)+1, file_str,
|
||||
(strlen(file_str) > ((BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width) - terminal_width) ?
|
||||
((BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width) - terminal_width) :
|
||||
strlen(file_str)));
|
||||
|
||||
memcpy(btm_buffer + (BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width - terminal_width) , "(y/N)", strlen("(y/N)"));
|
||||
btm_buffer[BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width] = '\0';
|
||||
}
|
||||
memcpy(btm_buffer + (BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width - terminal_width) , "(y/N)", strlen("(y/N)"));
|
||||
btm_buffer[BTM_WINDOW_HEIGHT_ON_STR_INTERACTION * terminal_width-1] = '\0';
|
||||
|
||||
|
||||
|
||||
|
||||
1
main.c
1
main.c
@@ -91,6 +91,7 @@ int main(){
|
||||
temp_heigth = terminal_height;
|
||||
}
|
||||
if (status & STATUS_RUN_BACKEND) {
|
||||
free(global_path);
|
||||
global_path = getcwd(NULL, 0);
|
||||
pthread_cond_signal(&cond_top);
|
||||
pthread_cond_signal(&cond_mid);
|
||||
|
||||
54
threading.c
54
threading.c
@@ -93,9 +93,7 @@ void *thread_mid(){
|
||||
mid_file_count = 0;
|
||||
|
||||
}
|
||||
pthread_mutex_lock(&mutex_selection);
|
||||
update_selected_file();
|
||||
pthread_mutex_unlock(&mutex_selection);
|
||||
}
|
||||
|
||||
btm_status = local_status;
|
||||
@@ -157,20 +155,11 @@ void *thread_rgt(){
|
||||
|
||||
|
||||
pthread_mutex_lock(&mutex_mid);
|
||||
char *path;
|
||||
if (mid_file_count != 0) {
|
||||
path = malloc(strlen(mid_content[selected_file_current].file_name) + 1);
|
||||
memcpy(path, mid_content[selected_file_current].file_name, strlen(mid_content[selected_file_current].file_name)+1);
|
||||
} else {
|
||||
path = malloc(sizeof(char));
|
||||
path[0] = '\0';
|
||||
}
|
||||
file_current.file_type = mid_content[selected_file_current].file_type;
|
||||
file_current.file_size = mid_content[selected_file_current].file_size;
|
||||
file_current.status = mid_content[selected_file_current].status;
|
||||
char *path = mid_content[selected_file_current].file_name;
|
||||
memcpy(&file_current, &mid_content[selected_file_current], sizeof(file));
|
||||
pthread_mutex_unlock(&mutex_mid);
|
||||
|
||||
if (mid_content[selected_file_current].permissions & S_IRUSR) {
|
||||
if (file_current.permissions & S_IRUSR) {
|
||||
if (file_current.file_type &= FILE_TYPE_DIR) {
|
||||
#if SETTINGS_UEBERZUG_IMAGE_PREVIEW != 0
|
||||
images_clear();
|
||||
@@ -185,14 +174,20 @@ void *thread_rgt(){
|
||||
free(rgt_content);
|
||||
|
||||
rgt_file_count = get_dir_size(path);
|
||||
rgt_content = malloc(rgt_file_count * sizeof(file));
|
||||
memset(rgt_content, '\0', rgt_file_count * sizeof(file));
|
||||
get_dir_content(path, &rgt_file_count, rgt_content);
|
||||
rgt_content[0].status &= ~FILE_STATUS_FILE_OPEN;
|
||||
if (rgt_file_count) { /* fails if dir empty */
|
||||
rgt_content = malloc(rgt_file_count * sizeof(file));
|
||||
memset(rgt_content, '\0', rgt_file_count * sizeof(file));
|
||||
get_dir_content(path, &rgt_file_count, rgt_content);
|
||||
rgt_content[0].status &= ~FILE_STATUS_FILE_OPEN;
|
||||
|
||||
free(rgt_buffer);
|
||||
rgt_buffer = malloc(sizeof(char));
|
||||
rgt_buffer[0] = '\0';
|
||||
free(rgt_buffer);
|
||||
rgt_buffer = malloc(sizeof(char));
|
||||
rgt_buffer[0] = '\0';
|
||||
} else { /* the hovered dir is empty */
|
||||
rgt_content = malloc(sizeof(file));
|
||||
rgt_content->file_type = 0;
|
||||
rgt_content->permissions = mid_content[selected_file_current].permissions;
|
||||
}
|
||||
} else if ((status & STATUS_DELTA_TIME) != STATUS_DELTA_TIME) {
|
||||
|
||||
unsigned long i = 0;
|
||||
@@ -225,8 +220,9 @@ void *thread_rgt(){
|
||||
rgt_buffer = malloc(sizeof(char));
|
||||
rgt_buffer[0] = '\0';
|
||||
}
|
||||
|
||||
/*
|
||||
free(path);
|
||||
*/
|
||||
|
||||
pthread_mutex_unlock(&mutex_rgt);
|
||||
}
|
||||
@@ -282,6 +278,9 @@ void *thread_btm(){
|
||||
|
||||
free(ui_btm_right_block);
|
||||
|
||||
if(path) {
|
||||
free(path);
|
||||
}
|
||||
path = getcwd(NULL, 0);
|
||||
struct statvfs fs;
|
||||
statvfs(path, &fs);
|
||||
@@ -338,10 +337,9 @@ void *thread_btm(){
|
||||
if (buffer_width != terminal_width) {
|
||||
buffer_width = terminal_width;
|
||||
free(btm_buffer);
|
||||
btm_buffer = malloc(buffer_width);
|
||||
memset(btm_buffer, ' ', buffer_width/2);
|
||||
btm_buffer = malloc(buffer_width+1);
|
||||
}
|
||||
memset(btm_buffer + (buffer_width/2), ' ', buffer_width/2);
|
||||
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);
|
||||
@@ -379,13 +377,11 @@ void threading_init(){
|
||||
|
||||
mid_content->file_type = 0;
|
||||
mid_content->file_size = 0;
|
||||
mid_content->file_name = malloc(sizeof(char));
|
||||
mid_content->file_name[0] = '\0';
|
||||
mid_content->file_name = "";
|
||||
|
||||
rgt_content->file_type = 0;
|
||||
rgt_content->file_size = 0;
|
||||
rgt_content->file_name = malloc(sizeof(char));
|
||||
rgt_content->file_name[0] = '\0';
|
||||
rgt_content->file_name = "";
|
||||
|
||||
|
||||
volatile char vol; /* needed to make sure higher optimization steps dont move these around */
|
||||
|
||||
Reference in New Issue
Block a user