We needed the reverse wrap around in the teken library and I thought you might like it as well. Cheers! diff -u -r -N teken/teken.c teken_/teken.c --- teken/teken.c 2018-01-12 01:48:10.832926321 +0100 +++ teken_/teken.c 2018-01-12 01:50:08.108822290 +0100 @@ -58,6 +58,7 @@ #define TS_CONS25 0x0040 /* cons25 emulation. */ #define TS_INSTRING 0x0080 /* Inside string. */ #define TS_CURSORKEYS 0x0100 /* Cursor keys mode. */ +#define TS_REVWRAP 0x0200 /* reverse Wraparound */ /* Character that blanks a cell. */ #define BLANK ' ' diff -u -r -N teken/teken_subr.h teken_/teken_subr.h --- teken/teken_subr.h 2018-01-12 01:48:10.833926389 +0100 +++ teken_/teken_subr.h 2018-01-12 01:50:08.108822290 +0100 @@ -213,6 +213,16 @@ } else { t->t_cursor.tp_col--; } + } else if (t->t_stateflags & TS_REVWRAP) { + if (t->t_cursor.tp_col == 0) { + if (t->t_cursor.tp_row == t->t_originreg.ts_begin) + return; + t->t_cursor.tp_row--; + t->t_cursor.tp_col = t->t_winsize.tp_col - 2; + } else { + t->t_cursor.tp_col--; + t->t_stateflags &= ~TS_WRAPPED; + } } else { if (t->t_cursor.tp_col == 0) return;
unfortunately I lost some lines in the previous diff... here is the updated patch: diff -u -r -N teken/teken.c teken_/teken.c --- teken/teken.c 2018-01-12 01:48:10.832926321 +0100 +++ teken_/teken.c 2018-01-12 01:50:08.108822290 +0100 @@ -58,6 +58,7 @@ #define TS_CONS25 0x0040 /* cons25 emulation. */ #define TS_INSTRING 0x0080 /* Inside string. */ #define TS_CURSORKEYS 0x0100 /* Cursor keys mode. */ +#define TS_REVWRAP 0x0200 /* reverse Wraparound */ /* Character that blanks a cell. */ #define BLANK ' ' diff -u -r -N teken/teken_subr.h teken_/teken_subr.h --- teken/teken_subr.h 2018-01-12 01:48:10.833926389 +0100 +++ teken_/teken_subr.h 2018-01-12 12:33:37.831931927 +0100 @@ -213,6 +213,16 @@ } else { t->t_cursor.tp_col--; } + } else if (t->t_stateflags & TS_REVWRAP) { + if (t->t_cursor.tp_col == 0) { + if (t->t_cursor.tp_row == t->t_originreg.ts_begin) + return; + t->t_cursor.tp_row--; + t->t_cursor.tp_col = t->t_winsize.tp_col - 2; + } else { + t->t_cursor.tp_col--; + t->t_stateflags &= ~TS_WRAPPED; + } } else { if (t->t_cursor.tp_col == 0) return; @@ -934,7 +944,8 @@ teken_printf("DECRST allow 132\n"); break; case 45: /* Disable reverse wraparound. */ - teken_printf("DECRST reverse wraparound\n"); + t->t_stateflags &= ~TS_REVWRAP; + teken_printf("DECRST reverse wraparound disabled\n"); break; case 47: /* Switch to alternate buffer. */ teken_printf("Switch to alternate buffer\n"); @@ -1092,7 +1103,8 @@ teken_printf("DECSET allow 132\n"); break; case 45: /* Enable reverse wraparound. */ - teken_printf("DECSET reverse wraparound\n"); + t->t_stateflags |= TS_REVWRAP; + teken_printf("DECSET reverse wraparound enabled\n"); break; case 47: /* Switch to alternate buffer. */ teken_printf("Switch away from alternate buffer\n");
Ed does this look good to go in?
Hey! The patch looks decent, but I'm wondering whether it's possible to merge some of the now redundant logic in teken_subr_backspace(), e.g.: ... } else { if (t->t_cursor.tp_col == 0) { if ((t->t_stateflags & TS_REVWRAP) == 0) return; t->t_cursor.tp_row--; t->t_cursor.tp_col = t->t_winsize.tp_col - 2; } else { t->t_cursor.tp_col--; t->t_stateflags &= ~TS_WRAPPED; } } Also, I think you might need to take TS_WRAPPED into account. Depending on the value of that flag, you may need to jump to 't->t_winsize.tp_col - 1' or 't->t_winsize.tp_col - 2'. Also, feel free to remove the teken_printf() calls there. They were just a debugging aid to display unsupported escape sequences.