aboutsummaryrefslogtreecommitdiff
path: root/unix/sun/arrow.c
diff options
context:
space:
mode:
authorJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
committerJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
commit40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch)
tree4464880c571602d54f6ae114729bf62a89518057 /unix/sun/arrow.c
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'unix/sun/arrow.c')
-rw-r--r--unix/sun/arrow.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/unix/sun/arrow.c b/unix/sun/arrow.c
new file mode 100644
index 00000000..1cc55aad
--- /dev/null
+++ b/unix/sun/arrow.c
@@ -0,0 +1,66 @@
+/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+ */
+
+#include <sys/types.h>
+#include <sundev/kbio.h>
+#include <sundev/kbd.h>
+
+/*
+ * ARROW.C -- Code to enable and disable the arrow key function-key mappings
+ * (R8,10,12,14).
+ */
+
+#define NKEYS 4
+static unsigned char station[NKEYS] = { 0x45, 0x5b, 0x5d, 0x71 };
+static unsigned char entry[NKEYS] = { RF(8), RF(10), RF(12), RF(14) };
+static struct kiockey o_key[NKEYS];
+
+
+/* DISABLE_ARROW_KEYS -- Save the arrow key keyboard translation table
+ * entries, and then disable the mapping of the function keys to the ANSI
+ * arrow key sequences. This is necessary to read the function key as
+ * an event rather than an escape sequence in a Sunview event handler.
+ */
+disable_arrow_keys()
+{
+ register int fd, i;
+ struct kiockey key;
+ int status = 0;
+
+ if ((fd = open ("/dev/kbd", 2)) == -1)
+ return (-1);
+
+ for (i=0; i < NKEYS; i++) {
+ o_key[i].kio_station = station[i];
+ if ((status = ioctl (fd, KIOCGETKEY, &o_key[i])) != 0)
+ break;
+ key = o_key[i];
+ key.kio_entry = entry[i];
+ if ((status = ioctl (fd, KIOCSETKEY, &key)) != 0)
+ break;
+ }
+
+ close (fd);
+ return (status);
+}
+
+
+/* ENABLE_ARROW_KEYS -- Restore the saved arrow key keyboard translation table
+ * entries.
+ */
+enable_arrow_keys()
+{
+ register int fd, i;
+ struct kiockey key;
+ int status = 0;
+
+ if ((fd = open ("/dev/kbd", 2)) == -1)
+ return (-1);
+
+ for (i=0; i < NKEYS; i++)
+ if ((status = ioctl (fd, KIOCSETKEY, &o_key[i])) != 0)
+ break;
+
+ close (fd);
+ return (status);
+}