changeset 2220:b1c70c500de4 vim73

Found a way to make the MS-Windows installer wait for the uninstaller to finish, no need for the user to press Enter.
author Bram Moolenaar <bram@vim.org>
date Tue, 25 May 2010 21:02:00 +0200
parents c81f0a037059
children fef4bd7afb26
files runtime/doc/options.txt runtime/doc/quotes.txt runtime/doc/todo.txt runtime/evim.vim src/Make_ivc.mak src/Make_mvc.mak src/dosinst.c
diffstat 7 files changed, 77 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -7226,7 +7226,7 @@ A jump table for the options with a shor
 			{not in Vi}
 			{only when compiled with the +persistent_undo feature}
 	List of directory names for undo files, separated with commas.
-	See |'backupdir'| for the format.
+	See |'backupdir'| for details of the format.
 	"." means using the directory of the file.  The undo file name for
 	"file.txt" is ".file.txt.un~".
 	For other directories the file name is the full path of the edited
@@ -7246,9 +7246,9 @@ A jump table for the options with a shor
 	When on, Vim automatically saves undo history to an undo file when
 	writing a buffer to a file, and restores undo history from the same
 	file on buffer read.
-	The name of the undo file is specified by 'undodir'.
-	See |undo-persistence|.
-	WARNING: this is a very new feature.  Use at your own risc!
+	The directory where the undo file is stored is specified by 'undodir'.
+	For more information about this feature see |undo-persistence|.
+	WARNING: this is a very new feature.  Use at your own risk!
 
 						*'undolevels'* *'ul'*
 'undolevels' 'ul'	number	(default 100, 1000 for Unix, VMS,
--- a/runtime/doc/quotes.txt
+++ b/runtime/doc/quotes.txt
@@ -211,7 +211,7 @@ I cannot believe how great it is to use 
 getting tired of hearing me bragging about it.  Others eyes are lighting up.
 (Rick Croote)
 
-Emacs takes way too much time to start up and run, it is to big and bulky for
+Emacs takes way too much time to start up and run, it is too big and bulky for
 effective use and the interface is more confusing than it is of any help.  VIM
 however is short, it is fast, it is powerful, it has a good interface and it
 is all purpose.  (Paal Ditlefsen Ekran)
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -1085,14 +1085,17 @@ restored. (Luc St-Louis)
 
 Vim 7.3:
 - Win32 DOS and Win32 console version: test69 fails.
+- Win32 binary: vim -r fails. (Antonio Colombo)  Also on Unix.
 - using NSIS 2.46: install on Windows 7 works, but no "Edit with Vim" menu.
    Ron's version: http://dev.ronware.org/p/vim/finfo?name=gvim.nsi
 - When running uninstall program from NSIS via install.exe, still need to
-  ask confirmation in console window, uninstaller doesn't wait.  Is there an
-  NSIS option to wait?
+  ask confirmation in console window, uninstaller doesn't wait.
+  Wait until the uninstaller is deleted -> doesn't work when cancelling
+  Wait until window is gone with EnumWindows (see os_win32.c).
 Patches to include:
 - Persistent undo bugs / fixes:
     - Add undofile(name): get undo file name for buffer "name".
+    - When there is no undo info (undolevels negative), delete the undo file.
 - Extend test62 for gettabvar() and settabvar(). (Yegappan Lakshmanan, 2010
   May 23)
 - Also crypt the undo file.
@@ -1163,6 +1166,7 @@ Needs some work:
   Includes changes for omnicompletion.
   Needs some more testing.
   Update 2010 Apr 20, patch by Andy Kittner, May 16
+  Build the MS-Windows version with Python 2.6.5 and 3.1.2?
 -   Easier/standard way to disable default plugins.
 -   ":{range}source": source the lines from the current file.
 	You can already yank lines and use :@" to execute them.
--- a/runtime/evim.vim
+++ b/runtime/evim.vim
@@ -15,15 +15,15 @@ set insertmode
 set hidden
 
 " Make cursor keys ignore wrapping
-inoremap <Down> <C-R>=pumvisible() ? "\<lt>Down>" : "\<lt>C-O>gj"<CR>
-inoremap <Up> <C-R>=pumvisible() ? "\<lt>Up>" : "\<lt>C-O>gk"<CR>
+inoremap <silent> <Down> <C-R>=pumvisible() ? "\<lt>Down>" : "\<lt>C-O>gj"<CR>
+inoremap <silent> <Up> <C-R>=pumvisible() ? "\<lt>Up>" : "\<lt>C-O>gk"<CR>
 
 " CTRL-F does Find dialog instead of page forward
-noremap <C-F> :promptfind<CR>
-vnoremap <C-F> y:promptfind <C-R>"<CR>
-onoremap <C-F> <C-C>:promptfind<CR>
-inoremap <C-F> <C-O>:promptfind<CR>
-cnoremap <C-F> <C-C>:promptfind<CR>
+noremap <silent> <C-F> :promptfind<CR>
+vnoremap <silent> <C-F> y:promptfind <C-R>"<CR>
+onoremap <silent> <C-F> <C-C>:promptfind<CR>
+inoremap <silent> <C-F> <C-O>:promptfind<CR>
+cnoremap <silent> <C-F> <C-C>:promptfind<CR>
 
 
 set backspace=2		" allow backspacing over everything in insert mode
--- a/src/Make_ivc.mak
+++ b/src/Make_ivc.mak
@@ -288,7 +288,7 @@ CLEAN :
 
 
 install.exe: dosinst.c
-	$(CPP) /Fe$@ /nologo /W3 -DNDEBUG -DWIN32 dosinst.c kernel32.lib shell32.lib ole32.lib advapi32.lib uuid.lib
+	$(CPP) /Fe$@ /nologo /W3 -DNDEBUG -DWIN32 dosinst.c kernel32.lib shell32.lib user32.lib ole32.lib advapi32.lib uuid.lib
 
 uninstal.exe: uninstal.c
 	$(CPP) /nologo /W3 -DNDEBUG -DWIN32 uninstal.c shell32.lib advapi32.lib
--- a/src/Make_mvc.mak
+++ b/src/Make_mvc.mak
@@ -830,7 +830,7 @@ all:	$(VIM).exe vimrun.exe install.exe u
 
 install.exe: dosinst.c
 	$(CC) /nologo -DNDEBUG -DWIN32 dosinst.c kernel32.lib shell32.lib \
-		ole32.lib advapi32.lib uuid.lib
+		user32.lib ole32.lib advapi32.lib uuid.lib
 	- if exist install.exe del install.exe
 	ren dosinst.exe install.exe
 
--- a/src/dosinst.c
+++ b/src/dosinst.c
@@ -446,6 +446,25 @@ get_vim_env(void)
     }
 }
 
