1
0
mirror of https://git.zap.org.au/git/trader.git synced 2024-07-21 16:14:14 -04:00

Change the handling of default value keycodes to be configurable

This commit is contained in:
John Zaitseff 2011-08-30 12:45:45 +10:00
parent 0a518102ec
commit 8bbee054ad
6 changed files with 84 additions and 38 deletions

View File

@ -14,8 +14,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: trader 7.3\n" "Project-Id-Version: trader 7.3\n"
"Report-Msgid-Bugs-To: J.Zaitseff@zap.org.au\n" "Report-Msgid-Bugs-To: J.Zaitseff@zap.org.au\n"
"POT-Creation-Date: 2011-08-30 09:08+1000\n" "POT-Creation-Date: 2011-08-30 12:38+1000\n"
"PO-Revision-Date: 2011-08-30 08:26+1000\n" "PO-Revision-Date: 2011-08-30 12:42+1000\n"
"Last-Translator: John Zaitseff <J.Zaitseff@zap.org.au>\n" "Last-Translator: John Zaitseff <J.Zaitseff@zap.org.au>\n"
"Language-Team: English (Australian)\n" "Language-Team: English (Australian)\n"
"Language: en_AU\n" "Language: en_AU\n"
@ -1409,7 +1409,7 @@ msgstr "Page %d of %d"
#. TRANSLATORS: The reason the user is not asked "Press any #. TRANSLATORS: The reason the user is not asked "Press any
#. key to continue" is historical: many, many people used to #. key to continue" is historical: many, many people used to
#. ask "where is the <ANY> key?" :-) #. ask "where is the <ANY> key?" :-)
#: src/help.c:473 src/intf.c:3025 #: src/help.c:473 src/intf.c:3035
msgid "[ Press <SPACE> to continue ] " msgid "[ Press <SPACE> to continue ] "
msgstr "[ Press <SPACE> to continue ] " msgstr "[ Press <SPACE> to continue ] "
@ -1451,7 +1451,17 @@ msgstr "mkchstr_conv: NUL"
msgid "mkchstr: `%s'" msgid "mkchstr: `%s'"
msgstr "mkchstr: %s" msgstr "mkchstr: %s"
#: src/intf.c:2025 src/intf.c:2070 #. TRANSLATORS: This string specifies the keycodes used to insert the
#. default value into the input string, if entered as the very first
#. character. Ideally, it should contain an easily-accessible
#. keycode that would NOT be used in ordinary input. Digits, ".",
#. ",", "+" and "-" are definitely NOT acceptable.
#: src/intf.c:2020
msgctxt "input|DefaultValue"
msgid "=;"
msgstr "=;"
#: src/intf.c:2034 src/intf.c:2079
#, c-format #, c-format
msgid "gettxline: illegal character in string: `%ls'" msgid "gettxline: illegal character in string: `%ls'"
msgstr "gettxline: illegal character in string: %ls" msgstr "gettxline: illegal character in string: %ls"
@ -1460,12 +1470,12 @@ msgstr "gettxline: illegal character in string: %ls"
#. "input|No" contain the keycodes used to determine whether a #. "input|No" contain the keycodes used to determine whether a
#. user is answering "Yes" or "No" in response to some question. #. user is answering "Yes" or "No" in response to some question.
#. Both upper and lower-case versions should be present. #. Both upper and lower-case versions should be present.
#: src/intf.c:2942 #: src/intf.c:2952
msgctxt "input|Yes" msgctxt "input|Yes"
msgid "Yy" msgid "Yy"
msgstr "Yy" msgstr "Yy"
#: src/intf.c:2944 #: src/intf.c:2954
msgctxt "input|No" msgctxt "input|No"
msgid "Nn" msgid "Nn"
msgstr "Nn" msgstr "Nn"
@ -1473,12 +1483,12 @@ msgstr "Nn"
#. TRANSLATORS: The strings "Yes" and "No" are printed as a #. TRANSLATORS: The strings "Yes" and "No" are printed as a
#. response to user input in answer to questions like "Are you #. response to user input in answer to questions like "Are you
#. sure? [Y/N] " #. sure? [Y/N] "
#: src/intf.c:2995 #: src/intf.c:3005
msgctxt "answer" msgctxt "answer"
msgid "Yes" msgid "Yes"
msgstr "Yes" msgstr "Yes"
#: src/intf.c:2997 #: src/intf.c:3007
msgctxt "answer" msgctxt "answer"
msgid "No" msgid "No"
msgstr "No" msgstr "No"

