File area choosers now use lightbars

This commit is contained in:
Andrew Pamment 2018-01-17 16:03:15 +10:00
parent 1aeaee5031
commit 85fc0d57cd
5 changed files with 211 additions and 35 deletions

View File

@ -250,3 +250,5 @@ File exists!\r\n
\e[%d;1H\e[1;30;40m[\e[1;34;44m%.4d\e[1;30;40m] \e[1;37m%s\e[K
\e[%d;1H\e[1;30;40m[\e[1;34m%.4d\e[1;30;40m] \e[1;37m%s\e[K
\e[1;37;44mChoose an Area in %s\e[K
\e[1;37;44mChoose an Subdir in %s\e[K
\e[1;37;44mChoose a Directory\e[K

View File

@ -306,8 +306,8 @@ extern void upload_zmodem(struct user_record *user, char *upload_p);
extern int ttySetRaw(int fd, struct termios *prevTermios);
extern int do_upload(struct user_record *user, char *final_path);
extern int do_download(struct user_record *user, char *file);
extern void choose_directory(struct user_record *user);
extern void choose_subdir(struct user_record *user);
extern void choose_directory();
extern void choose_subdir();
extern void list_files(struct user_record *user);
extern void upload(struct user_record *user);
extern void download(struct user_record *user);

View File

@ -1341,6 +1341,107 @@ void list_files(struct user_record *user) {
do_list_files(files_e, files_c);
}
struct subdir_tmp_t {
struct file_sub *sub;
int index;
};
void choose_subdir() {
int i;
int list_tmp = 0;
struct subdir_tmp_t **sub_tmp;
int redraw = 1;
int start = 0;
int selected = 0;
char c;
for (i=0;i<conf.file_directories[gUser->cur_file_dir]->file_sub_count;i++) {
if (conf.file_directories[gUser->cur_file_dir]->file_subs[i]->download_sec_level <= gUser->sec_level) {
if (list_tmp == 0) {
sub_tmp = (struct subdir_tmp_t **)malloc(sizeof(struct subdir_tmp_t *));
} else {
sub_tmp = (struct subdir_tmp_t **)realloc(sub_tmp, sizeof(struct subdir_tmp_t *) * (list_tmp + 1));
}
sub_tmp[list_tmp] = (struct subdir_tmp_t *)malloc(sizeof(struct subdir_tmp_t));
sub_tmp[list_tmp]->sub = conf.file_directories[gUser->cur_file_dir]->file_subs[i];
sub_tmp[list_tmp]->index = i;
list_tmp++;
}
}
while (1) {
if (redraw) {
s_printf("\e[2J\e[1;1H");
s_printf(get_string(252), conf.file_directories[gUser->cur_file_dir]->name);
s_printf(get_string(248));
for (i=start;i<start+22 && i < list_tmp;i++) {
if (i == selected) {
s_printf(get_string(249), i - start + 2, sub_tmp[i]->index, sub_tmp[i]->sub->name);
} else {
s_printf(get_string(250), i - start + 2, sub_tmp[i]->index, sub_tmp[i]->sub->name);
}
}
redraw = 0;
}
c = s_getchar();
if (tolower(c) == 'q') {
break;
} else if (c == 27) {
c = s_getchar();
if (c == 91) {
c = s_getchar();
if (c == 66) {
// down
if (selected + 1 > start + 22) {
start += 22;
if (start >= list_tmp) {
start = list_tmp - 22;
}
redraw = 1;
}
selected++;
if (selected >= list_tmp) {
selected = list_tmp - 1;
} else {
if (!redraw) {
s_printf(get_string(250), selected - start + 1, sub_tmp[selected - 1]->index, sub_tmp[selected - 1]->sub->name);
s_printf(get_string(249), selected - start + 2, sub_tmp[selected]->index, sub_tmp[selected]->sub->name);
}
}
} else if (c == 65) {
// up
if (selected - 1 < start) {
start -= 22;
if (start < 0) {
start = 0;
}
redraw = 1;
}
selected--;
if (selected < 0) {
selected = 0;
} else {
if (!redraw) {
s_printf(get_string(249), selected - start + 2, sub_tmp[selected]->index, sub_tmp[selected]->sub->name);
s_printf(get_string(250), selected - start + 3, sub_tmp[selected + 1]->index, sub_tmp[selected + 1]->sub->name);
}
}
}
}
} else if (c == 13) {
gUser->cur_file_sub = sub_tmp[selected]->index;
break;
}
}
for (i=0;i<list_tmp;i++) {
free(sub_tmp[i]);
}
free(sub_tmp);
}
/*
void choose_subdir(struct user_record *user) {
int i;
char c;
@ -1368,7 +1469,110 @@ void choose_subdir(struct user_record *user) {
}
}
}
*/
struct dir_tmp_t {
struct file_directory *dir;
int index;
};
void choose_directory() {
int i;
int list_tmp = 0;
struct dir_tmp_t **dir_tmp;
int redraw = 1;
int start = 0;
int selected = 0;
char c;
for (i=0;i<conf.file_directory_count;i++) {
if (conf.file_directories[i]->sec_level <= gUser->sec_level) {
if (list_tmp == 0) {
dir_tmp = (struct dir_tmp_t **)malloc(sizeof(struct dir_tmp_t *));
} else {
dir_tmp = (struct dir_tmp_t **)realloc(dir_tmp, sizeof(struct dir_tmp_t *) * (list_tmp + 1));
}
dir_tmp[list_tmp] = (struct dir_tmp_t *)malloc(sizeof(struct dir_tmp_t));
dir_tmp[list_tmp]->dir = conf.file_directories[i];
dir_tmp[list_tmp]->index = i;
list_tmp++;
}
}
while (1) {
if (redraw) {
s_printf("\e[2J\e[1;1H");
s_printf(get_string(253));
s_printf(get_string(248));
for (i=start;i<start+22 && i < list_tmp;i++) {
if (i == selected) {
s_printf(get_string(249), i - start + 2, dir_tmp[i]->index, dir_tmp[i]->dir->name);
} else {
s_printf(get_string(250), i - start + 2, dir_tmp[i]->index, dir_tmp[i]->dir->name);
}
}
redraw = 0;
}
c = s_getchar();
if (tolower(c) == 'q') {
break;
} else if (c == 27) {
c = s_getchar();
if (c == 91) {
c = s_getchar();
if (c == 66) {
// down
if (selected + 1 > start + 22) {
start += 22;
if (start >= list_tmp) {
start = list_tmp - 22;
}
redraw = 1;
}
selected++;
if (selected >= list_tmp) {
selected = list_tmp - 1;
} else {
if (!redraw) {
s_printf(get_string(250), selected - start + 1, dir_tmp[selected - 1]->index, dir_tmp[selected - 1]->dir->name);
s_printf(get_string(249), selected - start + 2, dir_tmp[selected]->index, dir_tmp[selected]->dir->name);
}
}
} else if (c == 65) {
// up
if (selected - 1 < start) {
start -= 22;
if (start < 0) {
start = 0;
}
redraw = 1;
}
selected--;
if (selected < 0) {
selected = 0;
} else {
if (!redraw) {
s_printf(get_string(249), selected - start + 2, dir_tmp[selected]->index, dir_tmp[selected]->dir->name);
s_printf(get_string(250), selected - start + 3, dir_tmp[selected + 1]->index, dir_tmp[selected + 1]->dir->name);
}
}
}
}
} else if (c == 13) {
gUser->cur_file_dir = dir_tmp[selected]->index;
gUser->cur_file_sub = 0;
break;
}
}
for (i=0;i<list_tmp;i++) {
free(dir_tmp[i]);
}
free(dir_tmp);
}
/*
void choose_directory(struct user_record *user) {
int i;
char c;
@ -1398,7 +1602,7 @@ void choose_directory(struct user_record *user) {
}
}
}
*/
void clear_tagged_files() {
int i;
// Clear tagged files

View File

@ -2756,36 +2756,6 @@ void choose_area() {
}
/*
void choose_area(struct user_record *user) {
int i;
int j;
char c;
char buffer[6];
s_printf(get_string(135));
for (i=0;i<conf.mail_conferences[user->cur_mail_conf]->mail_area_count;i++) {
if (conf.mail_conferences[user->cur_mail_conf]->mail_areas[i]->read_sec_level <= user->sec_level) {
s_printf(get_string(136), i, conf.mail_conferences[user->cur_mail_conf]->mail_areas[i]->name);
}
if (i != 0 && i % 20 == 0) {
s_printf(get_string(6));
c = s_getc();
}
}
s_printf(get_string(137));
s_readstring(buffer, 5);
if (tolower(buffer[0]) != 'q') {
j = atoi(buffer);
if (j < 0 || j >= conf.mail_conferences[user->cur_mail_conf]->mail_area_count || conf.mail_conferences[user->cur_mail_conf]->mail_areas[j]->read_sec_level > user->sec_level) {
s_printf(get_string(138));
} else {
s_printf("\r\n");
user->cur_mail_area = j;
}
}
}
*/
void next_mail_conf(struct user_record *user) {
int i;

View File

@ -451,10 +451,10 @@ int menu_system(char *menufile) {
bwave_upload_reply();
break;
case MENU_CHOOSEFILEDIR:
choose_directory(gUser);
choose_directory();
break;
case MENU_CHOOSEFILESUB:
choose_subdir(gUser);
choose_subdir();
break;
case MENU_LISTFILES:
list_files(gUser);