1. RE: Console window size: rows and columns
- Posted by Brian Broker <bkb at cnw.com> Aug 13, 2004
- 695 views
Terry Constant wrote: > > > posted by: Terry Constant <EUforum at terryconstant.com> > > Terry wrote: > "I am using WinXp. When I use the video_config() function, the number > of rows/columns reported is 25/80. However, the console in which > I am in is 100/80. Is there a way to get the correct number > of rows/columns for the actual console in which a Euphoria program > is running. BTW, I am using exwc.exe." > > 100/80 should be 80/100 rows/columns. Further, output sometimes > gets confused and treats my 100 column console as if it only had > 80 columns. This second issue is not important (at least not now). > I just added it as a bit more information. I am mainly interested > in being able to get the correct number of rows and columns > for a console text screen. > > > Terry Constant You should be able to get that info using GetConsoleScreenBufferInfo in kernel32. If you'd like help with it let me know. If so, I'd like to know if you are using any windows helper libraries before I go through the trouble of coding in pure Euphoria. -- Brian
2. RE: Console window size: rows and columns
- Posted by Terry Constant <EUforum at terryconstant.com> Aug 13, 2004
- 693 views
Brian wrote: "You should be able to get that info using GetConsoleScreenBufferInfo in kernel32. If you'd like help with it let me know. If so, I'd like to know if you are using any windows helper libraries before I go through the trouble of coding in pure Euphoria." Brian, thanks for the response. After getting your answer, I decided that the capability that I wanted was not part of Euphoria. I do not have an appropriate helper library and did not want to write them, if I did not have to. So I did some searching in the archives. I found wconsole.zip by Ken Roger in which he has already coded some routines for console I/O. I have not yet tested them, but they look like they will suffice. You might want to look at them. Terry Constant
3. RE: Console window size: rows and columns
- Posted by Brian Broker <bkb at cnw.com> Aug 13, 2004
- 705 views
Terry Constant wrote: > > Brian wrote: > "You should be able to get that info using GetConsoleScreenBufferInfo in > > kernel32. If you'd like help with it let me know. If so, I'd like to > know if you are using any windows helper libraries before I go through > the trouble of coding in pure Euphoria." > > Brian, thanks for the response. After getting your answer, I decided > that > the capability that I wanted was not part of Euphoria. I do not have an > appropriate helper library and did not want to write them, if I did not > have to. So I did some searching in the archives. > > I found wconsole.zip by Ken Roger in which he has already coded some > routines for console I/O. I have not yet tested them, but they look like > > they will suffice. You might want to look at them. > > Terry Constant I just had a look at Ken's library and it's close but not quite. It needs some tweaks to get what you want... my program:}}} <eucode> include wconsole.e ? getscreenheight() ? getscreenwidth() </eucode> {{{ returns: 15 140 I think it's returning the console buffer size (which on my system is 140 width and 9999 height). The actual window size is 140 width and 82 height. You just want the size of the visible console window, correct? (not the size of the console buffer...?) Anyway, you can try it and see if it works for you, otherwise I could tweak the lib or continue to work on the pure Eu version that I've already started... -- Brian
4. RE: Console window size: rows and columns
- Posted by Terry Constant <EUforum at terryconstant.com> Aug 13, 2004
- 682 views
Brian, You are correct. I will be looking into the specifics (such as those you mention) in a little while. I will let you know what I determine. Terry Constant
5. RE: Console window size: rows and columns
- Posted by Brian Broker <bkb at cnw.com> Aug 13, 2004
- 689 views
Terry Constant wrote: > > Brian, > > You are correct. I will be looking into the specifics > (such as those you mention) in a little while. I will > let you know what I determine. > > Terry Constant Well, I'm not sure this is going to help you either since the info returned pertains strictly to the console buffer. If you run the program below a few times you'll see what I mean (notice the changing values). But between this code and Ken's you might be able to get something going. I typically take weekends away from the computer so I'll just give you my code. To fix Ken's code, just make note of my use of peek2u() instead of his simple peek()'s...
include dll.e include machine.e without warning constant STD_INPUT_HANDLE = -10, --((DWORD)-10) STD_OUTPUT_HANDLE = -11, --((DWORD)-11) STD_ERROR_HANDLE = -12 --((DWORD)-12) constant SBI_BYTES = 22, SBI_SIZEX = 0, SBI_SIZEY = 2, SBI_CPOSX = 4, SBI_CPOSY = 6, SBI_ATTR = 8, SBI_WINX1 = 10, SBI_WINY1 = 12, SBI_WINX2 = 14, SBI_WINY2 = 16, SBI_MAXX = 18, SBI_MAXY = 20 constant kernel32 = open_dll( "kernel32.dll" ), xGetStdHandle = define_c_func( kernel32, "GetStdHandle", {C_UINT}, C_POINTER ), xGetConsoleScreenBufferInfo = define_c_func( kernel32, "GetConsoleScreenBufferInfo", {C_POINTER,C_POINTER}, C_INT ) constant Info = allocate( SBI_BYTES*8 ) constant hStdHandle = c_func( xGetStdHandle, { STD_OUTPUT_HANDLE } ) ------------------------------ function peek2u( atom address ) sequence bytes bytes = peek({address,2}) return bytes[2]*256+bytes[1] end function ------------------------------ if not c_func( xGetConsoleScreenBufferInfo, { hStdHandle, Info } ) then puts(1,"Doh!!!") abort(1) end if ------------------------------ printf(1,"Console screen buffer size: %d x %d\n", {peek2u(Info+SBI_SIZEX),peek2u(Info+SBI_SIZEY)}) printf(1,"Current buffer cursor postion: (%d,%d)\n", {peek2u(Info+SBI_CPOSX),peek2u(Info+SBI_CPOSY)}) printf(1,"Console screen buffer coordinates: (%d,%d)-(%d,%d)\n", {peek2u(Info+SBI_WINX1),peek2u(Info+SBI_WINY1),peek2u(Info+SBI_WINX2),peek2u(Info+SBI_WINY1)}) printf(1,"Maximum size of the console window: %d x %d\n", {peek2u(Info+SBI_MAXX),peek2u(Info+SBI_MAXY)})
-- Good Luck!!! -- Brian
6. RE: Console window size: rows and columns
- Posted by Terry Constant <EUforum at terryconstant.com> Aug 13, 2004
- 682 views
Brian wrote: "just make note of my use of peek2u() instead of his simple peek()'s" Thanks for peek2u(). I have applied it. The code and returns seem to be working consistently now. I think I will be able to do what I want. Terry Constant