Index: uspace/lib/c/generic/io/console.c
===================================================================
--- uspace/lib/c/generic/io/console.c	(revision caad59aaedb0d9190a12111b1fd41fed41df0d07)
+++ uspace/lib/c/generic/io/console.c	(revision 9f1362d4e7eaaca0f48042dc579d07341d14e38a)
@@ -45,28 +45,21 @@
 }
 
-int console_get_size(int phone, int *cols, int *rows)
+int console_get_size(int phone, ipcarg_t *cols, ipcarg_t *rows)
 {
-	ipcarg_t cols_v;
-	ipcarg_t rows_v;
-	int rc;
-
-	rc = async_req_0_2(phone, CONSOLE_GET_SIZE, &cols_v, &rows_v);
-
-	*cols = (int) cols_v;
-	*rows = (int) rows_v;
-	return rc;
+	return async_req_0_2(phone, CONSOLE_GET_SIZE, cols, rows);
 }
 
-void console_set_style(int phone, int style)
+void console_set_style(int phone, uint8_t style)
 {
 	async_msg_1(phone, CONSOLE_SET_STYLE, style);
 }
 
-void console_set_color(int phone, int fg_color, int bg_color, int flags)
+void console_set_color(int phone, uint8_t fg_color, uint8_t bg_color,
+    uint8_t flags)
 {
 	async_msg_3(phone, CONSOLE_SET_COLOR, fg_color, bg_color, flags);
 }
 
-void console_set_rgb_color(int phone, int fg_color, int bg_color)
+void console_set_rgb_color(int phone, uint32_t fg_color, uint32_t bg_color)
 {
 	async_msg_2(phone, CONSOLE_SET_RGB_COLOR, fg_color, bg_color);
@@ -75,16 +68,10 @@
 void console_cursor_visibility(int phone, bool show)
 {
-	async_msg_1(phone, CONSOLE_CURSOR_VISIBILITY, show != false);
+	async_msg_1(phone, CONSOLE_CURSOR_VISIBILITY, (show != false));
 }
 
-int console_get_color_cap(int phone, int *ccap)
+int console_get_color_cap(int phone, ipcarg_t *ccap)
 {
-	ipcarg_t ccap_tmp;
-	int rc;
-
-	rc = async_req_0_1(phone, CONSOLE_GET_COLOR_CAP, &ccap_tmp);
-	*ccap = ccap_tmp;
-
-	return rc;
+	return async_req_0_1(phone, CONSOLE_GET_COLOR_CAP, ccap);
 }
 
@@ -94,18 +81,10 @@
 }
 
-int console_get_pos(int phone, int *col, int *row)
+int console_get_pos(int phone, ipcarg_t *col, ipcarg_t *row)
 {
-	ipcarg_t col_v;
-	ipcarg_t row_v;
-	int rc;
-
-	rc = async_req_0_2(phone, CONSOLE_GET_POS, &col_v, &row_v);
-
-	*col = (int) col_v;
-	*row = (int) row_v;
-	return rc;
+	return async_req_0_2(phone, CONSOLE_GET_POS, col, row);
 }
 
