📄 keyio.c
字号:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include "keyio.h"
#include <termio.h>
#define PASSWORD_LENGTH 256
struct termio oldtty, noecho;
void EchoOff()
{
int fd = fileno(stdin);
if (ioctl(fd, TCGETA, &oldtty) < 0)
perror("ioctl");
noecho = oldtty;
noecho.c_lflag &= ~ECHO;
if (ioctl(fd, TCSETA, &noecho) < 0)
perror("ioctl");
}
void EchoOn()
{
int fd = fileno(stdin);
if (ioctl(fd, TCSETA, &oldtty) < 0)
perror("ioctl");
}
void GetPassword( char *szPass,char *passwd )
{
EchoOff();
(void)printf("Password:");
strcpy(szPass,passwd);
//(void)fgets(szPass,PASSWORD_LENGTH,stdin);
(void)strtok(szPass,"\n");
EchoOn(stdin,1);
(void)printf("\r\n");
}
int GetInput(char *command)
{
char ch;
int i;
while( (ch=getchar()) == ' ' || ch == '\t') ;
if( ch != '\n') {
command[0] = ch;
fgets(&command[1],1024,stdin);
strtok(command,"\n");
i = strlen(command) - 1;
while( i>0 && isspace(command[i]))
i--;
if( i>= 0)
command[i+1] = 0;
}
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -