Skip to content

Commit

Permalink
added active module indication by name
Browse files Browse the repository at this point in the history
  • Loading branch information
allinurl committed Jul 27, 2013
1 parent 33092d5 commit 22dcb8c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
14 changes: 5 additions & 9 deletions goaccess.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,16 +344,12 @@ render_screens (GLog * logger)
refresh ();

/* call general stats header */
display_general (header_win, conf.ifile, logger->piping,
logger->process, logger->invalid, logger->resp_size);
display_general (header_win, conf.ifile, logger->piping, logger->process,
logger->invalid, logger->resp_size);
wrefresh (header_win);

/* display active label based on current module */
wattron (header_win, COLOR_PAIR (BLUE_GREEN));
wmove (header_win, 0, 30);
mvwprintw (header_win, 0, col - 18, "[Active Module %d]", scrolling.current);
wattroff (header_win, COLOR_PAIR (BLUE_GREEN));
wrefresh (header_win);
update_active_module (header_win, scrolling.current);

display_content (main_win, logger, dash, &scrolling);
/* no valid entries to process from the log */
Expand Down Expand Up @@ -414,7 +410,7 @@ get_keys (GLog * logger)
scrolling.current++;
if (scrolling.current == TOTAL_MODULES)
scrolling.current = 0;
update_active_module (header_win, scrolling.current);
render_screens (logger);
break;
case 353: /* Shift TAB */
/* reset expanded module */
Expand All @@ -423,7 +419,7 @@ get_keys (GLog * logger)
scrolling.current = TOTAL_MODULES - 1;
else
scrolling.current--;
update_active_module (header_win, scrolling.current);
render_screens (logger);
break;
case 'g': /* g = top */
if (!scrolling.expanded)
Expand Down
26 changes: 25 additions & 1 deletion ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,39 @@ term_size (WINDOW * main_win)
wmove (main_win, real_size_y, 0);
}

const char *
module_to_label (GModule module)
{
static const char *modules[] = {
"Visitors",
"Requests",
"Static Requests",
"Not Found",
"Hosts",
"OS",
"Browsers",
"Referrers",
"Referring Sites",
"Keyphrases",
"Status Codes"
};

return modules[module];
}

/* rerender header window to reflect active module */
void
update_active_module (WINDOW * header_win, GModule current)
{
const char *module = module_to_label (current);
int col = getmaxx (stdscr);

char *lbl = xmalloc (snprintf (NULL, 0, "[Active Module: %s]", module) + 1);
sprintf (lbl, "[Active Module: %s]", module);

wattron (header_win, COLOR_PAIR (BLUE_GREEN));
wmove (header_win, 0, 30);
mvwprintw (header_win, 0, col - 18, "[Active Module %d]", current);
mvwprintw (header_win, 0, col - strlen (lbl) - 1, "%s", lbl);
wattroff (header_win, COLOR_PAIR (BLUE_GREEN));
wrefresh (header_win);
}
Expand Down

0 comments on commit 22dcb8c

Please sign in to comment.