Re: Asking for help with Phix program under Linux
- Posted by petelomax Nov 11, 2022
- 664 views
When video_config() is missing under Linux, which is sad news to me, does that mean that get_position() and position() don't work, either? Well, my own fault, to write console programs …
position() is fine, but get_position() under Linux currently just returns {0,0} - the relevant code in builtins\VM\pFileioN.e is
-- position: elsif platform()=LINUX then printf(1,"\E[%d;%dH", {line, col}) -- get_position: --DEV OpenEuphoria maintains screen_line/col.. mov [posX],ebx mov [posY],ebx
I've updated the get_position() docs: Note that under Linux get_position() simply always returns {0,0}. I doubt it would be spectacularly difficult to maintain a couple of new variables in builtins\VM\pfileioN.e to keep track of the cursor position: fairly trivial for plain ascii, slightly trickier for embedded \r\n, but getting quite a bit thornier for embedded ncurses and unicode characters. It would probably be a safer bet for an application to maintain it's own x,y internally, if at all possible. </end doc update>
Of course as always I'm open to help and/or test programs, and should note that quite probably a good 70% of any such effort (all bar ncurses) could be done/verified on windows [too], iygwim.
(By ncurses I mean that "\E[%d;%dH" stuff, not quite sure its the right term for me to use.) I'm fine with any "works bar XYZ" solutions too, as long as XYZ sounds bearable.
Does the iff(platform()=WINDOWS?video_config()[10]:80) workaround mean that I can rely on 80 to be the default width of a Linux console window? I guess I could live with that, if get_position() and position() work, but if the user changes the window size that would mess things up. Well, they'd have to be told not to.
On the development sources/docs, I've cleaned up pscreen.e a bit, such that video_config() simply returns {1,3,25,80,0,0,32,1,25,80}, ie assumes a 25x80 screen. Should anyone know of any way to obtain the current terminal size (in characters), let me know. I've also just marked get/put_screen_char() and save/display_text_image() as strictly windows_only.