Revert "term: Reverse video should not make the cursor invisible"

This reverts commit a5def082c3.
This commit is contained in:
mintsuki 2021-08-26 01:23:27 +02:00
parent 9d8fd54127
commit 57c44befee
2 changed files with 11 additions and 22 deletions

View File

@ -29,6 +29,8 @@ static struct context {
#define cursor_status context.cursor_status
uint8_t text_palette;
#define text_palette context.text_palette
uint8_t cursor_palette;
#define cursor_palette context.cursor_palette
bool scroll_enabled;
#define scroll_enabled context.scroll_enabled
} context;
@ -41,8 +43,7 @@ static void clear_cursor(void) {
static void draw_cursor(void) {
if (cursor_status) {
uint16_t c = current_buffer[cursor_offset + 1];
video_mem[cursor_offset + 1] = (c << 4) | (c >> 4);
video_mem[cursor_offset + 1] = cursor_palette;
}
}
@ -164,6 +165,7 @@ void init_vga_textmode(size_t *_rows, size_t *_cols, bool managed) {
cursor_offset = 0;
cursor_status = true;
text_palette = 0x07;
cursor_palette = 0x70;
scroll_enabled = true;
text_clear(false);

View File

@ -86,16 +86,11 @@ void gterm_swap_palette(void) {
}
}
#define A(rgb) ((uint8_t)((rgb) >> 24))
#define R(rgb) ((uint8_t)((rgb) >> 16))
#define G(rgb) ((uint8_t)((rgb) >> 8))
#define B(rgb) ((uint8_t)((rgb) >> 0))
#define ARGB(a, r, g, b) ( \
((uint32_t)((a) & 0xFF) << 24) \
| ((uint32_t)((r) & 0xFF) << 16) \
| ((uint32_t)((g) & 0xFF) << 8) \
| ((uint32_t)((b) & 0xFF) << 0) \
)
#define A(rgb) (uint8_t)(rgb >> 24)
#define R(rgb) (uint8_t)(rgb >> 16)
#define G(rgb) (uint8_t)(rgb >> 8)
#define B(rgb) (uint8_t)(rgb)
#define ARGB(a, r, g, b) (a << 24) | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | (b & 0xFF)
static inline uint32_t colour_blend(uint32_t fg, uint32_t bg) {
unsigned alpha = 255 - A(fg);
@ -342,16 +337,8 @@ static void clear_cursor(void) {
static void draw_cursor(void) {
if (cursor_status) {
struct gterm_char c = grid[cursor_x + cursor_y * cols];
uint32_t tmp = c.fg;
if (c.bg == 0xffffffff) {
c.fg = ARGB(A(tmp),
R(tmp) < 128 ? 255 : 0,
G(tmp) < 128 ? 255 : 0,
B(tmp) < 128 ? 255 : 0);
} else {
c.fg = c.bg;
}
c.bg = tmp;
c.fg = 0;
c.bg = 0xcccccc;
plot_char_grid_force(&c, cursor_x, cursor_y);
}
}