-void console_goto(int phone, int col, int row)
+void console_set_pos(int phone, ipcarg_t col, ipcarg_t row)
 {
 	async_msg_2(phone, CONSOLE_GOTO, col, row);
Index: uspace/lib/c/include/io/console.h
===================================================================
--- uspace/lib/c/include/io/console.h	(revision caad59aaedb0d9190a12111b1fd41fed41df0d07)
+++ uspace/lib/c/include/io/console.h	(revision 9f1362d4e7eaaca0f48042dc579d07341d14e38a)
@@ -68,14 +68,15 @@
 extern void console_clear(int phone);
 
-extern int console_get_size(int phone, int *cols, int *rows);
-extern int console_get_pos(int phone, int *col, int *row);
-extern void console_goto(int phone, int col, int row);
+extern int console_get_size(int phone, ipcarg_t *cols, ipcarg_t *rows);
+extern int console_get_pos(int phone, ipcarg_t *col, ipcarg_t *row);
+extern void console_set_pos(int phone, ipcarg_t col, ipcarg_t row);
 
-extern void console_set_style(int phone, int style);
-extern void console_set_color(int phone, int fg_color, int bg_color, int flags);
-extern void console_set_rgb_color(int phone, int fg_color, int bg_color);
+extern void console_set_style(int phone, uint8_t style);
+extern void console_set_color(int phone, uint8_t fg_color, uint8_t bg_color,
+    uint8_t flags);
+extern void console_set_rgb_color(int phone, uint32_t fg_color, uint32_t bg_color);
 
 extern void console_cursor_visibility(int phone, bool show);
-extern int console_get_color_cap(int phone, int *ccap);
+extern int console_get_color_cap(int phone, ipcarg_t *ccap);
 extern void console_kcon_enable(int phone);
 
Index: uspace/lib/c/include/io/style.h
===================================================================
--- uspace/lib/c/include/io/style.h	(revision caad59aaedb0d9190a12111b1fd41fed41df0d07)
+++ uspace/lib/c/include/io/style.h	(revision 9f1362d4e7eaaca0f48042dc579d07341d14e38a)
@@ -38,5 +38,7 @@
 enum console_style {
 	STYLE_NORMAL   = 0,
-	STYLE_EMPHASIS = 1
+	STYLE_EMPHASIS = 1,
+	STYLE_INVERTED = 2,
+	STYLE_SELECTED = 3
 };
 
Index: uspace/lib/clui/Makefile
===================================================================
--- uspace/lib/clui/Makefile	(revision caad59aaedb0d9190a12111b1fd41fed41df0d07)
+++ uspace/lib/clui/Makefile	(revision 9f1362d4e7eaaca0f48042dc579d07341d14e38a)
@@ -28,4 +28,5 @@
 
 USPACE_PREFIX = ../..
+EXTRA_CFLAGS = -I.
 LIBRARY = libclui
 
Index: uspace/lib/clui/tinput.c
===================================================================
--- uspace/lib/clui/tinput.c	(revision caad59aaedb0d9190a12111b1fd41fed41df0d07)
+++ uspace/lib/clui/tinput.c	(revision 9f1362d4e7eaaca0f48042dc579d07341d14e38a)
@@ -40,6 +40,5 @@
 #include <assert.h>
 #include <bool.h>
-
-#include "tinput.h"
+#include <tinput.h>
 
 /** Seek direction */
@@ -49,16 +48,16 @@
 } seek_dir_t;
 
-static void tinput_init(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);
-static void tinput_sel_all(tinput_t *ti);
-static void tinput_sel_delete(tinput_t *ti);
-static void tinput_key_ctrl(tinput_t *ti, console_event_t *ev);
-static void tinput_key_shift(tinput_t *ti, console_event_t *ev);
-static void tinput_key_ctrl_shift(tinput_t *ti, console_event_t *ev);
-static void tinput_key_unmod(tinput_t *ti, console_event_t *ev);
-static void tinput_pre_seek(tinput_t *ti, bool shift_held);
-static void tinput_post_seek(tinput_t *ti, bool shift_held);
+static void tinput_init(tinput_t *);
+static void tinput_insert_string(tinput_t *, const char *);
+static void tinput_sel_get_bounds(tinput_t *, size_t *, size_t *);
+static bool tinput_sel_active(tinput_t *);
+static void tinput_sel_all(tinput_t *);
+static void tinput_sel_delete(tinput_t *);
+static void tinput_key_ctrl(tinput_t *, console_event_t *);
+static void tinput_key_shift(tinput_t *, console_event_t *);
+static void tinput_key_ctrl_shift(tinput_t *, console_event_t *);
+static void tinput_key_unmod(tinput_t *, console_event_t *);
+static void tinput_pre_seek(tinput_t *, bool);
+static void tinput_post_seek(tinput_t *, bool);
 
 /** Create a new text input field. */
