Edinburgh Speech Tools
2.4-release
Loading...
Searching...
No Matches
el_sys_win32.c
1
/****************************************************************************/
2
/* */
3
/* Copyright 1992 Simmule Turner and Rich Salz. All rights reserved. */
4
/* */
5
/* This software is not subject to any license of the American Telephone */
6
/* and Telegraph Company or of the Regents of the University of California. */
7
/* */
8
/* Permission is granted to anyone to use this software for any purpose on */
9
/* any computer system, and to alter it and redistribute it freely, subject */
10
/* to the following restrictions: */
11
/* 1. The authors are not responsible for the consequences of use of this */
12
/* software, no matter how awful, even if they arise from flaws in it. */
13
/* 2. The origin of this software must not be misrepresented, either by */
14
/* explicit claim or by omission. Since few users ever read sources, */
15
/* credits must appear in the documentation. */
16
/* 3. Altered versions must be plainly marked as such, and must not be */
17
/* misrepresented as being the original software. Since few users */
18
/* ever read sources, credits must appear in the documentation. */
19
/* 4. This notice may not be removed or altered. */
20
/* */
21
/****************************************************************************/
22
/* */
23
/* This is a line-editing library, it can be linked into almost any */
24
/* program to provide command-line editing and recall. */
25
/* */
26
/* Posted to comp.sources.misc Sun, 2 Aug 1992 03:05:27 GMT */
27
/* by rsalz@osf.org (Rich $alz) */
28
/* */
29
/****************************************************************************/
30
/* */
31
/* The version contained here has some modifications by awb@cstr.ed.ac.uk */
32
/* (Alan W Black) in order to integrate it with the Edinburgh Speech Tools */
33
/* library and Scheme-in-one-defun in particular. All modifications to */
34
/* to this work are continued with the same copyright above. That is */
35
/* this version of editline does not have the "no commercial use" */
36
/* restriction that some of the rest of the EST library may have */
37
/* awb Dec 30 1998 */
38
/* */
39
/****************************************************************************/
40
/* $Revision: 1.2 $
41
**
42
** Win32 system-dependant routines for editline library.
43
*/
44
#include <windows.h>
45
#include "editline.h"
46
47
extern
CONST ECHAR el_NIL[];
48
49
int
el_user_intr = 0;
50
int
el_PushBack=0;
51
int
el_Pushed=0;
52
CONST ECHAR *el_Input = el_NIL;
53
54
extern
void
TTYflush();
55
56
STATIC
HANDLE
hStdin;
57
58
void
rl_ttyset(
int
Reset
)
59
{
60
HANDLE
hStdout
=
GetStdHandle
(
STD_OUTPUT_HANDLE
);
61
hStdin =
GetStdHandle
(
STD_INPUT_HANDLE
);
62
63
SetConsoleMode
(hStdin, 0);
64
SetConsoleMode
(
hStdout
,
ENABLE_PROCESSED_OUTPUT
);
65
}
66
67
unsigned
int
TTYget()
68
{
69
ECHAR c;
70
int
n;
71
72
TTYflush();
73
if
(el_Pushed) {
74
el_Pushed = 0;
75
return
el_PushBack;
76
}
77
if
(*el_Input)
78
return
*el_Input++;
79
if
(!
ReadFile
(hStdin, &c, 1, &n, NULL))
80
c=
EOF
;
81
return
c;
82
}
83
84
#if !defined(S_ISDIR)
85
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
86
#endif
/* !defined(S_ISDIR) */
87
88
void
rl_add_slash(
char
*path,
char
*p)
89
{
90
#if 0
91
struct
stat
Sb
;
92
93
if
(
stat
(path, &
Sb
) >= 0)
94
(
void
)
strcat
(p, S_ISDIR(
Sb
.st_mode) ?
"\\"
:
" "
);
95
#endif
96
}
97
98
int
el_is_directory(
char
*path)
99
{
100
101
#if 0
102
struct
stat
Sb
;
103
104
if
((
stat
(path, &
Sb
) >= 0) && S_ISDIR(
Sb
.st_mode))
105
return
1;
106
else
107
#endif
108
return
0;
109
}
110
111
void
do_user_intr()
112
{
113
#if 0
114
if
(el_user_intr)
115
kill
(getpid(),
SIGINT
);
116
#endif
117
}
118
119
int
tgetent(
char
*
bp
,
const
char
*name)
120
{
121
/* Always OK. */
122
return
1;
123
}
124
125
int
tgetnum(
const
char
*
id
)
126
{
127
if
(
strcmp
(
id
,
"co"
) == 0)
128
return
80;
129
else
if
(
strcmp
(
id
,
"li"
) == 0)
130
return
20;
131
return
0;
132
}
133
134
#define ESC "\033"
135
#define ESCB "\033["
136
137
138
int
tgetstr(
const
char
*
id
,
char
**
area
)
139
{
140
if
(
strcmp
(
id
,
"le"
) == 0)
141
return
(
int
)
"\010"
;
/* BACKSPACE */
142
else
if
(
strcmp
(
id
,
"up"
) == 0)
143
return
0;
/* (int)ESCB "A"; */
144
else
if
(
strcmp
(
id
,
"cl"
) == 0)
145
return
(
int
)ESCB
"H"
ESCB
"J"
;
146
else
if
(
strcmp
(
id
,
"nl"
) == 0)
147
return
(
int
)
"\n"
;
148
else
if
(
strcmp
(
id
,
"cr"
) == 0)
149
return
(
int
)
"\r"
;
150
else
if
(
strcmp
(
id
,
"nd"
) == 0)
151
return
0;
/* (int)ESCB "C"; */
152
return
0;
153
}
EST_Hash_Pair
Definition
EST_THash.h:75
siod
el_sys_win32.c
Generated on Tue Mar 12 2024 07:03:34 for Edinburgh Speech Tools by
1.9.8