View File

@ -14,8 +14,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: trader 7.3\n" "Project-Id-Version: trader 7.3\n"
"Report-Msgid-Bugs-To: J.Zaitseff@zap.org.au\n" "Report-Msgid-Bugs-To: J.Zaitseff@zap.org.au\n"
"POT-Creation-Date: 2011-08-30 09:08+1000\n" "POT-Creation-Date: 2011-08-30 12:38+1000\n"
"PO-Revision-Date: 2011-08-30 08:26+1000\n" "PO-Revision-Date: 2011-08-30 12:43+1000\n"
"Last-Translator: John Zaitseff <J.Zaitseff@zap.org.au>\n" "Last-Translator: John Zaitseff <J.Zaitseff@zap.org.au>\n"
"Language-Team: English (Canadian)\n" "Language-Team: English (Canadian)\n"
"Language: en_CA\n" "Language: en_CA\n"
@ -1409,7 +1409,7 @@ msgstr "Page %d of %d"
#. TRANSLATORS: The reason the user is not asked "Press any #. TRANSLATORS: The reason the user is not asked "Press any
#. key to continue" is historical: many, many people used to #. key to continue" is historical: many, many people used to
#. ask "where is the <ANY> key?" :-) #. ask "where is the <ANY> key?" :-)
#: src/help.c:473 src/intf.c:3025 #: src/help.c:473 src/intf.c:3035
msgid "[ Press <SPACE> to continue ] " msgid "[ Press <SPACE> to continue ] "
msgstr "[ Press <SPACE> to continue ] " msgstr "[ Press <SPACE> to continue ] "
@ -1451,7 +1451,17 @@ msgstr "mkchstr_conv: NUL"
msgid "mkchstr: `%s'" msgid "mkchstr: `%s'"
msgstr "mkchstr: %s" msgstr "mkchstr: %s"
#: src/intf.c:2025 src/intf.c:2070 #. TRANSLATORS: This string specifies the keycodes used to insert the
#. default value into the input string, if entered as the very first
#. character. Ideally, it should contain an easily-accessible
#. keycode that would NOT be used in ordinary input. Digits, ".",
#. ",", "+" and "-" are definitely NOT acceptable.
#: src/intf.c:2020
msgctxt "input|DefaultValue"
msgid "=;"
msgstr "=;"
#: src/intf.c:2034 src/intf.c:2079
#, c-format #, c-format
msgid "gettxline: illegal character in string: `%ls'" msgid "gettxline: illegal character in string: `%ls'"
msgstr "gettxline: illegal character in string: %ls" msgstr "gettxline: illegal character in string: %ls"
@ -1460,12 +1470,12 @@ msgstr "gettxline: illegal character in string: %ls"
#. "input|No" contain the keycodes used to determine whether a #. "input|No" contain the keycodes used to determine whether a
#. user is answering "Yes" or "No" in response to some question. #. user is answering "Yes" or "No" in response to some question.
#. Both upper and lower-case versions should be present. #. Both upper and lower-case versions should be present.
#: src/intf.c:2942 #: src/intf.c:2952
msgctxt "input|Yes" msgctxt "input|Yes"
msgid "Yy" msgid "Yy"
msgstr "Yy" msgstr "Yy"
#: src/intf.c:2944 #: src/intf.c:2954
msgctxt "input|No" msgctxt "input|No"
msgid "Nn" msgid "Nn"
msgstr "Nn" msgstr "Nn"
@ -1473,12 +1483,12 @@ msgstr "Nn"
#. TRANSLATORS: The strings "Yes" and "No" are printed as a #. TRANSLATORS: The strings "Yes" and "No" are printed as a
#. response to user input in answer to questions like "Are you #. response to user input in answer to questions like "Are you
#. sure? [Y/N] " #. sure? [Y/N] "
#: src/intf.c:2995 #: src/intf.c:3005
msgctxt "answer" msgctxt "answer"
msgid "Yes" msgid "Yes"
msgstr "Yes" msgstr "Yes"
#: src/intf.c:2997 #: src/intf.c:3007
msgctxt "answer" msgctxt "answer"
msgid "No" msgid "No"
msgstr "No" msgstr "No"