@@ -66,9 +65,9 @@
 {
 	tinput_t *ti;
-
+	
 	ti = malloc(sizeof(tinput_t));
 	if (ti == NULL)
 		return NULL;
-
+	
 	tinput_init(ti);
 	return ti;
@@ -81,17 +80,17 @@
 }
 
-static void tinput_display_tail(tinput_t *ti, int start, int pad)
-{
-	static wchar_t dbuf[INPUT_MAX_SIZE + 1];
-	int sa, sb;
-	int i, p;
-
+static void tinput_display_tail(tinput_t *ti, size_t start, size_t pad)
+{
+	wchar_t dbuf[INPUT_MAX_SIZE + 1];
+	
+	size_t sa;
+	size_t sb;
 	tinput_sel_get_bounds(ti, &sa, &sb);
-
-	console_goto(fphone(stdout), (ti->col0 + start) % ti->con_cols,
+	
+	console_set_pos(fphone(stdout), (ti->col0 + start) % ti->con_cols,
 	    ti->row0 + (ti->col0 + start) / ti->con_cols);
-	console_set_color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0);
-
-	p = start;
+	console_set_style(fphone(stdout), STYLE_NORMAL);
+	
+	size_t p = start;
 	if (p < sa) {
 		memcpy(dbuf, ti->buffer + p, (sa - p) * sizeof(wchar_t));
@@ -100,8 +99,8 @@
 		p = sa;
 	}
-
+	
 	if (p < sb) {
 		fflush(stdout);
-		console_set_color(fphone(stdout), COLOR_BLACK, COLOR_RED, 0);
+		console_set_style(fphone(stdout), STYLE_SELECTED);
 		memcpy(dbuf, ti->buffer + p,
 		    (sb - p) * sizeof(wchar_t));
@@ -110,8 +109,8 @@
 		p = sb;
 	}
-
+	
 	fflush(stdout);
-	console_set_color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0);
-
+	console_set_style(fphone(stdout), STYLE_NORMAL);
+	
 	if (p < ti->nc) {
 		memcpy(dbuf, ti->buffer + p,
@@ -120,7 +119,8 @@
 		printf("%ls", dbuf);
 	}
-
-	for (i = 0; i < pad; ++i)
+	
+	for (p = 0; p < pad; p++)
 		putchar(' ');
+	
 	fflush(stdout);
 }
@@ -133,5 +133,5 @@
 static void tinput_position_caret(tinput_t *ti)
 {
-	console_goto(fphone(stdout), (ti->col0 + ti->pos) % ti->con_cols,
+	console_set_pos(fphone(stdout), (ti->col0 + ti->pos) % ti->con_cols,
 	    ti->row0 + (ti->col0 + ti->pos) / ti->con_cols);
 }
@@ -140,33 +140,31 @@
 static void tinput_update_origin(tinput_t *ti)
 {
-	int width, rows;
-
-	width = ti->col0 + ti->nc;
-	rows = (width / ti->con_cols) + 1;
-
+	ipcarg_t width = ti->col0 + ti->nc;
+	ipcarg_t 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;	
+		ti->row0 = ti->con_rows - rows;
 }
 
 static void tinput_insert_char(tinput_t *ti, wchar_t c)
 {
-	int i;
-	int new_width, new_height;
-
 	if (ti->nc == INPUT_MAX_SIZE)
 		return;
-
-	new_width = ti->col0 + ti->nc + 1;
+	
+	ipcarg_t 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)
+		ipcarg_t new_height = (new_width / ti->con_cols) + 1;
+		if (new_height >= ti->con_rows) {
+			/* Disallow text longer than 1 page for now. */
+			return;
+		}
+	}
+	
+	size_t i;
+	for (i = ti->nc; i > ti->pos; i--)
 		ti->buffer[i] = ti->buffer[i - 1];
-
+	
 	ti->buffer[ti->pos] = c;
 	ti->pos += 1;
@@ -174,5 +172,5 @@
 	ti->buffer[ti->nc] = '\0';
 	ti->sel_start = ti->pos;
-
+	
 	tinput_display_tail(ti, ti->pos - 1, 0);
 	tinput_update_origin(ti);
@@ -182,41 +180,41 @@
 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((ssize_t) str_length(str), INPUT_MAX_SIZE - ti->nc);
+	size_t ilen = min(str_length(str), INPUT_MAX_SIZE - 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;
+	
+	ipcarg_t new_width = ti->col0 + ti->nc + ilen;
+	ipcarg_t new_height = (new_width / ti->con_cols) + 1;
+	if (new_height >= ti->con_rows) {
+		/* Disallow text longer than 1 page for now. */
+		return;
+	}
+	
+	if (ti->nc > 0) {
+		size_t i;
+		for (i = ti->nc; i > ti->pos; i--)
+			ti->buffer[i + ilen - 1] = ti->buffer[i - 1];
+	}
+	
+	size_t off = 0;
+	size_t i = 0;
 	while (i < ilen) {
-		c = str_decode(str, &off, STR_NO_LIMIT);
+		wchar_t c = str_decode(str, &off, STR_NO_LIMIT);
 		if (c == '\0')
 			break;
-
+		
 		/* Filter out non-printable chars. */
 		if (c < 32)
 			c = 32;
-
+		
 		ti->buffer[ti->pos + i] = c;
-		++i;
-	}
-
+		i++;
+	}
+	
 	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);
