1
0
mirror of https://gittea.dev/nova/th.git synced 2025-10-21 18:30:15 -04:00

relative lines

This commit is contained in:
nova
2025-08-17 01:46:54 +02:00
parent 2af21a0875
commit 017bf407d9

25
dir.c
View File

@@ -159,16 +159,23 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file
unsigned long offset_vertical = 0;
unsigned long offset_back = 0;
#if SETTINGS_LINE_NUMBERS == 0
unsigned long offset_front = 0;
#else
unsigned long offset_front = 2;
#endif
unsigned long offset_index = 2; /* only used for the index of the file itself */
if (print_info) {
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
}
if (selected_file_current > (terminal_height/3)*2 && *dir_file_count > terminal_height - 2) {
if (selected_file_current + (terminal_height/3) >= *dir_file_count) {
@@ -253,19 +260,29 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file
mvwaddstr(win, i-offset_vertical, 0, bg);
if(print_info) {
#if SETTINGS_LINE_NUMBERS == 2
long i_ = (selected_file_current) - i;
offset_index = !((selected_file_current) - i);
while(i_) {
offset_index++;
i_ /= 10;
}
long relative_index = selected_file_current - i;
if (relative_index < 0) {
relative_index = relative_index * -1;
}
mvwprintw(win, i-offset_vertical, offset_front-offset_index-1, "%ld", relative_index);
#elif SETTINGS_LINE_NUMBERS == 1
unsigned long i_ = i;
offset_index = 2;
while(i_ > 9) {
offset_index++;
i_ /= 10;
}
#if SETTINGS_LINE_NUMBERS == 2
mvwprintw(win, i-offset_vertical, offset_front-offset_index, "a");
#elif SETTINGS_LINE_NUMBERS == 1
mvwprintw(win, i-offset_vertical, offset_front-offset_index, "%ld", i);
#endif
mvwaddnstr(win, i-offset_vertical, offset_front+is_selected, file_name, line_width-offset_front-is_selected-2);
free(file_name);