From c8a1b720277bb31df1cbd7cae6a4615255d9d04f Mon Sep 17 00:00:00 2001 From: Frederic Culot Date: Sat, 24 Jan 2009 14:44:09 +0000 Subject: make it possible to use KEY_HOME and KEY_END to define new key bindings, and prevent user from assigning a non-recgnized key --- src/utils.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'src/utils.c') diff --git a/src/utils.c b/src/utils.c index 561b78e..6d83742 100755 --- a/src/utils.c +++ b/src/utils.c @@ -1,4 +1,4 @@ -/* $calcurse: utils.c,v 1.67 2009/01/05 20:12:08 culot Exp $ */ +/* $calcurse: utils.c,v 1.68 2009/01/24 14:44:25 culot Exp $ */ /* * Calcurse - text-based organizer @@ -81,12 +81,15 @@ fatalbox (const char *errmsg) { WINDOW *errwin; char *label = _("/!\\ INTERNAL ERROR /!\\"); - char *reportmsg = _("Please report the following bug:"); + char *reportmsg = _("Please report the following bug:"); const int WINROW = 10; const int WINCOL = col - 2; const int MSGLEN = WINCOL - 2; char msg[MSGLEN]; + if (errmsg == 0) + return; + (void)strncpy (msg, errmsg, MSGLEN); errwin = newwin (WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2); custom_apply_attr (errwin, ATTR_HIGHEST); @@ -101,6 +104,32 @@ fatalbox (const char *errmsg) doupdate (); } +void +warnbox (const char *msg) +{ + WINDOW *warnwin; + char *label = "/!\\"; + const int WINROW = 10; + const int WINCOL = col - 2; + const int MSGLEN = WINCOL - 2; + char displmsg[MSGLEN]; + + if (msg == 0) + return; + + (void)strncpy (displmsg, msg, MSGLEN); + warnwin = newwin (WINROW, WINCOL, (row - WINROW) / 2, (col - WINCOL) / 2); + custom_apply_attr (warnwin, ATTR_HIGHEST); + box (warnwin, 0, 0); + wins_show (warnwin, label); + mvwprintw (warnwin, 5, (WINCOL - strlen (displmsg)) / 2, "%s", displmsg); + custom_remove_attr (warnwin, ATTR_HIGHEST); + wrefresh (warnwin); + (void)wgetch (warnwin); + delwin (warnwin); + doupdate (); +} + /* * Print a message in the status bar. * Message texts for first line and second line are to be provided. -- cgit v1.2.3-54-g00ecf