79 #include <grass/config.h>
83 #include <grass/vask.h>
86 static void centered(
const char *);
87 static void fmt(
char *,
int,
double);
102 #define TARGET V__.usr_answ[at_answer].targetptr
103 #define ROW V__.usr_answ[at_answer].row
104 #define COL V__.usr_answ[at_answer].col
105 #define LENGTH V__.usr_answ[at_answer].length
106 #define TYPE V__.usr_answ[at_answer].var_type
107 #define ANSWER scr_answ[at_answer].position
108 #define RELINE do { \
110 for (incr2=0;incr2<LENGTH; incr2++) \
117 static int interrupts_ok = 0;
163 } scr_answ[MAX_ANSW];
169 for (incr = 0; incr < MAX_ANSW; incr++)
170 for (incr2 = 0; incr2 < 80; incr2++)
171 scr_answ[incr].position[incr2] = 000;
177 for (incr = 0; incr < MAX_LINE; incr++) {
179 addstr(
V__.page.line[incr]);
183 for (at_constant = 0; at_constant <
V__.NUM_CONST; at_constant++) {
184 move(
V__.constant[at_constant].row,
V__.constant[at_constant].col);
185 switch (
V__.constant[at_constant].var_type) {
187 addstr(
V__.constant[at_constant].targetptr.c);
190 sprintf(temp,
"%d", *
V__.constant[at_constant].targetptr.i);
194 sprintf(temp,
"%ld", *
V__.constant[at_constant].targetptr.l);
198 fmt(temp,
V__.constant[at_constant].decimal_places,
199 (
double)*
V__.constant[at_constant].targetptr.f);
203 fmt(temp,
V__.constant[at_constant].decimal_places,
204 (
double)*
V__.constant[at_constant].targetptr.d);
213 for (at_answer = 0; at_answer <
V__.NUM_ANSW; at_answer++) {
215 for (incr = 0; incr < 80; incr++)
216 scr_answ[at_answer].position[incr] = 000;
222 for (incr = 0; incr <
LENGTH; incr++) {
223 if (*(
TARGET.c + incr) ==
'\000')
224 while (incr++ < LENGTH)
227 addch(*(
TARGET.c + incr));
241 fmt(
ANSWER,
V__.usr_answ[at_answer].decimal_places,
247 fmt(
ANSWER,
V__.usr_answ[at_answer].decimal_places,
256 num_answers = at_answer;
263 centered(
"AFTER COMPLETING ALL ANSWERS, HIT <ESC><ENTER> TO CONTINUE");
265 sprintf(temp,
"(OR <Ctrl-C> TO %s)",
V__.interrupt_msg);
275 for (done = 0; !done;) {
285 if (
V__.NUM_ANSW <= 0)
290 if (interrupts_ok ||
V__.NUM_ANSW <= 0)
298 new_answer = (at_answer + num_answers - 1) % num_answers;
307 new_answer = (at_answer + 1) % num_answers;
309 if (lastchar ==
ESC && (newchar ==
CR || newchar ==
NL))
315 ans_col = (ans_col - 1 >= 0) ? ans_col - 1 : 0;
323 ans_col = (ans_col - 1 >= 0) ? ans_col - 1 : 0;
333 ans_col = (ans_col + 1 <
LENGTH &&
334 ANSWER[ans_col]) ? ans_col + 1 : ans_col;
368 if (ans_col < LENGTH && newchar >= 040 && newchar <= 0377) {
370 ANSWER[ans_col] = newchar;
376 if (new_answer != at_answer || done) {
399 fmt(
ANSWER,
V__.usr_answ[at_answer].decimal_places,
407 fmt(
ANSWER,
V__.usr_answ[at_answer].decimal_places,
416 at_answer = new_answer;
426 return (newchar !=
CTRLC);
477 strcpy(
V__.interrupt_msg, msg);
481 static void fmt(
char *
s,
int n,
double x)
488 strcpy(buf,
"%.5lf");
499 static void centered(
const char *
msg)
503 indent = (80 - strlen(msg)) / 2;
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
void V__remove_trail(int ans_col, char *answer)
Remove trailing text from answer?
void V_exit(void)
Erases the current screen and flushes the current curses setup.
int V_call(void)
Interact with the user.
#define ERR
A fatal error message.
char buf[GNAME_MAX+sizeof(G3D_DIRECTORY)+2]
int V__dump_window(void)
Dumps screen to file.
void V_intrpt_msg(const char *msg)
Change CTRL-C message.
void V_init(void)
Initialize curses and prepare screen.
void V__trim_decimal(char *buf)
Remove trailing zeros from decimal number.
void V_intrpt_ok(void)
Allow CTRL-C.