summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2018-06-20 15:52:58 +0000
committerAlbrecht Schlosser <albrechts.fltk@online.de>2018-06-20 15:52:58 +0000
commitec0ac46aa869143be91b194e400bf700be9fc558 (patch)
treedec6c63f1902382ed7f66e74073eda9da5b5296f /src/drivers
parent0a6ebfea9dd7c0feecbc590679588f5088fd6f58 (diff)
Move platform specific shortcut code to platform drivers.
Tested on Windows and Linux (not tested on MacOS/Android). git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12951 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/Darwin/Fl_Darwin_System_Driver.cxx48
-rw-r--r--src/drivers/X11/Fl_X11_System_Driver.H8
-rw-r--r--src/drivers/X11/Fl_X11_System_Driver.cxx24
3 files changed, 77 insertions, 3 deletions
diff --git a/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx b/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx
index 335bbc8ec..aa18e09c4 100644
--- a/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx
+++ b/src/drivers/Darwin/Fl_Darwin_System_Driver.cxx
@@ -16,8 +16,10 @@
// http://www.fltk.org/str.php
//
+// *FIXME* Do we really need config_lib.h ? We should NOT!
+// *FIXME* We should not even need config.h in this file. AlbrechtS.
+// #include "../../config_lib.h"
-#include "../../config_lib.h"
#include "Fl_Darwin_System_Driver.H"
#include <FL/platform.H>
#include <FL/Fl.H>
@@ -38,6 +40,47 @@
#include <sys/mount.h>
#include <sys/stat.h>
+// This key table is used for the Darwin system driver. It is defined here
+// "static" and assigned in the constructor to avoid static initialization
+// race conditions. It is used in fl_shortcut.cxx.
+//
+// This table must be in numeric order by fltk (X) keysym number:
+
+Fl_System_Driver::Keyname darwin_key_table[] = {
+ // v - this column may contain UTF-8 characters
+ {' ', "Space"},
+ {FL_BackSpace, "\xe2\x8c\xab"}, // erase to the left
+ {FL_Tab, "\xe2\x87\xa5"}, // rightwards arrow to bar
+ {0xff0b, "\xe2\x8c\xa6"}, // erase to the right
+ {FL_Enter, "\xe2\x86\xa9"}, // leftwards arrow with hook
+ {FL_Pause, "Pause"},
+ {FL_Scroll_Lock, "Scroll_Lock"},
+ {FL_Escape, "\xe2\x90\x9b"},
+ {FL_Home, "\xe2\x86\x96"}, // north west arrow
+ {FL_Left, "\xe2\x86\x90"}, // leftwards arrow
+ {FL_Up, "\xe2\x86\x91"}, // upwards arrow
+ {FL_Right, "\xe2\x86\x92"}, // rightwards arrow
+ {FL_Down, "\xe2\x86\x93"}, // downwards arrow
+ {FL_Page_Up, "\xe2\x87\x9e"}, // upwards arrow with double stroke
+ {FL_Page_Down, "\xe2\x87\x9f"}, // downwards arrow with double stroke
+ {FL_End, "\xe2\x86\x98"}, // south east arrow
+ {FL_Print, "Print"},
+ {FL_Insert, "Insert"},
+ {FL_Menu, "Menu"},
+ {FL_Num_Lock, "Num_Lock"},
+ {FL_KP_Enter, "\xe2\x8c\xa4"}, // up arrow head between two horizontal bars
+ {FL_Shift_L, "Shift_L"},
+ {FL_Shift_R, "Shift_R"},
+ {FL_Control_L, "Control_L"},
+ {FL_Control_R, "Control_R"},
+ {FL_Caps_Lock, "\xe2\x87\xaa"}, // upwards white arrow from bar
+ {FL_Meta_L, "Meta_L"},
+ {FL_Meta_R, "Meta_R"},
+ {FL_Alt_L, "Alt_L"},
+ {FL_Alt_R, "Alt_R"},
+ {FL_Delete, "\xe2\x8c\xa7"} // x in a rectangle box
+};
+
const char *Fl_Darwin_System_Driver::shift_name() {
return "⇧\\"; // "\xe2\x87\xa7\\"; // U+21E7 (upwards white arrow)
}
@@ -63,6 +106,9 @@ Fl_System_Driver *Fl_System_Driver::newSystemDriver()
Fl_Darwin_System_Driver::Fl_Darwin_System_Driver() : Fl_Posix_System_Driver() {
if (fl_mac_os_version == 0) fl_mac_os_version = calc_mac_os_version();
+ // initialize key table
+ key_table = darwin_key_table;
+ key_table_size = sizeof(darwin_key_table)/sizeof(*darwin_key_table);
}
int Fl_Darwin_System_Driver::single_arg(const char *arg) {
diff --git a/src/drivers/X11/Fl_X11_System_Driver.H b/src/drivers/X11/Fl_X11_System_Driver.H
index 1f24ff511..b7d6e9ff7 100644
--- a/src/drivers/X11/Fl_X11_System_Driver.H
+++ b/src/drivers/X11/Fl_X11_System_Driver.H
@@ -4,7 +4,7 @@
// Definition of Posix system driver
// for the Fast Light Tool Kit (FLTK).
//
-// Copyright 2010-2016 by Bill Spitzak and others.
+// Copyright 2010-2018 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
@@ -24,7 +24,11 @@
class Fl_X11_System_Driver : public Fl_Posix_System_Driver {
public:
- Fl_X11_System_Driver() : Fl_Posix_System_Driver() {}
+ Fl_X11_System_Driver() : Fl_Posix_System_Driver() {
+ // X11 system driver does not use a key table
+ key_table = NULL;
+ key_table_size = 0;
+ }
virtual void display_arg(const char *arg);
virtual int XParseGeometry(const char*, int*, int*, unsigned int*, unsigned int*);
virtual int clocale_printf(FILE *output, const char *format, va_list args);
diff --git a/src/drivers/X11/Fl_X11_System_Driver.cxx b/src/drivers/X11/Fl_X11_System_Driver.cxx
index 491e08226..42d403299 100644
--- a/src/drivers/X11/Fl_X11_System_Driver.cxx
+++ b/src/drivers/X11/Fl_X11_System_Driver.cxx
@@ -517,6 +517,30 @@ int Fl_X11_System_Driver::utf8locale() {
return ret;
}
+#if !defined(FL_DOXYGEN)
+
+const char *Fl_X11_System_Driver::shortcut_add_key_name(unsigned key, char *p, char *buf, const char **eom)
+{
+ const char* q;
+ if (key == FL_Enter || key == '\r') q = "Enter"; // don't use Xlib's "Return":
+ else if (key > 32 && key < 0x100) q = 0;
+ else q = XKeysymToString(key);
+ if (!q) {
+ p += fl_utf8encode(fl_toupper(key), p);
+ *p = 0;
+ return buf;
+ }
+ if (p > buf) {
+ strcpy(p,q);
+ return buf;
+ } else {
+ if (eom) *eom = q;
+ return q;
+ }
+}
+
+#endif // !defined(FL_DOXYGEN)
+
//
// End of "$Id$".
//