Giter Site home page Giter Site logo

Resize problem about pdcurses HOT 10 CLOSED

wmcbrine avatar wmcbrine commented on May 24, 2024 2
Resize problem

from pdcurses.

Comments (10)

Bill-Gray avatar Bill-Gray commented on May 24, 2024

This example seems to work correctly with SDL2 and X11, and even with the VT and Windows GUI platforms in my fork. (I'm not currently at a machine where I can try Windows console mode.) So I suspect it's an issue specific to the Windows console platform.

I initially couldn't compile with ncurses because that library lacks is_termresized(). Replacing
if (is_termresized())
with
if( ch == KEY_RESIZE)
enabled it to compile, whereupon I found (as Bruce did) that it worked correctly.

from pdcurses.

wmcbrine avatar wmcbrine commented on May 24, 2024

Yeah, this is specific to wincon. And yeah, it's a bug, but the bug seems to be on the OS side -- the reduced value is being returned directly by Windows. And I can't see how to work around it.

The reduction factor isn't a constant 3, but rather, it's the width that the scroll bar would have, if there was a scroll bar. (You can see this by playing with the console's font size.) But so far, knowing that doesn't help me solve it.

from pdcurses.

aiafrasinei avatar aiafrasinei commented on May 24, 2024

Have a question related.
Im using x11 implementation, ubuntu 18.04:

resize_term(100, 100);

Doesnt seem to work , the window is not resized , function return -1 and i get a 24 80 window.

Is this a bug ?

from pdcurses.

wmcbrine avatar wmcbrine commented on May 24, 2024

No, it's intentional. Programmatic resizing is not implemented for X11. (I'm trying in vain to find documentation or discussion of this from years ago, but what I remember is that it was Very Strongly Discouraged for X11 apps to do this.)

from pdcurses.

Bill-Gray avatar Bill-Gray commented on May 24, 2024

@aiafrasinei : note that it is implemented for SDL2, so you could just switch to that.
Alternatively, you can "borrow" a few lines of code from here :
https://github.com/Bill-Gray/PDCurses/blob/master/x11/pdcscrn.c#L58
With this, you can call PDC_resize_screen before initscr to specify a desired initial window size. Note that you still can't programmatically resize the window after initscr is called. For that, your options are SDL or (if you use my fork) VT.
William, your comment about resizing being Very Strongly Discouraged in X11 interests me. I haven't done it, solely because it looked unreasonably difficult (at least to a non-X11-knowledgeable person).
Oddly, ncurses (at least on my Xubuntu 18.04 system with xterm) lacks programmatic resizing, though it seems to me it would be simple enough to add it, as I did in the VT platform. Perhaps Thomas Dickey (author of ncurses) also thinks programmatic resizing in X is VSD.

from pdcurses.

wmcbrine avatar wmcbrine commented on May 24, 2024

Well, if you want to set the size before initscr(), you can just use X resources, or even the command line, e.g.:

./appname -cols 90 -lines 30

(X11 only, requires Xinitscr(argc, argv) instead of initscr().) For SDL, you can set the environment variables PDC_COLS and PDC_LINES. (Or you can manually create the SDL window, as in sdltest.c.)

from pdcurses.

aiafrasinei avatar aiafrasinei commented on May 24, 2024

Thank you for the info , ill use those command line options.

from pdcurses.

mrexodia avatar mrexodia commented on May 24, 2024

I encountered this issue and actually it looks like Windows doesn't restore the console to the same size (the Window width is actually shrinking every time you restore the size).

from pdcurses.

wmcbrine avatar wmcbrine commented on May 24, 2024

I encountered this issue and actually it looks like Windows doesn't restore the console to the same size (the Window width is actually shrinking every time you restore the size).

As I said: #42 (comment)

from pdcurses.

mrexodia avatar mrexodia commented on May 24, 2024

You can work around it with the following logic:

  • On init, get screen buffer size and save it
  • On resize to bigger, set flag
  • On resize to smaller, check flag
  • If the flag is set, restore the original buffer size

This heuristic can be improved further by using the GetConsoleScreenBufferInfoEx(?) function to get the maximum size and then you can update the resize handler to detect if the window size is the maximium you queried.

I implemented a similar workaround in ccmake and it seems to work great!

from pdcurses.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.