patch-2.0.15 linux/drivers/char/console.c

Next file: linux/drivers/char/mem.c
Previous file: linux/drivers/char/Makefile
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.0.14/linux/drivers/char/console.c linux/drivers/char/console.c
@@ -482,7 +482,7 @@
  */
 static void gotoxy(int currcons, int new_x, int new_y)
 {
-	int max_y;
+	int min_y, max_y;
 
 	if (new_x < 0)
 		x = 0;
@@ -492,21 +492,28 @@
 		else
 			x = new_x;
  	if (decom) {
-		new_y += top;
+		min_y = top;
 		max_y = bottom;
-	} else
+	} else {
+		min_y = 0;
 		max_y = video_num_lines;
-	if (new_y < 0)
-		y = 0;
+	}
+	if (new_y < min_y)
+		y = min_y;
+	else if (new_y >= max_y)
+		y = max_y - 1;
 	else
-		if (new_y >= max_y)
-			y = max_y - 1;
-		else
-			y = new_y;
+		y = new_y;
 	pos = origin + y*video_size_row + (x<<1);
 	need_wrap = 0;
 }
 
+/* for absolute user moves, when decom is set */
+static void gotoxay(int currcons, int new_x, int new_y)
+{
+	gotoxy(currcons, new_x, decom ? (top+new_y) : new_y);
+}
+
 /*
  * Hardware scrollback support
  */
@@ -1075,7 +1082,7 @@
 				break;
 			case 6:			/* Origin relative/absolute */
 				decom = on_off;
-				gotoxy(currcons,0,0);
+				gotoxay(currcons,0,0);
 				break;
 			case 7:			/* Autowrap on/off */
 				decawm = on_off;
@@ -1683,12 +1690,12 @@
 						continue;
 					case 'd':
 						if (par[0]) par[0]--;
-						gotoxy(currcons,x,par[0]);
+						gotoxay(currcons,x,par[0]);
 						continue;
 					case 'H': case 'f':
 						if (par[0]) par[0]--;
 						if (par[1]) par[1]--;
-						gotoxy(currcons,par[1],par[0]);
+						gotoxay(currcons,par[1],par[0]);
 						continue;
 					case 'J':
 						csi_J(currcons,par[0]);
@@ -1739,7 +1746,7 @@
 						    par[1] <= video_num_lines) {
 							top=par[0]-1;
 							bottom=par[1];
-							gotoxy(currcons,0,0);
+							gotoxay(currcons,0,0);
 						}
 						continue;
 					case 's':

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov