summaryrefslogtreecommitdiffstats
path: root/sys/teken/teken_subr.h
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-09-26 15:07:11 +0000
committered <ed@FreeBSD.org>2009-09-26 15:07:11 +0000
commitba94d1a005032941ea59b2f361257e1cbd4fa6bd (patch)
tree0e56b4e4e65e7856c15a34b3a6341fef11e59686 /sys/teken/teken_subr.h
parenta2eab704dfd8ad56039a95219c7462c5d84c721e (diff)
downloadFreeBSD-src-ba94d1a005032941ea59b2f361257e1cbd4fa6bd.zip
FreeBSD-src-ba94d1a005032941ea59b2f361257e1cbd4fa6bd.tar.gz
Properly get out of origin mode if the cursor has to move outside of it.
In some cases events may occur that move the cursor outside the scrolling region while in origin mode, which is normally not possible. Events like these include: - Alignment test. - Restore cursor. Properly switch off origin mode in these cases. MFC after: 1 month
Diffstat (limited to 'sys/teken/teken_subr.h')
-rw-r--r--sys/teken/teken_subr.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/sys/teken/teken_subr.h b/sys/teken/teken_subr.h
index 0332770..4c31065 100644
--- a/sys/teken/teken_subr.h
+++ b/sys/teken/teken_subr.h
@@ -185,11 +185,11 @@ teken_subr_alignment_test(teken_t *t)
{
teken_rect_t tr;
+ t->t_cursor.tp_row = t->t_cursor.tp_col = 0;
t->t_scrollreg.ts_begin = 0;
t->t_scrollreg.ts_end = t->t_winsize.tp_row;
-
- t->t_cursor.tp_row = t->t_cursor.tp_col = 0;
- t->t_stateflags &= ~TS_WRAPPED;
+ t->t_originreg = t->t_scrollreg;
+ t->t_stateflags &= ~(TS_WRAPPED|TS_ORIGIN);
teken_funcs_cursor(t);
tr.tr_begin.tp_row = 0;
@@ -988,6 +988,15 @@ teken_subr_restore_cursor(teken_t *t)
t->t_curattr = t->t_saved_curattr;
t->t_scs[t->t_curscs] = t->t_saved_curscs;
t->t_stateflags &= ~TS_WRAPPED;
+
+ /* Get out of origin mode when the cursor is moved outside. */
+ if (t->t_cursor.tp_row < t->t_originreg.ts_begin ||
+ t->t_cursor.tp_row >= t->t_originreg.ts_end) {
+ t->t_stateflags &= ~TS_ORIGIN;
+ t->t_originreg.ts_begin = 0;
+ t->t_originreg.ts_end = t->t_winsize.tp_row;
+ }
+
teken_funcs_cursor(t);
}
OpenPOWER on IntegriCloud