/* * cur.h * ***************************************************************************** * * Textmode Curscor Hide / Show for C * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ***************************************************************************** * * Author : Rajesh _ThE gReAt * Built on : Sunday, January 20, 2002, 11:59:31 AM * Last Modified on : Friday, February 08, 2002, 4:02:14 PM * * Known errors : --==(none)==-- * ***************************************************************************** * DISCLAIMER: ***************************************************************************** * * Programmers may incorporate any or all code into their programs, * giving proper credit within the source. Publication of the * source routines is permitted so long as proper credit is given * to Rajesh _ThE gReAt. * * Copyright (C) 2002, 2003 by Rajesh _ThE gReAt. You may use this program, or * code or tables extracted from it, as desired without restriction. * I can not and will not be held responsible for any damage caused from * the use of this software. * * Read license.txt from http://www.rajeshgoli.com/license.txt * or http://www.rajeshgoli.com/license.htm * before using / distributing / or any sort of use of my source * Also read my disclaimer http://www.rajeshgoli.com/disclaimer.htm * * YOU AGREE TO BE BOUND BY MY DISCLAIMER AND LICENSE BY IN ANY WAY * USING THIS FILE . * ***************************************************************************** * This source works with Turbo C 2.0 and Turbo C++ 3.0 and above. ***************************************************************************** * Rajesh _ThE gReAt is a synonym of Rajesh Goli * Source freely distributable *****************************************************************************/ /* Define this to test the header file , You need typer.h for this, find it at http://www.rajeshgoli.com/c/typer.h ( cool ) *//* #define TEST_CUR_H */ #ifndef __CUR_H #define __CUR_H #endif #ifndef __DOS_H #include #endif /* prototypes for functions */ void hidecur(void); void restorecur( void ); /* This function hides text mode cursor */ void hidecur(void) { union REGS wrkregs; wrkregs.h.ah = 0x01; wrkregs.h.ch = 0x10; wrkregs.h.cl = 0x00; int86(0x10,&wrkregs,&wrkregs); } /* This function restores default ( Hopefully default ) text mode cursor */ void restorecur( void ) { union REGS wrkregs; wrkregs.h.ah = 0x01; wrkregs.h.ch = 0x00; wrkregs.h.cl = 0x01; int86(0x10,&wrkregs,&wrkregs); } #ifdef TEST_CUR_H #ifndef __TYPER_H #include "typer.h" #endif #ifndef __STRING_H #include #endif /* typer or loop_typer "ungetch"s any key it trapped during its execution if we do not do this */ #undef UNGETCH_EXIT #define UNGETCH_EXIT 0 void main(int argc,char *argv[]) { char *string; int i,how_long = 3; /* This must be atleast 1 , i have kept +2 to be on the safer side */ /* Hide the cursor */ hidecur(); /* If we Have arguments passed */ if(argc > 1) { /* Find ourt how long our string ( argv[1] + " " + argv[2] + ... ) is */ for( i = 1 ; i < argc ; i++ ) how_long += ( strlen(argv[i]) + 1 ); /* The +1 is for " " (blank) */ /* try to Allocate memory , if it fails display standard message */ if((string = (char *)malloc( sizeof(char) * how_long )) == NULL) loop_typer("http://www.rajeshgoli.com",LIGHTGREEN,GREEN,200,20,11,0); /* Memory is successfully allocated , copy the arguments to our string */ else { strcpy(string,argv[1]); for( i = 2 ; i < argc ; i++ ) { strcat(string," "); strcat(string,argv[i]); } /* Print (type in Matrix style) the arguments */ loop_typer(string, LIGHTGREEN, GREEN, 200, 40 - ( strlen(string)/2 ) ,( 25/2 -1 ),0); } } /* we do not have any arguments , type the standard message */ else loop_typer("http://www.rajeshgoli.com",LIGHTGREEN,GREEN,200,20,11,0); /* Restore normal cursor */ restorecur(); clrscr(); } #endif