Skip to content

Commit

Permalink
Ensure request protocol and method are displayed only if available.
Browse files Browse the repository at this point in the history
  • Loading branch information
allinurl committed Jan 26, 2014
1 parent 7674128 commit 9a808e6
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions gdashboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,12 +504,16 @@ static void
render_method (WINDOW * win, GDashModule * module_data, int y, int *x, int idx,
int w, int selected)
{
const char *method = module_data->data[idx].method;
const GDashStyle *style = module_style;
GModule module = module_data->module;

if (style[module].color_method == -1)
return;

if (method == NULL || *method == '\0')
return;

if (selected) {
if (conf.color_scheme == STD_GREEN)
init_pair (1, COLOR_BLACK, COLOR_GREEN);
Expand All @@ -518,11 +522,11 @@ render_method (WINDOW * win, GDashModule * module_data, int y, int *x, int idx,

wattron (win, COLOR_PAIR (HIGHLIGHT));
mvwhline (win, y, *x, ' ', w);
mvwprintw (win, y, *x, "%s", module_data->data[idx].method);
mvwprintw (win, y, *x, "%s", method);
wattroff (win, COLOR_PAIR (HIGHLIGHT));
} else {
wattron (win, A_BOLD | COLOR_PAIR (style[module].color_method));
mvwprintw (win, y, *x, "%s", module_data->data[idx].method);
mvwprintw (win, y, *x, "%s", method);
wattroff (win, A_BOLD | COLOR_PAIR (style[module].color_method));
}
*x += strlen (module_data->data[idx].method) + DASH_SPACE;
Expand All @@ -533,12 +537,16 @@ static void
render_protocol (WINDOW * win, GDashModule * module_data, int y, int *x,
int idx, int w, int selected)
{
const char *protocol = module_data->data[idx].protocol;
const GDashStyle *style = module_style;
GModule module = module_data->module;

if (style[module].color_protocol == -1)
return;

if (protocol == NULL || *protocol == '\0')
return;

if (selected) {
if (conf.color_scheme == STD_GREEN)
init_pair (1, COLOR_BLACK, COLOR_GREEN);
Expand All @@ -547,11 +555,11 @@ render_protocol (WINDOW * win, GDashModule * module_data, int y, int *x,

wattron (win, COLOR_PAIR (HIGHLIGHT));
mvwhline (win, y, *x, ' ', w);
mvwprintw (win, y, *x, "%s", module_data->data[idx].protocol);
mvwprintw (win, y, *x, "%s", protocol);
wattroff (win, COLOR_PAIR (HIGHLIGHT));
} else {
wattron (win, COLOR_PAIR (style[module].color_protocol));
mvwprintw (win, y, *x, "%s", module_data->data[idx].protocol);
mvwprintw (win, y, *x, "%s", protocol);
wattroff (win, COLOR_PAIR (style[module].color_protocol));
}
*x += REQ_PROTO_LEN - 1 + DASH_SPACE;
Expand Down

0 comments on commit 9a808e6

Please sign in to comment.