Index: uspace/app/terminal/terminal.c
===================================================================
--- uspace/app/terminal/terminal.c	(revision 211fd689737d35925504cec0c8fb09d1af3bd74d)
+++ uspace/app/terminal/terminal.c	(revision 77ffa018e96bf200a6d7a188492a0574ecda4c99)
@@ -1,4 +1,4 @@
 /*
- * Copyright (c) 2024 Jiri Svoboda
+ * Copyright (c) 2021 Jiri Svoboda
  * Copyright (c) 2012 Petr Koupy
  * All rights reserved.
@@ -41,5 +41,4 @@
 #include <fbfont/font-8x16.h>
 #include <io/chargrid.h>
-#include <fibril.h>
 #include <gfx/bitmap.h>
 #include <gfx/context.h>
@@ -88,5 +87,4 @@
 static void term_set_rgb_color(con_srv_t *, pixel_t, pixel_t);
 static void term_set_cursor_visibility(con_srv_t *, bool);
-static errno_t term_set_caption(con_srv_t *, const char *);
 static errno_t term_get_event(con_srv_t *, cons_event_t *);
 static errno_t term_map(con_srv_t *, sysarg_t, sysarg_t, charfield_t **);
@@ -110,5 +108,4 @@
 	.set_rgb_color = term_set_rgb_color,
 	.set_cursor_visibility = term_set_cursor_visibility,
-	.set_caption = term_set_caption,
 	.get_event = term_get_event,
 	.map = term_map,
@@ -118,8 +115,8 @@
 
 static void terminal_close_event(ui_window_t *, void *);
-static void terminal_focus_event(ui_window_t *, void *, unsigned);
+static void terminal_focus_event(ui_window_t *, void *);
 static void terminal_kbd_event(ui_window_t *, void *, kbd_event_t *);
 static void terminal_pos_event(ui_window_t *, void *, pos_event_t *);
-static void terminal_unfocus_event(ui_window_t *, void *, unsigned);
+static void terminal_unfocus_event(ui_window_t *, void *);
 
 static ui_window_cb_t terminal_window_cb = {
@@ -131,6 +128,4 @@
 };
 
-static errno_t terminal_wait_fibril(void *);
-
 static terminal_t *srv_to_terminal(con_srv_t *srv)
 {
@@ -138,7 +133,7 @@
 }
 
-static errno_t getterm(task_wait_t *wait, const char *svc, const char *app)
-{
-	return task_spawnl(NULL, wait, APP_GETTERM, APP_GETTERM, svc,
+static void getterm(const char *svc, const char *app)
+{
+	task_spawnl(NULL, NULL, APP_GETTERM, APP_GETTERM, svc,
 	    LOCFS_MOUNT_POINT, "--msg", "--wait", "--", app, NULL);
 }
@@ -146,19 +141,19 @@
 static pixel_t color_table[16] = {
 	[COLOR_BLACK]       = PIXEL(255, 0, 0, 0),
-	[COLOR_BLUE]        = PIXEL(255, 0, 0, 170),
-	[COLOR_GREEN]       = PIXEL(255, 0, 170, 0),
-	[COLOR_CYAN]        = PIXEL(255, 0, 170, 170),
-	[COLOR_RED]         = PIXEL(255, 170, 0, 0),
-	[COLOR_MAGENTA]     = PIXEL(255, 170, 0, 170),
-	[COLOR_YELLOW]      = PIXEL(255, 170, 85, 0),
-	[COLOR_WHITE]       = PIXEL(255, 170, 170, 170),
-
-	[COLOR_BLACK + 8]   = PIXEL(255, 85, 85, 85),
-	[COLOR_BLUE + 8]    = PIXEL(255, 85, 85, 255),
-	[COLOR_GREEN + 8]   = PIXEL(255, 85, 255, 85),
-	[COLOR_CYAN + 8]    = PIXEL(255, 85, 255, 255),
-	[COLOR_RED + 8]     = PIXEL(255, 255, 85, 85),
-	[COLOR_MAGENTA + 8] = PIXEL(255, 255, 85, 255),
-	[COLOR_YELLOW + 8]  = PIXEL(255, 255, 255, 85),
+	[COLOR_BLUE]        = PIXEL(255, 0, 0, 240),
+	[COLOR_GREEN]       = PIXEL(255, 0, 240, 0),
+	[COLOR_CYAN]        = PIXEL(255, 0, 240, 240),
+	[COLOR_RED]         = PIXEL(255, 240, 0, 0),
+	[COLOR_MAGENTA]     = PIXEL(255, 240, 0, 240),
+	[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),
+	[COLOR_GREEN + 8]   = PIXEL(255, 0, 255, 0),
+	[COLOR_CYAN + 8]    = PIXEL(255, 0, 255, 255),
+	[COLOR_RED + 8]     = PIXEL(255, 255, 0, 0),
+	[COLOR_MAGENTA + 8] = PIXEL(255, 255, 0, 255),
+	[COLOR_YELLOW + 8]  = PIXEL(255, 255, 255, 0),
 	[COLOR_WHITE + 8]   = PIXEL(255, 255, 255, 255),
 };
@@ -170,23 +165,24 @@
 		switch (attrs.val.style) {
 		case STYLE_NORMAL:
-			*bgcolor = color_table[COLOR_WHITE + 8];
+			*bgcolor = color_table[COLOR_WHITE];
 			*fgcolor = color_table[COLOR_BLACK];
 			break;
 		case STYLE_EMPHASIS:
-			*bgcolor = color_table[COLOR_WHITE + 8];
-			*fgcolor = color_table[COLOR_RED + 8];
+			*bgcolor = color_table[COLOR_WHITE];
+			*fgcolor = color_table[COLOR_RED];
 			break;
 		case STYLE_INVERTED:
 			*bgcolor = color_table[COLOR_BLACK];
-			*fgcolor = color_table[COLOR_WHITE + 8];
+			*fgcolor = color_table[COLOR_WHITE];
 			break;
 		case STYLE_SELECTED:
-			*bgcolor = color_table[COLOR_RED + 8];
-			*fgcolor = color_table[COLOR_WHITE + 8];
+			*bgcolor = color_table[COLOR_RED];
+			*fgcolor = color_table[COLOR_WHITE];
 			break;
 		}
 		break;
 	case CHAR_ATTR_INDEX:
-		*bgcolor = color_table[(attrs.val.index.bgcolor & 7)];
+		*bgcolor = color_table[(attrs.val.index.bgcolor & 7) |
+		    ((attrs.val.index.attr & CATTR_BRIGHT) ? 8 : 0)];
 		*fgcolor = color_table[(attrs.val.index.fgcolor & 7) |
 		    ((attrs.val.index.attr & CATTR_BRIGHT) ? 8 : 0)];
@@ -647,24 +643,4 @@
 }
 
-static errno_t term_set_caption(con_srv_t *srv, const char *caption)
-{
-	terminal_t *term = srv_to_terminal(srv);
-	const char *cap;
-
-	fibril_mutex_lock(&term->mtx);
-
-	if (str_size(caption) > 0)
-		cap = caption;
-	else
-		cap = "Terminal";
-
-	ui_window_set_caption(term->window, cap);
-	fibril_mutex_unlock(&term->mtx);
-
-	term_update(term);
-	gfx_update(term->gc);
-	return EOK;
-}
-
 static errno_t term_get_event(con_srv_t *srv, cons_event_t *event)
 {
@@ -829,14 +805,15 @@
 	terminal_t *term = (terminal_t *) arg;
 
-	ui_quit(term->ui);
+	(void) term;
+
+	// XXX This is not really a clean way of terminating
+	exit(0);
 }
 
 /** Handle window focus event. */
