Lines Matching defs:code
362 struct tty_code *code;
401 code = &term->codes[i];
404 code->type = TTYCODE_NONE;
411 if (code->type == TTYCODE_STRING)
412 free(code->value.string);
413 code->value.string = xstrdup(value);
414 code->type = ent->type;
420 code->value.number = n;
421 code->type = ent->type;
424 code->value.flag = 1;
425 code->type = ent->type;
526 struct tty_code *code;
558 code = &term->codes[j];
559 code->type = TTYCODE_NONE;
564 code->type = TTYCODE_STRING;
565 code->value.string = tty_term_strip(value);
572 code->type = TTYCODE_NUMBER;
573 code->value.number = n;
577 code->type = TTYCODE_FLAG;
578 code->value.flag = (*value == '1');
750 tty_term_has(struct tty_term *term, enum tty_code_code code)
752 return (term->codes[code].type != TTYCODE_NONE);
756 tty_term_string(struct tty_term *term, enum tty_code_code code)
758 if (!tty_term_has(term, code))
760 if (term->codes[code].type != TTYCODE_STRING)
761 fatalx("not a string: %d", code);
762 return (term->codes[code].value.string);
766 tty_term_string_i(struct tty_term *term, enum tty_code_code code, int a)
768 const char *x = tty_term_string(term, code), *s;
772 log_debug("could not expand %s", tty_term_codes[code].name);
779 tty_term_string_ii(struct tty_term *term, enum tty_code_code code, int a, int b)
781 const char *x = tty_term_string(term, code), *s;
785 log_debug("could not expand %s", tty_term_codes[code].name);
792 tty_term_string_iii(struct tty_term *term, enum tty_code_code code, int a,
795 const char *x = tty_term_string(term, code), *s;
799 log_debug("could not expand %s", tty_term_codes[code].name);
806 tty_term_string_s(struct tty_term *term, enum tty_code_code code, const char *a)
808 const char *x = tty_term_string(term, code), *s;
812 log_debug("could not expand %s", tty_term_codes[code].name);
819 tty_term_string_ss(struct tty_term *term, enum tty_code_code code,
822 const char *x = tty_term_string(term, code), *s;
826 log_debug("could not expand %s", tty_term_codes[code].name);
833 tty_term_number(struct tty_term *term, enum tty_code_code code)
835 if (!tty_term_has(term, code))
837 if (term->codes[code].type != TTYCODE_NUMBER)
838 fatalx("not a number: %d", code);
839 return (term->codes[code].value.number);
843 tty_term_flag(struct tty_term *term, enum tty_code_code code)
845 if (!tty_term_has(term, code))
847 if (term->codes[code].type != TTYCODE_FLAG)
848 fatalx("not a flag: %d", code);
849 return (term->codes[code].value.flag);
853 tty_term_describe(struct tty_term *term, enum tty_code_code code)
858 switch (term->codes[code].type) {
861 code, tty_term_codes[code].name);
864 strnvis(out, term->codes[code].value.string, sizeof out,
867 code, tty_term_codes[code].name,
872 code, tty_term_codes[code].name,
873 term->codes[code].value.number);
877 code, tty_term_codes[code].name,
878 term->codes[code].value.flag ? "true" : "false");