Index: pace/lib/c/generic/io/chargrid.c
===================================================================
--- uspace/lib/c/generic/io/chargrid.c	(revision 6cef8d6a633ccd8d6545bfa8b87ae7113b8d30ed)
+++ 	(revision )
@@ -1,362 +1,0 @@
-/*
- * Copyright (c) 2006 Josef Cejka
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libc
- * @{
- */
-/** @file
- */
-
-#include <io/style.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <stdbool.h>
-#include <stddef.h>
-#include <as.h>
-#include <io/chargrid.h>
-
-/** Create a chargrid.
- *
- * @param[in] cols  Number of columns.
- * @param[in] rows  Number of rows.
- * @param[in] flags Chargrid flags.
- *
- * @return New chargrid.
- * @return NULL on failure.
- *
- */
-chargrid_t *chargrid_create(sysarg_t cols, sysarg_t rows,
-    chargrid_flag_t flags)
-{
-	size_t size =
-	    sizeof(chargrid_t) + cols * rows * sizeof(charfield_t);
-	chargrid_t *scrbuf;
-
-	if ((flags & CHARGRID_FLAG_SHARED) == CHARGRID_FLAG_SHARED) {
-		scrbuf = (chargrid_t *) as_area_create(AS_AREA_ANY, size,
-		    AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE,
-		    AS_AREA_UNPAGED);
-		if (scrbuf == AS_MAP_FAILED)
-			return NULL;
-	} else {
-		scrbuf = (chargrid_t *) malloc(size);
-		if (scrbuf == NULL)
-			return NULL;
-	}
-
-	scrbuf->size = size;
-	scrbuf->flags = flags;
-	scrbuf->cols = cols;
-	scrbuf->rows = rows;
-	scrbuf->cursor_visible = false;
-
-	scrbuf->attrs.type = CHAR_ATTR_STYLE;
-	scrbuf->attrs.val.style = STYLE_NORMAL;
-
-	scrbuf->top_row = 0;
-	chargrid_clear(scrbuf);
-
-	return scrbuf;
-}
-
-void chargrid_destroy(chargrid_t *srcbuf)
-{
-	// TODO
-}
-
-bool chargrid_cursor_at(chargrid_t *scrbuf, sysarg_t col, sysarg_t row)
-{
-	return ((scrbuf->cursor_visible) && (scrbuf->col == col) &&
-	    (scrbuf->row == row));
-}
-
-sysarg_t chargrid_get_top_row(chargrid_t *scrbuf)
-{
-	return scrbuf->top_row;
-}
-
-static sysarg_t chargrid_update_rows(chargrid_t *scrbuf)
-{
-	if (scrbuf->row == scrbuf->rows) {
-		scrbuf->row = scrbuf->rows - 1;
-		scrbuf->top_row = (scrbuf->top_row + 1) % scrbuf->rows;
-		chargrid_clear_row(scrbuf, scrbuf->row);
-
-		return scrbuf->rows;
-	}
-
-	return 2;
-}
-
-static sysarg_t chargrid_update_cols(chargrid_t *scrbuf)
-{
-	/* Column overflow */
-	if (scrbuf->col == scrbuf->cols) {
-		scrbuf->col = 0;
-		scrbuf->row++;
-		return chargrid_update_rows(scrbuf);
-	}
-
-	return 1;
-}
-
-/** Store one character to chargrid.
- *
- * Its position is determined by scrbuf->col
- * and scrbuf->row.
- *
- * @param scrbuf Chargrid.
- * @param ch     Character to store.
- * @param update Update coordinates.
- *
- * @return Number of rows which have been affected. In usual
- *         situations this is 1. If the current position was
- *         updated to a new row, this value is 2.
- *
- */
-sysarg_t chargrid_putuchar(chargrid_t *scrbuf, char32_t ch, bool update)
-{
-	assert(scrbuf->col < scrbuf->cols);
-	assert(scrbuf->row < scrbuf->rows);
-
-	charfield_t *field =
-	    chargrid_charfield_at(scrbuf, scrbuf->col, scrbuf->row);
-
-	field->ch = ch;
-	field->attrs = scrbuf->attrs;
-	field->flags |= CHAR_FLAG_DIRTY;
-
-	if (update) {
-		scrbuf->col++;
-		return chargrid_update_cols(scrbuf);
-	}
-
-	return 1;
-}
-
-/** Jump to a new row in chargrid.
- *
- * @param scrbuf Chargrid.
- *
- * @return Number of rows which have been affected. In usual
- *         situations this is 2 (the original row and the new
- *         row).
- *
- */
-sysarg_t chargrid_newline(chargrid_t *scrbuf)
-{
-	assert(scrbuf->col < scrbuf->cols);
-	assert(scrbuf->row < scrbuf->rows);
-
-	scrbuf->col = 0;
-	scrbuf->row++;
-
-	return chargrid_update_rows(scrbuf);
-}
-
-/** Jump to a new row in chargrid.
- *
- * @param scrbuf   Chargrid.
- * @param tab_size Tab size.
- *
- * @return Number of rows which have been affected. In usual
- *         situations this is 1. If the current position was
- *         updated to a new row, this value is 2.
- *
- */
-sysarg_t chargrid_tabstop(chargrid_t *scrbuf, sysarg_t tab_size)
-{
-	assert(scrbuf->col < scrbuf->cols);
-	assert(scrbuf->row < scrbuf->rows);
-
-	sysarg_t spaces = tab_size - scrbuf->cols % tab_size;
-	sysarg_t flush = 1;
-
-	for (sysarg_t i = 0; i < spaces; i++)
-		flush += chargrid_putuchar(scrbuf, ' ', true) - 1;
-
-	return flush;
-}
-
-/** Jump to the previous character in chargrid.
- *
- * Currently no scrollback is supported.
- *
- * @param scrbuf Chargrid.
- *
- * @return Number of rows which have been affected. In usual
- *         situations this is 1. If the current position was
- *         updated to the previous row, this value is 2.
- * @return 0 if no backspace is possible.
- *
- */
-sysarg_t chargrid_backspace(chargrid_t *scrbuf)
-{
-	assert(scrbuf->col < scrbuf->cols);
-	assert(scrbuf->row < scrbuf->rows);
-
-	if ((scrbuf->col == 0) && (scrbuf->row == 0))
-		return 0;
-
-	if (scrbuf->col == 0) {
-		scrbuf->col = scrbuf->cols - 1;
-		scrbuf->row--;
-
-		chargrid_putuchar(scrbuf, ' ', false);
-		return 2;
-	}
-
-	scrbuf->col--;
-	chargrid_putuchar(scrbuf, ' ', false);
-	return 1;
-}
-
-/** Clear the chargrid.
- *
- * @param scrbuf Chargrid.
- *
- */
-void chargrid_clear(chargrid_t *scrbuf)
-{
-	for (size_t pos = 0; pos < (scrbuf->cols * scrbuf->rows); pos++) {
-		scrbuf->data[pos].ch = 0;
-		scrbuf->data[pos].attrs = scrbuf->attrs;
-		scrbuf->data[pos].flags = CHAR_FLAG_DIRTY;
-	}
-
-	scrbuf->col = 0;
-	scrbuf->row = 0;
-}
-
-/** Update current chargrid coordinates
- *
- * @param scrbuf Chargrid.
- * @param col    New column.
- * @param row    New row.
- *
- */
-void chargrid_set_cursor(chargrid_t *scrbuf, sysarg_t col, sysarg_t row)
-{
-	if (col >= scrbuf->cols || row >= scrbuf->rows)
-		return;
-
-	scrbuf->col = col;
-	scrbuf->row = row;
-}
-
-void chargrid_set_cursor_visibility(chargrid_t *scrbuf, bool visible)
-{
-	scrbuf->cursor_visible = visible;
-}
-
-/** Get current chargrid coordinates
- *
- * @param scrbuf Chargrid.
- * @param col    Column.
- * @param row    Row.
- *
- */
-void chargrid_get_cursor(chargrid_t *scrbuf, sysarg_t *col,
-    sysarg_t *row)
-{
-	assert(col);
-	assert(row);
-
-	*col = scrbuf->col;
-	*row = scrbuf->row;
-}
-
-bool chargrid_get_cursor_visibility(chargrid_t *scrbuf)
-{
-	return scrbuf->cursor_visible;
-}
-
-/** Clear one buffer row.
- *
- * @param scrbuf Chargrid.
- * @param row    Row to clear.
- *
- */
-void chargrid_clear_row(chargrid_t *scrbuf, sysarg_t row)
-{
-	for (sysarg_t col = 0; col < scrbuf->cols; col++) {
-		charfield_t *field =
-		    chargrid_charfield_at(scrbuf, col, row);
-
-		field->ch = 0;
-		field->attrs = scrbuf->attrs;
-		field->flags |= CHAR_FLAG_DIRTY;
-	}
-}
-
-/** Set chargrid style.
- *
- * @param scrbuf Chargrid.
- * @param style  Style.
- *
- */
-void chargrid_set_style(chargrid_t *scrbuf, console_style_t style)
-{
-	scrbuf->attrs.type = CHAR_ATTR_STYLE;
-	scrbuf->attrs.val.style = style;
-}
-
-/** Set chargrid color.
- *
- * @param scrbuf  Chargrid.
- * @param bgcolor Background color.
- * @param fgcolor Foreground color.
- * @param attr    Color attribute.
- *
- */
-void chargrid_set_color(chargrid_t *scrbuf, console_color_t bgcolor,
-    console_color_t fgcolor, console_color_attr_t attr)
-{
-	scrbuf->attrs.type = CHAR_ATTR_INDEX;
-	scrbuf->attrs.val.index.bgcolor = bgcolor;
-	scrbuf->attrs.val.index.fgcolor = fgcolor;
-	scrbuf->attrs.val.index.attr = attr;
-}
-
-/** Set chargrid RGB color.
- *
- * @param scrbuf  Chargrid.
- * @param bgcolor Background color.
- * @param fgcolor Foreground color.
- *
- */
-void chargrid_set_rgb_color(chargrid_t *scrbuf, pixel_t bgcolor,
-    pixel_t fgcolor)
-{
-	scrbuf->attrs.type = CHAR_ATTR_RGB;
-	scrbuf->attrs.val.rgb.bgcolor = bgcolor;
-	scrbuf->attrs.val.rgb.fgcolor = fgcolor;
-}
-
-/** @}
- */
Index: pace/lib/c/include/io/charfield.h
===================================================================
--- uspace/lib/c/include/io/charfield.h	(revision 6cef8d6a633ccd8d6545bfa8b87ae7113b8d30ed)
+++ 	(revision )
@@ -1,107 +1,0 @@
-/*
- * Copyright (c) 2006 Josef Cejka
- * Copyright (c) 2011 Petr Koupy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libc
- * @{
- */
-/** @file
- */
-
-#ifndef _LIBC_IO_CHARFIELD_H_
-#define _LIBC_IO_CHARFIELD_H_
-
-#include <stdbool.h>
-#include <uchar.h>
-#include <io/color.h>
-#include <io/style.h>
-#include <io/pixel.h>
-
-typedef enum {
-	CHAR_FLAG_NONE = 0,
-	CHAR_FLAG_DIRTY = 1
-} char_flags_t;
-
-typedef enum {
-	CHAR_ATTR_STYLE,
-	CHAR_ATTR_INDEX,
-	CHAR_ATTR_RGB
-} char_attr_type_t;
-
-typedef struct {
-	console_color_t bgcolor;
-	console_color_t fgcolor;
-	console_color_attr_t attr;
-} char_attr_index_t;
-
-typedef struct {
-	pixel_t bgcolor;
-	pixel_t fgcolor;
-} char_attr_rgb_t;
-
-typedef union {
-	console_style_t style;
-	char_attr_index_t index;
-	char_attr_rgb_t rgb;
-} char_attr_val_t;
-
-typedef struct {
-	char_attr_type_t type;
-	char_attr_val_t val;
-} char_attrs_t;
-
-typedef struct {
-	char32_t ch;
-	char_attrs_t attrs;
-	char_flags_t flags;
-} charfield_t;
-
-static inline bool attrs_same(char_attrs_t a1, char_attrs_t a2)
-{
-	if (a1.type != a2.type)
-		return false;
-
-	switch (a1.type) {
-	case CHAR_ATTR_STYLE:
-		return (a1.val.style == a2.val.style);
-	case CHAR_ATTR_INDEX:
-		return (a1.val.index.bgcolor == a2.val.index.bgcolor) &&
-		    (a1.val.index.fgcolor == a2.val.index.fgcolor) &&
-		    (a1.val.index.attr == a2.val.index.attr);
-	case CHAR_ATTR_RGB:
-		return (a1.val.rgb.bgcolor == a2.val.rgb.bgcolor) &&
-		    (a1.val.rgb.fgcolor == a2.val.rgb.fgcolor);
-	}
-
-	return false;
-}
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/include/io/chargrid.h
===================================================================
--- uspace/lib/c/include/io/chargrid.h	(revision 6cef8d6a633ccd8d6545bfa8b87ae7113b8d30ed)
+++ 	(revision )
@@ -1,103 +1,0 @@
-/*
- * Copyright (c) 2011 Martin Decky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libc
- * @{
- */
-/**
- * @file
- */
-
-#ifndef _LIBC_IO_CHARGRID_H_
-#define _LIBC_IO_CHARGRID_H_
-
-#include <io/charfield.h>
-#include <types/common.h>
-#include <stddef.h>
-
-typedef enum {
-	CHARGRID_FLAG_NONE = 0,
-	CHARGRID_FLAG_SHARED = 1
-} chargrid_flag_t;
-
-typedef struct {
-	size_t size;            /**< Structure size */
-	chargrid_flag_t flags;  /**< Screenbuffer flags */
-
-	sysarg_t cols;          /**< Number of columns */
-	sysarg_t rows;          /**< Number of rows */
-
-	sysarg_t col;           /**< Current column */
-	sysarg_t row;           /**< Current row */
-	bool cursor_visible;    /**< Cursor visibility */
-
-	char_attrs_t attrs;     /**< Current attributes */
-
-	sysarg_t top_row;       /**< The first row in the cyclic buffer */
-	charfield_t data[];     /**< Screen contents (cyclic buffer) */
-} chargrid_t;
-
-static inline charfield_t *chargrid_charfield_at(chargrid_t *chargrid,
-    sysarg_t col, sysarg_t row)
-{
-	return chargrid->data +
-	    ((row + chargrid->top_row) % chargrid->rows) * chargrid->cols +
-	    col;
-}
-
-extern chargrid_t *chargrid_create(sysarg_t, sysarg_t,
-    chargrid_flag_t);
-extern void chargrid_destroy(chargrid_t *);
-
-extern bool chargrid_cursor_at(chargrid_t *, sysarg_t, sysarg_t);
-
-extern sysarg_t chargrid_get_top_row(chargrid_t *);
-
-extern sysarg_t chargrid_putuchar(chargrid_t *, char32_t, bool);
-extern sysarg_t chargrid_newline(chargrid_t *);
-extern sysarg_t chargrid_tabstop(chargrid_t *, sysarg_t);
-extern sysarg_t chargrid_backspace(chargrid_t *);
-
-extern void chargrid_clear(chargrid_t *);
-extern void chargrid_clear_row(chargrid_t *, sysarg_t);
-
-extern void chargrid_set_cursor(chargrid_t *, sysarg_t, sysarg_t);
-extern void chargrid_set_cursor_visibility(chargrid_t *, bool);
-extern bool chargrid_get_cursor_visibility(chargrid_t *);
-
-extern void chargrid_get_cursor(chargrid_t *, sysarg_t *, sysarg_t *);
-
-extern void chargrid_set_style(chargrid_t *, console_style_t);
-extern void chargrid_set_color(chargrid_t *, console_color_t,
-    console_color_t, console_color_attr_t);
-extern void chargrid_set_rgb_color(chargrid_t *, pixel_t, pixel_t);
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/include/io/color.h
===================================================================
--- uspace/lib/c/include/io/color.h	(revision 6cef8d6a633ccd8d6545bfa8b87ae7113b8d30ed)
+++ 	(revision )
@@ -1,58 +1,0 @@
-/*
- * Copyright (c) 2023 Jiri Svoboda
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libc
- * @{
- */
-/** @file
- */
-
-#ifndef _LIBC_IO_COLOR_H_
-#define _LIBC_IO_COLOR_H_
-
-typedef enum {
-	COLOR_BLACK   = 0,
-	COLOR_BLUE    = 1,
-	COLOR_GREEN   = 2,
-	COLOR_CYAN    = 3,
-	COLOR_RED     = 4,
-	COLOR_MAGENTA = 5,
-	COLOR_YELLOW  = 6,
-	COLOR_WHITE   = 7
-} console_color_t;
-
-typedef enum {
-	CATTR_NORMAL = 0,
-	CATTR_BRIGHT = 8,
-	CATTR_BLINK  = 16
-} console_color_attr_t;
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/include/io/concaps.h
===================================================================
--- uspace/lib/c/include/io/concaps.h	(revision 6cef8d6a633ccd8d6545bfa8b87ae7113b8d30ed)
+++ 	(revision )
@@ -1,48 +1,0 @@
-/*
- * Copyright (c) 2023 Jiri Svoboda
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libc
- * @{
- */
-/** @file
- */
-
-#ifndef _LIBC_IO_CONCAPS_H_
-#define _LIBC_IO_CONCAPS_H_
-
-typedef enum {
-	CONSOLE_CAP_NONE = 0,
-	CONSOLE_CAP_STYLE = 1,
-	CONSOLE_CAP_INDEXED = 2,
-	CONSOLE_CAP_RGB = 4
-} console_caps_t;
-
-#endif
-
-/** @}
- */
Index: uspace/lib/c/meson.build
===================================================================
--- uspace/lib/c/meson.build	(revision 6cef8d6a633ccd8d6545bfa8b87ae7113b8d30ed)
+++ uspace/lib/c/meson.build	(revision 10fc93c16560fdc34ca9ac37d93d5aa3511c7dcd)
@@ -104,5 +104,4 @@
 	'generic/io/asprintf.c',
 	'generic/io/io.c',
