Page 1 of 1

Row equivalent to getConsoleWidth()

Posted: 3 Feb 2022 1:20
by VPExplorer
Hi,

Got one more question for the week, and that should be enough to play with for the next few days, and learn by trial & error.

I'm trying to build a function similar to the Windows console FillConsoleOutputCharacter(). We have the method of getting the maximum number of characters in a row, the column width ; but I can't locate the function that returns the maximum number of rows, the height.

I think I saw it a couple of days ago, but cannot locate it anymore.

Re: Row equivalent to getConsoleWidth()

Posted: 3 Feb 2022 13:31
by Thomas Linder Puls
I don't know how to get the number you are looking for (and I don't even thing the Width is necessarily what you are looking for either).

A console has a Window which shows part of the Screen Buffer:
Console Layout properties
Console Layout properties
console-properties.png (22.56 KiB) Viewed 18458 times
The Width you can get is the Screen Buffer Width (which in Windows 10 is the same as the Window width, but in earlier versions of Windows I remember that the numbers could differ).

Similar to that number you can could also obtain the Screen Buffer Height, but that is most likely not at all the size of the window.

Re: Row equivalent to getConsoleWidth()

Posted: 3 Feb 2022 15:17
by VPExplorer
Thanks Thomas,

I'm familiar with the Properties dialog, but don't know how to get the maximum number of rows programatically. This is clear in other languages ; sometimes it's something like MaxColumn() and MaxRow() or something similar.

If we're doing a grid for example, we need to know the maximum **visible** number of rows, so that it can be scrolled down.

Re: Row equivalent to getConsoleWidth()

Posted: 3 Feb 2022 15:52
by Thomas Linder Puls
As mentioned there is no function for this in the console class (I am not sure why not, I have added one for future releases).

This is trivially similar to getConsoleWidth:

Code: Select all

clauses     getConsoleWidth() = Columns :-         bufferInfo(coord(Columns, _) | _) = getConsoleScreenBufferInfo().   clauses     getConsoleHeight() = Rows :-         bufferInfo(coord(_, Rows) | _) = getConsoleScreenBufferInfo().
But that does not help you in your version.

The recommended way to deal with modifications to pfc, is to have some directory which shadows the official pfc directory and place modified files there:
  • you place a copy of console.cl and console.pro in <myPath>\pfc\console and
  • make <myPath> an include directory (in Project -> Settings -> Directories -> Include Directories) higher in the list than $(ProDir) (but lower than ".").

Re: Row equivalent to getConsoleWidth()

Posted: 3 Feb 2022 16:36
by VPExplorer
Perfect, thanks Thomas.