Patch 8.2.2940
Problem:    MS-Windows: cannot see the size of the text area when resizing the
            gvim window.
Solution:   Show a tooltip with the text size. (Ken Takata, closes #8326)
Files:      src/gui_w32.c


*** ../vim-8.2.2939/src/gui_w32.c       2021-06-02 13:28:11.431120460 +0200
--- src/gui_w32.c       2021-06-05 16:22:53.510159602 +0200
***************
*** 2942,2948 ****
      int w,
      int h,
      int *valid_w,
!     int *valid_h)
  {
      int           base_width, base_height;
  
--- 2942,2950 ----
      int w,
      int h,
      int *valid_w,
!     int *valid_h,
!     int *cols,
!     int *rows)
  {
      int           base_width, base_height;
  
***************
*** 2957,2966 ****
        + gui_mswin_get_menu_height(FALSE)
  #endif
        ;
!     *valid_w = base_width +
!                   ((w - base_width) / gui.char_width) * gui.char_width;
!     *valid_h = base_height +
!                   ((h - base_height) / gui.char_height) * gui.char_height;
  }
  
      void
--- 2959,2968 ----
        + gui_mswin_get_menu_height(FALSE)
  #endif
        ;
!     *cols = (w - base_width) / gui.char_width;
!     *rows = (h - base_height) / gui.char_height;
!     *valid_w = base_width + *cols * gui.char_width;
!     *valid_h = base_height + *rows * gui.char_height;
  }
  
      void
***************
*** 4480,4485 ****
--- 4482,4527 ----
  }
  #endif
  
+ 
+ static HWND hwndTip = NULL;
+ 
+     static void
+ show_sizing_tip(int cols, int rows)
+ {
+     TOOLINFOA ti = {sizeof(ti)};
+     char buf[32];
+ 
+     ti.hwnd = s_hwnd;
+     ti.uId = (UINT_PTR)s_hwnd;
+     ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
+     ti.lpszText = buf;
+     sprintf(buf, "%dx%d", cols, rows);
+     if (hwndTip == NULL)
+     {
+       hwndTip = CreateWindowExA(0, TOOLTIPS_CLASSA, NULL,
+               WS_POPUP | TTS_ALWAYSTIP | TTS_NOPREFIX,
+               CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
+               s_hwnd, NULL, GetModuleHandle(NULL), NULL);
+       SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&ti);
+       SendMessage(hwndTip, TTM_TRACKACTIVATE, TRUE, (LPARAM)&ti);
+     }
+     else
+     {
+       SendMessage(hwndTip, TTM_UPDATETIPTEXT, 0, (LPARAM)&ti);
+     }
+     SendMessage(hwndTip, TTM_POPUP, 0, 0);
+ }
+ 
+     static void
+ destroy_sizing_tip(void)
+ {
+     if (hwndTip != NULL)
+     {
+       DestroyWindow(hwndTip);
+       hwndTip = NULL;
+     }
+ }
+ 
      static int
  _DuringSizing(
      UINT fwSide,
***************
*** 4488,4497 ****
      int           w, h;
      int           valid_w, valid_h;
      int           w_offset, h_offset;
  
      w = lprc->right - lprc->left;
      h = lprc->bottom - lprc->top;
!     gui_mswin_get_valid_dimensions(w, h, &valid_w, &valid_h);
      w_offset = w - valid_w;
      h_offset = h - valid_h;
  
--- 4530,4540 ----
      int           w, h;
      int           valid_w, valid_h;
      int           w_offset, h_offset;
+     int           cols, rows;
  
      w = lprc->right - lprc->left;
      h = lprc->bottom - lprc->top;
!     gui_mswin_get_valid_dimensions(w, h, &valid_w, &valid_h, &cols, &rows);
      w_offset = w - valid_w;
      h_offset = h - valid_h;
  
***************
*** 4508,4513 ****
--- 4551,4558 ----
      else if (fwSide == WMSZ_BOTTOM || fwSide == WMSZ_BOTTOMLEFT
                            || fwSide == WMSZ_BOTTOMRIGHT)
        lprc->bottom -= h_offset;
+ 
+     show_sizing_tip(cols, rows);
      return TRUE;
  }
  
***************
*** 4648,4653 ****
--- 4693,4702 ----
        return 0L;
  #endif
  
+     case WM_EXITSIZEMOVE:
+       destroy_sizing_tip();
+       break;
+ 
      case WM_SIZING:   // HANDLE_MSG doesn't seem to handle this one
        return _DuringSizing((UINT)wParam, (LPRECT)lParam);
  
*** ../vim-8.2.2939/src/version.c       2021-06-05 16:06:36.965265806 +0200
--- src/version.c       2021-06-05 16:24:59.605833636 +0200
***************
*** 752,753 ****
--- 752,755 ----
  {   /* Add new patch number below this line */
+ /**/
+     2940,
  /**/

-- 
ARTHUR: CHARGE!
   [The mighty ARMY charges.  Thundering noise of feet.  Clatter of coconuts.
   Shouts etc.   Suddenly there is a wail of a siren and a couple of police
   cars roar round in front of the charging ARMY and the POLICE leap out and
   stop them.  TWO POLICEMAN and the HISTORIAN'S WIFE.  Black Marias skid up
   behind them.]
HISTORIAN'S WIFE: They're the ones, I'm sure.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202106051425.155EPxiM054549%40masaka.moolenaar.net.

Raspunde prin e-mail lui