The Pedigree Project  0.1
SerialIO.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef SERIALIO_H
21 #define SERIALIO_H
22 
23 #include "pedigree/kernel/debugger/DebuggerIO.h"
24 #include "pedigree/kernel/processor/types.h"
25 
26 class Serial;
27 
34 class SerialIO : public DebuggerIO
35 {
36  public:
40  SerialIO(Serial *pSerial);
41  ~SerialIO();
42 
48  void setCliUpperLimit(size_t nlines);
49  void setCliLowerLimit(size_t nlines);
50 
56  void enableCli();
57  void disableCli();
58 
59  void cls();
60  char getCharNonBlock();
61 
62  void readDimensions();
63 
69  void drawHorizontalLine(
70  char c, size_t row, size_t colStart, size_t colEnd,
71  DebuggerIO::Colour foreColour, DebuggerIO::Colour backColour);
72  void drawVerticalLine(
73  char c, size_t col, size_t rowStart, size_t rowEnd,
74  DebuggerIO::Colour foreColour, DebuggerIO::Colour backColour);
75 
80  void drawString(
81  const char *str, size_t row, size_t col, DebuggerIO::Colour foreColour,
82  DebuggerIO::Colour backColour);
83 
87  size_t getWidth()
88  {
89  return m_nWidth;
90  }
91  size_t getHeight()
92  {
93  return m_nHeight;
94  }
95 
100  void enableRefreshes();
101  void disableRefreshes();
102  void forceRefresh();
103 
108  char getChar();
109 
110  void initialise();
111  void destroy();
112 
113  protected:
117  void scroll();
118 
122  void moveCursor();
123 
124  void putChar(
125  char c, DebuggerIO::Colour foreColour, DebuggerIO::Colour backColour);
126 
127  void
128  startColour(DebuggerIO::Colour foreColour, DebuggerIO::Colour backColour);
129  void endColour();
130 
131  void readCursor();
132  void setCursor();
133  void saveCursor();
134  void unsaveCursor();
135 
140  size_t m_LowerCliLimit;
142 
147  size_t m_nWidth;
148  size_t m_nHeight;
149 
153  size_t m_nCursorX;
154  size_t m_nCursorY;
155  size_t m_nOldCursorX;
156  size_t m_nOldCursorY;
157 
158  DebuggerIO::Colour m_ForeColour;
159  DebuggerIO::Colour m_BackColour;
160 
165 
166  bool m_bCli;
167 
168  private:
169  SerialIO(const SerialIO &);
170  SerialIO &operator=(const SerialIO &);
171 };
172 
175 #endif
size_t m_LowerCliLimit
Definition: SerialIO.h:141
void enableRefreshes()
Definition: SerialIO.cc:275
size_t m_nCursorX
Definition: SerialIO.h:153
void scroll()
Definition: SerialIO.cc:285
void enableCli()
Definition: SerialIO.cc:101
void setCliUpperLimit(size_t nlines)
Definition: SerialIO.cc:87
void drawString(const char *str, size_t row, size_t col, DebuggerIO::Colour foreColour, DebuggerIO::Colour backColour)
Definition: SerialIO.cc:254
size_t getWidth()
Definition: SerialIO.h:87
void drawHorizontalLine(char c, size_t row, size_t colStart, size_t colEnd, DebuggerIO::Colour foreColour, DebuggerIO::Colour backColour)
Definition: SerialIO.cc:154
void putChar(char c, DebuggerIO::Colour foreColour, DebuggerIO::Colour backColour)
Definition: SerialIO.cc:299
SerialIO(Serial *pSerial)
Definition: SerialIO.cc:25
void moveCursor()
Definition: SerialIO.cc:289
Serial * m_pSerial
Definition: SerialIO.h:164
size_t m_nWidth
Definition: SerialIO.h:147
char getChar()
Definition: SerialIO.cc:138
size_t m_UpperCliLimit
Definition: SerialIO.h:139