Stubplement an Info tab, make Help special

This commit is contained in:
Přemysl Eric Janouch 2016-10-04 07:10:08 +02:00
parent 8dff378617
commit 4a5be612c5
Signed by: p
GPG Key ID: B715679E3A361BE6
1 changed files with 47 additions and 13 deletions

View File

@ -224,7 +224,8 @@ static struct app_context
struct config config; ///< Program configuration struct config config; ///< Program configuration
struct tab *tabs; ///< All tabs struct tab *help_tab; ///< Special help tab
struct tab *tabs; ///< All other tabs
struct tab *active_tab; ///< Active tab struct tab *active_tab; ///< Active tab
// Emulated widgets: // Emulated widgets:
@ -897,9 +898,10 @@ app_redraw_top (void)
attrset (APP_ATTR (TAB_BAR)); attrset (APP_ATTR (TAB_BAR));
app_next_row (0); app_next_row (0);
// TODO: render this with APP_ATTR (TAB_ACTIVE) when the help tab is selected;
// ...maybe the help tab should not even be on the list? // The help tab is disguised so that it's not too intruding
size_t indent = app_write_utf8 (APP_TITLE, 0, -1); size_t indent = app_write_utf8 (APP_TITLE,
g_ctx.active_tab == g_ctx.help_tab ? APP_ATTR (TAB_ACTIVE) : 0, -1);
addch (' '); addch (' ');
indent++; indent++;
@ -1332,9 +1334,12 @@ app_process_left_mouse_click (int line, int column)
{ {
struct tab *winner = NULL; struct tab *winner = NULL;
int indent = strlen (APP_TITLE); int indent = strlen (APP_TITLE);
// TODO: set the winner to the special help tab in this case
if (column < indent) if (column < indent)
{
g_ctx.active_tab = g_ctx.help_tab;
app_redraw ();
return; return;
}
for (struct tab *iter = g_ctx.tabs; !winner && iter; iter = iter->next) for (struct tab *iter = g_ctx.tabs; !winner && iter; iter = iter->next)
{ {
if (column < (indent += iter->name_width)) if (column < (indent += iter->name_width))
@ -1795,6 +1800,36 @@ help_tab_create (void)
return super; return super;
} }
// --- Info tab ----------------------------------------------------------------
// TODO: either find something else to put in here or remove the wrapper struct
static struct
{
struct tab super; ///< Parent class
}
g_info_tab;
static void
info_tab_on_item_draw (struct tab *self, unsigned item_index,
struct row_buffer *buffer, int width)
{
(void) self;
(void) width;
// TODO
}
static struct tab *
info_tab_create (void)
{
struct tab *super = &g_info_tab.super;
tab_init (super, "Info");
super->on_item_draw = info_tab_on_item_draw;
super->item_count = 0;
super->item_selected = 0;
return super;
}
// --- Debug tab --------------------------------------------------------------- // --- Debug tab ---------------------------------------------------------------
struct debug_item struct debug_item
@ -2083,21 +2118,20 @@ main (int argc, char *argv[])
app_init_terminal (); app_init_terminal ();
// Redirect all messages from liberty to a special tab so they're not lost // Redirect all messages from liberty to a special tab so they're not lost
struct tab *new_tab;
if (g_debug_mode) if (g_debug_mode)
{ {
struct tab *tab = debug_tab_create (); new_tab = debug_tab_create ();
LIST_PREPEND (g_ctx.tabs, tab); LIST_PREPEND (g_ctx.tabs, new_tab);
} }
g_log_message_real = app_log_handler; g_log_message_real = app_log_handler;
// TODO: create more tabs, beware of the list macro new_tab = info_tab_create ();
{ LIST_PREPEND (g_ctx.tabs, new_tab);
struct tab *tab = help_tab_create ();
LIST_PREPEND (g_ctx.tabs, tab);
}
g_ctx.active_tab = g_ctx.tabs; g_ctx.help_tab = help_tab_create ();
g_ctx.active_tab = g_ctx.help_tab;
app_redraw (); app_redraw ();
signals_setup_handlers (); signals_setup_handlers ();