View File

@ -14,8 +14,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: trader 7.3\n" "Project-Id-Version: trader 7.3\n"
"Report-Msgid-Bugs-To: J.Zaitseff@zap.org.au\n" "Report-Msgid-Bugs-To: J.Zaitseff@zap.org.au\n"
"POT-Creation-Date: 2011-08-30 09:08+1000\n" "POT-Creation-Date: 2011-08-30 12:38+1000\n"
"PO-Revision-Date: 2011-08-30 08:26+1000\n" "PO-Revision-Date: 2011-08-30 12:43+1000\n"
"Last-Translator: John Zaitseff <J.Zaitseff@zap.org.au>\n" "Last-Translator: John Zaitseff <J.Zaitseff@zap.org.au>\n"
"Language-Team: English (British)\n" "Language-Team: English (British)\n"
"Language: en_GB\n" "Language: en_GB\n"
@ -1409,7 +1409,7 @@ msgstr "Page %d of %d"
#. TRANSLATORS: The reason the user is not asked "Press any #. TRANSLATORS: The reason the user is not asked "Press any
#. key to continue" is historical: many, many people used to #. key to continue" is historical: many, many people used to
#. ask "where is the <ANY> key?" :-) #. ask "where is the <ANY> key?" :-)
#: src/help.c:473 src/intf.c:3025 #: src/help.c:473 src/intf.c:3035
msgid "[ Press <SPACE> to continue ] " msgid "[ Press <SPACE> to continue ] "
msgstr "[ Press <SPACE> to continue ] " msgstr "[ Press <SPACE> to continue ] "
@ -1451,7 +1451,17 @@ msgstr "mkchstr_conv: NUL"
msgid "mkchstr: `%s'" msgid "mkchstr: `%s'"
msgstr "mkchstr: %s" msgstr "mkchstr: %s"
#: src/intf.c:2025 src/intf.c:2070 #. TRANSLATORS: This string specifies the keycodes used to insert the
#. default value into the input string, if entered as the very first
#. character. Ideally, it should contain an easily-accessible
#. keycode that would NOT be used in ordinary input. Digits, ".",
#. ",", "+" and "-" are definitely NOT acceptable.
#: src/intf.c:2020
msgctxt "input|DefaultValue"
msgid "=;"
msgstr "=;"
#: src/intf.c:2034 src/intf.c:2079
#, c-format #, c-format
msgid "gettxline: illegal character in string: `%ls'" msgid "gettxline: illegal character in string: `%ls'"
msgstr "gettxline: illegal character in string: %ls" msgstr "gettxline: illegal character in string: %ls"
@ -1460,12 +1470,12 @@ msgstr "gettxline: illegal character in string: %ls"
#. "input|No" contain the keycodes used to determine whether a #. "input|No" contain the keycodes used to determine whether a
#. user is answering "Yes" or "No" in response to some question. #. user is answering "Yes" or "No" in response to some question.
#. Both upper and lower-case versions should be present. #. Both upper and lower-case versions should be present.
#: src/intf.c:2942 #: src/intf.c:2952
msgctxt "input|Yes" msgctxt "input|Yes"
msgid "Yy" msgid "Yy"
msgstr "Yy" msgstr "Yy"
#: src/intf.c:2944 #: src/intf.c:2954
msgctxt "input|No" msgctxt "input|No"
msgid "Nn" msgid "Nn"
msgstr "Nn" msgstr "Nn"
@ -1473,12 +1483,12 @@ msgstr "Nn"
#. TRANSLATORS: The strings "Yes" and "No" are printed as a #. TRANSLATORS: The strings "Yes" and "No" are printed as a
#. response to user input in answer to questions like "Are you #. response to user input in answer to questions like "Are you
#. sure? [Y/N] " #. sure? [Y/N] "
#: src/intf.c:2995 #: src/intf.c:3005
msgctxt "answer" msgctxt "answer"
msgid "Yes" msgid "Yes"
msgstr "Yes" msgstr "Yes"
#: src/intf.c:2997 #: src/intf.c:3007
msgctxt "answer" msgctxt "answer"
msgid "No" msgid "No"
msgstr "No" msgstr "No"