-	'generic/io/chargrid.c',
 	'generic/io/printf.c',
 	'generic/io/log.c',
Index: uspace/lib/console/meson.build
===================================================================
--- uspace/lib/console/meson.build	(revision 6cef8d6a633ccd8d6545bfa8b87ae7113b8d30ed)
+++ uspace/lib/console/meson.build	(revision 10fc93c16560fdc34ca9ac37d93d5aa3511c7dcd)
@@ -27,5 +27,5 @@
 #
 
-deps = [ 'input' ]
+deps = [ 'input', 'output' ]
 src = files(
 	'src/con_srv.c',
Index: uspace/lib/meson.build
===================================================================
--- uspace/lib/meson.build	(revision 6cef8d6a633ccd8d6545bfa8b87ae7113b8d30ed)
+++ uspace/lib/meson.build	(revision 10fc93c16560fdc34ca9ac37d93d5aa3511c7dcd)
@@ -54,4 +54,5 @@
 
 	'input',
+	'output',
 	'console',
 	'device',
@@ -78,5 +79,4 @@
 	'nettl',
 	'ofw',
-	'output',
 	'pcm',
 	'pcut',
Index: uspace/lib/output/include/io/charfield.h
===================================================================
--- uspace/lib/output/include/io/charfield.h	(revision 10fc93c16560fdc34ca9ac37d93d5aa3511c7dcd)
+++ uspace/lib/output/include/io/charfield.h	(revision 10fc93c16560fdc34ca9ac37d93d5aa3511c7dcd)
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2006 Josef Cejka
+ * Copyright (c) 2011 Petr Koupy
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup liboutput
+ * @{
+ */
+/** @file
+ */
+
+#ifndef _LIBOUTPUT_IO_CHARFIELD_H_
+#define _LIBOUTPUT_IO_CHARFIELD_H_
+
+#include <stdbool.h>
+#include <uchar.h>
+#include <io/color.h>
+#include <io/style.h>
+#include <io/pixel.h>
+
+typedef enum {
+	CHAR_FLAG_NONE = 0,
+	CHAR_FLAG_DIRTY = 1
+} char_flags_t;
+
+typedef enum {
+	CHAR_ATTR_STYLE,
+	CHAR_ATTR_INDEX,
+	CHAR_ATTR_RGB
+} char_attr_type_t;
+
+typedef struct {
+	console_color_t bgcolor;
+	console_color_t fgcolor;
+	console_color_attr_t attr;
+} char_attr_index_t;
+
+typedef struct {
+	pixel_t bgcolor;
+	pixel_t fgcolor;
+} char_attr_rgb_t;
+
+typedef union {
+	console_style_t style;
+	char_attr_index_t index;
+	char_attr_rgb_t rgb;
+} char_attr_val_t;
+
+typedef struct {
+	char_attr_type_t type;
+	char_attr_val_t val;
+} char_attrs_t;
+
+typedef struct {
+	char32_t ch;
+	char_attrs_t attrs;
+	char_flags_t flags;
+} charfield_t;
+
+static inline bool attrs_same(char_attrs_t a1, char_attrs_t a2)
+{
+	if (a1.type != a2.type)
+		return false;
+
+	switch (a1.type) {
+	case CHAR_ATTR_STYLE:
+		return (a1.val.style == a2.val.style);
+	case CHAR_ATTR_INDEX:
+		return (a1.val.index.bgcolor == a2.val.index.bgcolor) &&
+		    (a1.val.index.fgcolor == a2.val.index.fgcolor) &&
+		    (a1.val.index.attr == a2.val.index.attr);
+	case CHAR_ATTR_RGB:
+		return (a1.val.rgb.bgcolor == a2.val.rgb.bgcolor) &&
+		    (a1.val.rgb.fgcolor == a2.val.rgb.fgcolor);
+	}
+
+	return false;
+}
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/output/include/io/chargrid.h
===================================================================
--- uspace/lib/output/include/io/chargrid.h	(revision 10fc93c16560fdc34ca9ac37d93d5aa3511c7dcd)
+++ uspace/lib/output/include/io/chargrid.h	(revision 10fc93c16560fdc34ca9ac37d93d5aa3511c7dcd)
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2011 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup liboutput
+ * @{
+ */
+/**
+ * @file
+ */
+
+#ifndef _LIBOUTPUT_IO_CHARGRID_H_
+#define _LIBOUTPUT_IO_CHARGRID_H_
+
+#include <io/charfield.h>
+#include <types/common.h>
+#include <stddef.h>
+
+typedef enum {
+	CHARGRID_FLAG_NONE = 0,
+	CHARGRID_FLAG_SHARED = 1
+} chargrid_flag_t;
+
+typedef struct {
+	size_t size;            /**< Structure size */
+	chargrid_flag_t flags;  /**< Screenbuffer flags */
+
+	sysarg_t cols;          /**< Number of columns */
+	sysarg_t rows;          /**< Number of rows */
+
+	sysarg_t col;           /**< Current column */
+	sysarg_t row;           /**< Current row */
+	bool cursor_visible;    /**< Cursor visibility */
+
+	char_attrs_t attrs;     /**< Current attributes */
+
+	sysarg_t top_row;       /**< The first row in the cyclic buffer */
+	charfield_t data[];     /**< Screen contents (cyclic buffer) */
+} chargrid_t;
+
+static inline charfield_t *chargrid_charfield_at(chargrid_t *chargrid,
+    sysarg_t col, sysarg_t row)
+{
+	return chargrid->data +
+	    ((row + chargrid->top_row) % chargrid->rows) * chargrid->cols +
+	    col;
+}
+
+extern chargrid_t *chargrid_create(sysarg_t, sysarg_t,
+    chargrid_flag_t);
+extern void chargrid_destroy(chargrid_t *);
+
+extern bool chargrid_cursor_at(chargrid_t *, sysarg_t, sysarg_t);
+
+extern sysarg_t chargrid_get_top_row(chargrid_t *);
+
+extern sysarg_t chargrid_putuchar(chargrid_t *, char32_t, bool);
+extern sysarg_t chargrid_newline(chargrid_t *);
+extern sysarg_t chargrid_tabstop(chargrid_t *, sysarg_t);
+extern sysarg_t chargrid_backspace(chargrid_t *);
+
+extern void chargrid_clear(chargrid_t *);
+extern void chargrid_clear_row(chargrid_t *, sysarg_t);
+
+extern void chargrid_set_cursor(chargrid_t *, sysarg_t, sysarg_t);
+extern void chargrid_set_cursor_visibility(chargrid_t *, bool);
+extern bool chargrid_get_cursor_visibility(chargrid_t *);
+
+extern void chargrid_get_cursor(chargrid_t *, sysarg_t *, sysarg_t *);
+
+extern void chargrid_set_style(chargrid_t *, console_style_t);
+extern void chargrid_set_color(chargrid_t *, console_color_t,
+    console_color_t, console_color_attr_t);
+extern void chargrid_set_rgb_color(chargrid_t *, pixel_t, pixel_t);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/output/include/io/color.h
===================================================================
--- uspace/lib/output/include/io/color.h	(revision 10fc93c16560fdc34ca9ac37d93d5aa3511c7dcd)
+++ uspace/lib/output/include/io/color.h	(revision 10fc93c16560fdc34ca9ac37d93d5aa3511c7dcd)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2023 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup liboutput
+ * @{
+ */
+/** @file
+ */
+
+#ifndef _LIBOUTPUT_IO_COLOR_H_
+#define _LIBOUTPUT_IO_COLOR_H_
+
+typedef enum {
+	COLOR_BLACK   = 0,
+	COLOR_BLUE    = 1,
+	COLOR_GREEN   = 2,
+	COLOR_CYAN    = 3,
+	COLOR_RED     = 4,
+	COLOR_MAGENTA = 5,
+	COLOR_YELLOW  = 6,
+	COLOR_WHITE   = 7
+} console_color_t;
+
+typedef enum {
+	CATTR_NORMAL = 0,
+	CATTR_BRIGHT = 8,
+	CATTR_BLINK  = 16
+} console_color_attr_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/output/include/io/concaps.h
===================================================================
--- uspace/lib/output/include/io/concaps.h	(revision 10fc93c16560fdc34ca9ac37d93d5aa3511c7dcd)
+++ uspace/lib/output/include/io/concaps.h	(revision 10fc93c16560fdc34ca9ac37d93d5aa3511c7dcd)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2023 Jiri Svoboda
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup liboutput
+ * @{
+ */
+/** @file
+ */
+
+#ifndef _LIBOUTPUT_IO_CONCAPS_H_
+#define _LIBOUTPUT_IO_CONCAPS_H_
+
+typedef enum {
+	CONSOLE_CAP_NONE = 0,
+	CONSOLE_CAP_STYLE = 1,
+	CONSOLE_CAP_INDEXED = 2,
+	CONSOLE_CAP_RGB = 4
+} console_caps_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/output/meson.build
===================================================================
--- uspace/lib/output/meson.build	(revision 6cef8d6a633ccd8d6545bfa8b87ae7113b8d30ed)
+++ uspace/lib/output/meson.build	(revision 10fc93c16560fdc34ca9ac37d93d5aa3511c7dcd)
@@ -28,4 +28,5 @@
 
 src = files(
+	'src/chargrid.c',
 	'src/output.c',
 )
Index: uspace/lib/output/src/chargrid.c
===================================================================
--- uspace/lib/output/src/chargrid.c	(revision 10fc93c16560fdc34ca9ac37d93d5aa3511c7dcd)
+++ uspace/lib/output/src/chargrid.c	(revision 10fc93c16560fdc34ca9ac37d93d5aa3511c7dcd)
@@ -0,0 +1,362 @@
+/*
+ * Copyright (c) 2006 Josef Cejka
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup liboutput
+ * @{
+ */
+/** @file
+ */
+
+#include <io/style.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <as.h>
+#include <io/chargrid.h>
+
+/** Create a chargrid.
+ *
+ * @param[in] cols  Number of columns.
+ * @param[in] rows  Number of rows.
+ * @param[in] flags Chargrid flags.
+ *
+ * @return New chargrid.
+ * @return NULL on failure.
+ *
+ */
+chargrid_t *chargrid_create(sysarg_t cols, sysarg_t rows,
+    chargrid_flag_t flags)
+{
+	size_t size =
+	    sizeof(chargrid_t) + cols * rows * sizeof(charfield_t);
+	chargrid_t *scrbuf;
+
+	if ((flags & CHARGRID_FLAG_SHARED) == CHARGRID_FLAG_SHARED) {
+		scrbuf = (chargrid_t *) as_area_create(AS_AREA_ANY, size,
+		    AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE,
+		    AS_AREA_UNPAGED);
+		if (scrbuf == AS_MAP_FAILED)
+			return NULL;
+	} else {
+		scrbuf = (chargrid_t *) malloc(size);
+		if (scrbuf == NULL)
+			return NULL;
+	}
+
+	scrbuf->size = size;
+	scrbuf->flags = flags;
+	scrbuf->cols = cols;
+	scrbuf->rows = rows;
+	scrbuf->cursor_visible = false;
+
+	scrbuf->attrs.type = CHAR_ATTR_STYLE;
+	scrbuf->attrs.val.style = STYLE_NORMAL;
+
+	scrbuf->top_row = 0;
+	chargrid_clear(scrbuf);
+
+	return scrbuf;
+}
+
+void chargrid_destroy(chargrid_t *srcbuf)
+{
+	// TODO
+}
+
+bool chargrid_cursor_at(chargrid_t *scrbuf, sysarg_t col, sysarg_t row)
+{
+	return ((scrbuf->cursor_visible) && (scrbuf->col == col) &&
+	    (scrbuf->row == row));
+}
+
+sysarg_t chargrid_get_top_row(chargrid_t *scrbuf)
+{
+	return scrbuf->top_row;
+}
+
+static sysarg_t chargrid_update_rows(chargrid_t *scrbuf)
+{
+	if (scrbuf->row == scrbuf->rows) {
+		scrbuf->row = scrbuf->rows - 1;
+		scrbuf->top_row = (scrbuf->top_row + 1) % scrbuf->rows;
+		chargrid_clear_row(scrbuf, scrbuf->row);
+
+		return scrbuf->rows;
+	}
+
+	return 2;
+}
+
+static sysarg_t chargrid_update_cols(chargrid_t *scrbuf)
+{
+	/* Column overflow */
+	if (scrbuf->col == scrbuf->cols) {
+		scrbuf->col = 0;
+		scrbuf->row++;
+		return chargrid_update_rows(scrbuf);
+	}
+
+	return 1;
+}
+
+/** Store one character to chargrid.
+ *
+ * Its position is determined by scrbuf->col
+ * and scrbuf->row.
+ *
+ * @param scrbuf Chargrid.
+ * @param ch     Character to store.
+ * @param update Update coordinates.
+ *
+ * @return Number of rows which have been affected. In usual
+ *         situations this is 1. If the current position was
+ *         updated to a new row, this value is 2.
+ *
+ */
+sysarg_t chargrid_putuchar(chargrid_t *scrbuf, char32_t ch, bool update)
+{
+	assert(scrbuf->col < scrbuf->cols);
+	assert(scrbuf->row < scrbuf->rows);
+
+	charfield_t *field =
+	    chargrid_charfield_at(scrbuf, scrbuf->col, scrbuf->row);
+
+	field->ch = ch;
+	field->attrs = scrbuf->attrs;
+	field->flags |= CHAR_FLAG_DIRTY;
+
+	if (update) {
+		scrbuf->col++;
+		return chargrid_update_cols(scrbuf);
+	}
+
+	return 1;
+}
+
+/** Jump to a new row in chargrid.
+ *
+ * @param scrbuf Chargrid.
+ *
+ * @return Number of rows which have been affected. In usual
+ *         situations this is 2 (the original row and the new
+ *         row).
+ *
+ */
+sysarg_t chargrid_newline(chargrid_t *scrbuf)
+{
+	assert(scrbuf->col < scrbuf->cols);
+	assert(scrbuf->row < scrbuf->rows);
+
+	scrbuf->col = 0;
+	scrbuf->row++;
+
+	return chargrid_update_rows(scrbuf);
+}
+
+/** Jump to a new row in chargrid.
+ *
+ * @param scrbuf   Chargrid.
+ * @param tab_size Tab size.
+ *
+ * @return Number of rows which have been affected. In usual
+ *         situations this is 1. If the current position was
+ *         updated to a new row, this value is 2.
+ *
+ */
+sysarg_t chargrid_tabstop(chargrid_t *scrbuf, sysarg_t tab_size)
+{
+	assert(scrbuf->col < scrbuf->cols);
+	assert(scrbuf->row < scrbuf->rows);
+
+	sysarg_t spaces = tab_size - scrbuf->cols % tab_size;
+	sysarg_t flush = 1;
+
+	for (sysarg_t i = 0; i < spaces; i++)
+		flush += chargrid_putuchar(scrbuf, ' ', true) - 1;
+
+	return flush;
+}
+
+/** Jump to the previous character in chargrid.
+ *
+ * Currently no scrollback is supported.
+ *
+ * @param scrbuf Chargrid.
+ *
+ * @return Number of rows which have been affected. In usual
+ *         situations this is 1. If the current position was
+ *         updated to the previous row, this value is 2.
+ * @return 0 if no backspace is possible.
+ *
+ */
+sysarg_t chargrid_backspace(chargrid_t *scrbuf)
+{
+	assert(scrbuf->col < scrbuf->cols);
+	assert(scrbuf->row < scrbuf->rows);
+
+	if ((scrbuf->col == 0) && (scrbuf->row == 0))
+		return 0;
+
+	if (scrbuf->col == 0) {
+		scrbuf->col = scrbuf->cols - 1;
+		scrbuf->row--;
+
+		chargrid_putuchar(scrbuf, ' ', false);
+		return 2;
+	}
+
+	scrbuf->col--;
+	chargrid_putuchar(scrbuf, ' ', false);
+	return 1;
+}
+
+/** Clear the chargrid.
+ *
+ * @param scrbuf Chargrid.
+ *
+ */
+void chargrid_clear(chargrid_t *scrbuf)
+{
+	for (size_t pos = 0; pos < (scrbuf->cols * scrbuf->rows); pos++) {
+		scrbuf->data[pos].ch = 0;
+		scrbuf->data[pos].attrs = scrbuf->attrs;
+		scrbuf->data[pos].flags = CHAR_FLAG_DIRTY;
+	}
+
+	scrbuf->col = 0;
+	scrbuf->row = 0;
+}
+
+/** Update current chargrid coordinates
+ *
+ * @param scrbuf Chargrid.
+ * @param col    New column.
+ * @param row    New row.
+ *
+ */
+void chargrid_set_cursor(chargrid_t *scrbuf, sysarg_t col, sysarg_t row)
+{
+	if (col >= scrbuf->cols || row >= scrbuf->rows)
+		return;
+
+	scrbuf->col = col;
+	scrbuf->row = row;
+}
+
+void chargrid_set_cursor_visibility(chargrid_t *scrbuf, bool visible)
+{
+	scrbuf->cursor_visible = visible;
+}
+
+/** Get current chargrid coordinates
+ *
+ * @param scrbuf Chargrid.
+ * @param col    Column.
+ * @param row    Row.
+ *
+ */
+void chargrid_get_cursor(chargrid_t *scrbuf, sysarg_t *col,
+    sysarg_t *row)
+{
+	assert(col);
+	assert(row);
+
+	*col = scrbuf->col;
+	*row = scrbuf->row;
+}
+
+bool chargrid_get_cursor_visibility(chargrid_t *scrbuf)
+{
+	return scrbuf->cursor_visible;
+}
+
+/** Clear one buffer row.
+ *
+ * @param scrbuf Chargrid.
+ * @param row    Row to clear.
+ *
+ */
+void chargrid_clear_row(chargrid_t *scrbuf, sysarg_t row)
+{
+	for (sysarg_t col = 0; col < scrbuf->cols; col++) {
+		charfield_t *field =
+		    chargrid_charfield_at(scrbuf, col, row);
+
+		field->ch = 0;
+		field->attrs = scrbuf->attrs;
+		field->flags |= CHAR_FLAG_DIRTY;
+	}
+}
+
+/** Set chargrid style.
+ *
+ * @param scrbuf Chargrid.
+ * @param style  Style.
+ *
+ */
+void chargrid_set_style(chargrid_t *scrbuf, console_style_t style)
+{
+	scrbuf->attrs.type = CHAR_ATTR_STYLE;
+	scrbuf->attrs.val.style = style;
+}
+
+/** Set chargrid color.
+ *
+ * @param scrbuf  Chargrid.
+ * @param bgcolor Background color.
+ * @param fgcolor Foreground color.
+ * @param attr    Color attribute.
+ *
+ */
+void chargrid_set_color(chargrid_t *scrbuf, console_color_t bgcolor,
+    console_color_t fgcolor, console_color_attr_t attr)
+{
+	scrbuf->attrs.type = CHAR_ATTR_INDEX;
+	scrbuf->attrs.val.index.bgcolor = bgcolor;
+	scrbuf->attrs.val.index.fgcolor = fgcolor;
+	scrbuf->attrs.val.index.attr = attr;
+}
+
+/** Set chargrid RGB color.
+ *
+ * @param scrbuf  Chargrid.
+ * @param bgcolor Background color.
+ * @param fgcolor Foreground color.
+ *
+ */
+void chargrid_set_rgb_color(chargrid_t *scrbuf, pixel_t bgcolor,
+    pixel_t fgcolor)
+{
+	scrbuf->attrs.type = CHAR_ATTR_RGB;
+	scrbuf->attrs.val.rgb.bgcolor = bgcolor;
+	scrbuf->attrs.val.rgb.fgcolor = fgcolor;
+}
+
+/** @}
+ */
