Index: uspace/app/bdsh/input.c
===================================================================
--- uspace/app/bdsh/input.c	(revision fd34f4efe98bf9c503af9ed1e7284c9cdde893e0)
+++ uspace/app/bdsh/input.c	(revision 4a2aa91b3c7c2f4bcc5a3694e7870a8f757af68c)
@@ -39,4 +39,5 @@
 #include <errno.h>
 #include <assert.h>
+#include <macros.h>
 #include <bool.h>
 
@@ -125,5 +126,6 @@
 	int i;
 
-	console_goto(fphone(stdout), ti->col0 + start, ti->row0);
+	console_goto(fphone(stdout), (ti->col0 + start) % ti->con_cols,
+	    ti->row0 + (ti->col0 + start) / ti->con_cols);
 	printf("%ls", ti->buffer + start);
 	for (i = 0; i < pad; ++i)
@@ -139,5 +141,19 @@
 static void tinput_position_caret(tinput_t *ti)
 {
-	console_goto(fphone(stdout), ti->col0 + ti->pos, ti->row0);
+	console_goto(fphone(stdout), (ti->col0 + ti->pos) % ti->con_cols,
+	    ti->row0 + (ti->col0 + ti->pos) / ti->con_cols);
+}
+
+/** Update row0 in case the screen could have scrolled. */
+static void tinput_update_origin(tinput_t *ti)
+{
+	int width, rows;
+
+	width = ti->col0 + ti->nc;
+	rows = (width / ti->con_cols) + 1;
+ 
+	/* Update row0 if the screen scrolled. */
+	if (ti->row0 + rows > ti->con_rows)
+		ti->row0 = ti->con_rows - rows;	
 }
 
@@ -145,10 +161,16 @@
 {
 	int i;
+	int new_width, new_height;
 
 	if (ti->nc == INPUT_MAX)
 		return;
 
-	if (ti->col0 + ti->nc >= ti->con_cols - 1)
-		return;
+	new_width = ti->col0 + ti->nc + 1;
+	if (new_width % ti->con_cols == 0) {
+		/* Advancing to new line. */
+		new_height = (new_width / ti->con_cols) + 1;
+		if (new_height >= ti->con_rows)
+			return; /* Disallow text longer than 1 page for now. */
+	}
 
 	for (i = ti->nc; i > ti->pos; --i)
@@ -161,4 +183,5 @@
 
 	tinput_display_tail(ti, ti->pos - 1, 0);
+	tinput_update_origin(ti);
 	tinput_position_caret(ti);
 }
@@ -239,4 +262,14 @@
 }
 
+static void tinput_seek_vertical(tinput_t *ti, seek_dir_t dir)
+{
+	if (dir == seek_forward)
+		ti->pos = min(ti->pos + ti->con_cols, ti->nc);
+	else 
+		ti->pos = max(0, ti->pos - ti->con_cols);
+
+	tinput_position_caret(ti);
+}
+
 static void tinput_seek_max(tinput_t *ti, seek_dir_t dir)
 {
@@ -298,4 +331,5 @@
 	tinput_set_str(ti, ti->history[ti->hpos]);
 	tinput_display_tail(ti, 0, pad);
+	tinput_update_origin(ti);
 	tinput_position_caret(ti);
 }
@@ -341,4 +375,10 @@
 				tinput_seek_word(ti, seek_forward);
 				break;
+			case KC_UP:
+				tinput_seek_vertical(ti, seek_backward);
+				break;
+			case KC_DOWN:
+				tinput_seek_vertical(ti, seek_forward);
+				break;
 			}
 		}
@@ -382,4 +422,6 @@
 
 done:
+	ti->pos = ti->nc;
+	tinput_position_caret(ti);
 	putchar('\n');
 
