summaryrefslogtreecommitdiff
path: root/Build/source/utils/dialog/dialog-1.1-20080819/mousewget.c
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2009-03-19 13:59:30 +0000
committerPeter Breitenlohner <peb@mppmu.mpg.de>2009-03-19 13:59:30 +0000
commit0b7b2c69ec83497d9accab064da0f4ad07662d42 (patch)
treee8f22a2acecbf3035850f56beb1c8161c53cdf2d /Build/source/utils/dialog/dialog-1.1-20080819/mousewget.c
parentee507bbd1fc483c58acb33cca25509a4dd81df9b (diff)
prepare for new build system
git-svn-id: svn://tug.org/texlive/trunk@12429 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/dialog/dialog-1.1-20080819/mousewget.c')
-rw-r--r--Build/source/utils/dialog/dialog-1.1-20080819/mousewget.c91
1 files changed, 91 insertions, 0 deletions
diff --git a/Build/source/utils/dialog/dialog-1.1-20080819/mousewget.c b/Build/source/utils/dialog/dialog-1.1-20080819/mousewget.c
new file mode 100644
index 00000000000..13a021bfc02
--- /dev/null
+++ b/Build/source/utils/dialog/dialog-1.1-20080819/mousewget.c
@@ -0,0 +1,91 @@
+/*
+ * $Id: mousewget.c,v 1.21 2008/03/16 20:09:03 tom Exp $
+ *
+ * mousewget.c -- mouse/wgetch support for dialog
+ *
+ * Copyright 2000-2006,2008 Thomas E. Dickey
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License, version 2.1
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to
+ * Free Software Foundation, Inc.
+ * 51 Franklin St., Fifth Floor
+ * Boston, MA 02110, USA.
+ */
+
+#include <dialog.h>
+#include <dlg_keys.h>
+
+static int
+mouse_wgetch(WINDOW *win, int *fkey, bool ignore_errs)
+{
+ int mouse_err = FALSE;
+ int key;
+
+ do {
+
+ key = dlg_getc(win, fkey);
+
+#if USE_MOUSE
+
+ mouse_err = FALSE;
+ if (fkey && (key == KEY_MOUSE)) {
+ MEVENT event;
+ mseRegion *p;
+
+ if (getmouse(&event) != ERR) {
+ if ((p = dlg_mouse_region(event.y, event.x)) != 0) {
+ key = DLGK_MOUSE(p->code);
+ } else if ((p = dlg_mouse_bigregion(event.y, event.x)) != 0) {
+ int x = event.x - p->x;
+ int y = event.y - p->y;
+ int row = (p->X - p->x) / p->step_x;
+
+ key = -(p->code);
+ switch (p->mode) {
+ case 1: /* index by lines */
+ key += y;
+ break;
+ case 2: /* index by columns */
+ key += (x / p->step_x);
+ break;
+ default:
+ case 3: /* index by cells */
+ key += (x / p->step_x) + (y * row);
+ break;
+ }
+ } else {
+ (void) beep();
+ mouse_err = TRUE;
+ }
+ } else {
+ (void) beep();
+ mouse_err = TRUE;
+ }
+ }
+#endif
+
+ } while (ignore_errs && mouse_err);
+
+ return key;
+}
+
+int
+dlg_mouse_wgetch(WINDOW *win, int *fkey)
+{
+ return mouse_wgetch(win, fkey, TRUE);
+}
+
+int
+dlg_mouse_wgetch_nowait(WINDOW *win, int *fkey)
+{
+ return mouse_wgetch(win, fkey, FALSE);
+}