-/* $Id: term.c,v 1.254 2015/10/13 22:59:54 schwarze Exp $ */
+/* $Id: term.c,v 1.259 2017/01/08 18:16:58 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
if (' ' == p->buf[j] || '\t' == p->buf[j])
break;
- /* Back over the the last printed character. */
+ /* Back over the last printed character. */
if (8 == p->buf[j]) {
assert(j);
vend -= (*p->width)(p, p->buf[j - 1]);
if (++p->fonti == p->fontsz) {
p->fontsz += 8;
p->fontq = mandoc_reallocarray(p->fontq,
- p->fontsz, sizeof(enum termfont *));
+ p->fontsz, sizeof(*p->fontq));
}
p->fontq[p->fonti] = f;
}
}
}
/* Trim trailing backspace/blank pair. */
- if (p->col > 2 && p->buf[p->col - 1] == ' ')
+ if (p->col > 2 &&
+ (p->buf[p->col - 1] == ' ' ||
+ p->buf[p->col - 1] == '\t'))
p->col -= 2;
continue;
default:
if (p->col + 7 >= p->maxcols)
adjbuf(p, p->col + 7);
- f = (c == ASCII_HYPH || isgraph(c)) ?
+ f = (c == ASCII_HYPH || c > 127 || isgraph(c)) ?
p->fontq[p->fonti] : TERMFONT_NONE;
if (p->flags & TERMP_BACKBEFORE) {
- if (p->buf[p->col - 1] == ' ')
+ if (p->buf[p->col - 1] == ' ' || p->buf[p->col - 1] == '\t')
p->col--;
else
p->buf[p->col++] = 8;
if (ASCII_HYPH == word[i] ||
isgraph((unsigned char)word[i]))
encode1(p, word[i]);
- else
+ else {
p->buf[p->col++] = word[i];
+
+ /*
+ * Postpone the effect of \z while handling
+ * an overstrike sequence from ascii_uc2str().
+ */
+
+ if (word[i] == '\b' &&
+ (p->flags & TERMP_BACKBEFORE)) {
+ p->flags &= ~TERMP_BACKBEFORE;
+ p->flags |= TERMP_BACKAFTER;
+ }
+ }
}
}