STIR
6.2.0
home
sirfuser
devel
STIRdistrib
STIR
src
display
gen.h
Go to the documentation of this file.
1
/*
2
*/
3
/*
4
Copyright (C) 2000 PARAPET partners
5
Copyright (C) 2000- 2001, IRSL
6
SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license
7
See STIR/LICENSE.txt for details
8
*/
49
#include <stdio.h>
50
51
/* Change November 1997: added next 3 lines */
52
#ifdef __cplusplus
53
extern
"C"
54
{
55
#endif
56
57
#ifdef VAX
58
/* The VAX library does not have getch. An implemenation is provided in gen.c
59
getch reads a character from the keyboard without waiting for a
60
carriage return. You can use it for detecting arrowkeys
61
in combination with the KB_... macro's.
62
*/
63
extern
char
getch(
void
);
64
/* Macro's for using the arrowkeys. Use in the following way:
65
char ch;
66
ch = getch();
67
if (KB_DIRECTION(ch))
68
{ // ch is now the last character of the escape code
69
switch(ch)
70
{ KB_UPARROW: ...
71
...
72
}
73
}
74
else ...
75
// ch is not changed, or the second character in the escape code
76
Note: The following are ANSI escape sequences
77
*/
78
# define KB_DIRECTION(c) (c == 0x1b && getch() == 0x5b && (c = getch()) >= 0x41 && c <= 0x44)
79
# define KB_UPARROW 0x41
80
# define KB_DNARROW 0x42
81
# define KB_RTARROW 0x43
82
# define KB_LTARROW 0x44
83
#endif
/* VAX */
84
85
#if (defined(_WIN32) || defined(WIN32)) && !defined(MSDOS)
86
# define MSDOS
87
#endif
88
89
#ifdef MSDOS
90
/* Change 05/02/98 */
91
# ifdef __GNUC__
92
/* TODO */
93
# define getch() getchar()
94
# else
95
# include <conio.h>
/* for getch */
96
# define getch _getch
97
# endif
98
99
/* Macro's for using the arrowkeys. For explanation see above.
100
Replace "escape code" with "extended charcode"
101
*/
102
# define KB_DIRECTION(c) (c == '\0' && ((c = (char)getch()) == 0x48 || c == 0x4b || c == 0x4d || c == 0x50))
103
# define KB_UPARROW 0x48
104
# define KB_DNARROW 0x50
105
# define KB_RTARROW 0x4d
106
# define KB_LTARROW 0x4b
107
#endif
/* MSDOS */
108
109
#if !defined(VAX) && !defined(MSDOS) && !defined(__MSL__)
110
# include <curses.h>
/* for getch */
111
/* Change November 1997: added 7 lines
112
work-around a 'bug'. screen.h includes curses.h which #defines some
113
symbols which conflict in other C++ includes
114
*/
115
116
# ifdef clear
117
# undef clear
118
# endif
119
# ifdef erase
120
# undef erase
121
# endif
122
123
/* Macro's for using the arrowkeys. For explanation see above.
124
*/
125
# define KB_DIRECTION(c) (c == 0x1b && getch() == 0x5b && (c = getch()) >= 0x41 && c <= 0x44)
126
# define KB_UPARROW 0x41
127
# define KB_DNARROW 0x42
128
# define KB_RTARROW 0x43
129
# define KB_LTARROW 0x44
130
#endif
/*ultrix*/
131
132
#ifdef SC_XWINDOWS
133
# undef KB_DIRECTION
134
# undef KB_UPARROW
135
# undef KB_DNARROW
136
# undef KB_RTARROW
137
# undef KB_LTARROW
138
/* the next one is probably wrong */
139
# define KB_DIRECTION(c) (c == 0x1b && getch() == 0x5b && (c = getch()) >= 0x41 && c <= 0x44)
140
# define KB_UPARROW XK_Up
141
# define KB_DNARROW XK_Down
142
# define KB_RTARROW XK_Right
143
# define KB_LTARROW XK_Left
144
#endif
145
146
#include <stdlib.h>
147
148
#ifndef Min
149
# define Min(x, y) ((x) < (y) ? (x) : (y))
150
#endif
151
#ifndef Max
152
# define Max(x, y) ((x) > (y) ? (x) : (y))
153
#endif
154
155
/**************************************************************************
156
157
***************************************************************************/
158
extern
size_t
fread_check(
char
str[],
void
* buffer,
size_t
size, FILE* infile);
159
extern
size_t
fwrite_check(
char
str[],
void
* buffer,
size_t
size, FILE* outfile);
160
extern
void
fseek_check(
char
str[], FILE* file,
long
offset,
int
pos);
161
162
extern
int
asknr(
char
str[],
int
minv,
int
maxv,
int
def);
163
164
extern
void
message(
char
* fmt, ...);
165
extern
void
error
(
char
* fmt, ...);
166
167
/* Change November 1997: added next 3 lines (end of extern "C") */
168
#ifdef __cplusplus
169
}
170
#endif
stir::error
void error(const char *const s,...)
Print error with format string a la printf and throw exception.
Definition:
error.cxx:42
Generated on Tue Jul 23 2024 09:13:08 for STIR by
1.8.13