Dec 282017
Replace BGI text functions with conio.h-style functions. For Turbo/Borland C/C++.
File GCONIO.ZIP from The Programmer’s Corner in
Category C++ Source Code
Replace BGI text functions with conio.h-style functions. For Turbo/Borland C/C++.
File Name File Size Zip Size Zip Type
GCONIO.CPP 13696 3615 deflated
GCONIO.DOC 5920 2443 deflated
GCONIO.HPP 1824 773 deflated

Download File GCONIO.ZIP Here

Contents of the GCONIO.DOC file

GCONIO for Borland C++

Thank you for down loading! I found text
I/O to be somewhat burdensome using the Borland BGI
outtext() routines so I wrote this class for the

Simply include gconio.hpp in your applications. The
GraphicsConsole class has member functions with the
same names as the conio.h i/o function prototypes.
These functions operate just like their conio.h
counter parts but in graphics modes with the current
font style! You need to instantiate one instance
the of GraphicsConsole of course and only call its
member functions sandwiched between calls to
Borland's initgraph() and closegraph().

Compile and run gconio.cpp for a demonstration of
the GraphicsConsole class. The demo's source code
appears in the function main() at the bottom of
gconio.cpp. Study the demo's source code to see
how easy it is to use the GraphicsConsole class.

Besure to comment out "#define TEST_GCONIO_CPP"
just above main() before using gconio.cpp in
your applications.

Column Justification

GraphicsConsole::cputs() operates on a column
concept when the justification is CENTER_TEXT or
RIGHT_TEXT for horizonal fonts and CENTER_TEXT or
TOP_TEXT for vertical fonts. The CR/LF puts the CP
(current pointer) on the next line aligned with the
previous line instead of the left side of the
current viewport. With LEFT_TEXT justify in
conjunction with a horizonal font, the CR/LF puts
the CP on the next line flush left with the current
viewport. If you want to display a column, left
justified, then set GraphicsConsole::ColumnLeft to
true! Then LEFT_TEXT justify works on the column
concept too. The same is true with a vertical font
that is BOTTOM_TEXT justified. SettingColumnLeft
to false will cause a CR/LF to put the CP on the
next line flush against the bottom of the viewport.
This is the most satisfactory arrangement that I
could come up with. You will recall that outtext
only advances the CP with (LEFT_TEXT,TOP_TEXT)

Write Mode for cprintf(), cputs(), putch() and
Stroked Fonts

GraphicsConsole::OutputWriteMode only affects the
stroked fonts. Normally, if not always, you will
want the text written on the graphics screen with
setwritemode(COPY_PUT). If you want the output
text to be XOR_PUT onto the screen then assign
XOR_PUT to OutputWriteMode.

Character Background for I/O

Assign true to GraphicsConsole::ClearTextBk if you
want the background cleared before writing a
character. GraphicsConsole::TextBkPattern specifies
the background fill pattern to be used in this case.
Its default is SOLID_FILL.

GraphicsConsole::TextBkColor specifies the color of
the background fill. If it is 0 (zero) then the
current background color is used. Both
TextBkPattern and TextBkColor are used by the
backspace in cgets() to rub out the character
whenever GraphicsConsole::InputWriteMode is COPY_PUT
or the DEFAULT_FONT (non-stroked) is the current font.

Cgets(), cscanf() features

GraphicsConsole::InputWriteMode determines whether
stroked font characters echoed to the screen are
COPY_PUT or XOR_PUT. The default is COPY_PUT.
Sometimes you may want to use XOR_PUT in which case
backspacing on input will erase the character if the
current font is stroked. This is handy in paint
programs where you only want the finished line to be
COPY_PUT. Set InputWriteMode to XOR_PUT and
InputRewrite to true to accomplish this.
InputRewrite being set to true causes the input line
to be rewritten in the COPY_PUT mode after the user
terminates the input line with enter. On the other
hand, backspacing will "blacken" out the rubbed out
character if InputWriteMode is set to COPY_PUT or
the DEFAULT_FONT is current. Wow!
You may want to reread this.

GraphicsConsole::CursorChar is really a string of
one character.(There were internal reasons for
making it a string.) This is the cursor that is
displayed by cgets() and consequently cscanf(). I
chose the vertical bar "|" which is present in all
the supplied fonts. If you don't want a cursor
displayed then assign the zero character to the
string, i.e. CursorChar[0] = '\0'. CursorOnMsec and
CursorOffMsec are the parameters passed internally
to delay() to determine the blink rate. 100
milliseconds appears to be acceptable. If you think
not then these are the variables to monkey with.

It may seem odd for GraphicsConsole::InputDone to be
placed in public section of the GraphicsConsole class.
It controls the input loop for cgets(). The reason
it's there is so that any interrupt routine you may
have included in your application can automatically
terminate a cgets() in progress. I am writing a
Paint program where I need the mouse interrupt to be
able to terminate the text paint tool which happens
to use GraphicsConsole::cgets(). Perhaps you may
need it too! By the way the paint program is a demo
for which I should be uploading soon.
The program is pretty primitive since it's only a
demo for cmouse. The cmouse class has all 30 some
methods (mouse functions) and some other necessities
like an automatic interrupt handler, etc, which
should make your mouse programming a snap.


If you find gconio useful and are using it in your
applications, tell your friends. You don't need to
register gconio -- it's freeware! All I ask is that
you leave my copyright notice intact!

Thanks again!

John W. Small
CIS: 73757,2233

PSW / Power SoftWare
P.O. Box 10072
McLean, VA 22102 8072
(703) 759-3838

 December 28, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>