Conio module (WIN32)

BlitzMax Forums/BlitzMax Programming/Conio module (WIN32)

grable(Posted 2007) [#1]
Heres a module wrapper for the Conio library (Console IO) for WIN32.

Functions to print colored text anywhere in a console window.

The library just wraps the relevant Win32API calls but its a much nicer interface ;)

I also added some handy utility functions.

Enjoy!

EDIT: updated, added functions to resize the window & buffer

Download


grable(Posted 2007) [#2]
Heres screenshot for the lazy.. hehe



GfK(Posted 2007) [#3]
I think people might show more/any interest if they knew what it was/what its useful for.


grable(Posted 2007) [#4]
hmm.. i suppose your right, although its realy nothing special.

Its just some functions that allows you to print colored text anywhere in a console/terminal.

With a few helper functions for making boxes,lists,etc and convert an attributed string into something that can be printed

example:
' $00-15 = background color
' #00-15 = foreground color
PutString( 1,1, "$09#14Press any key to exit...")

I needed this for a console based vm debugger im working on,
and i thought others might have use for it as well.


LAB[au](Posted 2007) [#5]
Thanks! I don't know if I will do something with it but anyhow it's cool ;)


Triforce Guardian(Posted 2007) [#6]
I have a bug. Running Windows Vista Home Basic, fully updated.


grable(Posted 2007) [#7]
hmm.. thats wierd, seems like vista is using a font that doesnt handle extended characters properly.
It could also be your language set (if any) that has rearranged the table (unlikely).

Open the console properties and check the font tab, and post what font its using.

And could you post a screen of the chartab.exe example also?
It should be similar to the screenshot i posted above.

Also test the included example exe's to see if they do this too.

Sorry i dont have vista to test myself :/


Triforce Guardian(Posted 2007) [#8]
Yeah, I'll try to work out a fix for you. It doesn't seem to be a big issue.
EDIT: Ran chartab.exe and there does seem to be missing characters. I changed the font and same result. I'll see what I can do to patch this.


grable(Posted 2007) [#9]
Thanks, much appreciated =)


grable(Posted 2007) [#10]
I added 2 new functions to resize the console window and set its buffer (removes the ugly scrollbars ;)

Its done automatically by InitConio() & FreeConio() (they just handle common start/end stuff you can do manually if needed)


altitudems(Posted 2007) [#11]
Hmm..useless except for a ZZT clone or a BBS. LOL


grable(Posted 2007) [#12]
Hmm..useless except for a ZZT clone or a BBS. LOL

Heh, most of the things i code are in console mode. So i wouldn't call it useless.


altitudems(Posted 2007) [#13]
I'm sorry, it is probably very useful for other things too. I remember once I made a complete GUI system with ASCII characters.


Brucey(Posted 2007) [#14]
This is very cool :-)

A lot of people/companies still use console mode for their UIs (generally it's much faster to navigate a text-only UI than it is to move the mouse and click stuff)

Reminds me of curses and stuff on Unix... (now.. there's an idea.....)


Panno(Posted 2008) [#15]
remember me on a old powerbasic gui
cool


Dabhand(Posted 2008) [#16]
I suppose it would be handy for some stuff... When I did a fruit machine simulator it all started out on a console, mostly running millions of spins and seeing if the odds were running correctly when lines would drop in.

Using this would of tarted it up nicely! :D


GW(Posted 2008) [#17]
Is there anyway to get this working when run from the IDE?


deps(Posted 2008) [#18]
I guess not. The IDE is not a console terminal.


Muttley(Posted 2008) [#19]
Looks great. Who's going to write the first BlitzMax Dwarf Fortress clone with it then? :)


GW(Posted 2008) [#20]
I'm doing a small roguelike.
The best choice for the interface would be this C library

But sadly, my C skills are not enough to create the interface.
Without a reliable curses lib for Bmax, i'm writing my own.


Sledge(Posted 2008) [#21]
Anyone know how to clear the keyboard buffer in grb.conio.mod?


grable(Posted 2008) [#22]
Anyone know how to clear the keyboard buffer in grb.conio.mod?

I dont know if blitz uses the right security bits, but this should work:
Extern "Win32"
	Const STD_INPUT_HANDLE:Int = -10
	Const STD_OUTPUT_HANDLE:Int = -11
	Const STD_ERROR_HANDLE:Int = -12
	Function GetStdHandle:Int( stdh:Int)
	Function FlushConsoleInputBuffer:Int( console:Int)
EndExtern

Function FlushInput()
	FlushConsoleInputBuffer( GetStdHandle( STD_INPUT_HANDLE))
EndFunction



Sledge(Posted 2008) [#23]
Cheers, I'll give that a go.

EDIT: Looks good! I had a little Millisecs() based hack in place that has been duly relegated to a fallback.
Const FLUSHKEYS_WITH_GRABLE_CODE:Int = True
:D


iamdaman13(Posted 2008) [#24]
Windows changes so much that I finally decided to make my roguelikes cross compatible by making all my characters and extended characters tiled images that look like text :)


impixi(Posted 2008) [#25]
Sorry, resurrecting an old topic, and posting a slightly OT response...

For those with MaxGui, you could probably create a decent cross-platform technique based on the HTML gadget, for use in Roguelike games. Eg:



Seems to work okay on WindowsXP and Mac OS10.5.4..