added directory scrolling via offset_vertical
This commit is contained in:
22
backend.c
22
backend.c
@@ -13,8 +13,8 @@ extern unsigned int settings;
|
||||
extern unsigned int file_modifiers;
|
||||
extern unsigned int color_count;
|
||||
extern unsigned int terminal_height;
|
||||
extern volatile unsigned long selected_file_current;
|
||||
extern color *colors;
|
||||
unsigned long file_offset;
|
||||
int (*order_func)() = sort_natural;
|
||||
|
||||
|
||||
@@ -159,12 +159,16 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file
|
||||
char is_selected = 0;
|
||||
static const char sizes[6] = { 'B', 'K', 'M', 'G', 'T', 'P' };
|
||||
|
||||
unsigned long offset_vertical = 0;
|
||||
unsigned long offset_back = 0;
|
||||
unsigned long offset_front = 2;
|
||||
if (*dir_file_count > 9) {
|
||||
offset_front = (snprintf(NULL, 0, "%ld", *dir_file_count)) + 1;
|
||||
}
|
||||
for (i = file_offset; i < *dir_file_count && i < terminal_height; i++) {
|
||||
if (selected_file_current > (terminal_height/3)*2 && print_info) {
|
||||
offset_vertical = selected_file_current - (terminal_height/3)*2;
|
||||
}
|
||||
for (i = offset_vertical; i < *dir_file_count && i < (terminal_height + offset_vertical); i++) {
|
||||
if (print_info) {
|
||||
file_size = dir_content[i].file_size;
|
||||
char size_index = 0;
|
||||
@@ -236,21 +240,21 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file
|
||||
file_name[file_name_width] = '\0';
|
||||
}
|
||||
|
||||
mvwaddstr(win, i, 0, bg);
|
||||
mvwaddstr(win, i-offset_vertical, 0, bg);
|
||||
if(print_info) {
|
||||
mvwprintw(win, i, 0, "%ld", i);
|
||||
mvwaddnstr(win, i, offset_front+is_selected, file_name, line_width-offset_front-is_selected-2);
|
||||
mvwprintw(win, i-offset_vertical, 0, "%ld", i);
|
||||
mvwaddnstr(win, i-offset_vertical, offset_front+is_selected, file_name, line_width-offset_front-is_selected-2);
|
||||
free(file_name);
|
||||
|
||||
if (dir_content[i].file_type == FILE_TYPE_DIR || dir_content[i].file_type == FILE_TYPE_SYMLINK) {
|
||||
mvwprintw(win, i, offset_back, "%ld", dir_content[i].file_size);
|
||||
mvwprintw(win, i-offset_vertical, offset_back, "%ld", dir_content[i].file_size);
|
||||
}else if (size_char =='B') {
|
||||
mvwprintw(win, i, offset_back, "%0.0lf %c", printed_size, size_char);
|
||||
mvwprintw(win, i-offset_vertical, offset_back, "%0.0lf %c", printed_size, size_char);
|
||||
} else {
|
||||
mvwprintw(win, i, offset_back, "%0.2lf %c", printed_size, size_char);
|
||||
mvwprintw(win, i-offset_vertical, offset_back, "%0.2lf %c", printed_size, size_char);
|
||||
}
|
||||
} else {
|
||||
mvwaddnstr(win, i, 0, file_name, line_width);
|
||||
mvwaddnstr(win, i-offset_vertical, 0, file_name, line_width);
|
||||
free(file_name);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user