?? getline.c
字號:
/*------------------------------------------------------------------------------
GETLINE.C: Line Edited Character Input
Copyright 1995-1996 Keil Software, Inc.
------------------------------------------------------------------------------*/
#include <stdio.h>
#include "measure.h" /* global project definition file */
#define CNTLQ 0x11
#define CNTLS 0x13
#define DEL 0x7F
#define BACKSPACE 0x08
#define CR 0x0D
#define LF 0x0A
/***************/
/* Line Editor */
/***************/
void getline (unsigned char idata *line, unsigned char n) {
unsigned char cnt = 0;
unsigned char c;
do {
if ((c = _getkey ()) == CR) c = LF; /* read character */
if (c == BACKSPACE || c == DEL) { /* process backspace */
if (cnt != 0) {
cnt--; /* decrement count */
line--; /* and line pointer */
putchar (0x08); /* echo backspace */
putchar (' ');
putchar (0x08);
}
}
else if (c != CNTLQ && c != CNTLS) { /* ignore Control S/Q */
putchar ((char) (*line = c)); /* echo and store character */
line++; /* increment line pointer */
cnt++; /* and count */
}
} while (cnt < n - 1 && c != LF); /* check limit and line feed */
*line = 0; /* mark end of string */
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -