Index: uspace/lib/gui/terminal.c
===================================================================
--- uspace/lib/gui/terminal.c	(revision 1d6dd2a62370f8442aef510558ad86b6439e6653)
+++ uspace/lib/gui/terminal.c	(revision f1380b76772fb5d1aa03637b5e57bd9b929fea61)
@@ -118,5 +118,5 @@
 	[COLOR_YELLOW]      = PIXEL(255, 240, 240, 0),
 	[COLOR_WHITE]       = PIXEL(255, 240, 240, 240),
-	
+
 	[COLOR_BLACK + 8]   = PIXEL(255, 0, 0, 0),
 	[COLOR_BLUE + 8]    = PIXEL(255, 0, 0, 255),
@@ -170,23 +170,23 @@
 	charfield_t *field =
 	    chargrid_charfield_at(term->backbuf, col, row);
-	
+
 	bool inverted = chargrid_cursor_at(term->backbuf, col, row);
-	
+
 	sysarg_t bx = sx + (col * FONT_WIDTH);
 	sysarg_t by = sy + (row * FONT_SCANLINES);
-	
+
 	pixel_t bgcolor = 0;
 	pixel_t fgcolor = 0;
-	
+
 	if (inverted)
 		attrs_rgb(field->attrs, &fgcolor, &bgcolor);
 	else
 		attrs_rgb(field->attrs, &bgcolor, &fgcolor);
-	
+
 	// FIXME: Glyph type should be actually uint32_t
 	//        for full UTF-32 coverage.
-	
+
 	uint16_t glyph = fb_font_glyph(field->ch, NULL);
