R UI: file list key actions
I UI: bottom keys menu
This commit is contained in:
+41
-2
@@ -89,6 +89,25 @@ void draw_borders(app_t *app) {
|
|||||||
box(app->right_win, 0, 0);
|
box(app->right_win, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct action_key {
|
||||||
|
char *const key;
|
||||||
|
char *const title;
|
||||||
|
};
|
||||||
|
|
||||||
|
int64_t print_bottom_menu_option(WINDOW *win, char *key, char *title, int64_t y,
|
||||||
|
int64_t x, int32_t size) {
|
||||||
|
int32_t key_len = 0;
|
||||||
|
int32_t title_len = 0;
|
||||||
|
|
||||||
|
wattrset(win, A_BOLD);
|
||||||
|
mvwprintw(win, y, x, " %s%n", key, &key_len);
|
||||||
|
size -= key_len + strlen(title) + 1;
|
||||||
|
wattrset(win, COLOR_PAIR(4) | A_REVERSE);
|
||||||
|
mvwprintw(win, y, x + key_len, "%s %*s%n", title, size, "", &title_len);
|
||||||
|
wattrset(win, COLOR_PAIR(0) | A_REVERSE);
|
||||||
|
return key_len + title_len;
|
||||||
|
}
|
||||||
|
|
||||||
void print_bars(app_t *app) {
|
void print_bars(app_t *app) {
|
||||||
char top_text[64] = "Hello!";
|
char top_text[64] = "Hello!";
|
||||||
|
|
||||||
@@ -111,8 +130,28 @@ void print_bars(app_t *app) {
|
|||||||
mvwprintw(app->win, 1, 2, "%s", top_text);
|
mvwprintw(app->win, 1, 2, "%s", top_text);
|
||||||
|
|
||||||
/* add content to the bottom bar */
|
/* add content to the bottom bar */
|
||||||
mvwprintw(app->win, app->coordinates.cur_y - 2, 2,
|
|
||||||
"F1 - Help | U - upload | S - search | F9 - Quit");
|
struct action_key action_keys[] = {
|
||||||
|
{.key = "F1", .title = "Help"},
|
||||||
|
{.key = "U", .title = "Upload"},
|
||||||
|
{.key = "S", .title = "Search"},
|
||||||
|
{.key = "F9", .title = "Quit"},
|
||||||
|
};
|
||||||
|
|
||||||
|
int t_margin = 0; /* tab margin */
|
||||||
|
int c_size = app->coordinates.max_x / 4; /* column size */
|
||||||
|
int incr_last = app->coordinates.max_x % 4; /* increment size fo the last element (fill empty space) */
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
struct action_key *k = &action_keys[i];
|
||||||
|
t_margin +=
|
||||||
|
print_bottom_menu_option(app->win, k->key, k->title,
|
||||||
|
app->coordinates.cur_y - 2, t_margin, c_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
t_margin += print_bottom_menu_option(
|
||||||
|
app->win, action_keys[3].key, action_keys[3].title,
|
||||||
|
app->coordinates.cur_y - 2, t_margin, c_size + incr_last);
|
||||||
|
|
||||||
wattroff(app->win, A_REVERSE);
|
wattroff(app->win, A_REVERSE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,19 +115,10 @@ void dialogue_default_callback(callback_args_t *args) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KEY_UP:
|
case KEY_UP:
|
||||||
if (d->active_el->type == w_fs_file_list) {
|
|
||||||
new_args.element = d->g_content;
|
|
||||||
group_default_callback(&new_args);
|
|
||||||
} else {
|
|
||||||
/* CH_GROUP(d, g_action, g_content); */
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case KEY_DOWN:
|
case KEY_DOWN:
|
||||||
if (d->active_el->type == w_fs_file_list) {
|
if (d->active_el->type == w_fs_file_list) {
|
||||||
new_args.element = d->g_content;
|
new_args.element = d->g_content;
|
||||||
group_default_callback(&new_args);
|
group_default_callback(&new_args);
|
||||||
} else {
|
|
||||||
/* CH_GROUP(d, g_content, g_action); */
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
#include "fs_file_list.h"
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ncursesw/ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
@@ -13,6 +12,9 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <utils.h>
|
#include <utils.h>
|
||||||
|
|
||||||
|
#include "fs_file_list.h"
|
||||||
|
#include "widget_core.h"
|
||||||
|
|
||||||
void reset_file_list(ui_fs_file_list_t *fl_ui);
|
void reset_file_list(ui_fs_file_list_t *fl_ui);
|
||||||
|
|
||||||
struct fl_args {
|
struct fl_args {
|
||||||
|
|||||||
Reference in New Issue
Block a user