Compare commits

...
4 Commits
Author SHA1 Message Date
nova 60127a6b9b cleanup 2026-06-16 23:53:35 +02:00
nova 7091c47a2c comment 2026-06-16 23:41:39 +02:00
nova e6318f8d1e wattroff -> wattrset to disable all attributes 2026-06-16 23:37:13 +02:00
nova f6c39ce039 minor changes 2026-06-16 23:28:03 +02:00
+21 -29
View File
@@ -50,11 +50,6 @@ unsigned long get_dir_size(char *path){
void get_dir_content(char *path, dir *dir){
if (dir->file_count == 0) {
return;
dir = NULL;
}
struct dirent **entry = NULL;
if (file_modifiers & FILE_MODIFIERS_HIDDEN_FILES) { /* print hidden files */
scandir(path, &entry, skip_dot, NULL);
@@ -167,24 +162,24 @@ void print_dir(WINDOW *win, char print_info, dir *dir){
unsigned long offset_vertical = 0;
unsigned long offset_back = 0;
#if SETTINGS_LINE_NUMBERS == 0
unsigned long offset_front = 0;
unsigned long offset_front = 0;
#else
long offset_front = 2;
long offset_front = 2;
#endif
unsigned long selected_file_current = dir->current_file - dir->file_list;
long offset_index = 2; /* only used for the index of the file itself */
if (print_info) {
#if SETTINGS_LINE_NUMBERS != 0
if (dir->file_count > 9) {
#if SETTINGS_LINE_NUMBERS != 0
unsigned long dir_file_count_ = dir->file_count;
while(dir_file_count_ > 9) {
offset_front++;
dir_file_count_ /= 10;
}
#endif
}
#endif
/* scrolling of the directory if too many files are in a dir */
if (selected_file_current > (terminal_height/3)*2 && dir->file_count > terminal_height - 2) {
if (selected_file_current + (terminal_height/3) >= dir->file_count) {
offset_vertical = dir->file_count - terminal_height+2;
@@ -197,8 +192,6 @@ void print_dir(WINDOW *win, char print_info, dir *dir){
}
for (i = offset_vertical; i < dir->file_count && i < (terminal_height + offset_vertical); i++) {
if (print_info) {
file_size = dir->file_list[i].file_size;
char size_index = -1;
@@ -212,7 +205,7 @@ void print_dir(WINDOW *win, char print_info, dir *dir){
if (dir->file_list[i].file_type & FILE_TYPE_DIR) {
offset_back = line_width - (snprintf(NULL,0,"%ld", dir->file_list[i].file_size) + 1);
} else if (size_char =='B') {
} else if (size_char == size_unit[0]) {
offset_back = line_width - (snprintf(NULL,0,"%0.0lf %c", printed_size, size_char) + 1);
} else {
offset_back = line_width - (snprintf(NULL,0,"%0.2lf %c", printed_size, size_char) + 1);
@@ -222,28 +215,20 @@ void print_dir(WINDOW *win, char print_info, dir *dir){
}
if (dir->file_list[i].status & FILE_STATUS_SELECTED) {
wattron(win, COLOR_PAIR(8)); /* FIFO, as seen in colors.c */
is_selected = 1;
} else {
is_selected = 0;
}
if (dir->file_list[i].status & FILE_STATUS_SELECTED) {
wattron(win, COLOR_PAIR(8));
} else {
wattron(win, COLOR_PAIR(dir->file_list[i].color_pair));
is_selected = 0;
}
if (&dir->file_list[i] == dir->current_file) {
wattron(win, A_REVERSE);
unsigned long bg = 0;
for (bg = 0; bg < line_width; bg++) {
mvwaddch(win, i-offset_vertical, bg, ' ');
}
}
} else {
wattroff(win, A_REVERSE);
}
if(print_info) {
#if SETTINGS_LINE_NUMBERS == 2
long i_ = (selected_file_current) - i;
@@ -278,12 +263,12 @@ void print_dir(WINDOW *win, char print_info, dir *dir){
if (dir->file_list[i].file_type & FILE_TYPE_DIR) {
mvwprintw(win, i-offset_vertical, offset_back, "%ld", dir->file_list[i].file_size);
}else if (size_char =='B') {
}else if (size_char == size_unit[0]) {
mvwprintw(win, i-offset_vertical, offset_back, "%0.0lf %c", printed_size, size_char);
} else {
mvwprintw(win, i-offset_vertical, offset_back, "%0.2lf %c", printed_size, size_char);
}
}
}
char *extension = strrchr(dir->file_list[i].file_name, '.');
unsigned long printable_size = offset_back-offset_front-is_selected-2;
@@ -295,11 +280,14 @@ void print_dir(WINDOW *win, char print_info, dir *dir){
}
wattrset(win, 0);
/*
if (dir->file_list[i].status & FILE_STATUS_SELECTED) {
wattroff(win, COLOR_PAIR(8));
} else {
wattroff(win, COLOR_PAIR(dir->file_list[i].color_pair));
}
*/
}
}
@@ -331,7 +319,7 @@ void dir_changed(){
}
void change_dir(char *new_path){
char *old_path = getcwd(NULL, 0);
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) {
@@ -344,7 +332,12 @@ void change_dir(char *new_path){
current_linked_dir->index = mid_dir.current_file - mid_dir.file_list;
}
chdir(new_path);
if (chdir(new_path) != 0) {
/* i have made the decission that this is a case that i do not want to handle
* god may help me if this ever fails, cuz damn thatll be hard to debug
* especially in like 2 years when i even forgot about this possibility */
return;
}
char *new_path_real = getcwd(NULL, 0);
current_linked_dir = list_beginning;
@@ -367,7 +360,6 @@ void change_dir(char *new_path){
}
mid_dir.current_file = &mid_dir.file_list[current_linked_dir->index];
free(old_path);
free(new_path_real);
}