1
0
forked from aniani/vim

patch 8.0.1232: MS-Windows users are confused about default mappings

Problem:    MS-Windows users are confused about default mappings.
Solution:   Don't map keys in the console where they don't work.  Add a choice
            in the installer to use MS-Windows key bindings or not. (Christian
            Brabandt, Ken Takata, closes #2093)
This commit is contained in:
Bram Moolenaar 2017-10-28 18:36:48 +02:00
parent c312b8b87a
commit c3fdf7f80b
6 changed files with 161 additions and 17 deletions

View File

@ -451,6 +451,7 @@ SRC_DOS = \
src/xxd/Make_mvc.mak \ src/xxd/Make_mvc.mak \
nsis/gvim.nsi \ nsis/gvim.nsi \
nsis/gvim_version.nsh \ nsis/gvim_version.nsh \
nsis/vimrc.ini \
nsis/README.txt \ nsis/README.txt \
uninstal.txt \ uninstal.txt \
src/VisVim/Commands.cpp \ src/VisVim/Commands.cpp \

View File

@ -83,6 +83,7 @@ SilentInstall normal
# These are the pages we use # These are the pages we use
Page license Page license
Page components Page components
Page custom SetCustom ValidateCustom ": _vimrc setting"
Page directory "" "" CheckInstallDir Page directory "" "" CheckInstallDir
Page instfiles Page instfiles
UninstPage uninstConfirm UninstPage uninstConfirm
@ -135,6 +136,10 @@ Function .onInit
StrCpy $1 "-register-OLE" StrCpy $1 "-register-OLE"
StrCpy $2 "gvim evim gview gvimdiff vimtutor" StrCpy $2 "gvim evim gview gvimdiff vimtutor"
# Extract InstallOptions files
# $PLUGINSDIR will automatically be removed when the installer closes
InitPluginsDir
File /oname=$PLUGINSDIR\vimrc.ini "vimrc.ini"
FunctionEnd FunctionEnd
Function .onUserAbort Function .onUserAbort
@ -404,7 +409,7 @@ Section "Add an Edit-with-Vim context menu entry"
SectionEnd SectionEnd
########################################################## ##########################################################
Section "Create a _vimrc if it doesn't exist" Section "Create a _vimrc if it doesn't exist" sec_vimrc_id
SectionIn 1 3 SectionIn 1 3
StrCpy $1 "$1 -create-vimrc" StrCpy $1 "$1 -create-vimrc"
@ -462,6 +467,45 @@ Section -post
BringToFront BringToFront
SectionEnd SectionEnd
##########################################################
Function SetCustom
# Display the InstallOptions dialog
# Check if a _vimrc should be created
SectionGetFlags ${sec_vimrc_id} $0
IntOp $0 $0 & 1
StrCmp $0 "1" +2 0
Abort
Push $3
InstallOptions::dialog "$PLUGINSDIR\vimrc.ini"
Pop $3
Pop $3
FunctionEnd
Function ValidateCustom
ReadINIStr $3 "$PLUGINSDIR\vimrc.ini" "Field 2" "State"
StrCmp $3 "1" 0 +3
StrCpy $1 "$1 -vimrc-remap no"
Goto behave
StrCpy $1 "$1 -vimrc-remap win"
behave:
ReadINIStr $3 "$PLUGINSDIR\vimrc.ini" "Field 5" "State"
StrCmp $3 "1" 0 +3
StrCpy $1 "$1 -vimrc-behave unix"
Goto done
ReadINIStr $3 "$PLUGINSDIR\vimrc.ini" "Field 6" "State"
StrCmp $3 "1" 0 +3
StrCpy $1 "$1 -vimrc-behave mswin"
Goto done
StrCpy $1 "$1 -vimrc-behave default"
done:
FunctionEnd
########################################################## ##########################################################
Section Uninstall Section Uninstall
# Apparently $INSTDIR is set to the directory where the uninstaller is # Apparently $INSTDIR is set to the directory where the uninstaller is

68
nsis/vimrc.ini Normal file
View File

@ -0,0 +1,68 @@
[Settings]
NumFields=7
[Field 1]
Type=GroupBox
Left=0
Right=-1
Top=0
Bottom=53
Text=" Key remapping "
[Field 2]
Type=radiobutton
Text=Do not remap keys for Windows behavior (Default)
Left=10
Right=-10
Top=17
Bottom=25
State=1
Flags=GROUP
[Field 3]
Type=radiobutton
Text=Remap a few keys for Windows behavior (<C-V>, <C-C>, <C-A>, <C-S>, <C-F>, etc)
Left=10
Right=-10
Top=30
Bottom=47
State=0
Flags=NOTABSTOP
[Field 4]
Type=GroupBox
Left=0
Right=-1
Top=55
Bottom=-5
Text=" Mouse behavior "
[Field 5]
Type=radiobutton
Text=Right button extends selection, left button starts visual mode (Unix)
Left=10
Right=-5
Top=72
Bottom=80
State=0
Flags=GROUP
[Field 6]
Type=radiobutton
Text=Right button has a popup menu, left button starts select mode (Windows)
Left=10
Right=-5
Top=85
Bottom=93
State=0
Flags=NOTABSTOP
[Field 7]
Type=radiobutton
Text=Right button has a popup menu, left button starts visual mode (Default)
Left=10
Right=-5
Top=98
Bottom=106
State=1
Flags=NOTABSTOP

View File

@ -1,7 +1,7 @@
" Set options and add mapping such that Vim behaves a lot like MS-Windows " Set options and add mapping such that Vim behaves a lot like MS-Windows
" "
" Maintainer: Bram Moolenaar <Bram@vim.org> " Maintainer: Bram Moolenaar <Bram@vim.org>
" Last change: 2017 Feb 09 " Last change: 2017 Oct 28
" bail out if this isn't wanted (mrsvim.vim uses this). " bail out if this isn't wanted (mrsvim.vim uses this).
if exists("g:skip_loading_mswin") && g:skip_loading_mswin if exists("g:skip_loading_mswin") && g:skip_loading_mswin
@ -105,14 +105,15 @@ onoremap <C-F4> <C-C><C-W>c
if has("gui") if has("gui")
" CTRL-F is the search dialog " CTRL-F is the search dialog
noremap <C-F> :promptfind<CR> noremap <expr> <C-F> has("gui_running") ? ":promptfind\<CR>" : "/"
inoremap <C-F> <C-\><C-O>:promptfind<CR> inoremap <expr> <C-F> has("gui_running") ? "\<C-\>\<C-O>:promptfind\<CR>" : "\<C-\>\<C-O>/"
cnoremap <C-F> <C-\><C-C>:promptfind<CR> cnoremap <expr> <C-F> has("gui_running") ? "\<C-\>\<C-C>:promptfind\<CR>" : "\<C-\>\<C-O>/"
" CTRL-H is the replace dialog " CTRL-H is the replace dialog,
noremap <C-H> :promptrepl<CR> " but in console, it might be backspace, so don't map it there
inoremap <C-H> <C-\><C-O>:promptrepl<CR> nnoremap <expr> <C-H> has("gui_running") ? ":promptrepl\<CR>" : "\<C-H>"
cnoremap <C-H> <C-\><C-C>:promptrepl<CR> inoremap <expr> <C-H> has("gui_running") ? "\<C-\>\<C-O>:promptrepl\<CR>" : "\<C-H>"
cnoremap <expr> <C-H> has("gui_running") ? "\<C-\>\<C-C>:promptrepl\<CR>" : "\<C-H>"
endif endif
" restore 'cpoptions' " restore 'cpoptions'

View File

@ -80,21 +80,23 @@ char *(remap_choices[]) =
"Do not remap keys for Windows behavior", "Do not remap keys for Windows behavior",
"Remap a few keys for Windows behavior (CTRL-V, CTRL-C, CTRL-F, etc)", "Remap a few keys for Windows behavior (CTRL-V, CTRL-C, CTRL-F, etc)",
}; };
int remap_choice = (int)remap_win; int remap_choice = (int)remap_no;
char *remap_text = "- %s"; char *remap_text = "- %s";
enum enum
{ {
mouse_xterm = 1, mouse_xterm = 1,
mouse_mswin mouse_mswin,,
mouse_default
}; };
char *(mouse_choices[]) = char *(mouse_choices[]) =
{ {
"\nChoose the way how Vim uses the mouse:", "\nChoose the way how Vim uses the mouse:",
"right button extends selection (the Unix way)", "right button extends selection (the Unix way)",
"right button has a popup menu (the Windows way)", "right button has a popup menu, left button starts select mode (the Windows way)",
"right button has a popup menu, left button starts visual mode",
}; };
int mouse_choice = (int)mouse_mswin; int mouse_choice = (int)mouse_default;
char *mouse_text = "- The mouse %s"; char *mouse_text = "- The mouse %s";
enum enum
@ -155,8 +157,7 @@ get_choice(char **table, int entries)
{ {
if (idx) if (idx)
printf("%2d ", idx); printf("%2d ", idx);
printf(table[idx]); puts(table[idx]);
printf("\n");
} }
printf("Choice: "); printf("Choice: ");
if (scanf("%d", &answer) != 1) if (scanf("%d", &answer) != 1)
@ -1176,6 +1177,8 @@ install_vimrc(int idx)
case mouse_mswin: case mouse_mswin:
fprintf(fd, "behave mswin\n"); fprintf(fd, "behave mswin\n");
break; break;
case mouse_default:
break;
} }
if ((tfd = fopen("diff.exe", "r")) != NULL) if ((tfd = fopen("diff.exe", "r")) != NULL)
{ {
@ -2205,6 +2208,10 @@ print_cmd_line_help(void)
printf(" Create .bat files for Vim variants in the Windows directory.\n"); printf(" Create .bat files for Vim variants in the Windows directory.\n");
printf("-create-vimrc\n"); printf("-create-vimrc\n");
printf(" Create a default _vimrc file if one does not already exist.\n"); printf(" Create a default _vimrc file if one does not already exist.\n");
printf("-vimrc-remap [no|win]\n");
printf(" Remap keys when creating a default _vimrc file.\n");
printf("-vimrc-behave [unix|mswin|default]\n");
printf(" Set mouse behavior when creating a default _vimrc file.\n");
printf("-install-popup\n"); printf("-install-popup\n");
printf(" Install the Edit-with-Vim context menu entry\n"); printf(" Install the Edit-with-Vim context menu entry\n");
printf("-install-openwith\n"); printf("-install-openwith\n");
@ -2260,6 +2267,28 @@ command_line_setup_choices(int argc, char **argv)
*/ */
init_vimrc_choices(); init_vimrc_choices();
} }
else if (strcmp(argv[i], "-vimrc-remap") == 0)
{
if (i + 1 == argc)
break;
i++;
if (strcmp(argv[i], "no") == 0)
remap_choice = remap_no;
else if (strcmp(argv[i], "win") == 0)
remap_choice = remap_win;
}
else if (strcmp(argv[i], "-vimrc-behave") == 0)
{
if (i + 1 == argc)
break;
i++;
if (strcmp(argv[i], "unix") == 0)
mouse_choice = mouse_xterm;
else if (strcmp(argv[i], "mswin") == 0)
mouse_choice = mouse_mswin;
else if (strcmp(argv[i], "default") == 0)
mouse_choice = mouse_default;
}
else if (strcmp(argv[i], "-install-popup") == 0) else if (strcmp(argv[i], "-install-popup") == 0)
{ {
init_popup_choice(); init_popup_choice();
@ -2424,8 +2453,7 @@ NULL
printf("\n"); printf("\n");
for (i = 0; items[i] != NULL; ++i) for (i = 0; items[i] != NULL; ++i)
{ {
printf(items[i]); puts(items[i]);
printf("\n");
printf("Hit Enter to continue, b (back) or q (quit help): "); printf("Hit Enter to continue, b (back) or q (quit help): ");
c = getchar(); c = getchar();
rewind(stdin); rewind(stdin);

View File

@ -761,6 +761,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1232,
/**/ /**/
1231, 1231,
/**/ /**/