- update instruments configurations
- new six version with status display - bugfixes on TecsClient - some changed samp. env. devices
This commit is contained in:
20
tecs/term.c
20
tecs/term.c
@@ -104,7 +104,13 @@ int term_get_key(char *key, int msecTmo) {
|
||||
} else if (k >= 'l' && k <= 'y') {
|
||||
k=k-64;
|
||||
} else {
|
||||
k='?';
|
||||
switch (k) { /* L,R,U,D arrows */
|
||||
case 'D': k=L_ARROW; break;
|
||||
case 'C': k=R_ARROW; break;
|
||||
case 'A': k=U_ARROW; break;
|
||||
case 'B': k=D_ARROW; break;
|
||||
default: k='?';
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '\177': /* del */
|
||||
@@ -132,6 +138,14 @@ static char *history[HISTORY_LINES]={NULL};
|
||||
|
||||
static int hist_pos=0; /* position when scrolling through the history */
|
||||
static int hist_end=0; /* end of history. Always history[hist_end]==NULL */
|
||||
static int dirty=0; /* line is to be cleared through a call of term_clear_line */
|
||||
|
||||
void term_clear(void) {
|
||||
if (dirty) {
|
||||
fputs("\r\033[K", stdout);
|
||||
dirty=0;
|
||||
}
|
||||
}
|
||||
|
||||
int term_get_line(char *buf, int size, int *pos, char *prompt, fd_set *mask) {
|
||||
char key, *lin;
|
||||
@@ -166,13 +180,13 @@ int term_get_line(char *buf, int size, int *pos, char *prompt, fd_set *mask) {
|
||||
}
|
||||
switch (key) {
|
||||
case EVT_CHAR:
|
||||
fputs("\r\033[K", stdout);
|
||||
/* caller must clear line before next write with term_clear() */
|
||||
dirty=1;
|
||||
return(iret);
|
||||
|
||||
/* interrupted EXIT */
|
||||
|
||||
case RET_CHAR:
|
||||
/* fputs("\r\033[K", stdout); */
|
||||
i=hist_end-1; if (i<0) i=HISTORY_LINES-1;
|
||||
if ((history[i]==NULL || 0!=strcmp(history[i], buf)) && buf[0]!='\0') { /* do not save equal and empty lines */
|
||||
buflen=strlen(buf)+1;
|
||||
|
||||
Reference in New Issue
Block a user