implement variable-width backspace (VWBS: private mode 8901)

This commit is contained in:
uobikiemukot 2015-08-01 22:52:04 +09:00
parent 4bd08ab2cb
commit cdec33b1fe
4 changed files with 23 additions and 2 deletions

View file

@ -310,6 +310,8 @@ void set_mode(struct terminal_t *term, struct parm_t *parm)
term->mode |= MODE_AMRIGHT;
} else if (mode == 25) {
term->mode |= MODE_CURSOR;
} else if (mode == 8901) {
term->mode |= MODE_VWBS;
}
}
@ -332,6 +334,8 @@ void reset_mode(struct terminal_t *term, struct parm_t *parm)
term->wrap_occured = false;
} else if (mode == 25) {
term->mode &= ~MODE_CURSOR;
} else if (mode == 8901) {
term->mode &= ~MODE_VWBS;
}
}

View file

@ -2,7 +2,14 @@
/* function for control character */
void bs(struct terminal_t *term)
{
move_cursor(term, 0, -1);
int prev_cell = term->cursor.y * term->cols + term->cursor.x - 1;
if (term->mode & MODE_VWBS
&& 0 <= prev_cell && prev_cell < term->lines * term->cols
&& term->cells[prev_cell].width == NEXT_TO_WIDE)
move_cursor(term, 0, -2);
else
move_cursor(term, 0, -1);
}
void tab(struct terminal_t *term)

View file

@ -66,6 +66,12 @@ int set_cell(struct terminal_t *term, int y, int x, const struct glyph_t *glyphp
cellp->width = NEXT_TO_WIDE;
return WIDE;
}
if (cell.width == HALF /* isolated NEXT_TO_WIDE cell */
&& x + 1 < term->cols
&& term->cells[y * term->cols + (x + 1)].width == NEXT_TO_WIDE) {
erase_cell(term, y, x + 1);
}
return HALF;
}

6
yaft.h
View file

@ -50,7 +50,6 @@ enum misc {
DRCS_CHARS = DRCS_CHARSETS * GLYPHS_PER_CHARSET,
DEFAULT_CHAR = SPACE, /* used for erase char */
BRIGHT_INC = 8, /* value used for brightening color */
OSC_GWREPT = 8900, /* OSC Ps: mode number of yaft GWREPT */
};
enum char_attr {
@ -78,11 +77,16 @@ const uint32_t bit_mask[] = {
0x1FFFFFFF, 0x3FFFFFFF, 0x7FFFFFFF, 0xFFFFFFFF,
};
enum osc {
OSC_GWREPT = 8900, /* OSC Ps: mode number of yaft GWREPT */
};
enum term_mode {
MODE_RESET = 0x00,
MODE_ORIGIN = 0x01, /* origin mode: DECOM */
MODE_CURSOR = 0x02, /* cursor visible: DECTCEM */
MODE_AMRIGHT = 0x04, /* auto wrap: DECAWM */
MODE_VWBS = 0x08, /* variable-width backspace */
};
enum esc_state {