-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathex_vkey.c
86 lines (72 loc) · 872 Bytes
/
ex_vkey.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <unistd.h>
#include "ex.h"
#ifdef VISUAL
#include "ex_tty.h"
#include "ex_vis.h"
/*
* Ex - a text editor
* Bill Joy UCB September 1977
*/
static int getbr(void);
char Peekkey;
void
ungetkey(int c)
{
Peekkey = c;
}
int
getkey(void)
{
int c;
do
c = getbr();
while (c == 0);
return (c);
}
int
peekbr(void)
{
Peekkey = getbr();
return (Peekkey == 0);
}
static int
getbr(void)
{
int c;
if (Peekkey) {
c = Peekkey;
Peekkey = 0;
return (c);
}
if (vglobp) {
if (*vglobp)
return (*vglobp++);
return (ESCAPE);
}
flusho();
if (read(0, &c, 1) != 1)
error("Input read error");
c &= 0177;
return (c);
}
int
getesc(void)
{
register int c;
c = getkey();
switch (c) {
case DELETE:
case FS:
ungetkey(c);
case ESCAPE:
return (0);
}
return (c);
}
int
peekkey(void)
{
Peekkey = getkey();
return (Peekkey);
}
#endif