To: vim_dev@googlegroups.com Subject: Patch 8.0.1232 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1232 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) Files: Filelist, nsis/gvim.nsi, nsis/vimrc.ini, src/dosinst.c, runtime/mswin.vim *** ../vim-8.0.1231/Filelist 2017-10-08 17:56:52.219266910 +0200 --- Filelist 2017-10-28 18:08:39.093555631 +0200 *************** *** 451,456 **** --- 451,457 ---- src/xxd/Make_mvc.mak \ nsis/gvim.nsi \ nsis/gvim_version.nsh \ + nsis/vimrc.ini \ nsis/README.txt \ uninstal.txt \ src/VisVim/Commands.cpp \ *** ../vim-8.0.1231/nsis/gvim.nsi 2017-10-15 21:43:15.961655416 +0200 --- nsis/gvim.nsi 2017-10-28 18:08:39.093555631 +0200 *************** *** 83,88 **** --- 83,89 ---- # These are the pages we use Page license Page components + Page custom SetCustom ValidateCustom ": _vimrc setting" Page directory "" "" CheckInstallDir Page instfiles UninstPage uninstConfirm *************** *** 135,140 **** --- 136,145 ---- StrCpy $1 "-register-OLE" 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 Function .onUserAbort *************** *** 404,410 **** SectionEnd ########################################################## ! Section "Create a _vimrc if it doesn't exist" SectionIn 1 3 StrCpy $1 "$1 -create-vimrc" --- 409,415 ---- SectionEnd ########################################################## ! Section "Create a _vimrc if it doesn't exist" sec_vimrc_id SectionIn 1 3 StrCpy $1 "$1 -create-vimrc" *************** *** 463,468 **** --- 468,512 ---- 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 # Apparently $INSTDIR is set to the directory where the uninstaller is # created. Thus the "vim61" directory is included in it. *** ../vim-8.0.1231/nsis/vimrc.ini 2017-10-28 18:25:52.426468082 +0200 --- nsis/vimrc.ini 2017-10-28 18:08:39.093555631 +0200 *************** *** 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 (, , , , , 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 *** ../vim-8.0.1231/src/dosinst.c 2017-10-14 19:05:38.948623050 +0200 --- src/dosinst.c 2017-10-28 18:11:31.384372871 +0200 *************** *** 80,100 **** "Do not remap keys for Windows behavior", "Remap a few keys for Windows behavior (CTRL-V, CTRL-C, CTRL-F, etc)", }; ! int remap_choice = (int)remap_win; char *remap_text = "- %s"; enum { mouse_xterm = 1, ! mouse_mswin }; char *(mouse_choices[]) = { "\nChoose the way how Vim uses the mouse:", "right button extends selection (the Unix way)", ! "right button has a popup menu (the Windows way)", }; ! int mouse_choice = (int)mouse_mswin; char *mouse_text = "- The mouse %s"; enum --- 80,102 ---- "Do not remap keys for Windows behavior", "Remap a few keys for Windows behavior (CTRL-V, CTRL-C, CTRL-F, etc)", }; ! int remap_choice = (int)remap_no; char *remap_text = "- %s"; enum { mouse_xterm = 1, ! mouse_mswin,, ! mouse_default }; char *(mouse_choices[]) = { "\nChoose the way how Vim uses the mouse:", "right button extends selection (the Unix 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_default; char *mouse_text = "- The mouse %s"; enum *************** *** 155,162 **** { if (idx) printf("%2d ", idx); ! printf(table[idx]); ! printf("\n"); } printf("Choice: "); if (scanf("%d", &answer) != 1) --- 157,163 ---- { if (idx) printf("%2d ", idx); ! puts(table[idx]); } printf("Choice: "); if (scanf("%d", &answer) != 1) *************** *** 1176,1181 **** --- 1177,1184 ---- case mouse_mswin: fprintf(fd, "behave mswin\n"); break; + case mouse_default: + break; } if ((tfd = fopen("diff.exe", "r")) != NULL) { *************** *** 2205,2210 **** --- 2208,2217 ---- printf(" Create .bat files for Vim variants in the Windows directory.\n"); printf("-create-vimrc\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 the Edit-with-Vim context menu entry\n"); printf("-install-openwith\n"); *************** *** 2260,2265 **** --- 2267,2294 ---- */ 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) { init_popup_choice(); *************** *** 2424,2431 **** printf("\n"); for (i = 0; items[i] != NULL; ++i) { ! printf(items[i]); ! printf("\n"); printf("Hit Enter to continue, b (back) or q (quit help): "); c = getchar(); rewind(stdin); --- 2453,2459 ---- printf("\n"); for (i = 0; items[i] != NULL; ++i) { ! puts(items[i]); printf("Hit Enter to continue, b (back) or q (quit help): "); c = getchar(); rewind(stdin); *** ../vim-8.0.1231/runtime/mswin.vim 2017-02-09 20:22:25.997738785 +0100 --- runtime/mswin.vim 2017-10-28 18:25:19.046696364 +0200 *************** *** 1,7 **** " Set options and add mapping such that Vim behaves a lot like MS-Windows " " Maintainer: Bram Moolenaar ! " Last change: 2017 Feb 09 " bail out if this isn't wanted (mrsvim.vim uses this). if exists("g:skip_loading_mswin") && g:skip_loading_mswin --- 1,7 ---- " Set options and add mapping such that Vim behaves a lot like MS-Windows " " Maintainer: Bram Moolenaar ! " Last change: 2017 Oct 28 " bail out if this isn't wanted (mrsvim.vim uses this). if exists("g:skip_loading_mswin") && g:skip_loading_mswin *************** *** 105,118 **** if has("gui") " CTRL-F is the search dialog ! noremap :promptfind ! inoremap :promptfind ! cnoremap :promptfind ! ! " CTRL-H is the replace dialog ! noremap :promptrepl ! inoremap :promptrepl ! cnoremap :promptrepl endif " restore 'cpoptions' --- 105,119 ---- if has("gui") " CTRL-F is the search dialog ! noremap has("gui_running") ? ":promptfind\" : "/" ! inoremap has("gui_running") ? "\\:promptfind\" : "\\/" ! cnoremap has("gui_running") ? "\\:promptfind\" : "\\/" ! ! " CTRL-H is the replace dialog, ! " but in console, it might be backspace, so don't map it there ! nnoremap has("gui_running") ? ":promptrepl\" : "\" ! inoremap has("gui_running") ? "\\:promptrepl\" : "\" ! cnoremap has("gui_running") ? "\\:promptrepl\" : "\" endif " restore 'cpoptions' *** ../vim-8.0.1231/src/version.c 2017-10-28 17:53:00.387998480 +0200 --- src/version.c 2017-10-28 18:25:41.990539454 +0200 *************** *** 763,764 **** --- 763,766 ---- { /* Add new patch number below this line */ + /**/ + 1232, /**/ -- Why isn't there mouse-flavored cat food? /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///