-	
+
 	for (unsigned int y = 0; y < FONT_SCANLINES; y++) {
 		pixel_t *dst = pixelmap_pixel_at(
@@ -207,10 +207,10 @@
 {
 	sysarg_t top_row = chargrid_get_top_row(term->frontbuf);
-	
+
 	if (term->top_row == top_row)
 		return false;
-	
+
 	term->top_row = top_row;
-	
+
 	for (sysarg_t row = 0; row < term->rows; row++) {
 		for (sysarg_t col = 0; col < term->cols; col++) {
@@ -220,22 +220,22 @@
 			    chargrid_charfield_at(term->backbuf, col, row);
 			bool update = false;
-			
+
 			if (front_field->ch != back_field->ch) {
 				back_field->ch = front_field->ch;
 				update = true;
 			}
-			
+
 			if (!attrs_same(front_field->attrs, back_field->attrs)) {
 				back_field->attrs = front_field->attrs;
 				update = true;
 			}
-			
+
 			front_field->flags &= ~CHAR_FLAG_DIRTY;
-			
+
 			if (update)
 				term_update_char(term, surface, sx, sy, col, row);
 		}
 	}
-	
+
 	return true;
 }
@@ -245,13 +245,13 @@
 {
 	bool damage = false;
-	
+
 	sysarg_t front_col;
 	sysarg_t front_row;
 	chargrid_get_cursor(term->frontbuf, &front_col, &front_row);
-	
+
 	sysarg_t back_col;
 	sysarg_t back_row;
 	chargrid_get_cursor(term->backbuf, &back_col, &back_row);
-	
+
 	bool front_visibility =
 	    chargrid_get_cursor_visibility(term->frontbuf) &&
@@ -259,5 +259,5 @@
 	bool back_visibility =
 	    chargrid_get_cursor_visibility(term->backbuf);
-	
+
 	if (front_visibility != back_visibility) {
 		chargrid_set_cursor_visibility(term->backbuf,
@@ -266,5 +266,5 @@
 		damage = true;
 	}
-	
+
 	if ((front_col != back_col) || (front_row != back_row)) {
 		chargrid_set_cursor(term->backbuf, front_col, front_row);
@@ -273,5 +273,5 @@
 		damage = true;
 	}
-	
+
 	return damage;
 }
@@ -280,5 +280,5 @@
 {
 	fibril_mutex_lock(&term->mtx);
-	
+
 	surface_t *surface = window_claim(term->widget.window);
 	if (!surface) {
@@ -287,9 +287,9 @@
 		return;
 	}
-	
+
 	bool damage = false;
 	sysarg_t sx = term->widget.hpos;
 	sysarg_t sy = term->widget.vpos;
-	
+
 	if (term_update_scroll(term, surface, sx, sy)) {
 		damage = true;
@@ -302,5 +302,5 @@
 				    chargrid_charfield_at(term->backbuf, x, y);
 				bool update = false;
-				
+
 				if ((front_field->flags & CHAR_FLAG_DIRTY) ==
 				    CHAR_FLAG_DIRTY) {
@@ -309,5 +309,5 @@
 						update = true;
 					}
-					
+
 					if (!attrs_same(front_field->attrs,
 					    back_field->attrs)) {
@@ -315,8 +315,8 @@
 						update = true;
 					}
-					
+
 					front_field->flags &= ~CHAR_FLAG_DIRTY;
 				}
-				
+
 				if (update) {
 					term_update_char(term, surface, sx, sy, x, y);
@@ -326,13 +326,13 @@
 		}
 	}
-	
+
 	if (term_update_cursor(term, surface, sx, sy))
 		damage = true;
-	
+
 	window_yield(term->widget.window);
-	
+
 	if (damage)
 		window_damage(term->widget.window);
-	
+
 	fibril_mutex_unlock(&term->mtx);
 }
@@ -341,5 +341,5 @@
 {
 	fibril_mutex_lock(&term->mtx);
-	
+
 	surface_t *surface = window_claim(term->widget.window);
 	if (!surface) {
@@ -348,8 +348,8 @@
 		return;
 	}
-	
+
 	sysarg_t sx = term->widget.hpos;
 	sysarg_t sy = term->widget.vpos;
-	
+
 	if (!term_update_scroll(term, surface, sx, sy)) {
 		for (sysarg_t y = 0; y < term->rows; y++) {
@@ -359,19 +359,19 @@
 				charfield_t *back_field =
 				    chargrid_charfield_at(term->backbuf, x, y);
-				
+
 				back_field->ch = front_field->ch;
 				back_field->attrs = front_field->attrs;
 				front_field->flags &= ~CHAR_FLAG_DIRTY;
-				
+
 				term_update_char(term, surface, sx, sy, x, y);
 			}
 		}
 	}
-	
+
 	term_update_cursor(term, surface, sx, sy);
-	
+
 	window_yield(term->widget.window);
 	window_damage(term->widget.window);
-	
+
 	fibril_mutex_unlock(&term->mtx);
 }
@@ -392,5 +392,5 @@
 	uint8_t *bbuf = buf;
 	size_t pos = 0;
-	
+
 	/*
 	 * Read input from keyboard and copy it to the buffer.
@@ -403,17 +403,17 @@
 			bbuf[pos] = term->char_remains[0];
 			pos++;
-			
+
 			/* Unshift the array. */
 			for (size_t i = 1; i < term->char_remains_len; i++)
 				term->char_remains[i - 1] = term->char_remains[i];
-			
+
 			term->char_remains_len--;
 		}
-		
+
 		/* Still not enough? Then get another key from the queue. */
 		if (pos < size) {
 			link_t *link = prodcons_consume(&term->input_pc);
 			cons_event_t *event = list_get_instance(link, cons_event_t, link);
-			
+
 			/* Accept key presses of printable chars only. */
 			if (event->type == CEV_KEY && event->ev.key.type == KEY_PRESS &&
@@ -423,13 +423,13 @@
 					0
 				};
-				
+
 				wstr_to_str(term->char_remains, UTF8_CHAR_BUFFER_SIZE, tmp);
 				term->char_remains_len = str_size(term->char_remains);
 			}
-			
+
 			free(event);
 		}
 	}
-	
+
 	*nread = size;
 	return EOK;
