pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
pinentry-fltk: Patch for keyboard shortcuts in buttons added
Module Name: pkgsrc-wip
Committed By: Michael Baeuerle <michael.baeuerle%stz-e.de@localhost>
Pushed By: micha
Date: Mon Jan 21 10:16:45 2019 +0100
Changeset: f0d0dbe4c3ffd3034d6f228f9510ae22c9ad3ff0
Modified Files:
pinentry-fltk/TODO
pinentry-fltk/patches/patch-fltk_main.cxx
Log Message:
pinentry-fltk: Patch for keyboard shortcuts in buttons added
GPG2 passes the button label string with hint for keyboard shortcut
as underscore (e.g. "_OK"). This is now correctly converted to the
internal representation of FLTK (&).
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=f0d0dbe4c3ffd3034d6f228f9510ae22c9ad3ff0
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
pinentry-fltk/TODO | 3 +-
pinentry-fltk/patches/patch-fltk_main.cxx | 61 ++++++++++++++++++++++++++++++-
2 files changed, 61 insertions(+), 3 deletions(-)
diffs:
diff --git a/pinentry-fltk/TODO b/pinentry-fltk/TODO
index 1bd4facd8c..23597adac2 100644
--- a/pinentry-fltk/TODO
+++ b/pinentry-fltk/TODO
@@ -1 +1,2 @@
-[ ] Keyboard shortcut handling (via '_') doesn't work yet
+[X] Keyboard shortcut handling (via '_') doesn't work yet
+ => Patch added
diff --git a/pinentry-fltk/patches/patch-fltk_main.cxx b/pinentry-fltk/patches/patch-fltk_main.cxx
index 315673d54a..d6af2ef915 100644
--- a/pinentry-fltk/patches/patch-fltk_main.cxx
+++ b/pinentry-fltk/patches/patch-fltk_main.cxx
@@ -1,10 +1,67 @@
$NetBSD$
+Handle '_' in labels as keyboard shortcuts (used by GPG2).
Fix format string handling (Patch from Debian).
--- fltk/main.cxx.orig 2017-12-03 16:13:05.000000000 +0000
+++ fltk/main.cxx
-@@ -241,12 +241,12 @@ static int fltk_cmd_handler(pinentry_t p
+@@ -78,6 +78,44 @@ static std::string escape_accel_utf8(con
+ return result;
+ }
+
++// For button labels
++// Accelerator '_' (used e.g. by GPG2) is converted to '&' (for FLTK)
++// '&' is escaped as in escape_accel_utf8()
++static std::string convert_accel_utf8(const char *s)
++{
++ static bool last_was_underscore = false;
++ std::string result;
++ if (NULL != s)
++ {
++ result.reserve(strlen(s));
++ for (const char *p = s; *p; ++p)
++ {
++ // & => &&
++ if ('&' == *p)
++ result.push_back(*p);
++ // _ => & (handle '__' as escaped underscore)
++ if ('_' == *p)
++ {
++ if (last_was_underscore)
++ {
++ result.push_back(*p);
++ last_was_underscore = false;
++ }
++ else
++ last_was_underscore = true;
++ }
++ else
++ {
++ if (last_was_underscore)
++ result.push_back('&');
++ result.push_back(*p);
++ last_was_underscore = false;
++ }
++ }
++ }
++ return result;
++}
++
+ class cancel_exception
+ {
+
+@@ -111,8 +149,8 @@ static int fltk_cmd_handler(pinentry_t p
+ // TODO: Add parent window to pinentry-fltk window
+ //if (pe->parent_wid){}
+ std::string title = !is_empty(pe->title)?pe->title:PGMNAME;
+- std::string ok = escape_accel_utf8(pe->ok?pe->ok:(pe->default_ok?pe->default_ok:OK_STRING));
+- std::string cancel = escape_accel_utf8(pe->cancel?pe->cancel:(pe->default_cancel?pe->default_cancel:CANCEL_STRING));
++ std::string ok = convert_accel_utf8(pe->ok?pe->ok:(pe->default_ok?pe->default_ok:OK_STRING));
++ std::string cancel = convert_accel_utf8(pe->cancel?pe->cancel:(pe->default_cancel?pe->default_cancel:CANCEL_STRING));
+
+ if (!!pe->pin) // password (or confirmation)
+ {
+@@ -241,12 +279,12 @@ static int fltk_cmd_handler(pinentry_t p
if (pe->one_button)
{
fl_ok = ok.c_str();
@@ -19,7 +76,7 @@ Fix format string handling (Patch from Debian).
{
case 0: result = 1; break;
case 2: result = 0; break;
-@@ -256,7 +256,7 @@ static int fltk_cmd_handler(pinentry_t p
+@@ -256,7 +294,7 @@ static int fltk_cmd_handler(pinentry_t p
}
else
{
Home |
Main Index |
Thread Index |
Old Index