Get Window Size from terminal
Hi,
Can I get "Window Size" from terminal? By command line.
Terminal > Edit > Window Size
I already tried to use 'do CURRENT^%IS', but without success. It does not return the change, for example, when the column is 132.
Is there any routine or method for this?
Check %Device class:
Yes, I have also tried this method (It is used in the CURRENT^%IS routine). But it does not return the changed size. Here it returns fixed 80 for column , even changed to 132.
This is one of my personal reasons to use PuTTY or WebTerminal or anything else than TERMINAL.
Thanks Vitaliy Serdtsev, now I understand where the values are stored. With that I know the limitations in obtaining this data.
This data is saved in the registry. You can even save greater value than allowed by the program (see screenshot).
Example of work with the registry directly from Caché Object Script can be found here.
There is nothing built into Caché to get a updating virtual terminal window size like you would have with ncurses. You could...
(1) Write the terminal portions of you application in a language with ncurses support (like "C"), and then use either call-in or call-out to combine the ncurses portions of your application with the COS portions. Call-in would probably be easier.
(2) If you can live without an automated update, the traditional solution is to assign a key in your application to repaint the screen after modem line noise (remember that) messed-up the screen. Traditionally, that was <CTRL+R>. You could just add to the work done by <CTRL+R> to be.
(a) Clear the screen.
(b) Position the cursor at the lower right hand corner.
(c) Clear the typeahead buffer.
(d) Ask the terminal were its cursor is.
(e) Read, and parse the Cursor Position Report.
The position of the cursor is the window size.
(f) Repaint the screen at its current size.
Step (a) could be moved later in the sequence if you like.
Steps (b) and (c) can be reversed.
If you only care about supporting modern terminal emulators, all of which emulate VT-100+ terminals, the code is