aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils.c
diff options
context:
space:
mode:
authorFrederic Culot <calcurse@culot.org>2009-01-24 14:44:09 +0000
committerFrederic Culot <calcurse@culot.org>2009-01-24 14:44:09 +0000
commitc8a1b720277bb31df1cbd7cae6a4615255d9d04f (patch)
treef75f15def6c2fd0ddd5bf04768a0230ccb699a59 /src/utils.c
parent9abf70b4a66171904cf8040c0808ee788ccd47f9 (diff)
downloadcalcurse-c8a1b720277bb31df1cbd7cae6a4615255d9d04f.tar.gz
calcurse-c8a1b720277bb31df1cbd7cae6a4615255d9d04f.zip
make it possible to use KEY_HOME and KEY_END to define new key bindings, and prevent user from assigning a non-recgnized key
Diffstat (limited to 'src/utils.c')
-rwxr-xr-xsrc/utils.c33
1 files changed, 31 insertions, 2 deletions
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.