mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:28:12 +00:00
Kernel/Graphics: Implement basic cursor for FramebufferConsole
This commit is contained in:
parent
00a0b1bd14
commit
0d784de3a6
2 changed files with 19 additions and 1 deletions
|
@ -213,16 +213,31 @@ size_t GenericFramebufferConsoleImpl::chars_per_line() const
|
||||||
return width() / bytes_per_base_glyph();
|
return width() / bytes_per_base_glyph();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericFramebufferConsoleImpl::set_cursor(size_t, size_t)
|
void GenericFramebufferConsoleImpl::set_cursor(size_t x, size_t y)
|
||||||
{
|
{
|
||||||
|
hide_cursor();
|
||||||
|
m_x = x;
|
||||||
|
m_y = y;
|
||||||
|
show_cursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericFramebufferConsoleImpl::hide_cursor()
|
void GenericFramebufferConsoleImpl::hide_cursor()
|
||||||
{
|
{
|
||||||
|
auto* offset_in_framebuffer = (u32*)&framebuffer_data()[m_x * sizeof(u32) * m_pixels_per_column + m_y * m_pixels_per_row * framebuffer_pitch()];
|
||||||
|
offset_in_framebuffer = (u32*)((u8*)offset_in_framebuffer + framebuffer_pitch() * 15);
|
||||||
|
for (size_t current_x = 0; current_x < m_pixels_per_column; current_x++) {
|
||||||
|
offset_in_framebuffer[current_x] = m_cursor_overriden_pixels[current_x];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericFramebufferConsoleImpl::show_cursor()
|
void GenericFramebufferConsoleImpl::show_cursor()
|
||||||
{
|
{
|
||||||
|
auto* offset_in_framebuffer = (u32*)&framebuffer_data()[m_x * sizeof(u32) * m_pixels_per_column + m_y * m_pixels_per_row * framebuffer_pitch()];
|
||||||
|
offset_in_framebuffer = (u32*)((u8*)offset_in_framebuffer + framebuffer_pitch() * 15);
|
||||||
|
for (size_t current_x = 0; current_x < m_pixels_per_column; current_x++) {
|
||||||
|
m_cursor_overriden_pixels[current_x] = offset_in_framebuffer[current_x];
|
||||||
|
memset(offset_in_framebuffer + current_x, 0xff, 4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericFramebufferConsoleImpl::clear(size_t x, size_t y, size_t length)
|
void GenericFramebufferConsoleImpl::clear(size_t x, size_t y, size_t length)
|
||||||
|
|
|
@ -43,6 +43,7 @@ protected:
|
||||||
: Console(width, height)
|
: Console(width, height)
|
||||||
, m_pitch(pitch)
|
, m_pitch(pitch)
|
||||||
{
|
{
|
||||||
|
m_cursor_overriden_pixels.fill(0);
|
||||||
}
|
}
|
||||||
virtual u8* framebuffer_data() = 0;
|
virtual u8* framebuffer_data() = 0;
|
||||||
size_t framebuffer_pitch() const { return m_pitch; }
|
size_t framebuffer_pitch() const { return m_pitch; }
|
||||||
|
@ -51,6 +52,8 @@ protected:
|
||||||
size_t const m_pixels_per_column { 8 };
|
size_t const m_pixels_per_column { 8 };
|
||||||
size_t const m_pixels_per_row { 16 };
|
size_t const m_pixels_per_row { 16 };
|
||||||
|
|
||||||
|
Array<u32, 8> m_cursor_overriden_pixels;
|
||||||
|
|
||||||
size_t m_pitch;
|
size_t m_pitch;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue