Category : C Source Code
Archive   : TCUI.ZIP
Filename : PL.C

 
Output of file : PL.C contained in archive : TCUI.ZIP
/*--------------------------------------------------------------------------
The following are routines to provide an attractive and simple user
interface for your TurboC programs. They manage a user defined prompt
line to be used for a quick command summary and and work space for user
interaction. The size of the workspace depends on the size of the prompt
line. For example: if the prompt line is defined to be the 1/2 of the
screen, then the work space is the other 1/2. In other words, what the
prompt line doesn't use, the workspace will.

If you like these routines please use them freely. If you would like to
be registered for the reciepent of future updates or new products then
fill out the provided form and send it with $15 to:

Robert Klein Jr.
1606 Colony Rd
Pasadena, MD 21122

Enjoy and happy programmimg!
--------------------------------------------------------------------------*/

#include
#include
#include
#include
#include "box.h"



unsigned char a_left, /* left cord for prompt line */
a_top, /* top cord for prompt line */
a_right, /* right cord for prompt line */
a_bottom; /* bottom cord for prompt line */

#define BACKGROUND BLUE /* prompt line background color */
#define T_TEXT_COLOR LIGHTGRAY /* time text color */
#define PL_LEFT a_left
#define PL_TOP a_top
#define PL_RIGHT 64
#define PL_BOTTOM a_bottom
#define T_LEFT 74
#define T_TOP a_top
#define T_RIGHT 80
#define T_BOTTOM a_bottom
#define BOX_LEFT 1
#define BOX_TOP 1
#define BOX_RIGHT 80
#define BOX_BOTTOM PL_TOP-1
#define WB_COLOR 1
#define WB_BACK 0
#define WW_COLOR 7
#define WW_BACK 0



/* set up the coordinates for the prompt line
*/
set_pl (int at, int al, int ab, int ar)
{
a_left = at;
a_top = al;
a_right = ab;
a_bottom = ar;
clr_l();
}



/* clear the prompt line
*/
clr_l()
{
window (a_left, a_top, a_right, a_bottom);
textbackground (BACKGROUND);
clrscr();
}



/* clear the prompt line leaving the date in tact
*/
clr_pl()
{
window (PL_LEFT, PL_TOP, PL_RIGHT, PL_BOTTOM);
textbackground (BACKGROUND);
clrscr();
}



/* write a string to the prompt line.
This routine has the ability to define text colors in the actual string
you are writing. The '@' character is used as a delimeter for the colors
to be used in the string. For example:

write_pl ("@4@Robert @7@Klein");

will write "Robert" in red and "Klein" in light gray.
*/
write_pl (char *st)
{
char st_color [40];
int i;
struct text_info info;

gettextinfo (&info); /* save current text and window information */

clr_pl();
for (; *st; st++) {
i=0;
if (*st == '@') {
st++;
for (; *st != '@'; st++, i++)
st_color [i] = *st;
st_color [i] = 0;
st++;
textcolor (atoi (st_color));
}
putch (*st);
}

/* restore previous text and window information */
window (info.winleft, info.wintop, info.winright, info.winbottom);
textattr (info.attribute);
gotoxy (info.curx, info.cury);
}



/* writes the time to the prompt line
*/
write_time()
{
struct text_info info;
struct time t;
char hour [3], min [3];

gettextinfo (&info); /* save current text and window information */
gettime (&t);

window (T_LEFT, T_TOP, T_RIGHT, T_BOTTOM);
textcolor (T_TEXT_COLOR);
textbackground (BACKGROUND);

t_convert (hour, t.ti_hour);
t_convert (min, t.ti_min);
cprintf (" %s:%s", hour, min);

/* restore previous text and window information */
window (info.winleft, info.wintop, info.winright, info.winbottom);
textattr (info.attribute);
gotoxy (info.curx, info.cury);
}



/* convert integer time to string
*/
t_convert (char *c_time, int i_time)
{
char temp [3];

itoa (i_time, temp, 10);
if (strlen (temp) == 1) {
temp [1] = temp [0];
temp [0] = '0';
temp [2] = 0;
}
strcpy (c_time, temp);
}



/* set and activate the workspace
*/
set_wwin()
{
window (1, 1, 80, 25);
textcolor (WB_COLOR);
textbackground (WB_BACK);
draw_box(BOX_LEFT, BOX_TOP, BOX_RIGHT, BOX_BOTTOM);
window (BOX_LEFT+1, BOX_TOP+1, BOX_RIGHT-1, BOX_BOTTOM-1);
textcolor (WW_COLOR);
textbackground (WW_BACK);
clrscr();
}


  3 Responses to “Category : C Source Code
Archive   : TCUI.ZIP
Filename : PL.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/