To: [email protected]
Subject: patch 5.4p.11
Fcc: outbox
From: Bram Moolenaar <[email protected]>
------------

This replaces the patch that was previously sent out for testing.  I
discovered that the code in gui_w32.c was already doing the same thing.  I
merged the MS-Windows and the X11 code.


Patch 5.4p.11
Problem:    Motif, Athena and GTK: When closing the GUI window when there is a
           changed buffer, there was only an error message and Vim would not
           exit.
Solution:   Put up a dialog, like for ":confirm qa".  Uses the code that was
           already used for MS-Windows.
Files:      src/gui.c, src/gui_w32.c


*** ../vim-5.4p/src/gui.c       Mon Jul 19 11:10:55 1999
--- src/gui.c   Thu Jul 22 13:47:04 1999
***************
*** 502,507 ****
--- 502,508 ----
     gui_mch_exit(rc);
 }

+ #if defined(USE_GUI_GTK) || defined(USE_GUI_X11) || defined(USE_GUI_MSWIN)
 /*
  * Called when the GUI window is closed by the user.  If there are no changed
  * files Vim exits, otherwise there will be a dialog to ask the user what to
***************
*** 511,525 ****
     void
 gui_window_closed()
 {
     /* Only exit when there are no changed files */
     exiting = TRUE;
!     if (!check_changed_any(FALSE)) /* will give warning for changed buffer */
       getout(0);

     exiting = FALSE;
     setcursor();              /* position cursor */
     out_flush();
 }

 /*
  * Set the font. Uses the 'font' option. The first font name that works is
--- 512,548 ----
     void
 gui_window_closed()
 {
+ # ifdef USE_BROWSE
+     int save_browse = browse;
+ # endif
+ # if defined(GUI_DIALOG) || defined(CON_DIALOG)
+     int       save_confirm = confirm;
+ # endif
+
     /* Only exit when there are no changed files */
     exiting = TRUE;
! # ifdef USE_BROWSE
!     browse = TRUE;
! # endif
! # if defined(GUI_DIALOG) || defined(CON_DIALOG)
!     confirm = TRUE;
! # endif
!     /* If there are changed buffers, present the user with a dialog if
!      * possible, otherwise give an error message. */
!     if (!check_changed_any(FALSE))
       getout(0);

     exiting = FALSE;
+ # ifdef USE_BROWSE
+     browse = save_browse;
+ # endif
+ # if defined(GUI_DIALOG) || defined(CON_DIALOG)
+     confirm = save_confirm;
+ # endif
     setcursor();              /* position cursor */
     out_flush();
 }
+ #endif

 /*
  * Set the font. Uses the 'font' option. The first font name that works is
*** ../vim-5.4p/src/gui_w32.c   Mon Jul 19 11:09:06 1999
--- src/gui_w32.c       Thu Jul 22 13:44:15 1999
***************
*** 604,636 ****
 _OnClose(
     HWND hwnd)
 {
! #ifdef USE_BROWSE
!     int save_browse = browse;
! #endif
! #if defined(GUI_DIALOG) || defined(CON_DIALOG)
!     int save_confirm = confirm;
! #endif
!
!     /* Only exit when there are no changed files */
!     exiting = TRUE;
! #ifdef USE_BROWSE
!     browse = TRUE;
! #endif
! #if defined(GUI_DIALOG) || defined(CON_DIALOG)
!     confirm = TRUE;
! #endif
!     if (!check_changed_any(FALSE))    /* will give warning for changed buffer */
!       getout(0);
!
!     exiting = FALSE;
! #ifdef USE_BROWSE
!     browse = save_browse;
! #endif
! #if defined(GUI_DIALOG) || defined(CON_DIALOG)
!     confirm = save_confirm;
! #endif
!     setcursor();                  /* position cursor */
!     out_flush();
 }

 /*
--- 598,604 ----
 _OnClose(
     HWND hwnd)
 {
!     gui_window_closed();
 }

 /*

--
hundred-and-one symptoms of being an internet addict:
221. Your wife melts your keyboard in the oven.

--/-/---- Bram Moolenaar ---- [email protected] ---- [email protected] ---\-\--
 \ \    www.vim.org/iccf      www.moolenaar.net       www.vim.org    / /