20 #include "pedigree/kernel/debugger/LocalIO.h" 21 #include "pedigree/kernel/machine/Keyboard.h" 22 #include "pedigree/kernel/machine/Vga.h" 25 : m_nWidth(80), m_nHeight(25), m_UpperCliLimit(0), m_LowerCliLimit(0),
26 m_CursorX(0), m_CursorY(0), m_pVga(pVga), m_pKeyboard(pKeyboard)
35 void LocalIO::initialise()
44 for (
size_t i = 0; i < MAX_CONSOLE_WIDTH * MAX_CONSOLE_HEIGHT; i++)
46 uint8_t attributeByte =
47 (DebuggerIO::Black << 4) | (DebuggerIO::White & 0x0F);
48 uint16_t blank =
' ' | (attributeByte << 8);
58 MAX_CONSOLE_WIDTH * MAX_CONSOLE_HEIGHT * 2);
67 void LocalIO::destroy()
72 MAX_CONSOLE_WIDTH * MAX_CONSOLE_HEIGHT * 2);
79 if (nlines < m_nHeight)
87 void LocalIO::setCliLowerLimit(
size_t nlines)
90 if (nlines < m_nHeight)
101 for (
size_t i = 0; i < m_nWidth * m_nHeight; i++)
103 uint8_t attributeByte =
104 (DebuggerIO::Black << 4) | (DebuggerIO::White & 0x0F);
105 uint16_t blank =
' ' | (attributeByte << 8);
118 void LocalIO::disableCli()
121 for (
size_t i = 0; i < m_nWidth * m_nHeight; i++)
123 uint8_t attributeByte =
124 (DebuggerIO::Black << 4) | (DebuggerIO::White & 0x0F);
125 uint16_t blank =
' ' | (attributeByte << 8);
136 char LocalIO::getCharNonBlock()
147 char c,
size_t row,
size_t colStart,
size_t colEnd,
151 if (colStart > colEnd)
153 size_t tmp = colStart;
158 if (colEnd >= m_nWidth)
159 colEnd = m_nWidth - 1;
160 if (static_cast<int32_t>(colStart) < 0)
162 if (row >= m_nHeight)
164 if (static_cast<int32_t>(row) < 0)
167 uint8_t attributeByte = (backColour << 4) | (foreColour & 0x0F);
168 for (
size_t i = colStart; i <= colEnd; i++)
177 void LocalIO::drawVerticalLine(
178 char c,
size_t col,
size_t rowStart,
size_t rowEnd,
182 if (rowStart > rowEnd)
184 size_t tmp = rowStart;
189 if (rowEnd >= m_nHeight)
190 rowEnd = m_nHeight - 1;
191 if (static_cast<int32_t>(rowStart) < 0)
195 if (static_cast<int32_t>(col) < 0)
198 uint8_t attributeByte = (backColour << 4) | (foreColour & 0x0F);
199 for (
size_t i = rowStart; i <= rowEnd; i++)
215 size_t savedY = m_CursorY;
221 bool bRefreshWasEnabled =
false;
224 bRefreshWasEnabled =
true;
230 putChar(*str++, foreColour, backColour);
232 if (bRefreshWasEnabled)
252 void LocalIO::disableRefreshes()
257 void LocalIO::forceRefresh()
260 reinterpret_cast<uint8_t *>(
m_pFramebuffer), m_nWidth * m_nHeight * 2);
267 uint8_t attributeByte =
268 (DebuggerIO::Black << 4) | (DebuggerIO::White & 0x0F);
269 uint16_t blank =
' ' | (attributeByte << 8);
289 void LocalIO::putChar(
305 uint8_t attributeByte = (backColour << 4) | (foreColour & 0x0F);
307 ' ' | (attributeByte << 8);
311 else if (c == 0x09 && (((
m_CursorX + 8) & ~(8 - 1)) < m_nWidth))
328 uint8_t attributeByte = (backColour << 4) | (foreColour & 0x0F);
330 c | (attributeByte << 8);
347 for (
size_t i = 0; i < m_nWidth * m_nHeight; i++)
349 unsigned char attributeByte =
350 (DebuggerIO::Black << 4) | (DebuggerIO::White & 0x0F);
351 unsigned short blank =
' ' | (attributeByte << 8);
LocalIO(Vga *pVga, Keyboard *pKeyboard)
virtual void moveCursor(size_t nX, size_t nY)=0
virtual void restoreMode()=0
void setCliUpperLimit(size_t nlines)
virtual void rememberMode()=0
virtual char getCharNonBlock()=0
virtual void pokeBuffer(uint8_t *pBuffer, size_t nBufLen)=0
char m_pCommand[COMMAND_MAX]
void drawString(const char *str, size_t row, size_t col, DebuggerIO::Colour foreColour, DebuggerIO::Colour backColour)
void drawHorizontalLine(char c, size_t row, size_t colStart, size_t colEnd, DebuggerIO::Colour foreColour, DebuggerIO::Colour backColour)
uint16_t m_pFramebuffer[MAX_CONSOLE_WIDTH *MAX_CONSOLE_HEIGHT]
uint16_t m_pOldFramebuffer[MAX_CONSOLE_WIDTH *MAX_CONSOLE_HEIGHT]
virtual void peekBuffer(uint8_t *pBuffer, size_t nBufLen)=0
virtual bool setLargestTextMode()=0
virtual size_t getNumRows()=0
virtual size_t getNumCols()=0