@@ -226,21 +224,21 @@
 static void tinput_backspace(tinput_t *ti)
 {
-	int i;
-
 	if (tinput_sel_active(ti)) {
 		tinput_sel_delete(ti);
 		return;
 	}
-
+	
 	if (ti->pos == 0)
 		return;
-
-	for (i = ti->pos; i < ti->nc; ++i)
+	
+	size_t i;
+	for (i = ti->pos; i < ti->nc; i++)
 		ti->buffer[i - 1] = ti->buffer[i];
+	
 	ti->pos -= 1;
 	ti->nc -= 1;
 	ti->buffer[ti->nc] = '\0';
 	ti->sel_start = ti->pos;
-
+	
 	tinput_display_tail(ti, ti->pos, 1);
 	tinput_position_caret(ti);
@@ -253,11 +251,11 @@
 		return;
 	}
-
+	
 	if (ti->pos == ti->nc)
 		return;
-
+	
 	ti->pos += 1;
 	ti->sel_start = ti->pos;
-
+	
 	tinput_backspace(ti);
 }
@@ -266,5 +264,5 @@
 {
 	tinput_pre_seek(ti, shift_held);
-
+	
 	if (dir == seek_forward) {
 		if (ti->pos < ti->nc)
@@ -274,5 +272,5 @@
 			ti->pos -= 1;
 	}
-
+	
 	tinput_post_seek(ti, shift_held);
 }