View File

@ -14,8 +14,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: trader 7.3\n" "Project-Id-Version: trader 7.3\n"
"Report-Msgid-Bugs-To: J.Zaitseff@zap.org.au\n" "Report-Msgid-Bugs-To: J.Zaitseff@zap.org.au\n"
"POT-Creation-Date: 2011-08-30 09:08+1000\n" "POT-Creation-Date: 2011-08-30 12:38+1000\n"
"PO-Revision-Date: 2011-08-30 08:27+1000\n" "PO-Revision-Date: 2011-08-30 12:43+1000\n"
"Last-Translator: John Zaitseff <J.Zaitseff@zap.org.au>\n" "Last-Translator: John Zaitseff <J.Zaitseff@zap.org.au>\n"
"Language-Team: English\n" "Language-Team: English\n"
"Language: en_US\n" "Language: en_US\n"
@ -1409,7 +1409,7 @@ msgstr "Page %d of %d"
#. TRANSLATORS: The reason the user is not asked "Press any #. TRANSLATORS: The reason the user is not asked "Press any
#. key to continue" is historical: many, many people used to #. key to continue" is historical: many, many people used to
#. ask "where is the <ANY> key?" :-) #. ask "where is the <ANY> key?" :-)
#: src/help.c:473 src/intf.c:3025 #: src/help.c:473 src/intf.c:3035
msgid "[ Press <SPACE> to continue ] " msgid "[ Press <SPACE> to continue ] "
msgstr "[ Press <SPACE> to continue ] " msgstr "[ Press <SPACE> to continue ] "
@ -1451,7 +1451,17 @@ msgstr "mkchstr_conv: NUL"
msgid "mkchstr: `%s'" msgid "mkchstr: `%s'"
msgstr "mkchstr: %s" msgstr "mkchstr: %s"
#: src/intf.c:2025 src/intf.c:2070 #. TRANSLATORS: This string specifies the keycodes used to insert the
#. default value into the input string, if entered as the very first
#. character. Ideally, it should contain an easily-accessible
#. keycode that would NOT be used in ordinary input. Digits, ".",
#. ",", "+" and "-" are definitely NOT acceptable.
#: src/intf.c:2020
msgctxt "input|DefaultValue"
msgid "=;"
msgstr "=;"
#: src/intf.c:2034 src/intf.c:2079
#, c-format #, c-format
msgid "gettxline: illegal character in string: `%ls'" msgid "gettxline: illegal character in string: `%ls'"
msgstr "gettxline: illegal character in string: %ls" msgstr "gettxline: illegal character in string: %ls"
@ -1460,12 +1470,12 @@ msgstr "gettxline: illegal character in string: %ls"
#. "input|No" contain the keycodes used to determine whether a #. "input|No" contain the keycodes used to determine whether a
#. user is answering "Yes" or "No" in response to some question. #. user is answering "Yes" or "No" in response to some question.
#. Both upper and lower-case versions should be present. #. Both upper and lower-case versions should be present.
#: src/intf.c:2942 #: src/intf.c:2952
msgctxt "input|Yes" msgctxt "input|Yes"
msgid "Yy" msgid "Yy"
msgstr "Yy" msgstr "Yy"
#: src/intf.c:2944 #: src/intf.c:2954
msgctxt "input|No" msgctxt "input|No"
msgid "Nn" msgid "Nn"
msgstr "Nn" msgstr "Nn"
@ -1473,12 +1483,12 @@ msgstr "Nn"
#. TRANSLATORS: The strings "Yes" and "No" are printed as a #. TRANSLATORS: The strings "Yes" and "No" are printed as a
#. response to user input in answer to questions like "Are you #. response to user input in answer to questions like "Are you
#. sure? [Y/N] " #. sure? [Y/N] "
#: src/intf.c:2995 #: src/intf.c:3005
msgctxt "answer" msgctxt "answer"
msgid "Yes" msgid "Yes"
msgstr "Yes" msgstr "Yes"
#: src/intf.c:2997 #: src/intf.c:3007
msgctxt "answer" msgctxt "answer"
msgid "No" msgid "No"
msgstr "No" msgstr "No"