+static int num_windows;
+
+/*
+ * Callback used for EnumWindows():
+ * Count the window if the title looks like it is for the uninstaller.
+ */
+/*ARGSUSED*/
+    static BOOL CALLBACK
+window_cb(HWND hwnd, LPARAM lparam)
+{
+    char title[256];
+
+    title[0] = 0;
+    GetWindowText(hwnd, title, 256);
+    if (strstr(title, "Vim ") != NULL && strstr(title, "Uninstall:") != NULL)
+	++num_windows;
+    return TRUE;
+}
+
 /*
  * Check for already installed Vims.
  * Return non-zero when found one.
@@ -543,26 +562,51 @@ uninstall_check(int skip_question)
 					     &orig_num_keys, NULL, NULL, NULL,
 						      NULL, NULL, NULL, NULL);
 
-#if 0 /* let the uninstall program delete the key */
-			/* Delete the uninstall key.  It has no subkeys, so
-			 * this is easy.  Do this before uninstalling, that
-			 * may try to delete the key as well. */
-			RegDeleteKey(key_handle, subkey_name_buff);
-#endif
-
 			/* Find existing .bat files before deleting them. */
 			find_bat_exe(TRUE);
 
 			/* Execute the uninstall program.  Put it in double
 			 * quotes if there is an embedded space. */
-			if (strchr(temp_string_buffer, ' ') != NULL)
 			{
 			    char buf[BUFSIZE];
 
-			    strcpy(buf, temp_string_buffer);
-			    sprintf(temp_string_buffer, "\"%s\"", buf);
+			    if (strchr(temp_string_buffer, ' ') != NULL)
+				sprintf(buf, "\"%s\"", temp_string_buffer);
+			    else
+				strcpy(buf, temp_string_buffer);
+			    run_command(buf);
 			}
-			run_command(temp_string_buffer);
+
+			/* Count the number of windows with a title that match
+			 * the installer, so that we can check when it's done.
+			 * The uninstaller copies itself, executes the copy
+			 * and exits, thus we can't wait for the process to
+			 * finish. */
+			Sleep(1000);  /* wait for uninstaller to start up */
+			num_windows = 0;
+			EnumWindows(window_cb, 0);
+			Sleep(1000);  /* wait for windows to be counted */
+			if (num_windows == 0)
+			{
+			    /* Did not find the uninstaller, ask user to press
+			     * Enter when done. Just in case. */
+			    printf("Press Enter when the uninstaller is finished\n");
+			    rewind(stdin);
+			    (void)getchar();
+			}
+			else
+			{
+			    printf("Waiting for the uninstaller to finish (press CTRL-C to abort).");
+			    do
+			    {
+				printf(".");
+				fflush(stdout);
+				num_windows = 0;
+				EnumWindows(window_cb, 0);
+				Sleep(1000);  /* wait for windows to be counted */
+			    } while (num_windows > 0);
+			}
+			printf("\nDone!\n");
 
 			/* Check if an uninstall reg key was deleted.
 			 * if it was, we want to decrement key_index.
@@ -2393,16 +2437,9 @@ main(int argc, char **argv)
 	get_vim_env();
 
 	/* When nothing found exit quietly.  If something found wait for
-	 * hitting Enter.
-	 * We would like to exit without hitting Enter, but the uninstaller
-	 * detaches itself, thus we get here before it's finished. */
+	 * a little while, so that the user can read the messages. */
 	if (i)
-	{
-	    printf("\n");
-	    printf("When the uninstall program is finished, press Enter to continue\n");
-	    rewind(stdin);
-	    (void)getchar();
-	}
+	    Sleep(3000);
 	exit(0);
     }
 #endif