1
0
mirror of https://github.com/irssi/irssi.git synced 2025-01-03 14:56:47 -05:00

Ugly quick hack to make act: never disappear but print as much activity

to statusbar as fits.


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1172 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2001-01-31 11:23:29 +00:00 committed by cras
parent 8acf2cd5f9
commit 2a31ecaa32
3 changed files with 20 additions and 8 deletions

View File

@ -314,7 +314,7 @@ static void sig_statusbar_channel_redraw_window_item(WI_ITEM_REC *item)
statusbar_item_redraw(channel_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; WINDOW_REC *window;
GList *tmp; GList *tmp;
@ -324,7 +324,7 @@ static void draw_activity(gchar *title, gboolean act, gboolean det)
set_color(stdscr, sbar_color_normal); addstr(title); set_color(stdscr, sbar_color_normal); addstr(title);
first = TRUE; 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; window = tmp->data;
@ -338,6 +338,7 @@ static void draw_activity(gchar *title, gboolean act, gboolean det)
{ {
set_color(stdscr, sbar_color_dim); set_color(stdscr, sbar_color_dim);
addch(','); addch(',');
size--;
} }
ltoa(str, window->refnum); 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); set_color(stdscr, sbar_color_act_highlight);
break; break;
} }
if (strlen(str) > size)
break;
size -= strlen(str);
addstr(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) static void statusbar_activity(SBAR_ITEM_REC *item, int ypos)
{ {
WINDOW_REC *window; 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 (det) size_needed += 6; /* [Det: ], -1 */
if (act && det) size_needed--; if (act && det) size_needed--;
if (item->size != size_needed) if (!item->shrinked && item->size != size_needed)
{ {
/* we need more (or less..) space! */ /* we need more (or less..) space! */
statusbar_item_resize(item, size_needed); statusbar_item_resize(item, size_needed);
return; return;
} }
if (item->size == 0) if (item->size <= 7)
return; return;
move(ypos, item->xpos); move(ypos, item->xpos);
set_color(stdscr, sbar_color_dim); addch('['); 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 (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(']'); set_color(stdscr, sbar_color_dim); addch(']');
screen_refresh(NULL); screen_refresh(NULL);

View File

@ -57,11 +57,15 @@ static void statusbar_redraw_line(STATUSBAR_REC *bar)
SBAR_ITEM_REC *rec = tmp->data; SBAR_ITEM_REC *rec = tmp->data;
if (!rec->right_justify && if (!rec->right_justify &&
(rec->max_size || xpos+rec->size < COLS)) { (rec->max_size || xpos < COLS)) {
rec->xpos = xpos; rec->xpos = xpos;
if (rec->max_size) if (rec->max_size)
rec->size = COLS-1-xpos; 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 = (STATUSBAR_FUNC) rec->func;
func(rec, bar->ypos); func(rec, bar->ypos);

View File

@ -19,6 +19,7 @@ typedef struct {
STATUSBAR_REC *bar; STATUSBAR_REC *bar;
int xpos, size; int xpos, size;
int shrinked; /* couldn't give the requested size */
int right_justify, max_size; int right_justify, max_size;
void *func; void *func;
} SBAR_ITEM_REC; } SBAR_ITEM_REC;