mirror of
https://gittea.dev/nova/th.git
synced 2025-10-22 10:50:15 -04:00
relative lines
This commit is contained in:
25
dir.c
25
dir.c
@@ -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_vertical = 0;
|
||||||
unsigned long offset_back = 0;
|
unsigned long offset_back = 0;
|
||||||
|
#if SETTINGS_LINE_NUMBERS == 0
|
||||||
|
unsigned long offset_front = 0;
|
||||||
|
#else
|
||||||
unsigned long offset_front = 2;
|
unsigned long offset_front = 2;
|
||||||
|
#endif
|
||||||
|
|
||||||
unsigned long offset_index = 2; /* only used for the index of the file itself */
|
unsigned long offset_index = 2; /* only used for the index of the file itself */
|
||||||
if (print_info) {
|
if (print_info) {
|
||||||
if (*dir_file_count > 9) {
|
if (*dir_file_count > 9) {
|
||||||
|
|
||||||
|
#if SETTINGS_LINE_NUMBERS != 0
|
||||||
unsigned long dir_file_count_ = *dir_file_count;
|
unsigned long dir_file_count_ = *dir_file_count;
|
||||||
while(dir_file_count_ > 9) {
|
while(dir_file_count_ > 9) {
|
||||||
offset_front++;
|
offset_front++;
|
||||||
dir_file_count_ /= 10;
|
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)*2 && *dir_file_count > terminal_height - 2) {
|
||||||
if (selected_file_current + (terminal_height/3) >= *dir_file_count) {
|
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);
|
mvwaddstr(win, i-offset_vertical, 0, bg);
|
||||||
if(print_info) {
|
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;
|
unsigned long i_ = i;
|
||||||
offset_index = 2;
|
offset_index = 2;
|
||||||
while(i_ > 9) {
|
while(i_ > 9) {
|
||||||
offset_index++;
|
offset_index++;
|
||||||
i_ /= 10;
|
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);
|
mvwprintw(win, i-offset_vertical, offset_front-offset_index, "%ld", i);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
mvwaddnstr(win, i-offset_vertical, offset_front+is_selected, file_name, line_width-offset_front-is_selected-2);
|
mvwaddnstr(win, i-offset_vertical, offset_front+is_selected, file_name, line_width-offset_front-is_selected-2);
|
||||||
free(file_name);
|
free(file_name);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user