@@ -281,17 +279,17 @@
 {
 	tinput_pre_seek(ti, shift_held);
-
+	
 	if (dir == seek_forward) {
 		if (ti->pos == ti->nc)
 			return;
-
-		while (1) {
+		
+		while (true) {
 			ti->pos += 1;
-
+			
 			if (ti->pos == ti->nc)
 				break;
-
-			if (ti->buffer[ti->pos - 1] == ' ' &&
-			    ti->buffer[ti->pos] != ' ')
+			
+			if ((ti->buffer[ti->pos - 1] == ' ') &&
+			    (ti->buffer[ti->pos] != ' '))
 				break;
 		}
@@ -299,18 +297,18 @@
 		if (ti->pos == 0)
 			return;
-
-		while (1) {
+		
+		while (true) {
 			ti->pos -= 1;
-
+			
 			if (ti->pos == 0)
 				break;
-
+			
 			if (ti->buffer[ti->pos - 1] == ' ' &&
 			    ti->buffer[ti->pos] != ' ')
 				break;
 		}
-
-	}
-
+	
+	}
+	
 	tinput_post_seek(ti, shift_held);
 }
@@ -319,13 +317,13 @@
 {
 	tinput_pre_seek(ti, shift_held);
-
+	
 	if (dir == seek_forward) {
 		if (ti->pos + ti->con_cols <= ti->nc)
 			ti->pos = ti->pos + ti->con_cols;
 	} else {
-		if (ti->pos - ti->con_cols >= 0)
+		if (ti->pos >= ti->con_cols)
 			ti->pos = ti->pos - ti->con_cols;
 	}
-
+	
 	tinput_post_seek(ti, shift_held);
 }
@@ -334,10 +332,10 @@
 {
 	tinput_pre_seek(ti, shift_held);
-
+	
 	if (dir == seek_backward)
 		ti->pos = 0;
 	else
 		ti->pos = ti->nc;
-
+	
 	tinput_post_seek(ti, shift_held);
 }
@@ -345,5 +343,5 @@
 static void tinput_pre_seek(tinput_t *ti, bool shift_held)
 {
-	if (tinput_sel_active(ti) && !shift_held) {
+	if ((tinput_sel_active(ti)) && (!shift_held)) {
 		/* Unselect and redraw. */
 		ti->sel_start = ti->pos;
@@ -362,4 +360,5 @@
 		ti->sel_start = ti->pos;
 	}
+	
 	tinput_position_caret(ti);
 }
@@ -367,6 +366,4 @@
 static void tinput_history_insert(tinput_t *ti, char *str)
 {
-	int i;
-
 	if (ti->hnum < HISTORY_LEN) {
 		ti->hnum += 1;
@@ -375,10 +372,11 @@
 			free(ti->history[HISTORY_LEN]);
 	}
-
-	for (i = ti->hnum; i > 1; --i)
+	
+	size_t i;
+	for (i = ti->hnum; i > 1; i--)
 		ti->history[i] = ti->history[i - 1];
-
+	
 	ti->history[1] = str_dup(str);
-
+	
 	if (ti->history[0] != NULL) {
 		free(ti->history[0]);
@@ -395,5 +393,5 @@
 }
 
-static void tinput_sel_get_bounds(tinput_t *ti, int *sa, int *sb)
+static void tinput_sel_get_bounds(tinput_t *ti, size_t *sa, size_t *sb)
 {
 	if (ti->sel_start < ti->pos) {
@@ -408,5 +406,5 @@
 static bool tinput_sel_active(tinput_t *ti)
 {
-	return ti->sel_start != ti->pos;
+	return (ti->sel_start != ti->pos);
 }
 
@@ -421,16 +419,18 @@
 static void tinput_sel_delete(tinput_t *ti)
 {
-	int sa, sb;
-
+	size_t sa;
+	size_t sb;
+	
 	tinput_sel_get_bounds(ti, &sa, &sb);
 	if (sa == sb)
 		return;
-
+	
 	memmove(ti->buffer + sa, ti->buffer + sb,
 	    (ti->nc - sb) * sizeof(wchar_t));
+	
 	ti->pos = ti->sel_start = sa;
 	ti->nc -= (sb - sa);
 	ti->buffer[ti->nc] = '\0';
-
+	
 	tinput_display_tail(ti, sa, sb - sa);
 	tinput_position_caret(ti);
@@ -439,9 +439,11 @@
 static void tinput_sel_copy_to_cb(tinput_t *ti)
 {
-	int sa, sb;
+	size_t sa;
+	size_t sb;
+	
+	tinput_sel_get_bounds(ti, &sa, &sb);
+	
 	char *str;
-
-	tinput_sel_get_bounds(ti, &sa, &sb);
-
+	
 	if (sb < ti->nc) {
 		wchar_t tmp_c = ti->buffer[sb];
@@ -454,13 +456,14 @@
 	if (str == NULL)
 		goto error;
-
+	
 	if (clipboard_put_str(str) != EOK)
 		goto error;
-
+	
 	free(str);
 	return;
+	
 error:
+	/* TODO: Give the user some kind of warning. */
 	return;
-	/* TODO: Give the user some warning. */
 }
 
@@ -468,10 +471,11 @@
 {
 	char *str;
-	int rc;
-
-	rc = clipboard_get_str(&str);
-	if (rc != EOK || str == NULL)
-		return; /* TODO: Give the user some warning. */
-
+	int rc = clipboard_get_str(&str);
+	
+	if ((rc != EOK) || (str == NULL)) {
+		/* TODO: Give the user some kind of warning. */
+		return;
+	}
+	
 	tinput_insert_string(ti, str);
 	free(str);
@@ -480,20 +484,24 @@
 static void tinput_history_seek(tinput_t *ti, int offs)
 {
-	int pad;
-
-	if (ti->hpos + offs < 0 || ti->hpos + offs > ti->hnum)
-		return;
-
+	if (offs >= 0) {
+		if (ti->hpos + offs > ti->hnum)
+			return;
+	} else {
+		if (ti->hpos < (size_t) -offs)
+			return;
+	}
+	
 	if (ti->history[ti->hpos] != NULL) {
 		free(ti->history[ti->hpos]);
 		ti->history[ti->hpos] = NULL;
 	}
-
+	
 	ti->history[ti->hpos] = tinput_get_str(ti);
 	ti->hpos += offs;
-
-	pad = ti->nc - str_length(ti->history[ti->hpos]);
-	if (pad < 0) pad = 0;
-
+	
+	int pad = (int) ti->nc - str_length(ti->history[ti->hpos]);
+	if (pad < 0)
+		pad = 0;
+	
 	tinput_set_str(ti, ti->history[ti->hpos]);
 	tinput_display_tail(ti, 0, pad);
@@ -515,55 +523,54 @@
 /** Read in one line of input.
  *
- * @param ti	Text input.
- * @param dstr	Place to save pointer to new string.
- * @return	EOK on success, ENOENT if user requested abort, EIO
- *		if communication with console failed.
+ * @param ti   Text input.
+ * @param dstr Place to save pointer to new string.
+ *
+ * @return EOK on success
+ * @return ENOENT if user requested abort
+ * @return EIO if communication with console failed
+ *
  */
 int tinput_read(tinput_t *ti, char **dstr)
 {
-	console_event_t ev;
-	char *str;
-
 	fflush(stdout);
-
 	if (console_get_size(fphone(stdin), &ti->con_cols, &ti->con_rows) != EOK)
 		return EIO;
+	
 	if (console_get_pos(fphone(stdin), &ti->col0, &ti->row0) != EOK)
 		return EIO;
-
-	ti->pos = ti->sel_start = 0;
+	
+	ti->pos = 0;
+	ti->sel_start = 0;
 	ti->nc = 0;
 	ti->buffer[0] = '\0';
 	ti->done = false;
 	ti->exit_clui = false;
-
+	
 	while (!ti->done) {
 		fflush(stdout);
+		
+		console_event_t ev;
 		if (!console_get_event(fphone(stdin), &ev))
 			return EIO;
-
+		
 		if (ev.type != KEY_PRESS)
 			continue;
-
-		if ((ev.mods & KM_CTRL) != 0 &&
-		    (ev.mods & (KM_ALT | KM_SHIFT)) == 0) {
+		
+		if (((ev.mods & KM_CTRL) != 0) &&
+		    ((ev.mods & (KM_ALT | KM_SHIFT)) == 0))
 			tinput_key_ctrl(ti, &ev);
-		}
-
-		if ((ev.mods & KM_SHIFT) != 0 &&
-		    (ev.mods & (KM_CTRL | KM_ALT)) == 0) {
+		
+		if (((ev.mods & KM_SHIFT) != 0) &&
+		    ((ev.mods & (KM_CTRL | KM_ALT)) == 0))
 			tinput_key_shift(ti, &ev);
-		}
-
-		if ((ev.mods & KM_CTRL) != 0 &&
-		    (ev.mods & KM_SHIFT) != 0 &&
-		    (ev.mods & KM_ALT) == 0) {
+		
+		if (((ev.mods & KM_CTRL) != 0) &&
+		    ((ev.mods & KM_SHIFT) != 0) &&
+		    ((ev.mods & KM_ALT) == 0))
 			tinput_key_ctrl_shift(ti, &ev);
-		}
-
-		if ((ev.mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0) {
+		
+		if ((ev.mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0)
 			tinput_key_unmod(ti, &ev);
-		}
-
+		
 		if (ev.c >= ' ') {
 			tinput_sel_delete(ti);
@@ -571,18 +578,18 @@
 		}
 	}
-
+	
 	if (ti->exit_clui)
 		return ENOENT;
-
+	
 	ti->pos = ti->nc;
 	tinput_position_caret(ti);
 	putchar('\n');
-
-	str = tinput_get_str(ti);
+	
+	char *str = tinput_get_str(ti);
 	if (str_cmp(str, "") != 0)
 		tinput_history_insert(ti, str);
-
+	
 	ti->hpos = 0;
-
+	
 	*dstr = str;
 	return EOK;
@@ -700,5 +707,5 @@
 		break;
 	case KC_UP:
-		tinput_history_seek(ti, +1);
+		tinput_history_seek(ti, 1);
 		break;
 	case KC_DOWN:
Index: uspace/lib/clui/tinput.h
===================================================================
--- uspace/lib/clui/tinput.h	(revision caad59aaedb0d9190a12111b1fd41fed41df0d07)
+++ uspace/lib/clui/tinput.h	(revision 9f1362d4e7eaaca0f48042dc579d07341d14e38a)
@@ -29,5 +29,5 @@
 /** @addtogroup libclui
  * @{
- */ 
+ */
 /**
  * @file
@@ -37,6 +37,8 @@
 #define LIBCLUI_TINPUT_H_
 
-#define HISTORY_LEN 10
-#define INPUT_MAX_SIZE 1024
+#include <ipc/ipc.h>
+
+#define HISTORY_LEN     10
+#define INPUT_MAX_SIZE  1024
 
 /** Text input field (command line).
@@ -47,23 +49,34 @@
 	/** Buffer holding text currently being edited */
 	wchar_t buffer[INPUT_MAX_SIZE + 1];
+	
 	/** Screen coordinates of the top-left corner of the text field */
-	int col0, row0;
+	ipcarg_t col0;
+	ipcarg_t row0;
+	
 	/** Screen dimensions */
-	int con_cols, con_rows;
+	ipcarg_t con_cols;
+	ipcarg_t con_rows;
+	
 	/** Number of characters in @c buffer */
-	int nc;
+	size_t nc;
+	
 	/** Caret position within buffer */
-	int pos;
+	size_t pos;
+	
 	/** Selection mark position within buffer */
-	int sel_start;
-
+	size_t sel_start;
+	
 	/** History (dynamically allocated strings) */
-	char *history[1 + HISTORY_LEN];
+	char *history[HISTORY_LEN + 1];
+	
 	/** Number of entries in @c history, not counting [0] */
-	int hnum;
+	size_t hnum;
+	
 	/** Current position in history */
-	int hpos;
+	size_t hpos;
+	
 	/** @c true if finished with this line (return to caller) */
 	bool done;
+	
 	/** @c true if user requested to abort interactive loop */
 	bool exit_clui;
@@ -71,6 +84,6 @@
 
 extern tinput_t *tinput_new(void);
-extern void tinput_destroy(tinput_t *ti);
-extern int tinput_read(tinput_t *ti, char **str);
+extern void tinput_destroy(tinput_t *);
+extern int tinput_read(tinput_t *, char **);
 
 #endif
@@ -78,3 +91,2 @@
 /** @}
  */
-
