Lines Matching +full:read +full:- +full:1

30  * University Copyright- Copyright (c) 1982, 1986, 1988
34 * University Acknowledgment- Portions of this document are derived from
52 * Read a key typed from the terminal
54 * interpret: = 0 for single-char key only
55 * = 1 for matching function key and macro patterns.
56 * = 2 same as 1 but no time-out for funckey matching.
66 int i = 0, j, collapse = 1; in tgetch()
69 chtype *inputQ = cur_term->_input_queue; in tgetch()
70 char *chars_onQ = &(cur_term->_chars_on_queue); in tgetch()
78 * will be non-destructive. in tgetch()
80 cur_term->fl_typeahdok = TRUE; in tgetch()
84 if (cur_term->_ungotten > 0) { in tgetch()
85 cur_term->_ungotten--; in tgetch()
87 inp = -inputQ[0]; in tgetch()
89 /* Only read a character if there is no typeahead/peekahead. */ in tgetch()
100 * a key that starts with -1. Also, we don't want to in tgetch()
101 * access funckeystarter[-1]. in tgetch()
112 fprintf(outf, "TGETCH read '%s'\n", unctrl(inp)); in tgetch()
116 if (interpret && cur_term->funckeystarter[inp]) in tgetch()
117 collapse = _getkey(interpret - 1, &inp); in tgetch()
124 (*chars_onQ) -= collapse; in tgetch()
137 if (cur_term->_delay == 0) { in _readchar()
140 (void) ioctl(cur_term->_inputfd, FIONREAD, &arg); in _readchar()
145 if (arg < 1) in _readchar()
146 return (-1); in _readchar()
148 if (cur_term->_delay > 0) { in _readchar()
152 infd = 1 << cur_term->_inputfd; in _readchar()
153 t.tv_sec = cur_term->_delay / 1000; in _readchar()
154 t.tv_usec = (cur_term->_delay % 1000) * 1000; in _readchar()
158 i = read(cur_term->_inputfd, &c, 1); in _readchar()
160 i = read(cur_term->_inputfd, &c, 1); in _readchar()
164 fprintf(outf, "read from %d returns %d chars, first %o\n", in _readchar()
165 cur_term->_inputfd, i, c); in _readchar()
194 _KEY_MAP **kp = cur_term->_keys; in _getkey()
195 int key, num_keys = cur_term->_ksz; in _getkey()
197 chtype *inputQ = cur_term->_input_queue; in _getkey()
198 char *chars_onQ = &(cur_term->_chars_on_queue); in _getkey()
199 char flag = cur_term->funckeystarter[*inp]; in _getkey()
200 int first, collapse = 1; in _getkey()
212 key = cur_term->_first_macro; in _getkey()
218 if (kp[key]->_sends[0] == *inp) { in _getkey()
219 for (i = 1; i < INP_QSIZE; i++) { in _getkey()
221 if (kp[key]->_sends[i] == '\0') in _getkey()
229 case -2: in _getkey()
231 * Since -2 signifies a timeout we don't really in _getkey()
235 (*chars_onQ)--; in _getkey()
251 cur_term->_first_macro) - in _getkey()
252 1; in _getkey()
258 case -1: in _getkey()
264 if (kp[key]->_sends[i] != inputQ[i]) in _getkey()
268 /* SS-mouse */ in _getkey()
269 if (kp[key]->_keyval == KEY_MOUSE) { in _getkey()
275 /* read the mouse status information */ in _getkey()
278 rc = -3; /* NOT IMPLEMENTED */ in _getkey()
282 if (rc == -1) /* read error */ in _getkey()
284 else if (rc == -2 || rc == -3) /* timeout */ in _getkey()
289 else if (rc >= 1 && rc <= 3) in _getkey()
296 ((Mouse_status.button[1] != in _getkey()
297 old_mouse.button[1]) << 1) | in _getkey()
302 /* We found it! Read in any chars left in _sends */ in _getkey()
305 for (; kp[key]->_sends[i]; i++) in _getkey()
314 if (key > cur_term->_first_macro) in _getkey()
315 lorder = &(cur_term->_lastmacro_ordered); in _getkey()
317 lorder = &(cur_term->_lastkey_ordered); in _getkey()
327 for (j = i--; j > first; ) in _getkey()
328 kp[j--] = kp[i--]; in _getkey()
331 *inp = kp[first]->_keyval; in _getkey()
334 * SS-mouse support: if mouse button event in _getkey()
342 (SP->slk != (SLK_MAP *) NULL) && in _getkey()
343 (SP->_map_mbe_to_key != 0)) { in _getkey()
364 /* SS-mouse */
365 /* this function tries to read in information that follows KEY_MOUSE: */
366 /* the first character identifies what button is involved (1,2,or 3) */
370 * -3: not a mouse button event
371 * -2: read timed out
372 * -1: the read failed
373 * [0, 1, 2, 3] - the first character in the mouse event
378 chtype *inputQ = cur_term->_input_queue; /* ??? */ in get_xterm_mouse()
380 chtype *chars_onQ = (chtype *) &(cur_term->_chars_on_queue); in get_xterm_mouse()
384 /* the first character should be 0, 1, 2, or 4 */ in get_xterm_mouse()
388 /* read error or timeout */ in get_xterm_mouse()
395 return (-3); in get_xterm_mouse()
397 /* if the character is 1, 2, or 3 it must be followed by */ in get_xterm_mouse()
409 return (-3); in get_xterm_mouse()
412 /* read X and Y coordinates of the mouse */ in get_xterm_mouse()
421 mx = c1 - ' '; in get_xterm_mouse()
423 my = c1 - ' '; in get_xterm_mouse()
431 mx = c1 * (c2 - ' '); in get_xterm_mouse()
433 my = c1 * (c2 - ' '); in get_xterm_mouse()
435 return (-3); in get_xterm_mouse()
437 return (-3); in get_xterm_mouse()
440 /* read complete mouse event: update the Mouse_status structure */ in get_xterm_mouse()
444 j = char1 - '0'; in get_xterm_mouse()
466 /* SS-mouse-end */
471 * quickly if there is nothing waiting, returning -1.
472 * f is an output stdio descriptor, we read from the fileno.
476 * -2 is returned if we time out, -1 is returned if interrupted, and the
483 * Traditional implementation. The best resolution we have is 1 second,
484 * so we set a 1 second alarm and try to read. If we fail for 1 second,
485 * we assume there is no key waiting. Problem here is that 1 second is
489 * after each read does not work because the tty driver's timeout
502 sig_caught = 1; in _catch_alarm()
509 int infd = cur_term->_inputfd; in _fpk()
522 (void) alarm(1); in _fpk()
523 rc = read(cur_term->_inputfd, (char *)&c, 1); in _fpk()
529 * read() call above. The interrupt will cause the in _fpk()
530 * read() call to retur, even if a character is really in _fpk()
531 * on the clist. So we do a non-blocking read() to make in _fpk()
535 if (sig_caught && rc != 1) in _fpk()
536 if (cur_term->_check_fd != -1) in _fpk()
537 rc = read(cur_term->_check_fd, (char *)&c, 1); in _fpk()
542 rc = read(infd, (char *)&c, 1); in _fpk()
548 if (sig_caught && oldalarm > 1) in _fpk()
549 oldalarm--; in _fpk()
551 if (rc == 1) /* got a character */ in _fpk()
555 return (-2); in _fpk()
557 return (-1); in _fpk()
564 * 1 second resolution, but this is no worse than what we have in the
575 infd = 1 << cur_term->_inputfd; in _fpk()
581 return (-2); in _fpk()
582 rc = read(fileno(f), &c, 1); in _fpk()
583 return (rc == 1 ? c : -1); in _fpk()
597 return ((read(cur_term->_inputfd, (char *)&c, 1) == 1) ? c : ERR); in _pk()
602 * SS-mouse: check if this mouse button event should map into
610 SLK_MAP *slk = SP->slk; in _map_button()
611 int num = slk->_num; in _map_button()
612 int len = slk->_len; in _map_button()
618 if (!(SP->_map_mbe_to_key & in _map_button()
621 (BUTTON_CHANGED(1) << BUTTON_STATUS(1))))) in _map_button()
625 if (MOUSE_X_POS < slk->_labx[i]) in _map_button()
627 if (MOUSE_X_POS > slk->_labx[i] + len) in _map_button()
629 *inp = KEY_F(1) + i; in _map_button()