-static void terminal_focus_event(ui_window_t *window, void *arg,
-    unsigned nfocus)
+static void terminal_focus_event(ui_window_t *window, void *arg)
 {
 	terminal_t *term = (terminal_t *) arg;
 
-	(void)nfocus;
 	term->is_focused = true;
 	term_update(term);
@@ -866,6 +843,5 @@
 	sysarg_t sy = -term->off.y;
 
-	if (event->type == POS_PRESS || event->type == POS_RELEASE ||
-	    event->type == POS_DCLICK) {
+	if (event->type == POS_PRESS || event->type == POS_RELEASE) {
 		cevent.type = CEV_POS;
 		cevent.ev.pos.type = event->type;
@@ -880,14 +856,11 @@
 
 /** Handle window unfocus event. */
-static void terminal_unfocus_event(ui_window_t *window, void *arg,
-    unsigned nfocus)
+static void terminal_unfocus_event(ui_window_t *window, void *arg)
 {
 	terminal_t *term = (terminal_t *) arg;
 
-	if (nfocus == 0) {
-		term->is_focused = false;
-		term_update(term);
-		gfx_update(term->gc);
-	}
+	term->is_focused = false;
+	term_update(term);
+	gfx_update(term->gc);
 }
 
@@ -915,6 +888,5 @@
 
 errno_t terminal_create(const char *display_spec, sysarg_t width,
-    sysarg_t height, terminal_flags_t flags, const char *command,
-    terminal_t **rterm)
+    sysarg_t height, terminal_flags_t flags, terminal_t **rterm)
 {
 	terminal_t *term;
@@ -974,4 +946,14 @@
 		wparams.placement = ui_wnd_place_top_left;
 
+	/*
+	 * Compute window rectangle such that application area corresponds
+	 * to rect
+	 */
+	ui_wdecor_rect_from_app(wparams.style, &rect, &wrect);
+	off = wrect.p0;
+	gfx_rect_rtranslate(&off, &wrect, &wparams.rect);
+
+	term->off = off;
+
 	rc = ui_create(display_spec, &term->ui);
 	if (rc != EOK) {
@@ -979,14 +961,4 @@
 		goto error;
 	}
-
-	/*
-	 * Compute window rectangle such that application area corresponds
-	 * to rect
-	 */
-	ui_wdecor_rect_from_app(term->ui, wparams.style, &rect, &wrect);
-	off = wrect.p0;
-	gfx_rect_rtranslate(&off, &wrect, &wparams.rect);
-
-	term->off = off;
 
 	rc = ui_window_create(term->ui, &wparams, &term->window);
@@ -1022,5 +994,5 @@
 	term->srvs.sarg = term;
 
-	rc = loc_server_register(NAME, &term->srv);
+	rc = loc_server_register(NAME);
 	if (rc != EOK) {
 		printf("Error registering server.\n");
@@ -1033,5 +1005,5 @@
 	    task_get_id());
 
-	rc = loc_service_register(term->srv, vc, &term->dsid);
+	rc = loc_service_register(vc, &term->dsid);
 	if (rc != EOK) {
 		printf("Error registering service.\n");
@@ -1041,13 +1013,5 @@
 
 	list_append(&term->link, &terms);
-	rc = getterm(&term->wait, vc, command);
-	if (rc != EOK)
-		goto error;
-
-	term->wfid = fibril_create(terminal_wait_fibril, term);
-	if (term->wfid == 0)
-		goto error;
-
-	fibril_add_ready(term->wfid);
+	getterm(vc, "/app/bdsh");
 
 	term->is_focused = true;
@@ -1063,8 +1027,4 @@
 	return EOK;
 error:
-	if (term->dsid != 0)
-		loc_service_unregister(term->srv, term->dsid);
-	if (term->srv != NULL)
-		loc_server_unregister(term->srv);
 	if (term->window != NULL)
 		ui_window_destroy(term->window);
@@ -1079,19 +1039,4 @@
 }
 
-static errno_t terminal_wait_fibril(void *arg)
-{
-	terminal_t *term = (terminal_t *)arg;
-	task_exit_t texit;
-	int retval;
-
-	/*
-	 * XXX There is no way to break the sleep if the task does not
-	 * exit.
-	 */
-	(void) task_wait(&term->wait, &texit, &retval);
-	ui_quit(term->ui);
-	return EOK;
-}
-
 /** @}
  */
