Skip to content

Commit

Permalink
Terminal: Set alpha channel to 0xFF
Browse files Browse the repository at this point in the history
This fixes a bug where VT::Color::Kind::Indexed colors from
index 16 to 255 were not being rendered because their
alpha channel was set to zero.
  • Loading branch information
ninadsachania authored and nico committed Nov 12, 2024
1 parent 66ee1a1 commit a7d5ea0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions Userland/Libraries/LibVT/TerminalWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ TerminalWidget::TerminalWidget(int ptm_fd, bool automatic_size_policy)
: m_terminal(*this)
, m_automatic_size_policy(automatic_size_policy)
{
static_assert(sizeof(m_colors) == sizeof(xterm_colors));
memcpy(m_colors, xterm_colors, sizeof(m_colors));
VERIFY(m_colors.size() == xterm_colors.size());
for (size_t i = 0; i < xterm_colors.size(); i++)
m_colors[i] = Gfx::Color::from_rgb(xterm_colors[i]);

set_override_cursor(Gfx::StandardCursor::IBeam);
set_focus_policy(GUI::FocusPolicy::StrongFocus);
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibVT/TerminalWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class TerminalWidget final
// Snapshot of m_hovered_href when opening a context menu for a hyperlink.
ByteString m_context_menu_href;

Gfx::Color m_colors[256];
Array<Gfx::Color, 256> m_colors;
Gfx::Color m_default_foreground_color;
Gfx::Color m_default_background_color;
bool m_show_bold_text_as_bright { true };
Expand Down
6 changes: 4 additions & 2 deletions Userland/Libraries/LibVT/XtermColors.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
* SPDX-License-Identifier: BSD-2-Clause
*/

#include <AK/Array.h>

#pragma once

static constexpr unsigned xterm_colors[256] = {
static constexpr Array<unsigned, 256> xterm_colors = to_array<unsigned>({
0x000000,
0xcc0000,
0x3e9a06,
Expand Down Expand Up @@ -263,4 +265,4 @@ static constexpr unsigned xterm_colors[256] = {
0xdadada,
0xe4e4e4,
0xeeeeee,
};
});

0 comments on commit a7d5ea0

Please sign in to comment.