Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Sep 2009 15:07:11 +0000 (UTC)
From:      Ed Schouten <ed@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r197521 - head/sys/teken
Message-ID:  <200909261507.n8QF7BFi063059@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ed
Date: Sat Sep 26 15:07:11 2009
New Revision: 197521
URL: http://svn.freebsd.org/changeset/base/197521

Log:
  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

Modified:
  head/sys/teken/teken_subr.h

Modified: head/sys/teken/teken_subr.h
==============================================================================
--- head/sys/teken/teken_subr.h	Sat Sep 26 15:03:42 2009	(r197520)
+++ head/sys/teken/teken_subr.h	Sat Sep 26 15:07:11 2009	(r197521)
@@ -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);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200909261507.n8QF7BFi063059>