@@ -439,7 +439,7 @@
 {
 	sysarg_t updated = 0;
-	
-	fibril_mutex_lock(&term->mtx);
-	
+
+	fibril_mutex_lock(&term->mtx);
+
 	switch (ch) {
 	case '\n':
@@ -457,7 +457,7 @@
 		updated = chargrid_putchar(term->frontbuf, ch, true);
 	}
-	
-	fibril_mutex_unlock(&term->mtx);
-	
+
+	fibril_mutex_unlock(&term->mtx);
+
 	if (updated > 1)
 		term_update(term);
@@ -467,9 +467,9 @@
 {
 	terminal_t *term = srv_to_terminal(srv);
-	
+
 	size_t off = 0;
 	while (off < size)
 		term_write_char(term, str_decode(data, &off, size));
-	
+
 	*nwritten = size;
 	return EOK;
@@ -479,5 +479,5 @@
 {
 	terminal_t *term = srv_to_terminal(srv);
-	
+
 	term_update(term);
 }
@@ -486,9 +486,9 @@
 {
 	terminal_t *term = srv_to_terminal(srv);
-	
+
 	fibril_mutex_lock(&term->mtx);
 	chargrid_clear(term->frontbuf);
 	fibril_mutex_unlock(&term->mtx);
-	
+
 	term_update(term);
 }
@@ -497,9 +497,9 @@
 {
 	terminal_t *term = srv_to_terminal(srv);
-	
+
 	fibril_mutex_lock(&term->mtx);
 	chargrid_set_cursor(term->frontbuf, col, row);
 	fibril_mutex_unlock(&term->mtx);
-	
+
 	term_update(term);
 }
@@ -508,9 +508,9 @@
 {
 	terminal_t *term = srv_to_terminal(srv);
-	
+
 	fibril_mutex_lock(&term->mtx);
 	chargrid_get_cursor(term->frontbuf, col, row);
 	fibril_mutex_unlock(&term->mtx);
-	
+
 	return EOK;
 }
@@ -519,10 +519,10 @@
 {
 	terminal_t *term = srv_to_terminal(srv);
-	
+
 	fibril_mutex_lock(&term->mtx);
 	*cols = term->cols;
 	*rows = term->rows;
 	fibril_mutex_unlock(&term->mtx);
-	
+
 	return EOK;
 }
@@ -532,5 +532,5 @@
 	(void) srv;
 	*caps = TERM_CAPS;
-	
+
 	return EOK;
 }
@@ -539,5 +539,5 @@
 {
 	terminal_t *term = srv_to_terminal(srv);
-	
+
 	fibril_mutex_lock(&term->mtx);
 	chargrid_set_style(term->frontbuf, style);
@@ -549,5 +549,5 @@
 {
 	terminal_t *term = srv_to_terminal(srv);
-	
+
 	fibril_mutex_lock(&term->mtx);
 	chargrid_set_color(term->frontbuf, bgcolor, fgcolor, attr);
@@ -559,5 +559,5 @@
 {
 	terminal_t *term = srv_to_terminal(srv);
-	
+
 	fibril_mutex_lock(&term->mtx);
 	chargrid_set_rgb_color(term->frontbuf, bgcolor, fgcolor);
@@ -568,9 +568,9 @@
 {
 	terminal_t *term = srv_to_terminal(srv);
-	
+
 	fibril_mutex_lock(&term->mtx);
 	chargrid_set_cursor_visibility(term->frontbuf, visible);
 	fibril_mutex_unlock(&term->mtx);
-	
+
 	term_update(term);
 }
@@ -581,5 +581,5 @@
 	link_t *link = prodcons_consume(&term->input_pc);
 	cons_event_t *ev = list_get_instance(link, cons_event_t, link);
-	
+
 	*event = *ev;
 	free(ev);
@@ -591,8 +591,8 @@
 	list_remove(&term->link);
 	widget_deinit(&term->widget);
-	
+
 	if (term->frontbuf)
 		chargrid_destroy(term->frontbuf);
-	
+
 	if (term->backbuf)
 		chargrid_destroy(term->backbuf);
@@ -602,5 +602,5 @@
 {
 	terminal_t *term = (terminal_t *) widget;
-	
+
 	deinit_terminal(term);
 	free(term);
@@ -616,9 +616,9 @@
 {
 	terminal_t *term = (terminal_t *) widget;
-	
+
 	widget_modify(widget, hpos, vpos, width, height);
 	widget->width_ideal = width;
 	widget->height_ideal = height;
-	
+
 	term_damage(term);
 }
@@ -627,5 +627,5 @@
 {
 	terminal_t *term = (terminal_t *) widget;
-	
+
 	term_damage(term);
 }
@@ -638,8 +638,8 @@
 	if (event == NULL)
 		return;
-	
+
 	*event = *ev;
 	link_initialize(&event->link);
-	
+
 	prodcons_produce(&term->input_pc, &event->link);
 }
@@ -651,8 +651,8 @@
 	terminal_t *term = (terminal_t *) widget;
 	cons_event_t event;
-	
+
 	event.type = CEV_KEY;
 	event.ev.key = kbd_event;
-	
+
 	terminal_queue_cons_event(term, &event);
 }
@@ -680,5 +680,5 @@
 {
 	terminal_t *term = NULL;
-	
+
 	list_foreach(terms, link, terminal_t, cur) {
 		if (cur->dsid == (service_id_t) IPC_GET_ARG2(*icall)) {
@@ -687,13 +687,13 @@
 		}
 	}
-	
+
 	if (term == NULL) {
 		async_answer_0(iid, ENOENT);
 		return;
 	}
-	
+
 	if (atomic_postinc(&term->refcnt) == 0)
 		chargrid_set_cursor_visibility(term->frontbuf, true);
-	
+
 	con_conn(iid, icall, &term->srvs);
 }
@@ -703,17 +703,17 @@
 {
 	widget_init(&term->widget, parent, data);
-	
+
 	link_initialize(&term->link);
 	fibril_mutex_initialize(&term->mtx);
 	atomic_set(&term->refcnt, 0);
-	
+
 	prodcons_initialize(&term->input_pc);
 	term->char_remains_len = 0;
-	
+
 	term->widget.width = width;
 	term->widget.height = height;
 	term->widget.width_ideal = width;
 	term->widget.height_ideal = height;
-	
+
 	term->widget.destroy = terminal_destroy;
 	term->widget.reconfigure = terminal_reconfigure;
@@ -722,11 +722,11 @@
 	term->widget.handle_keyboard_event = terminal_handle_keyboard_event;
 	term->widget.handle_position_event = terminal_handle_position_event;
-	
+
 	term->cols = width / FONT_WIDTH;
 	term->rows = height / FONT_SCANLINES;
-	
+
 	term->frontbuf = NULL;
 	term->backbuf = NULL;
-	
+
 	term->frontbuf = chargrid_create(term->cols, term->rows,
 	    CHARGRID_FLAG_NONE);
@@ -735,5 +735,5 @@
 		return false;
 	}
-	
+
 	term->backbuf = chargrid_create(term->cols, term->rows,
 	    CHARGRID_FLAG_NONE);
@@ -742,14 +742,14 @@
 		return false;
 	}
-	
+
 	chargrid_clear(term->frontbuf);
 	chargrid_clear(term->backbuf);
 	term->top_row = 0;
-	
+
 	async_set_fallback_port_handler(term_connection, NULL);
 	con_srvs_init(&term->srvs);
 	term->srvs.ops = &con_ops;
 	term->srvs.sarg = term;
-	
+
 	errno_t rc = loc_server_register(NAME);
 	if (rc != EOK) {
@@ -757,9 +757,9 @@
 		return false;
 	}
-	
+
 	char vc[LOC_NAME_MAXLEN + 1];
 	snprintf(vc, LOC_NAME_MAXLEN, "%s/%" PRIu64, NAMESPACE,
 	    task_get_id());
-	
+
 	rc = loc_service_register(vc, &term->dsid);
 	if (rc != EOK) {
@@ -767,8 +767,8 @@
 		return false;
 	}
-	
+
 	list_append(&term->link, &terms);
 	getterm(vc, "/app/bdsh");
-	
+
 	return true;
 }
@@ -780,5 +780,5 @@
 	if (!term)
 		return NULL;
-	
+
 	bool ret = init_terminal(term, parent, data, width, height);
 	if (!ret) {
@@ -786,5 +786,5 @@
 		return NULL;
 	}
-	
+
 	return term;
 }
