ReactOS  0.4.12-dev-18-gf469aca
tconsole.h
Go to the documentation of this file.
1 #pragma once
2 
3 //#include "tnconfig.h"
4 
5 /* A diagram of the following values:
6  *
7  * (0,0)
8  * +----------------------------------------+
9  * | |
10  * | |
11  * | |
12  * | |
13  * | |
14  * | |
15  * | |
16  * | |
17  * | |
18  * | |
19  * | |
20  * | |
21  * | |
22  * | CON_TOP |
23  * +---------------------------+.....?......| ---
24  * | . | | |
25  * | . | <-- OR --> | |
26  * | . | | |
27  * CON_LEFT | . | CON_RIGHT |
28  * (=0) | . | (=CON_ | CON_LINES
29  * |..............* | WIDTH) |
30  * | (CON_CUR_X, | | |
31  * | CON_CUR_Y) | | |
32  * | | | |
33  * | | | |
34  * | | | |
35  * +---------------------------+------------+ ---
36  * CON_BOTTOM (=CON_TOP + CON_HEIGHT)
37  *
38  * |--------- CON_COLS --------|
39  *
40  * Keep in mind that CON_TOP, CON_BOTTOM, CON_LEFT, and CON_RIGHT are relative
41  * to zero, but CON_CUR_X, CON_CUR_Y, CON_WIDTH, and CON_HEIGHT are relative to
42  * CON_TOP and CON_LEFT
43  */
44 
45 #define CON_TOP ConsoleInfo.srWindow.Top
46 #define CON_BOTTOM ConsoleInfo.srWindow.Bottom
47 
48 #define CON_LEFT 0
49 #define CON_RIGHT (ConsoleInfo.dwSize.X - 1)
50 
51 #define CON_HEIGHT (CON_BOTTOM - CON_TOP)
52 #define CON_WIDTH (CON_RIGHT - CON_LEFT)
53 #define CON_LINES (CON_HEIGHT + 1)
54 #define CON_COLS (CON_WIDTH + 1)
55 
56 #define CON_CUR_X (ConsoleInfo.dwCursorPosition.X - CON_LEFT)
57 #define CON_CUR_Y (ConsoleInfo.dwCursorPosition.Y - CON_TOP)
58 
59 
60 class TConsole {
61 public:
63  ~TConsole();
64  void sync();
65 
66  // Cursor movement routines
67  int GetRawCursorX() {return CON_CUR_X;}
68  int GetRawCursorY() {return CON_CUR_Y;}
69  int GetCursorX() {return CON_CUR_X;}
70  int GetCursorY() {
71  if(iScrollStart != -1)
72  return CON_CUR_Y - iScrollStart;
73  return GetRawCursorY();
74  }
75  void SetRawCursorPosition(int x, int y);
76  void SetCursorPosition(int x, int y);
77  void SetCursorSize(int pct);
78  void MoveCursorPosition(int x, int y);
79 
80  // Screen mode/size routines
81  int GetWidth() {return CON_COLS;}
82  int GetHeight() {return CON_LINES;}
83  void SetExtendedMode(int iFunction, BOOL bEnable);
84  void SetWindowSize(int width, int height); // Set the size of the window,
85  // but not the buffer
86 
87  // Color/attribute routines
88  void SetAttrib(unsigned char wAttr) {wAttributes = wAttr;}
89  unsigned char GetAttrib() {return wAttributes;}
90  void Normal(); // Reset all attributes
91  void HighVideo(); // Aka "bold"
92  void LowVideo();
93  void SetForeground(unsigned char wAttrib); // Set the foreground directly
94  void SetBackground(unsigned char wAttrib);
95  void BlinkOn(); // Blink on/off
96  void BlinkOff();
97  void UnderlineOn(); // Underline on/off
98  void UnderlineOff();
99  void UlBlinkOn(); // Blink+Underline on/off
100  void UlBlinkOff();
101  void ReverseOn(); // Reverse on/off
102  void ReverseOff();
103  void Lightbg(); // High-intensity background
104  void Darkbg(); // Low-intensity background
105  void setDefaultFg(unsigned char u) {defaultfg = u;}
106  void setDefaultBg(unsigned char u) {defaultbg = u;}
107 
108  // Text output routines
109  unsigned long WriteText(const char *pszString, unsigned long cbString);
110  unsigned long WriteString(const char* pszString, unsigned long cbString);
111  unsigned long WriteStringFast(const char *pszString, unsigned long cbString);
112  unsigned long WriteCtrlString(const char* pszString, unsigned long cbString);
113  unsigned long WriteCtrlChar(char c);
114  unsigned long NetWriteString(const char* pszString, unsigned long cbString);
115 
116  // Clear screen/screen area functions
117  void ClearScreen(char c = ' ');
118  void ClearWindow(int start, int end, char c = ' ');
119  void ClearEOScreen(char c = ' ');
120  void ClearBOScreen(char c = ' ');
121  void ClearLine(char c = ' ');
122  void ClearEOLine(char c = ' ');
123  void ClearBOLine(char c = ' ');
124 
125  // Scrolling and text output control functions
126  void SetScroll(int start, int end);
127  void ScrollDown(int iStartRow , int iEndRow, int bUp);
128  void ScrollAll(int bUp) {ScrollDown(iScrollStart, iScrollEnd, bUp);}
129  void index();
130  void reverse_index();
131  void setLineWrap(bool bEnabled){
132  if(!ini.get_lock_linewrap())
133  ini.set_value("Wrap_Line", bEnabled ? "true" : "false");
134  }
135  bool getLineWrap() {return ini.get_wrapline();}
136 
137  // Insert/delete characters/lines
138  void InsertLine(int numlines); // Added by Titus von Boxberg 30/3/97
139  void InsertCharacter(int numchar); // "
140  void DeleteCharacter(int numchar); // "
141  void InsertMode(int i) {insert_mode = i;}
142 
143  // Miscellaneous functions
144  void Beep();
145 
146 protected:
148 
150 
151  unsigned char wAttributes;
152  unsigned char fg, bg;
153  unsigned char defaultfg, defaultbg;
154  unsigned char origfg, origbg;
155 
156  bool blink;
157  bool underline;
158  bool reverse;
159 
163 };
164 
165 // Non-member functions for saving state -- used by the scrollback buffer viewer
166 void saveScreen(CHAR_INFO* chiBuffer);
167 void restoreScreen(CHAR_INFO* chiBuffer);
169 void deleteBuffer(CHAR_INFO* chiBuffer);
unsigned char fg
Definition: tconsole.h:152
void SetBackground(unsigned char wAttrib)
Definition: tconsole.cpp:147
void ClearBOScreen(char c=' ')
Definition: tconsole.cpp:721
GLint GLint GLsizei width
Definition: gl.h:1546
bool set_value(const char *var, const char *value)
Definition: tnconfig.cpp:442
int insert_mode
Definition: tconsole.h:162
bool reverse
Definition: tconsole.h:158
bool get_lock_linewrap() const
Definition: tnconfig.h:54
int iScrollEnd
Definition: tconsole.h:161
void ClearScreen(char c=' ')
Definition: tconsole.cpp:689
void DeleteCharacter(int numchar)
Definition: tconsole.cpp:832
void saveScreen(CHAR_INFO *chiBuffer)
Definition: tconsole.cpp:934
TConsole(HANDLE hConsole)
Definition: tconsole.cpp:56
void sync()
Definition: tconsole.cpp:109
unsigned char defaultfg
Definition: tconsole.h:153
unsigned long WriteCtrlString(const char *pszString, unsigned long cbString)
Definition: tconsole.cpp:542
void UnderlineOn()
Definition: tconsole.cpp:195
void ClearEOLine(char c=' ')
Definition: tconsole.cpp:743
#define CON_LINES
Definition: tconsole.h:53
void SetRawCursorPosition(int x, int y)
Definition: tconsole.cpp:860
GLenum GLclampf GLint GLenum GLuint GLenum GLenum GLsizei GLenum const GLvoid GLfloat GLfloat GLfloat GLfloat GLclampd GLint GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean GLboolean GLboolean GLboolean GLint GLenum GLsizei const GLvoid GLenum GLint GLenum GLint GLint GLsizei GLint GLenum GLint GLint GLint GLint GLsizei GLenum GLsizei const GLuint GLboolean GLenum GLenum GLint GLsizei GLenum GLsizei GLenum const GLvoid GLboolean const GLboolean GLenum const GLdouble * u
Definition: glfuncs.h:88
void LowVideo()
Definition: tconsole.cpp:117
GLuint GLuint end
Definition: gl.h:1545
void Normal()
Definition: tconsole.cpp:121
void index()
Definition: tconsole.cpp:589
void setLineWrap(bool bEnabled)
Definition: tconsole.h:131
INT INT y
Definition: msvc.h:62
unsigned long WriteString(const char *pszString, unsigned long cbString)
Definition: tconsole.cpp:473
GLenum GLclampf GLint i
Definition: glfuncs.h:14
void InsertCharacter(int numchar)
Definition: tconsole.cpp:800
unsigned char GetAttrib()
Definition: tconsole.h:89
void BlinkOff()
Definition: tconsole.cpp:176
int GetRawCursorX()
Definition: tconsole.h:67
void UlBlinkOff()
Definition: tconsole.cpp:247
void setDefaultBg(unsigned char u)
Definition: tconsole.h:106
void Lightbg()
Definition: tconsole.cpp:258
void SetCursorSize(int pct)
Definition: tconsole.cpp:929
void Darkbg()
Definition: tconsole.cpp:284
TConfig ini
Definition: tnconfig.cpp:45
void SetCursorPosition(int x, int y)
Definition: tconsole.cpp:885
int GetCursorY()
Definition: tconsole.h:70
HANDLE hConsole
Definition: tconsole.h:147
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned char origfg
Definition: tconsole.h:154
void MoveCursorPosition(int x, int y)
Definition: tconsole.cpp:907
unsigned long WriteStringFast(const char *pszString, unsigned long cbString)
Definition: tconsole.cpp:350
unsigned char origbg
Definition: tconsole.h:154
void BlinkOn()
Definition: tconsole.cpp:157
void SetForeground(unsigned char wAttrib)
Definition: tconsole.cpp:141
unsigned char defaultbg
Definition: tconsole.h:153
void UlBlinkOn()
Definition: tconsole.cpp:233
void ScrollDown(int iStartRow, int iEndRow, int bUp)
Definition: tconsole.cpp:625
unsigned char bg
Definition: tconsole.h:152
const GLubyte * c
Definition: glext.h:8905
void ClearBOLine(char c=' ')
Definition: tconsole.cpp:754
void ClearWindow(int start, int end, char c=' ')
Definition: tconsole.cpp:699
CHAR_INFO * newBuffer()
Definition: tconsole.cpp:995
void ReverseOn()
Definition: tconsole.cpp:311
bool get_wrapline() const
Definition: tnconfig.h:52
void ClearEOScreen(char c=' ')
Definition: tconsole.cpp:709
#define CON_CUR_X
Definition: tconsole.h:56
int GetWidth()
Definition: tconsole.h:81
unsigned long NetWriteString(const char *pszString, unsigned long cbString)
unsigned long WriteCtrlChar(char c)
Definition: tconsole.cpp:557
void SetAttrib(unsigned char wAttr)
Definition: tconsole.h:88
void SetWindowSize(int width, int height)
Definition: tconsole.cpp:93
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
_In_ BOOL bEnable
Definition: winddi.h:3426
CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
Definition: tconsole.h:149
INT x
Definition: msvc.h:62
GLuint start
Definition: gl.h:1545
unsigned long WriteText(const char *pszString, unsigned long cbString)
Definition: tconsole.cpp:335
void SetExtendedMode(int iFunction, BOOL bEnable)
Definition: tconsole.cpp:911
void deleteBuffer(CHAR_INFO *chiBuffer)
Definition: tconsole.cpp:1004
void ScrollAll(int bUp)
Definition: tconsole.h:128
bool blink
Definition: tconsole.h:156
int iScrollStart
Definition: tconsole.h:160
bool getLineWrap()
Definition: tconsole.h:135
void HighVideo()
Definition: tconsole.cpp:113
int GetCursorX()
Definition: tconsole.h:69
void InsertLine(int numlines)
Definition: tconsole.cpp:768
#define CON_CUR_Y
Definition: tconsole.h:57
int GetRawCursorY()
Definition: tconsole.h:68
unsigned char wAttributes
Definition: tconsole.h:151
bool underline
Definition: tconsole.h:157
void SetScroll(int start, int end)
Definition: tconsole.cpp:917
void reverse_index()
Definition: tconsole.cpp:613
void UnderlineOff()
Definition: tconsole.cpp:214
void ClearLine(char c=' ')
Definition: tconsole.cpp:732
void restoreScreen(CHAR_INFO *chiBuffer)
Definition: tconsole.cpp:964
void ReverseOff()
Definition: tconsole.cpp:328
void Beep()
Definition: tconsole.cpp:922
void InsertMode(int i)
Definition: tconsole.h:141
~TConsole()
Definition: tconsole.cpp:85
void setDefaultFg(unsigned char u)
Definition: tconsole.h:105
#define CON_COLS
Definition: tconsole.h:54
_In_ DWORD _In_ DWORD _Out_writes_to_opt_ pcchString LPSTR pszString
Definition: wincrypt.h:4507
int GetHeight()
Definition: tconsole.h:82