Windows Issues 2 and 3 - Copy and Resize Height

"Ken Koehler" <[email protected]>
Newsgroups gmane.comp.emulators.tn5250
Message-ID <[email protected]>
   I am using the Windows version of v0.17.4 exclusively. I've run into 3
   problems.

   1) Using "+resize_fonts" there is a problem when the system switches
   between 80 and 132 column. The resizing progressively creeps with each
   switch.

   2) You can copy outsize the limits of the screen data, thereby causing the
   program to abort.

   3) When you manually resize beyond a certain height it'll flip-out and
   make the bottom of the window extend below the desktop.

   Per Scott Klement I'm submitting my changes to win32\winterm.c in unified
   diff format.

   Issue #1 is very complex and I'll address it in it's own posting.
   Below I'm addressing issues #2 and #3.

   For #2 I imposed a MIN function to prevent the copy from attempting to
   read outside the screen buffer limits.
   For #3 I just had to straighten out the number of rows used in passing
   parameters.
    - When dealing with the 5250 screen buffer it should be 80x24 and 132x27.
    - When dealing with display sizing you want 1 greater row to allow for
   the status line, therefore 80x(24+1) and 132x(27+1).
   Some of the sizing was passed as 24 and some as 25 rows so the routines
   fought in a loop.
   I #define'd the row values to minimize this confusion in the future.

   --- winterm-prekjk.c 2008-11-21 03:12:22.000000000 -0500
   +++ winterm.c 2009-02-12 09:35:28.280478400 -0500
   @@ -20,6 +20,11 @@
     *
     */
    
   +/* Note that display sizing needs to add 1 to rows to include status line
   */
   +#define RowsFor80Col 24
   +#define RowsFor132Col 27
   +#define MIN(a, b)  (((a) < (b)) ? (a) : (b))
   +
    #define _TN5250_TERMINAL_PRIVATE_DEFINED
    #include "tn5250-private.h"
    #include "resource.h"
   @@ -810,8 +815,9 @@
       int h, w;
       int default_h, default_w;
    
   +   /* Allow for screen size plus status line */
       win32_calc_default_font_size(This->data->hwndMain,
   -                                80, 25, &default_w, &default_h);
   +                                80, RowsFor80Col+1, &default_w,
   &default_h);
    
       if (myfont80 != NULL) {
           size = strlen(myfont80) + 1;
   @@ -832,7 +838,7 @@
           This->data->font_80_w = default_w;
       }
    
   -   win32_terminal_font(This, This->data->font_80, 80, 25,
   This->data->font_80_w, This->data->font_80_h);
   +   win32_terminal_font(This, This->data->font_80, 80, RowsFor80Col+1,
   This->data->font_80_w,

   This->data->font_80_h);
    
       if (myfont132 != NULL) {
           size = strlen(myfont132) + 1;
   @@ -1254,7 +1260,7 @@
       int y, x;
       int mx, my;
       unsigned char attr, c;
   -   unsigned char text[132*27];
   +   unsigned char text[132*RowsFor132Col];
       HBRUSH oldbrush;
       HPEN oldpen;
       int len;
   @@ -2018,10 +2024,10 @@
                  win32_terminal_clear_screenbuf(hwnd, w, h, 1, 1);
                  if (globTerm!=NULL && globDisplay!=NULL) {
                      if (globTerm->data->resize_fonts) {
   -                       win32_calc_default_font_size(hwnd, 80, 24, &c,
   &r);
   +                       win32_calc_default_font_size(hwnd, 80,
   RowsFor80Col+1, &c, &r);
                           globTerm->data->font_80_h = r;
                           globTerm->data->font_80_w = c;
   -                       win32_calc_default_font_size(hwnd, 132, 27, &c,
   &r);
   +                       win32_calc_default_font_size(hwnd, 132,
   RowsFor132Col+1, &c, &r);
                           globTerm->data->font_132_h = r;
                           globTerm->data->font_132_w = c;
                           globTerm->data->resized = 1;
   @@ -2484,6 +2490,16 @@
          sy = This->data->selstr.y / This->data->font_height;
          ey = This->data->selend.y / This->data->font_height;
    
   +   /* Restrict copy to actual screen size. */
   +      TN5250_LOG(("WIN32-win32_copy_text_selection: Width=%d\n",
   tn5250_display_width (globDisplay)));
   +      if (tn5250_display_width (globDisplay)<100) {
   +         ex = MIN(ex, (80-1));
   +         ey = MIN(ey, (RowsFor80Col-1)); /* -1 for zero-based */
   +      } else {
   +         ex = MIN(ex, (132-1));
   +         ey = MIN(ey, (RowsFor132Col-1)); /* -1 for zero-based */
   +      }
   +
          while (ey>tn5250_display_height(display)) ey--;
    
          TN5250_LOG (("Copy to clipboard sx=%d,sy=%d,ex=%d,ey=%d\n",

   ------- Click on this link, and when the site opens, click on the purple
   box that says: Feed an Animal for free.
   http://www.theanimalrescuesite.com
   Verification: http://www.snopes.com/inboxer/charity/animalrescue.asp

    
-- 
This is the Linux 5250 Development Project (LINUX5250) mailing list
To post a message email: LINUX5250-Zwy7GipZuJhWk0Htik3J/[email protected]
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/linux5250
or email: LINUX5250-request-Zwy7GipZuJhWk0Htik3J/[email protected]
Before posting, please take a moment to review the archives
at http://archive.midrange.com/linux5250.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.