summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/fe-text/statusbar-items.c21
-rw-r--r--src/fe-text/statusbar.c6
-rw-r--r--src/fe-text/statusbar.h1
3 files changed, 20 insertions, 8 deletions
diff --git a/src/fe-text/statusbar-items.c b/src/fe-text/statusbar-items.c
index 7b3294be..8243a9ac 100644
--- a/src/fe-text/statusbar-items.c
+++ b/src/fe-text/statusbar-items.c
@@ -314,7 +314,7 @@ static void sig_statusbar_channel_redraw_window_item(WI_ITEM_REC *item)
statusbar_item_redraw(channel_item);
}
-static void draw_activity(gchar *title, gboolean act, gboolean det)
+static void draw_activity(gchar *title, gboolean act, gboolean det, int size)
{
WINDOW_REC *window;
GList *tmp;
@@ -324,7 +324,7 @@ static void draw_activity(gchar *title, gboolean act, gboolean det)
set_color(stdscr, sbar_color_normal); addstr(title);
first = TRUE;
- for (tmp = activity_list; tmp != NULL; tmp = tmp->next)
+ for (tmp = activity_list; tmp != NULL && size > 0; tmp = tmp->next)
{
window = tmp->data;
@@ -338,6 +338,7 @@ static void draw_activity(gchar *title, gboolean act, gboolean det)
{
set_color(stdscr, sbar_color_dim);
addch(',');
+ size--;
}
ltoa(str, window->refnum);
@@ -358,11 +359,17 @@ static void draw_activity(gchar *title, gboolean act, gboolean det)
set_color(stdscr, sbar_color_act_highlight);
break;
}
+ if (strlen(str) > size)
+ break;
+
+ size -= strlen(str);
addstr(str);
}
}
-/* redraw activity */
+/* redraw activity, FIXME: if we didn't get enough size, this gets buggy.
+ At least "Det:" isn't printed properly. also we should rearrange the
+ act list so that the highest priority items comes first. */
static void statusbar_activity(SBAR_ITEM_REC *item, int ypos)
{
WINDOW_REC *window;
@@ -388,21 +395,21 @@ static void statusbar_activity(SBAR_ITEM_REC *item, int ypos)
if (det) size_needed += 6; /* [Det: ], -1 */
if (act && det) size_needed--;
- if (item->size != size_needed)
+ if (!item->shrinked && item->size != size_needed)
{
/* we need more (or less..) space! */
statusbar_item_resize(item, size_needed);
return;
}
- if (item->size == 0)
+ if (item->size <= 7)
return;
move(ypos, item->xpos);
set_color(stdscr, sbar_color_dim); addch('[');
- if (act) draw_activity("Act: ", TRUE, !det);
+ if (act) draw_activity("Act: ", TRUE, !det, item->size-1);
if (act && det) addch(' ');
- if (det) draw_activity("Det: ", FALSE, TRUE);
+ if (det) draw_activity("Det: ", FALSE, TRUE, item->size-1);
set_color(stdscr, sbar_color_dim); addch(']');
screen_refresh(NULL);
diff --git a/src/fe-text/statusbar.c b/src/fe-text/statusbar.c
index 30f18efe..775bc87a 100644
--- a/src/fe-text/statusbar.c
+++ b/src/fe-text/statusbar.c
@@ -57,11 +57,15 @@ static void statusbar_redraw_line(STATUSBAR_REC *bar)
SBAR_ITEM_REC *rec = tmp->data;
if (!rec->right_justify &&
- (rec->max_size || xpos+rec->size < COLS)) {
+ (rec->max_size || xpos < COLS)) {
rec->xpos = xpos;
if (rec->max_size)
rec->size = COLS-1-xpos;
+ rec->shrinked = xpos+rec->size >= COLS;
+ if (rec->shrinked)
+ rec->size = COLS-1-xpos;
+
func = (STATUSBAR_FUNC) rec->func;
func(rec, bar->ypos);
diff --git a/src/fe-text/statusbar.h b/src/fe-text/statusbar.h
index f8011dbe..d49984fa 100644
--- a/src/fe-text/statusbar.h
+++ b/src/fe-text/statusbar.h
@@ -19,6 +19,7 @@ typedef struct {
STATUSBAR_REC *bar;
int xpos, size;
+ int shrinked; /* couldn't give the requested size */
int right_justify, max_size;
void *func;
} SBAR_ITEM_REC;