- if (TERMP_STYLE & p->flags) {
- if (TERMP_BOLD & p->flags) {
- term_chara(p, c);
- term_chara(p, 8);
- }
- if (TERMP_UNDER & p->flags) {
- term_chara(p, '_');
- term_chara(p, 8);
+ if (p->col + 1 >= p->maxcols)
+ adjbuf(p, p->col + 1);
+
+ p->buf[(int)p->col++] = c;
+}
+
+
+static void
+encode(struct termp *p, const char *word, size_t sz)
+{
+ enum termfont f;
+ int i;
+
+ /*
+ * Encode and buffer a string of characters. If the current
+ * font mode is unset, buffer directly, else encode then buffer
+ * character by character.
+ */
+
+ if (TERMFONT_NONE == (f = term_fonttop(p))) {
+ if (p->col + sz >= p->maxcols)
+ adjbuf(p, p->col + sz);
+ memcpy(&p->buf[(int)p->col], word, sz);
+ p->col += sz;
+ return;
+ }
+
+ /* Pre-buffer, assuming worst-case. */
+
+ if (p->col + 1 + (sz * 3) >= p->maxcols)
+ adjbuf(p, p->col + 1 + (sz * 3));
+
+ for (i = 0; i < (int)sz; i++) {
+ if ( ! isgraph((u_char)word[i])) {
+ p->buf[(int)p->col++] = word[i];
+ continue;