1

Environment:

  • PDCurses latest version
  • Windows 10
  • Visual Studio 2015 Update 2

Problem

PDCurses provides a function getmaxxy to get the maximum x and y coordinates of the screen. This returns correct values on startup, but if I resize the window with the mouse and then call getmaxxy again, I get back the same values.

Is this a bug/limitation in pdcurses? Is there a windows specific way to get this information instead?

I have also tried this windows specific solution and it too, always returns the startup values: Getting terminal size in c for windows?

Community
  • 1
  • 1
jackmott
  • 1,112
  • 8
  • 16
  • Having never used the library I don't know if this is right or not but to me `getmaxxy` sounds like a function that will give you the maximum window size possible and not the current window size. Can you check that? – NathanOliver May 27 '16 at 18:05
  • It correctly returns the size that the console is when the program first starts. It never changes, whether you make the window larger or smaller. – jackmott May 27 '16 at 18:08

2 Answers2

2

Reading the source,

  • the _maxx and _maxy members of WINDOW are set only when creating a window (including duplicating a window).
  • stdscr is a window

If you have resized the screen, then you should tell PDCurses about the new size, using resize_term (a function adapted from ncurses), e.g.,

resize_term(new_lines, new_cols);

and that recreates the standard windows such as stdscr.

For what it's worth, PDCurses provides these functions for compatibility with ncurses:

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
  • 1
    I see, so I need to use OS specific code to detect that the window has been resized, and figure out what to tell ncurses/pdcurses, it sounds like. – jackmott May 28 '16 at 01:09
  • 1
    ncurses has a `SIGWINCH` handler, and updates the screensize after reading `KEY_RESIZE`, but nothing exists for pcurses - some work needed. – Thomas Dickey May 28 '16 at 01:11
1

Just check for a KEY_RESIZE, and if it occurs, call resize_term(0, 0). You can see several examples of this in the demos (in testcurs, rain and worm). is_termresized() can be used if you're not checking keyboard input.

resize_term() is effectively two different functions -- with zeroes as the parameters, it responds to user-initiated resizing; with non-zeroes, it attempts to actually resize the window to the given size. Typically only one or the other capability (or neither) is available on a given platform. SDL allows both.

William McBrine
  • 2,166
  • 11
  • 7