Re: [PATCH] prompt_yn() accepts only keys from prompt_keys
Michael Bienia <[email protected]>
| Newsgroups | gmane.network.tin.devel |
|---|---|
| Message-ID | <[email protected]> |
On 2005-02-12 15:20:02 +0100, Urs JanÃen wrote: > On Fri, Feb 11, 2005 at 08:48:01PM +0100, Michael Bienia wrote: > > - or should they get added only when explicitly defined in the keymap > > file? > > this would be the cleaner approach, but then we should make > keymap.sample look like: > PromptYes y Y > PromptNo n N > and describle the possibillity of multiple keybindings (in tin.5) and > check the rest of the code where we (silently) allow uppercase > answers and ... Here are the changes to keymap.sample and tin.5 to document this possibility. I've also merged the other duplicate keynames this way and tried to stay compatible with older keymap files. "PageDown3" wasn't merged with "PageDown" because of the seperate handling in page.c. Michael
patch-20050308.diff
(text/plain, 9.7 KB)
doc/keymap.sample | 55 +++++++++++++++++-------------------------------
doc/tin.5 | 61 +++++++++++++++++++-----------------------------------
include/version.h | 2 -
src/keymap.c | 22 +++++--------------
4 files changed, 49 insertions(+), 91 deletions(-)
diff -Nurp tin-1.7.8/doc/keymap.sample tin-1.7.8.new/doc/keymap.sample
--- tin-1.7.8/doc/keymap.sample 2005-02-04 20:53:30.000000000 +0100
+++ tin-1.7.8.new/doc/keymap.sample 2005-03-07 18:04:08.910265341 +0100
@@ -1,4 +1,4 @@
-# Keymap file V1.0.2 for the TIN newsreader
+# Keymap file V1.0.3 for the TIN newsreader
#
# Sample keymap file
# This file contains the default key mappings
@@ -20,16 +20,15 @@ ToggleHelpDisplay H
ToggleInverseVideo I
LookupMessage L
OptionMenu M
-Postponed2 O
+Postponed O ^O
QuitTin Q
DisplayPostHist W
FirstPage ^
SearchAuthF a
-PageUp3 b
Help h
ToggleInfoLastLine i
-Down2 j
-Up2 k
+Down j ^N
+Up k ^P
Print o
Quit q
Version v
@@ -37,19 +36,13 @@ Post w
Pipe |
ScrollUp <
ScrollDown >
-PageUp ^B
-PageDown ^D
-PageDown2 ^F
+PageUp b ^B ^U
+PageDown ^D ^F
RedrawScr ^L
-Down ^N
-Postponed ^O
-Up ^P
-PageUp2 ^U
#####
-ConfigSelect ^J
-ConfigSelect2 ^M
+ConfigSelect ^J ^M
ConfigLastPage2 G
ConfigNoSave Q
ConfigFirstPage2 g
@@ -73,9 +66,8 @@ FilterSave s
GroupAutoSel ^A
GroupNextUnreadArtOrGrp TAB
-GroupReadBasenote ^J
+GroupReadBasenote ^J ^M
GroupKill ^K
-GroupReadBasenote2 ^M
GroupSelThd *
GroupDoAutoSel +
GroupToggleThdSel .
@@ -89,7 +81,7 @@ GroupMarkThdRead K
GroupNextUnreadArt N
GroupPrevUnreadArt P
GroupBugReport R
-GroupAutoSave S
+GroupAutoSave S
GroupTagParts T
GroupUntag U
GroupMarkUnselArtRead X
@@ -123,9 +115,8 @@ PageReplyQuoteHeaders ^E
PagePGPCheckArticle ^G
PageToggleHeaders ^H
PageNextUnread TAB
-PageNextThd ^J
+PageNextThd ^J ^M
PageAutoKill ^K
-PageNextThd2 ^M
PageToggleTabs ^T
PageFollowupQuoteHeaders ^W
PageToggleTex2iso "
@@ -144,7 +135,7 @@ PageKillThd K
PageNextUnreadArt N
PagePrevUnreadArt P
PageReply R
-PageAutoSave S
+PageAutoSave S
PageGroupSel T
PageViewUrl U
PageViewAttach V
@@ -184,10 +175,8 @@ PostContinue c
PostAbort a
PostIgnore i
PostMail m
-PostPost2 y
-PostPost3 p
-PostSend s
-PostSend2 y
+PostPost p y
+PostSend s y
PostSupersede s
PostPostpone o
@@ -198,8 +187,8 @@ PostponeAll A
#####
-PromptYes y
-PromptNo n
+PromptYes y Y
+PromptNo n N
#####
@@ -214,9 +203,8 @@ PProcYes y
#####
-SelectEnterNextUnreadGrp TAB
-SelectReadGrp ^J
-SelectReadGrp2 ^M
+SelectEnterNextUnreadGrp TAB n
+SelectReadGrp ^J ^M
SelectResetNewsrc ^R
SelectCatchupNextUnread C
SelectNextUnreadGrp N
@@ -225,32 +213,29 @@ SelectSubscribePat S
SelectUnsubscribePat U
SelectQuitNoWrite X
SelectSyncWithActive Y
-SelectMarkGrpUnread2 Z
SelectCatchup c
SelectToggleDescriptions d
SelectGoto g
SelectMoveGrp m
-SelectEnterNextUnreadGrp2 n
SelectToggleReadDisplay r
SelectSubscribe s
SelectUnsubscribe u
SelectYankActive y
-SelectMarkGrpUnread z
+SelectMarkGrpUnread z Z
#####
ThreadReadNextArtOrThread TAB
ThreadAutoSel ^A
-ThreadReadArt ^J
+ThreadReadArt ^J ^M
ThreadKill ^K
-ThreadReadArt2 ^M
ThreadSelArt *
ThreadToggleArtSel .
ThreadReverseSel @
ThreadCatchupNextUnread C
ThreadMarkArtRead K
ThreadBugReport R
-ThreadAutoSave S
+ThreadAutoSave S
ThreadUntag U
ThreadMarkThdUnread Z
ThreadCatchup c
diff -Nurp tin-1.7.8/doc/tin.5 tin-1.7.8.new/doc/tin.5
--- tin-1.7.8/doc/tin.5 2005-02-04 21:36:42.000000000 +0100
+++ tin-1.7.8.new/doc/tin.5 2005-03-07 18:03:28.421379181 +0100
@@ -706,11 +706,12 @@ subj=\\b(cd|[rk]?)?tin(d|pre)?[\-.0\-9]*
.\" sorry that one got a bit complex ,-)
.sp
.RS
-Keymap-file, containing "\fIkeyname\fR \fIvalue\fR" pairs.
-Below is a list of all rebindable keynames and their defaults.
+Keymap-file, containing "\fIkeyname\fR \fIvalue\fR \fI[value]\fR" pairs
+seperated by spaces or tabs. Below is a list of all rebindable keynames and
+their defaults.
.sp
.nf
-.ta \w'GroupSelThdIfUnreadSelected 'u +\w'SPACE'u
+.ta \w'GroupSelThdIfUnreadSelected 'u +\w'SPACE'u +\w'SPACE'u
\fBPageDown3\fP SPACE
\fBShellEscape\fP !
\fBSetRange\fP #
@@ -726,16 +727,15 @@ Below is a list of all rebindable keynam
\fBToggleInverseVideo\fP I
\fBLookupMessage\fP L
\fBOptionMenu\fP M
-\fBPostponed2\fP O
+\fBPostponed\fP O ^O
\fBQuitTin\fP Q
\fBDisplayPostHist\fP W
\fBFirstPage\fP ^
\fBSearchAuthF\fP a
-\fBPageUp3\fP b
\fBHelp\fP h
\fBToggleInfoLastLine\fP i
-\fBDown2\fP j
-\fBUp2\fP k
+\fBDown\fP j ^N
+\fBUp\fP k ^P
\fBPrint\fP o
\fBQuit\fP q
\fBVersion\fP v
@@ -743,17 +743,12 @@ Below is a list of all rebindable keynam
\fBPipe\fP |
\fBScrollUp\fP <
\fBScrollDown\fP >
-\fBPageUp\fP ^B
-\fBPageDown\fP ^D
-\fBPageDown2\fP ^F
+\fBPageUp\fP b ^B ^U
+\fBPageDown\fP ^D ^F
\fBRedrawScr\fP ^L
-\fBDown\fP ^N
\fBPostponed\fP ^O
-\fBUp\fP ^P
-\fBPageUp2\fP ^U
.sp
-\fBConfigSelect\fP ^J
-\fBConfigSelect2\fP ^M
+\fBConfigSelect\fP ^J ^M
\fBConfigLastPage2\fP G
\fBConfigNoSave\fP Q
\fBConfigFirstPage2\fP g
@@ -771,9 +766,8 @@ Below is a list of all rebindable keynam
.sp
\fBGroupAutoSel\fP ^A
\fBGroupNextUnreadArtOrGrp\fP TAB
-\fBGroupReadBasenote\fP ^J
+\fBGroupReadBasenote\fP ^J ^M
\fBGroupKill\fP ^K
-\fBGroupReadBasenote2\fP ^M
\fBGroupSelThd\fP *
\fBGroupDoAutoSel\fP +
\fBGroupToggleThdSel\fP .
@@ -817,9 +811,8 @@ Below is a list of all rebindable keynam
\fBPagePGPCheckArticle\fP ^G
\fBPageToggleHeaders\fP ^H
\fBPageNextUnread\fP TAB
-\fBPageNextThd\fP ^J
+\fBPageNextThd\fP ^J ^M
\fBPageAutoKill\fP ^K
-\fBPageNextThd2\fP ^M
\fBPageToggleTabs\fP ^T
\fBPageFollowupQuoteHeaders\fP ^W
\fBPageToggleTex2iso\fP "
@@ -875,32 +868,25 @@ Below is a list of all rebindable keynam
\fBPostIgnore\fP i
\fBPostMail\fP m
\fBPostPostpone\fP o
-\fBPostPost3\fP p
+\fBPostPost\fP p y
\fBPostSupersede\fP s
-\fBPostSend\fP s
-\fBPostSend2\fP y
-\fBPostPost2\fP y
+\fBPostSend\fP s y
.sp
\fBPostponeOverride\fP Y
\fBPostponeAll\fP A
.sp
-\fBPromptYes\fP y
-\fBPromptNo\fP n
+\fBPromptYes\fP y Y
+\fBPromptNo\fP n N
.sp
\fBSaveAppendFile\fP a
\fBSaveOverwriteFile\fP o
.sp
-\fBPProcExtractZip\fP E
-\fBPProcListZip\fP L
-\fBPProcExtractZoo\fP e
-\fBPProcListZoo\fP l
-\fBPProcShar\fP s
-\fBPProcUUDecode\fP u
\fBPProcNone\fP n
+\fBPProcShar\fP s
+\fBPProcYes\fP y
.sp
-\fBSelectEnterNextUnreadGrp\fP TAB
-\fBSelectReadGrp\fP ^J
-\fBSelectReadGrp2\fP ^M
+\fBSelectEnterNextUnreadGrp\fP TAB n
+\fBSelectReadGrp\fP ^J ^M
\fBSelectResetNewsrc\fP ^R
\fBSelectSortActive\fP .
\fBSelectCatchupNextUnread\fP C
@@ -910,23 +896,20 @@ Below is a list of all rebindable keynam
\fBSelectUnsubscribePat\fP U
\fBSelectQuitNoWrite\fP X
\fBSelectSyncWithActive\fP Y
-\fBSelectMarkGrpUnread2\fP Z
\fBSelectCatchup\fP c
\fBSelectToggleDescriptions\fP d
\fBSelectGoto\fP g
\fBSelectMoveGrp\fP m
-\fBSelectEnterNextUnreadGrp2\fP n
\fBSelectToggleReadDisplay\fP r
\fBSelectSubscribe\fP s
\fBSelectUnsubscribe\fP u
\fBSelectYankActive\fP y
-\fBSelectMarkGrpUnread\fP z
+\fBSelectMarkGrpUnread\fP z Z
.sp
\fBThreadReadNextArtOrThread\fP TAB
\fBThreadAutoSel\fP ^A
-\fBThreadReadArt\fP ^J
+\fBThreadReadArt\fP ^J ^M
\fBThreadKill\fP ^K
-\fBThreadReadArt2\fP ^M
\fBThreadSelArt\fP *
\fBThreadToggleArtSel\fP .
\fBThreadReverseSel\fP @
diff -Nurp tin-1.7.8/include/version.h tin-1.7.8.new/include/version.h
--- tin-1.7.8/include/version.h 2005-02-26 14:45:10.000000000 +0100
+++ tin-1.7.8.new/include/version.h 2005-03-07 18:04:30.114539780 +0100
@@ -48,7 +48,7 @@
# define TINRC_VERSION "1.3.7"
# define ATTRIBUTES_VERSION "1.0.3"
# define FILTER_VERSION "1.0.0"
-# define KEYMAP_VERSION "1.0.2"
+# define KEYMAP_VERSION "1.0.3"
# define SERVERCONFIG_VERSION "1.0.0"
# ifdef VMS
diff -Nurp tin-1.7.8/src/keymap.c tin-1.7.8.new/src/keymap.c
--- tin-1.7.8/src/keymap.c 2005-02-26 12:07:17.000000000 +0100
+++ tin-1.7.8.new/src/keymap.c 2005-03-08 00:22:04.761780648 +0100
@@ -329,13 +329,14 @@ process_keymap_file(
continue;
}
- kname = strtok(line, KEYSEPS);
- keydef = strtok(NULL, "\t\n");
+ kname = strsep(&line, KEYSEPS);
+ if (line != NULL)
+ keydef = str_trim(line);
/*
* Warn about basic syntax errors
*/
- if (keydef == NULL) {
+ if (line == NULL || !strlen(keydef)) {
wait_message(0, _(txt_keymap_missing_key), kname);
ret = FALSE;
continue;
@@ -1186,7 +1187,8 @@ process_mapping(
return TRUE;
}
- if (strcmp(keyname, "PostPost2") == 0 || strcmp(keyname, "PostPost3") == 0) {
+ if (strcmp(keyname, "PostPost") == 0 ||strcmp(keyname, "PostPost2") == 0 || strcmp(keyname, "PostPost3") == 0) {
+ /* TODO: PostPost2 and PostPost3 are deprecated, print a warning */
process_keys(GLOBAL_POST, keys, &post_ignore_fupto_keys);
process_keys(GLOBAL_POST, keys, &post_mail_fup_keys);
process_keys(GLOBAL_POST, keys, &post_post_keys);
@@ -1233,26 +1235,14 @@ process_mapping(
}
#endif /* !DISABLE_PRINTING */
if (strcmp(keyname, "PromptNo") == 0) {
- size_t i = 0;
-
process_keys(PROMPT_NO, keys, &post_postpone_keys);
process_keys(PROMPT_NO, keys, &prompt_keys);
- /* accept the keys for PROMPT_NO also in uppercase */
- for (; i < strlen(keys); i++)
- keys[i] = toupper(keys[i]);
- process_keys(PROMPT_NO, keys, &prompt_keys);
return TRUE;
}
if (strcmp(keyname, "PromptYes") == 0) {
- size_t i = 0;
-
process_keys(PROMPT_YES, keys, &post_postpone_keys);
process_keys(PROMPT_YES, keys, &prompt_keys);
- /* accept the keys for PROMPT_YES also in uppercase */
- for (; i < strlen(keys); i++)
- keys[i] = toupper(keys[i]);
- process_keys(PROMPT_YES, keys, &prompt_keys);
return TRUE;
}