Index: uspace/app/bdsh/input.c
===================================================================
--- uspace/app/bdsh/input.c	(revision 2a5af223633736d7b866a2f1a951142fe72dc78b)
+++ uspace/app/bdsh/input.c	(revision f1b37d6bd2486bb5de368a6ba65627cdf8e51695)
@@ -39,4 +39,5 @@
 #include <vfs/vfs.h>
 #include <clipboard.h>
+#include <macros.h>
 #include <errno.h>
 #include <assert.h>
@@ -86,4 +87,5 @@
 
 static char *tinput_read(tinput_t *ti);
+static void tinput_insert_string(tinput_t *ti, const char *str);
 static void tinput_sel_get_bounds(tinput_t *ti, int *sa, int *sb);
 static bool tinput_sel_active(tinput_t *ti);
@@ -245,4 +247,47 @@
 }
 
+static void tinput_insert_string(tinput_t *ti, const char *str)
+{
+	int i;
+	int new_width, new_height;
+	int ilen;
+	wchar_t c;
+	size_t off;
+
+	ilen = min(str_length(str), INPUT_MAX - ti->nc);
+	if (ilen == 0)
+		return;
+
+	new_width = ti->col0 + ti->nc + ilen;
+	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 - 1; i >= ti->pos; --i)
+		ti->buffer[i + ilen] = ti->buffer[i];
+
+	off = 0; i = 0;
+	while (i < ilen) {
+		c = str_decode(str, &off, STR_NO_LIMIT);
+		if (c == '\0')
+			break;
+
+		/* Filter out non-printable chars. */
+		if (c < 32)
+			c = 32;
+
+		ti->buffer[i++] = c;
+	}
+
+	ti->pos += ilen;
+	ti->nc += ilen;
+	ti->buffer[ti->nc] = '\0';
+	ti->sel_start = ti->pos;
+
+	tinput_display_tail(ti, ti->pos - ilen, 0);
+	tinput_update_origin(ti);
+	tinput_position_caret(ti);
+}
+
 static void tinput_backspace(tinput_t *ti)
 {
@@ -484,6 +529,4 @@
 {
 	char *str;
-	size_t off;
-	wchar_t c;
 	int rc;
 
@@ -492,14 +535,5 @@
 		return; /* TODO: Give the user some warning. */
 
-	off = 0;
-
-	while (true) {
-		c = str_decode(str, &off, STR_NO_LIMIT);
-		if (c == '\0')
-			break;
-
-		tinput_insert_char(ti, c);
-	}
-
+	tinput_insert_string(ti, str);
 	free(str);
 }
