Compare commits

...
2 Commits
Author SHA1 Message Date
nova cebacc7017 removal of unnecessary getcwd 2026-06-23 21:55:07 +02:00
nova edab9a62ad faster initial render 2026-06-23 21:42:10 +02:00
2 changed files with 17 additions and 13 deletions
+8 -10
View File
@@ -319,16 +319,15 @@ void dir_changed(){
}
void change_dir(char *new_path){
const char *old_path = global_path;
current_linked_dir = list_beginning;
while (current_linked_dir->next != NULL) {
if(strcmp(current_linked_dir->path, old_path) == 0) {
if(strcmp(current_linked_dir->path, global_path) == 0) {
break;
} else {
current_linked_dir = current_linked_dir->next;
}
}
if(strcmp(current_linked_dir->path, old_path) == 0) {
if(strcmp(current_linked_dir->path, global_path) == 0) {
current_linked_dir->index = mid_dir.current_file - mid_dir.file_list;
}
@@ -338,21 +337,22 @@ void change_dir(char *new_path){
* especially in like 2 years when i even forgot about this possibility */
return;
}
char *new_path_real = getcwd(NULL, 0);
free(global_path);
global_path = getcwd(NULL, 0);
current_linked_dir = list_beginning;
while (current_linked_dir->next != NULL) {
if(strcmp(current_linked_dir->path, new_path_real) == 0) {
if(strcmp(current_linked_dir->path, global_path) == 0) {
break;
} else {
current_linked_dir = current_linked_dir->next;
}
}
if(strcmp(current_linked_dir->path, new_path_real) != 0) {
if(strcmp(current_linked_dir->path, global_path) != 0) {
current_linked_dir->next = malloc(sizeof(linked_dir));
current_linked_dir = current_linked_dir->next;
current_linked_dir->path = malloc(strlen(new_path_real)+1);
memcpy(current_linked_dir->path, new_path_real, strlen(new_path_real)+1);
current_linked_dir->path = malloc(strlen(global_path)+1);
memcpy(current_linked_dir->path, global_path, strlen(global_path)+1);
current_linked_dir->next = NULL;
current_linked_dir->index = 0;
/*TODO(2026-05-25T22:49:30)
@@ -360,8 +360,6 @@ void change_dir(char *new_path){
}
mid_dir.current_file = &mid_dir.file_list[current_linked_dir->index];
free(new_path_real);
}
void dir_init(){
+9 -3
View File
@@ -18,7 +18,7 @@ unsigned int terminal_width;
unsigned int temp_heigth = 0; /*used for screen refresh*/
unsigned int temp_width = 0;
unsigned int file_modifiers = 0;
unsigned int status = (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_CLEAR | STATUS_UPDATE_SCREEN_RESIZE | STATUS_RELOAD_DIRECTORY) & ~STATUS_UPDATE_SCREEN_RESIZE;
unsigned int status = (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_CLEAR | STATUS_UPDATE_SCREEN_RESIZE | STATUS_RELOAD_DIRECTORY);
char *global_path;
time_t seed;
@@ -75,13 +75,19 @@ int main(){
timeout(SETTINGS_CURSES_TIMEOUT);
/* initial render pass to speed first render up,
* yes this only skips SETTINGS_CURSES_TIMEOUT, which by default is 100ms,
* but i started to write th out of spite; because anything else either is too slow and unresponsive
* or i just dont like their ux.
* will i ever make use of the 100ms? will i ever react and do faster inputs? no
* does it feel more responsive? sure does */
pthread_cond_signal(&cond_mid);
render_pass();
while(!(status & STATUS_QUIT_PROGRAM)){
getmaxyx(stdscr, terminal_height, terminal_width);
if (status & STATUS_RUN_BACKEND) {
free(global_path);
global_path = getcwd(NULL, 0);
pthread_cond_signal(&cond_mid);
pthread_cond_signal(&cond_lft);
status &= ~(STATUS_RUN_BACKEND);