Implement blink on fancy status
and fix a bug with condition labels on the TTY status
This commit is contained in:
committed by
Pasi Kallinen
parent
24d9c19378
commit
3398d250aa
@@ -331,6 +331,9 @@ extern void (*input_func)(Widget, XEvent *, String *, Cardinal *);
|
|||||||
|
|
||||||
extern struct window_procs X11_procs;
|
extern struct window_procs X11_procs;
|
||||||
|
|
||||||
|
/* Flag maintained by the blink callback */
|
||||||
|
extern boolean X11_blink;
|
||||||
|
|
||||||
/* Check for an invalid window id. */
|
/* Check for an invalid window id. */
|
||||||
#define check_winid(window) \
|
#define check_winid(window) \
|
||||||
do { \
|
do { \
|
||||||
@@ -424,6 +427,9 @@ extern void destroy_status_window(struct xwindow *);
|
|||||||
extern void adjust_status(struct xwindow *, const char *);
|
extern void adjust_status(struct xwindow *, const char *);
|
||||||
extern void null_out_status(void);
|
extern void null_out_status(void);
|
||||||
extern void check_turn_events(void);
|
extern void check_turn_events(void);
|
||||||
|
#ifdef STATUS_HILITES
|
||||||
|
extern void X11_tty_status_blink(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* ### wintext.c ### */
|
/* ### wintext.c ### */
|
||||||
extern void delete_text(Widget, XEvent *, String *, Cardinal *);
|
extern void delete_text(Widget, XEvent *, String *, Cardinal *);
|
||||||
@@ -519,11 +525,13 @@ extern XFontStruct *X11_italic_font(Display *, XFontStruct *);
|
|||||||
extern XFontStruct *X11_unicode_font(Display *, XFontStruct *);
|
extern XFontStruct *X11_unicode_font(Display *, XFontStruct *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* ### winlabel.c ### */
|
||||||
/* Functions for management of enhanced labels */
|
/* Functions for management of enhanced labels */
|
||||||
extern void X11_wrap_widget(Widget);
|
extern void X11_wrap_widget(Widget);
|
||||||
extern void X11_update_label(Widget);
|
extern void X11_update_label(Widget);
|
||||||
extern void X11_set_attrs(Widget, unsigned);
|
extern void X11_set_attrs(Widget, unsigned);
|
||||||
extern void X11_set_highlight(Widget, boolean);
|
extern void X11_set_highlight(Widget, boolean);
|
||||||
extern void X11_set_percent(Widget, unsigned, Pixel);
|
extern void X11_set_percent(Widget, unsigned, Pixel);
|
||||||
|
extern void X11_blink_labels(void);
|
||||||
|
|
||||||
#endif /* WINX_H */
|
#endif /* WINX_H */
|
||||||
|
|||||||
@@ -112,6 +112,9 @@ static void X11_error_handler(String) __attribute__((noreturn));
|
|||||||
ATTRNORETURN static XtErrorHandler X11_error_handler(String);
|
ATTRNORETURN static XtErrorHandler X11_error_handler(String);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
boolean X11_blink;
|
||||||
|
static unsigned blink_interval = 500; /* milliseconds */
|
||||||
|
|
||||||
static int X11_io_error_handler(Display *);
|
static int X11_io_error_handler(Display *);
|
||||||
|
|
||||||
static int (*old_error_handler)(Display *, XErrorEvent *);
|
static int (*old_error_handler)(Display *, XErrorEvent *);
|
||||||
@@ -200,6 +203,7 @@ static void release_yn_widgets(void);
|
|||||||
static int input_event(int);
|
static int input_event(int);
|
||||||
static void win_visible(Widget, XtPointer, XEvent *, Boolean *);
|
static void win_visible(Widget, XtPointer, XEvent *, Boolean *);
|
||||||
static void init_standard_windows(void);
|
static void init_standard_windows(void);
|
||||||
|
static void blink_callback(XtPointer client_data, XtIntervalId *timer);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Local variables.
|
* Local variables.
|
||||||
@@ -1611,6 +1615,7 @@ X11_init_nhwindows(int *argcp, char **argv)
|
|||||||
(ArgList) args, num_args);
|
(ArgList) args, num_args);
|
||||||
XtOverrideTranslations(toplevel,
|
XtOverrideTranslations(toplevel,
|
||||||
XtParseTranslationTable("<Message>WM_PROTOCOLS: X11_hangup()"));
|
XtParseTranslationTable("<Message>WM_PROTOCOLS: X11_hangup()"));
|
||||||
|
XtAppAddTimeOut(app_context, blink_interval, blink_callback, NULL);
|
||||||
|
|
||||||
/* We don't need to realize the top level widget. */
|
/* We don't need to realize the top level widget. */
|
||||||
|
|
||||||
@@ -1667,6 +1672,20 @@ X11_init_nhwindows(int *argcp, char **argv)
|
|||||||
X11_putstr(WIN_MESSAGE, 0, copyright_banner_line(i));
|
X11_putstr(WIN_MESSAGE, 0, copyright_banner_line(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
blink_callback(XtPointer client_data, XtIntervalId *timer)
|
||||||
|
{
|
||||||
|
nhUse(timer);
|
||||||
|
#ifdef STATUS_HILITES
|
||||||
|
X11_tty_status_blink();
|
||||||
|
#endif
|
||||||
|
X11_blink_labels();
|
||||||
|
|
||||||
|
X11_blink = !X11_blink;
|
||||||
|
/* Do it again */
|
||||||
|
XtAppAddTimeOut(app_context, blink_interval, blink_callback, client_data);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* All done.
|
* All done.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -282,6 +282,9 @@ update_label(Widget w, WidgetData *data)
|
|||||||
values.foreground = (values.foreground & 0xFEFEFE) >> 1;
|
values.foreground = (values.foreground & 0xFEFEFE) >> 1;
|
||||||
values.background = (values.background & 0xFEFEFE) >> 1;
|
values.background = (values.background & 0xFEFEFE) >> 1;
|
||||||
}
|
}
|
||||||
|
if ((attrs & HL_BLINK) && X11_blink) {
|
||||||
|
values.foreground = values.background;
|
||||||
|
}
|
||||||
values.font = font->fid;
|
values.font = font->fid;
|
||||||
values.function = GXcopy;
|
values.function = GXcopy;
|
||||||
GC ggc = XtGetGC(w,
|
GC ggc = XtGetGC(w,
|
||||||
@@ -505,3 +508,17 @@ delete_widget(Widget w)
|
|||||||
}
|
}
|
||||||
--num_widgets;
|
--num_widgets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/* Call every time the blink flag changes */
|
||||||
|
void
|
||||||
|
X11_blink_labels(void)
|
||||||
|
{
|
||||||
|
for (unsigned i = 0; i < num_widgets; ++i) {
|
||||||
|
WidgetBucket *bucket = &widget_table[i];
|
||||||
|
if (bucket->data->attrs & HL_BLINK) {
|
||||||
|
update_label(bucket->w, bucket->data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+5
-23
@@ -112,9 +112,6 @@ static void adjust_status_fancy(struct xwindow *, const char *);
|
|||||||
static void adjust_status_tty(struct xwindow *, const char *);
|
static void adjust_status_tty(struct xwindow *, const char *);
|
||||||
static void set_percent(int, int, int);
|
static void set_percent(int, int, int);
|
||||||
static void tty_status_exposed(Widget, XtPointer, XtPointer);
|
static void tty_status_exposed(Widget, XtPointer, XtPointer);
|
||||||
#ifdef STATUS_HILITES
|
|
||||||
static void tty_status_blink(XtPointer client_data, XtIntervalId *timer);
|
|
||||||
#endif
|
|
||||||
static void tty_status_redraw(Widget);
|
static void tty_status_redraw(Widget);
|
||||||
static int tty_render_field(Widget, int, int, enum statusfields);
|
static int tty_render_field(Widget, int, int, enum statusfields);
|
||||||
static void tty_status_colors(Widget, int, int, Pixel *, Pixel *);
|
static void tty_status_colors(Widget, int, int, Pixel *, Pixel *);
|
||||||
@@ -207,10 +204,6 @@ struct tty_cond_field {
|
|||||||
static Widget X11_status_widget;
|
static Widget X11_status_widget;
|
||||||
static struct tty_status_field X11_status_labels[MAXBLSTATS];
|
static struct tty_status_field X11_status_labels[MAXBLSTATS];
|
||||||
static struct tty_cond_field X11_cond_labels[32]; /* Ugh */
|
static struct tty_cond_field X11_cond_labels[32]; /* Ugh */
|
||||||
#ifdef STATUS_HILITES
|
|
||||||
static boolean blink;
|
|
||||||
static const unsigned long blink_interval = 500; /* milliseconds */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static struct xwindow *xw_status_win;
|
static struct xwindow *xw_status_win;
|
||||||
|
|
||||||
@@ -361,7 +354,7 @@ X11_status_update_tty(
|
|||||||
for (unsigned j = 0; j < SIZE(tt_condorder); ++j) {
|
for (unsigned j = 0; j < SIZE(tt_condorder); ++j) {
|
||||||
if ((mask & tt_condorder[j].mask) != 0) {
|
if ((mask & tt_condorder[j].mask) != 0) {
|
||||||
struct tty_cond_field *fldp = &X11_cond_labels[j];
|
struct tty_cond_field *fldp = &X11_cond_labels[j];
|
||||||
fldp->attrs |= 0x1 << (i - CLR_MAX);
|
fldp->attrs |= 0x1 << (i - HL_ATTCLR_NONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -542,10 +535,6 @@ create_tty_status(Widget parent, Widget top)
|
|||||||
|
|
||||||
XtAddCallback(X11_status_widget, XtNexposeCallback, tty_status_exposed,
|
XtAddCallback(X11_status_widget, XtNexposeCallback, tty_status_exposed,
|
||||||
(XtPointer) 0);
|
(XtPointer) 0);
|
||||||
#ifdef STATUS_HILITES
|
|
||||||
XtAppAddTimeOut(app_context, blink_interval, tty_status_blink,
|
|
||||||
(XtPointer) X11_status_widget);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return X11_status_widget;
|
return X11_status_widget;
|
||||||
}
|
}
|
||||||
@@ -564,12 +553,9 @@ tty_status_exposed(Widget w, XtPointer client_data, /* unused */
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef STATUS_HILITES
|
#ifdef STATUS_HILITES
|
||||||
static void
|
void
|
||||||
tty_status_blink(XtPointer client_data, XtIntervalId *timer)
|
X11_tty_status_blink(void)
|
||||||
{
|
{
|
||||||
Widget w = (Widget) client_data;
|
|
||||||
nhUse(timer);
|
|
||||||
|
|
||||||
/* Do we have any active blink attributes? */
|
/* Do we have any active blink attributes? */
|
||||||
boolean have_blink = FALSE;
|
boolean have_blink = FALSE;
|
||||||
for (unsigned i = 0; i < SIZE(X11_status_labels) && !have_blink; ++i) {
|
for (unsigned i = 0; i < SIZE(X11_status_labels) && !have_blink; ++i) {
|
||||||
@@ -580,12 +566,8 @@ tty_status_blink(XtPointer client_data, XtIntervalId *timer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (have_blink) {
|
if (have_blink) {
|
||||||
tty_status_redraw(w);
|
tty_status_redraw(X11_status_widget);
|
||||||
blink = !blink;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do it again */
|
|
||||||
XtAppAddTimeOut(app_context, blink_interval, tty_status_blink, client_data);
|
|
||||||
}
|
}
|
||||||
#endif /* STATUS_HILITES */
|
#endif /* STATUS_HILITES */
|
||||||
|
|
||||||
@@ -933,7 +915,7 @@ tty_status_colors(Widget w, int color, int attr, Pixel *fgpixel, Pixel *bgpixel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Implement blink */
|
/* Implement blink */
|
||||||
if ((attr & HL_BLINK) && blink) {
|
if ((attr & HL_BLINK) && X11_blink) {
|
||||||
*fgpixel = *bgpixel;
|
*fgpixel = *bgpixel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user