Lines Matching +full:number +full:- +full:of +full:- +full:wires
1 /*-
3 * The Regents of the University of California. All rights reserved.
46 * regardless of the user's choices for these characters. The user's erase
47 * and kill characters worked in addition to these characters. Nvi wires
91 (sizeof(keylist) / sizeof(keylist[0])) - ADDITIONAL_CHARACTERS;
94 * v_key_init --
107 gp = sp->gp; in v_key_init()
120 for (kp = keylist, cnt = nkeylist; cnt--; ++kp) in v_key_init()
121 gp->special_key[kp->ch] = kp->value; in v_key_init()
123 /* Find a non-printable character to use as a message separator. */ in v_key_init()
126 gp->noprint = ch; in v_key_init()
129 if (ch != gp->noprint) { in v_key_init()
130 msgq(sp, M_ERR, "079|No non-printable character found"); in v_key_init()
137 * v_keyval --
152 if (sp->gp->scr_keyval(sp, name, &ch, &dne)) in v_keyval()
158 for (kp = keylist; kp->value != K_NOTUSED; ++kp) in v_keyval()
159 if (kp->ch == ch) { in v_keyval()
160 kp->value = val; in v_keyval()
165 if (kp->value == K_NOTUSED) { in v_keyval()
173 * v_key_ilookup --
174 * Build the fast-lookup key display array.
186 for (gp = sp->gp, ch = 0;; ++ch) { in v_key_ilookup()
187 for (p = gp->cname[ch].name, t = v_key_name(sp, ch), in v_key_ilookup()
188 len = gp->cname[ch].len = sp->clen; len--;) in v_key_ilookup()
196 * v_key_len --
197 * Return the length of the string that will display the key.
206 return (sp->clen); in v_key_len()
210 * v_key_name --
229 if (ach && sp->lastc == ach) in v_key_name()
230 return (sp->cname); in v_key_name()
231 sp->lastc = ach; in v_key_name()
234 len = wctomb(sp->cname, ach); in v_key_name()
237 sp->cname[(len = 1)-1] = (u_char)ach; in v_key_name()
239 ch = (u_char)sp->cname[0]; in v_key_name()
240 sp->cname[len] = '\0'; in v_key_name()
244 if (strstr(chp, sp->cname) != NULL) in v_key_name()
247 if (strstr(chp, sp->cname) != NULL) in v_key_name()
257 * represented in <C-char> notations. Carriage feed, escape, and in v_key_name()
266 * The code prints non-printable wide characters in 4 or 5 digits in v_key_name()
274 len = strlcpy(sp->cname, notation, sizeof(sp->cname)); in v_key_name()
276 sp->cname[0] = '^'; in v_key_name()
277 sp->cname[1] = ch == 0x7f ? '?' : '@' + ch; in v_key_name()
284 int uc = -1; in v_key_name()
286 if (!strcmp(codeset(), "UTF-8")) in v_key_name()
287 uc = decode_utf8(sp->cname); in v_key_name()
290 char buf[sizeof(sp->cname)] = ""; in v_key_name()
291 size_t left = sizeof(sp->cname); in v_key_name()
292 char *in = sp->cname; in v_key_name()
294 iconv(sp->conv.id[IC_IE_TO_UTF16], in v_key_name()
296 iconv(sp->conv.id[IC_IE_TO_UTF16], in v_key_name()
302 len = snprintf(sp->cname, sizeof(sp->cname), in v_key_name()
309 sp->cname[0] = '\\'; in v_key_name()
310 sp->cname[1] = octdigit[(ch & 0300) >> 6]; in v_key_name()
311 sp->cname[2] = octdigit[(ch & 070) >> 3]; in v_key_name()
312 sp->cname[3] = octdigit[ ch & 07 ]; in v_key_name()
314 sp->cname[0] = '\\'; in v_key_name()
315 sp->cname[1] = 'x'; in v_key_name()
316 sp->cname[2] = hexdigit[(ch & 0xf0) >> 4]; in v_key_name()
317 sp->cname[3] = hexdigit[ ch & 0x0f ]; in v_key_name()
320 done: sp->cname[sp->clen = len] = '\0'; in v_key_name()
321 return (sp->cname); in v_key_name()
325 * v_key_val --
338 return (kp == NULL ? K_NOTUSED : kp->value); in v_key_val()
342 * v_event_push --
343 * Push events/keys onto the front of the buffer.
346 * end of the buffer by the terminal input routines, and pushed onto the
347 * front of the buffer by various other functions in ex/vi. Each key has
349 * and if it is the result of a mapping or an abbreviation.
357 size_t nitems, /* Number of items to push. */ in v_event_push()
365 gp = sp->gp; in v_event_push()
366 if (nitems <= gp->i_next || in v_event_push()
367 (gp->i_event != NULL && gp->i_cnt == 0 && nitems <= gp->i_nelem)) { in v_event_push()
368 if (gp->i_cnt != 0) in v_event_push()
369 gp->i_next -= nitems; in v_event_push()
379 total = gp->i_cnt + gp->i_next + nitems + TERM_PUSH_SHIFT; in v_event_push()
380 if (total >= gp->i_nelem && v_event_grow(sp, MAX(total, 64))) in v_event_push()
382 if (gp->i_cnt) in v_event_push()
383 memmove(gp->i_event + TERM_PUSH_SHIFT + nitems, in v_event_push()
384 gp->i_event + gp->i_next, gp->i_cnt * sizeof(EVENT)); in v_event_push()
385 gp->i_next = TERM_PUSH_SHIFT; in v_event_push()
388 copy: gp->i_cnt += nitems; in v_event_push()
389 for (evp = gp->i_event + gp->i_next; nitems--; ++evp) { in v_event_push()
393 evp->e_event = E_CHARACTER; in v_event_push()
394 evp->e_c = *p_s++; in v_event_push()
395 evp->e_value = KEY_VAL(sp, evp->e_c); in v_event_push()
396 F_INIT(&evp->e_ch, flags); in v_event_push()
403 * v_event_append --
404 * Append events onto the tail of the buffer.
412 size_t nevents; /* Number of events. */ in v_event_append()
415 nevents = argp->e_event == E_STRING ? argp->e_len : 1; in v_event_append()
416 gp = sp->gp; in v_event_append()
417 if (gp->i_event == NULL || in v_event_append()
418 nevents > gp->i_nelem - (gp->i_next + gp->i_cnt)) in v_event_append()
420 evp = gp->i_event + gp->i_next + gp->i_cnt; in v_event_append()
421 gp->i_cnt += nevents; in v_event_append()
423 /* Transform strings of characters into single events. */ in v_event_append()
424 if (argp->e_event == E_STRING) in v_event_append()
425 for (s = argp->e_csp; nevents--; ++evp) { in v_event_append()
426 evp->e_event = E_CHARACTER; in v_event_append()
427 evp->e_c = *s++; in v_event_append()
428 evp->e_value = KEY_VAL(sp, evp->e_c); in v_event_append()
429 evp->e_flags = 0; in v_event_append()
438 if ((gp->i_cnt -= len) == 0) \
439 gp->i_next = 0; \
441 gp->i_next += len; \
445 * v_event_get --
449 * The flag EC_NODIGIT probably needs some explanation. First, the idea of
451 * What's going on is that vi is reading a number, and the character following
452 * the number may or may not be mapped (EC_MAPCOMMAND). For example, if the
455 * into "z40xxx". However, if the user enters "35x", we want to put all of the
459 * mapping digits as long as they weren't the first character of the map, e.g.
460 * ":map ^A1 xxx" was okay. It also permitted the mapping of the digits 1-9
461 * (the digit 0 was a special case as it doesn't indicate the start of a count)
462 * as the first character of the map, but then ignored those mappings. While
466 * end-of-digit without "looking" at the next character, i.e. leaving it as the
476 * would return the keys "d2<end-of-digits>1G", when the user probably wanted
477 * "d21<end-of-digits>G". So, if a map starts off with a digit we continue as
479 * <end-of-digits>.
481 * Now that that's out of the way, let's talk about Energizer Bunny macros.
489 * without doing a full parse of the command, because the character that might
497 * get many (most?) of the tricky cases right, however, and it was certainly
506 * part of the mapped string was legal, and did not cause infinite loops, i.e.
508 * characters were returned instead of being remapped.
520 * this work in here without the complete abandonment of Rationality Itself.
523 * The final issue is recovery. It would be possible to undo all of the work
539 gp = sp->gp; in v_event_get()
551 if (gp->i_cnt != 0 && LF_ISSET(EC_TIMEOUT)) in v_event_get()
558 if (gp->i_cnt == 0 || LF_ISSET(EC_INTERRUPT | EC_TIMEOUT)) { in v_event_get()
565 loop: if (gp->scr_event(sp, argp, in v_event_get()
568 switch (argp->e_event) { in v_event_get()
577 (argp->e_event == E_SIGTERM ? 0: RCV_EMAIL)); in v_event_get()
584 F_SET(sp->gp, G_INTERRUPTED); in v_event_get()
608 newmap: evp = &gp->i_event[gp->i_next]; in v_event_get()
614 if (evp->e_event != E_CHARACTER) { in v_event_get()
630 if (istimeout || F_ISSET(&evp->e_ch, CH_NOMAP) || in v_event_get()
632 ((evp->e_c & ~MAX_BIT_SEQ) == 0 && in v_event_get()
633 !bit_test(gp->seqb, evp->e_c))) in v_event_get()
637 qp = seq_find(sp, NULL, evp, NULL, gp->i_cnt, in v_event_get()
652 * simply timeout <escape> characters at 1/10th of a second, but this in v_event_get()
657 timeout = (evp->e_value == K_ESCAPE ? in v_event_get()
667 nomap: if (!ISDIGIT(evp->e_c) && LF_ISSET(EC_MAPNODIGIT)) in v_event_get()
675 * If looking for the end of a digit string, and the first character in v_event_get()
676 * of the map is it, pretend we haven't seen the character. in v_event_get()
679 qp->output != NULL && !ISDIGIT(qp->output[0])) { in v_event_get()
680 not_digit: argp->e_c = CH_NOT_DIGIT; in v_event_get()
681 argp->e_value = K_NOTUSED; in v_event_get()
682 argp->e_event = E_CHARACTER; in v_event_get()
683 F_INIT(&argp->e_ch, 0); in v_event_get()
688 init_nomap = !e_memcmp(qp->output, &gp->i_event[gp->i_next], qp->ilen); in v_event_get()
691 QREM(qp->ilen); in v_event_get()
694 if (qp->output == NULL) in v_event_get()
707 (gp->scr_event(sp, &ev, in v_event_get()
709 F_SET(sp->gp, G_INTERRUPTED); in v_event_get()
710 argp->e_event = E_INTERRUPT; in v_event_get()
715 * If an initial part of the characters mapped, they are not in v_event_get()
716 * further remapped -- return the first one. Push the rest in v_event_get()
717 * of the characters, or all of the characters if no initial in v_event_get()
721 if (v_event_push(sp, NULL, qp->output + qp->ilen, in v_event_get()
722 qp->olen - qp->ilen, CH_MAPPED)) in v_event_get()
725 qp->output, qp->ilen, CH_NOMAP | CH_MAPPED)) in v_event_get()
727 evp = &gp->i_event[gp->i_next]; in v_event_get()
730 if (v_event_push(sp, NULL, qp->output, qp->olen, CH_MAPPED)) in v_event_get()
736 if (v_event_push(sp, NULL, qp->output, qp->olen, CH_MAPPED | CH_NOMAP)) in v_event_get()
743 * v_sync --
751 gp = sp->gp; in v_sync()
752 TAILQ_FOREACH(sp, gp->dq, q) in v_sync()
754 TAILQ_FOREACH(sp, gp->hq, q) in v_sync()
759 * alt_key_notation --
760 * Lookup for alternative notations of control characters.
767 return "<C-@>"; in alt_key_notation()
769 return "<C-a>"; in alt_key_notation()
771 return "<C-b>"; in alt_key_notation()
773 return "<C-c>"; in alt_key_notation()
775 return "<C-d>"; in alt_key_notation()
777 return "<C-e>"; in alt_key_notation()
779 return "<C-f>"; in alt_key_notation()
781 return "<C-g>"; in alt_key_notation()
783 return "<C-h>"; in alt_key_notation()
789 return "<C-k>"; in alt_key_notation()
791 return "<C-l>"; in alt_key_notation()
795 return "<C-n>"; in alt_key_notation()
797 return "<C-o>"; in alt_key_notation()
799 return "<C-p>"; in alt_key_notation()
801 return "<C-q>"; in alt_key_notation()
803 return "<C-r>"; in alt_key_notation()
805 return "<C-s>"; in alt_key_notation()
807 return "<C-t>"; in alt_key_notation()
809 return "<C-u>"; in alt_key_notation()
811 return "<C-v>"; in alt_key_notation()
813 return "<C-w>"; in alt_key_notation()
815 return "<C-x>"; in alt_key_notation()
817 return "<C-y>"; in alt_key_notation()
819 return "<C-z>"; in alt_key_notation()
823 return "<C-\\>"; in alt_key_notation()
825 return "<C-]>"; in alt_key_notation()
827 return "<C-^>"; in alt_key_notation()
829 return "<C-_>"; in alt_key_notation()
838 * v_event_err --
846 switch (evp->e_event) { in v_event_err()
851 msgq(sp, M_ERR, "277|Unexpected end-of-file event"); in v_event_err()
870 * Theoretically, none of these can occur, as they're handled at the in v_event_err()
881 free(evp->e_asp); in v_event_err()
885 * v_event_flush --
896 for (rval = 0, gp = sp->gp; gp->i_cnt != 0 && in v_event_flush()
897 F_ISSET(&gp->i_event[gp->i_next].e_ch, flags); rval = 1) in v_event_flush()
903 * v_event_grow --
912 gp = sp->gp; in v_event_grow()
913 new_nelem = gp->i_nelem + add; in v_event_grow()
914 olen = gp->i_nelem * sizeof(gp->i_event[0]); in v_event_grow()
915 BINC_RET(sp, EVENT, gp->i_event, olen, new_nelem * sizeof(gp->i_event[0])); in v_event_grow()
916 gp->i_nelem = olen / sizeof(gp->i_event[0]); in v_event_grow()
921 * v_key_cmp --
927 return (((KEYLIST *)ap)->ch - ((KEYLIST *)bp)->ch); in v_key_cmp()