diff --git a/repos/gems/run/sculpt/fonts.config b/repos/gems/run/sculpt/fonts.config index b5ee5db4be..b0623a1ce0 100644 --- a/repos/gems/run/sculpt/fonts.config +++ b/repos/gems/run/sculpt/fonts.config @@ -22,5 +22,5 @@ - + diff --git a/repos/gems/run/sculpt/leitzentrale.config b/repos/gems/run/sculpt/leitzentrale.config index 667be3b29e..6e5a8aecf6 100644 --- a/repos/gems/run/sculpt/leitzentrale.config +++ b/repos/gems/run/sculpt/leitzentrale.config @@ -244,8 +244,10 @@ - - + + + + diff --git a/repos/gems/src/app/sculpt_manager/main.cc b/repos/gems/src/app/sculpt_manager/main.cc index dfdbd0f4f0..3eec7ef5c2 100644 --- a/repos/gems/src/app/sculpt_manager/main.cc +++ b/repos/gems/src/app/sculpt_manager/main.cc @@ -956,9 +956,11 @@ void Sculpt::Main::_handle_nitpicker_mode() xml.node("default-policy", [&] () { xml.attribute("root", "/fonts"); }); auto gen_color = [&] (unsigned index, Color color) { - xml.node("color", [&] () { - xml.attribute("index", index); - xml.attribute("bg", String<16>(color)); + xml.node("palette", [&] () { + xml.node("color", [&] () { + xml.attribute("index", index); + xml.attribute("value", String<16>(color)); + }); }); }; diff --git a/repos/gems/src/server/terminal/README b/repos/gems/src/server/terminal/README new file mode 100644 index 0000000000..b2ae8a590a --- /dev/null +++ b/repos/gems/src/server/terminal/README @@ -0,0 +1,19 @@ +This is a graphical terminal implementation. It provides the Terminal +service and uses a nitpicker session for screen representation. + +Configuration +~~~~~~~~~~~~~ + +The default color palette can be configured via the XML +configuration node like follows. There are 16 colors configurable - +index 0-7 normal color and index 8-15 bright (bold) colors. + + +! +! +! +! +! +! ... +! + diff --git a/repos/gems/src/server/terminal/color_palette.h b/repos/gems/src/server/terminal/color_palette.h index f8bad17c3d..8dd4c654b6 100644 --- a/repos/gems/src/server/terminal/color_palette.h +++ b/repos/gems/src/server/terminal/color_palette.h @@ -1,11 +1,12 @@ /* * \brief Terminal color palette * \author Norman Feske + * \author Christian Helmuth * \date 2018-02-06 */ /* - * Copyright (C) 2018 Genode Labs GmbH + * Copyright (C) 2018-2019 Genode Labs GmbH * * This file is part of the Genode OS framework, which is distributed * under the terms of the GNU Affero General Public License version 3. @@ -16,6 +17,7 @@ /* Genode includes */ #include +#include /* local includes */ #include "types.h" @@ -33,44 +35,61 @@ class Terminal::Color_palette struct Highlighted { bool value; }; - struct Inverse { bool value; }; - private: enum { NUM_COLORS = 16U }; Color _colors[NUM_COLORS]; + static constexpr char const * _default_palette { + "" + " " /* black */ + " " /* red */ + " " /* green */ + " " /* yellow */ + " " /* blue */ + " " /* magenta */ + " " /* cyan */ + " " /* white */ + " " /* bright black */ + " " /* bright red */ + " " /* bright green */ + " " /* bright yellow */ + " " /* bright blue */ + " " /* bright magenta */ + " " /* bright cyan */ + " " /* bright white */ + "" }; + + Genode::Xml_node const _default { _default_palette }; + + void _apply_palette(Xml_node palette) + { + palette.for_each_sub_node("color", [&] (Xml_node node) { + if (!node.has_attribute("index")) return; + if (!node.has_attribute("value")) return; + + unsigned const index = node.attribute_value("index", 0U); + if (!(index <= NUM_COLORS)) return; + _colors[index] = node.attribute_value("value", Color()); + }); + } + public: Color_palette() { - _colors[0] = Color( 0, 0, 0); /* black */ - _colors[1] = Color(255, 128, 128); /* red */ - _colors[2] = Color(128, 255, 128); /* green */ - _colors[3] = Color(255, 255, 0); /* yellow */ - _colors[4] = Color(128, 128, 255); /* blue */ - _colors[5] = Color(255, 0, 255); /* magenta */ - _colors[6] = Color( 0, 255, 255); /* cyan */ - _colors[7] = Color(255, 255, 255); /* white */ - - /* the upper portion of the palette contains highlight colors */ - for (unsigned i = 0; i < NUM_COLORS/2; i++) { - Color const col = _colors[i]; - _colors[i + NUM_COLORS/2] = Color((col.r*2)/3, (col.g*2)/3, (col.b*2)/3); - } + _apply_palette(_default); } void apply_config(Xml_node config) { - config.for_each_sub_node("color", [&] (Xml_node color) { - unsigned const index = min(color.attribute_value("index", 0U), 15U); - Color const bg = color.attribute_value("bg", Color()); - _colors[index] = bg; - }); + _apply_palette(_default); + if (config.has_sub_node("palette")) + _apply_palette(config.sub_node("palette")); } - Color foreground(Index index, Highlighted highlighted, Inverse inverse) const + Color foreground(Index index, Highlighted highlighted) const { if (index.value >= NUM_COLORS/2) return Color(0, 0, 0); @@ -78,18 +97,15 @@ class Terminal::Color_palette Color const col = _colors[index.value + (highlighted.value ? NUM_COLORS/2 : 0)]; - return (inverse.value) ? Color(col.r/2, col.g/2, col.b/2) : col; + return col; } - Color background(Index index, Highlighted highlighted, Inverse inverse) const + Color background(Index index, Highlighted highlighted) const { - Color const color = - _colors[index.value + (highlighted.value ? NUM_COLORS/2 : 0)]; + Color const color = foreground(index, highlighted); - return (inverse.value) ? Color((color.r + 255)/2, - (color.g + 255)/2, - (color.b + 255)/2) - : color; + /* reduce the intensity of background colors */ + return Color(color.r*3/4, color.g*3/4, color.b*3/4); } }; diff --git a/repos/gems/src/server/terminal/text_screen_surface.h b/repos/gems/src/server/terminal/text_screen_surface.h index 358bfb744d..3dba87959b 100644 --- a/repos/gems/src/server/terminal/text_screen_surface.h +++ b/repos/gems/src/server/terminal/text_screen_surface.h @@ -1,6 +1,7 @@ /* * \brief Terminal graphics backend for textual screen * \author Norman Feske + * \author Christian Helmuth * \date 2018-02-06 */ @@ -177,8 +178,7 @@ class Terminal::Text_screen_surface { Color const bg_color = _palette.background(Color_palette::Index{0}, - Color_palette::Highlighted{false}, - Color_palette::Inverse{false}); + Color_palette::Highlighted{false}); Rect r[4] { }; Rect const all(Point(0, 0), _geometry.fb_size); _geometry.fb_rect().cut(_geometry.used_rect(), &r[0], &r[1], &r[2], &r[3]); @@ -197,20 +197,24 @@ class Terminal::Text_screen_surface Fixpoint_number x { (int)_geometry.start().x() }; for (unsigned column = 0; column < _cell_array.num_cols(); column++) { - Char_cell cell = _cell_array.get_cell(column, line); + Char_cell const cell = _cell_array.get_cell(column, line); _font.apply_glyph(cell.codepoint(), [&] (Glyph_painter::Glyph const &glyph) { Color_palette::Highlighted const highlighted { cell.highlight() }; - Color_palette::Inverse const inverse { cell.inverse() }; - Color fg_color = - _palette.foreground(Color_palette::Index{cell.colidx_fg()}, - highlighted, inverse); + Color_palette::Index fg_idx { cell.colidx_fg() }; + Color_palette::Index bg_idx { cell.colidx_bg() }; - Color bg_color = - _palette.background(Color_palette::Index{cell.colidx_bg()}, - highlighted, inverse); + /* swap color index for inverse cells */ + if (cell.inverse()) { + Color_palette::Index tmp { fg_idx }; + fg_idx = bg_idx; + bg_idx = tmp; + } + + Color fg_color = _palette.foreground(fg_idx, highlighted); + Color bg_color = _palette.background(bg_idx, highlighted); if (cell.has_cursor()) { fg_color = Color( 63, 63, 63);