开发者

C Cursor Question

开发者 https://www.devze.com 2023-03-11 20:41 出处:网络
I\'m a newbie in Turbo C... Just want to 开发者_JAVA百科ask what is the first thing should I do to enable the use of cursor. I\'d like to control the cursor and redefine keys on the keyboard as well.

I'm a newbie in Turbo C... Just want to 开发者_JAVA百科ask what is the first thing should I do to enable the use of cursor. I'd like to control the cursor and redefine keys on the keyboard as well. Please give me steps, thanks in advance!


When dinosaurs ruled the Earth and some professional programmers actually used Turbo C, the cursor support was handled through routines in an include file called conio.h.

http://en.wikipedia.org/wiki/Conio.h

You won't find a lot of Internet-era writings about this. But I managed to find a reference to someone using this in an online document:

/* Program to display text using special functions*/
#include <conio.h>

main (){
    int n,m,;

    /* clears the screen */
    clrscr ( );

    /* sets the text mode to 80 columns color*/
    textmode (3);

    /* SETS THE TEXT COLOR*/
    textcolor (4);

    /* sets the text background color */
    textbackground (2);

    /* Positions to 5th row and 14th column*/
    gotoxy (5,15);
    printf ("Enter two numbers:");
    scanf ("%d %d", &n, &m);
    gotoxy (10,15);
    printf ("Entered numbers are %d and %d \n\n", n,m);
}

It's not clear if you mean you want to redefine keys such that while your program is running, when a certain key is pressed by the user, it produces a different character output. If so you will probably want to use something like bioskey()...because getch() only reads characters and not things like function keys or modifiers:

http://www.softwareandfinance.com/Turbo_C/bioskey.html


You might take a look at the gotoxy(int x, int y) function, which is not ANSI C, but a Borland extension in Turbo C. It places the cursor at the coordinate (x, y) in a text mode display.

As far as redefining keystrokes, are you looking at doing this within your program or within the ide? If within your program, you can use the scan code returned by getchar() and alter it before re-outputting it with putchar(char c). As far as defining key bindings for ide functions, I THINK (it's been a long time) the user interface allowed that within the menus.

Sorry I couldn't be of more help.

0

精彩评论

暂无评论...
验证码 换一张
取 消