20 #include "pedigree/kernel/debugger/Scrollable.h" 22 Scrollable::Scrollable()
23 : m_x(0), m_y(0), m_width(0), m_height(0), m_line(0), m_ScrollUp(
'j'),
27 Scrollable::~Scrollable() =
default;
29 void Scrollable::move(
size_t x,
size_t y)
35 void Scrollable::resize(
size_t width,
size_t height)
41 void Scrollable::scroll(ssize_t lines)
46 (static_cast<ssize_t>(getLineCount()) - static_cast<ssize_t>(m_height)))
47 m_line =
static_cast<ssize_t
>(getLineCount()) -
48 static_cast<ssize_t>(m_height);
54 void Scrollable::scrollTo(
size_t absolute)
59 (static_cast<ssize_t>(getLineCount()) - static_cast<ssize_t>(m_height)))
60 m_line =
static_cast<ssize_t
>(getLineCount()) -
61 static_cast<ssize_t>(m_height);
69 pScreen->disableRefreshes();
74 bool bCanScrollUp = (m_line > 0);
75 bool bCanScrollDown = ((m_line + m_height) < getLineCount());
78 ssize_t line = m_line;
79 for (
size_t i = 0; i < m_height; i++)
82 ' ', m_y + i, m_x, m_x + m_width - 1, DebuggerIO::White,
85 if (line >= 0 && line < static_cast<ssize_t>(getLineCount()))
90 const char *Line = getLine1(line, colour, bgColour);
92 pScreen->
drawString(Line, m_y + i, m_x, colour, bgColour);
94 colour = DebuggerIO::White;
95 bgColour = DebuggerIO::Black;
96 Line = getLine2(line, colOffset, colour, bgColour);
99 Line, m_y + i, m_x + colOffset, colour, bgColour);
105 char str[4] = {
'^',
' ', m_ScrollUp,
'\0'};
108 str, m_y, m_x + m_width - 3, DebuggerIO::White, DebuggerIO::Blue);
110 str[2] = m_ScrollDown;
113 str, m_y + m_height - 1, m_x + m_width - 3, DebuggerIO::White,
119 void Scrollable::setScrollKeys(
char up,
char down)
125 ssize_t Scrollable::getLine()
130 void Scrollable::centreOn(
size_t line)
132 if (line > getLineCount())
133 line = getLineCount();
141 scrollTo(line - (m_height / 2));
144 size_t Scrollable::height()
const 148 size_t Scrollable::width()
const virtual void enableRefreshes()=0
virtual void drawString(const char *str, size_t row, size_t col, Colour foreColour, Colour backColour)=0
virtual void drawHorizontalLine(char c, size_t row, size_t colStart, size_t colEnd, Colour foreColour, Colour backColour)=0