View File

@ -1993,6 +1993,7 @@ int gettxline (WINDOW *win, wchar_t *restrict buf, int bufsize,
const wchar_t *allowed, bool stripspc, int y, int x, const wchar_t *allowed, bool stripspc, int y, int x,
int width, chtype attr) int width, chtype attr)
{ {
wchar_t *keycode_defval;
bool done, redraw, mod; bool done, redraw, mod;
int len, pos, st; int len, pos, st;
int clen, cpos; int clen, cpos;
@ -2010,6 +2011,14 @@ int gettxline (WINDOW *win, wchar_t *restrict buf, int bufsize,
chbuf = xmalloc(BUFSIZE * sizeof(chtype)); chbuf = xmalloc(BUFSIZE * sizeof(chtype));
keycode_defval = xmalloc(BUFSIZE * sizeof(wchar_t));
/* TRANSLATORS: This string specifies the keycodes used to insert the
default value into the input string, if entered as the very first
character. Ideally, it should contain an easily-accessible
keycode that would NOT be used in ordinary input. Digits, ".",
",", "+" and "-" are definitely NOT acceptable. */
xmbstowcs(keycode_defval, pgettext("input|DefaultValue", "=;"), BUFSIZE);
keypad(win, true); keypad(win, true);
meta(win, true); meta(win, true);
wtimeout(win, -1); wtimeout(win, -1);
@ -2055,8 +2064,8 @@ int gettxline (WINDOW *win, wchar_t *restrict buf, int bufsize,
if (rcode == OK) { if (rcode == OK) {
// Ordinary wide character // Ordinary wide character
if ((key == CHAR_DEFVAL1 || key == CHAR_DEFVAL2) if (defaultval != NULL && len == 0
&& defaultval != NULL && len == 0) { && wcschr(keycode_defval, key) != NULL) {
// Initialise buffer with the default value // Initialise buffer with the default value
wcsncpy(buf, defaultval, bufsize - 1); wcsncpy(buf, defaultval, bufsize - 1);
@ -2705,6 +2714,7 @@ int gettxline (WINDOW *win, wchar_t *restrict buf, int bufsize,
} }
free(chbuf); free(chbuf);
free(keycode_defval);
return ret; return ret;
} }

View File

@ -101,10 +101,6 @@ typedef enum curs_type {
#define KEY_CTRL(x) ((x) - 0100) // ASCII control character #define KEY_CTRL(x) ((x) - 0100) // ASCII control character
// Keycodes for inserting the default value in input routines
#define CHAR_DEFVAL1 L'='
#define CHAR_DEFVAL2 L';'
// Control-arrow key combinations, as returned by Ncurses // Control-arrow key combinations, as returned by Ncurses
#ifndef KEY_CDOWN #ifndef KEY_CDOWN
# define KEY_CDOWN 01007 // CTRL + Down Arrow # define KEY_CDOWN 01007 // CTRL + Down Arrow