ReactOS 0.4.15-dev-7906-g1b85a5f
TConsole Class Reference

#include <tconsole.h>

Collaboration diagram for TConsole:

Public Member Functions

 TConsole (HANDLE hConsole)
 
 ~TConsole ()
 
void sync ()
 
int GetRawCursorX ()
 
int GetRawCursorY ()
 
int GetCursorX ()
 
int GetCursorY ()
 
void SetRawCursorPosition (int x, int y)
 
void SetCursorPosition (int x, int y)
 
void SetCursorSize (int pct)
 
void MoveCursorPosition (int x, int y)
 
int GetWidth ()
 
int GetHeight ()
 
void SetExtendedMode (int iFunction, BOOL bEnable)
 
void SetWindowSize (int width, int height)
 
void SetAttrib (unsigned char wAttr)
 
unsigned char GetAttrib ()
 
void Normal ()
 
void HighVideo ()
 
void LowVideo ()
 
void SetForeground (unsigned char wAttrib)
 
void SetBackground (unsigned char wAttrib)
 
void BlinkOn ()
 
void BlinkOff ()
 
void UnderlineOn ()
 
void UnderlineOff ()
 
void UlBlinkOn ()
 
void UlBlinkOff ()
 
void ReverseOn ()
 
void ReverseOff ()
 
void Lightbg ()
 
void Darkbg ()
 
void setDefaultFg (unsigned char u)
 
void setDefaultBg (unsigned char u)
 
unsigned long WriteText (const char *pszString, unsigned long cbString)
 
unsigned long WriteString (const char *pszString, unsigned long cbString)
 
unsigned long WriteStringFast (const char *pszString, unsigned long cbString)
 
unsigned long WriteCtrlString (const char *pszString, unsigned long cbString)
 
unsigned long WriteCtrlChar (char c)
 
unsigned long NetWriteString (const char *pszString, unsigned long cbString)
 
void ClearScreen (char c=' ')
 
void ClearWindow (int start, int end, char c=' ')
 
void ClearEOScreen (char c=' ')
 
void ClearBOScreen (char c=' ')
 
void ClearLine (char c=' ')
 
void ClearEOLine (char c=' ')
 
void ClearBOLine (char c=' ')
 
void SetScroll (int start, int end)
 
void ScrollDown (int iStartRow, int iEndRow, int bUp)
 
void ScrollAll (int bUp)
 
void index ()
 
void reverse_index ()
 
void setLineWrap (bool bEnabled)
 
bool getLineWrap ()
 
void InsertLine (int numlines)
 
void InsertCharacter (int numchar)
 
void DeleteCharacter (int numchar)
 
void InsertMode (int i)
 
void Beep ()
 

Protected Attributes

HANDLE hConsole
 
CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
 
unsigned char wAttributes
 
unsigned char fg
 
unsigned char bg
 
unsigned char defaultfg
 
unsigned char defaultbg
 
unsigned char origfg
 
unsigned char origbg
 
bool blink
 
bool underline
 
bool reverse
 
int iScrollStart
 
int iScrollEnd
 
int insert_mode
 

Detailed Description

Definition at line 60 of file tconsole.h.

Constructor & Destructor Documentation

◆ TConsole()

TConsole::TConsole ( HANDLE  hConsole)

Definition at line 56 of file tconsole.cpp.

56 {
57 hConsole = h;
58
60
61 // Start with correct colors
62 int color_fg = ini.get_normal_fg();
63 int color_bg = ini.get_normal_bg();
64 if(color_fg == -1)
65 color_fg = defaultfg = origfg = ConsoleInfo.wAttributes & 0xF;
66 else
67 defaultfg = origfg = color_fg;
68 if(color_bg == -1)
69 color_bg = defaultbg = origbg = (ConsoleInfo.wAttributes >> 4) & 0xF;
70 else
71 defaultbg = origbg = color_bg;
72 wAttributes = color_fg | (color_bg << 4);
73 reverse = blink = underline = false;
75
76 insert_mode = 0;
77
78 // Set the screen size
80
81 iScrollStart = -1;
82 iScrollEnd = -1;
83}
BOOL WINAPI SetConsoleTextAttribute(IN HANDLE hConsoleOutput, IN WORD wAttributes)
Definition: console.c:672
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
Definition: console.c:595
int get_normal_fg() const
Definition: tnconfig.h:72
int get_term_height() const
Definition: tnconfig.h:57
int get_normal_bg() const
Definition: tnconfig.h:71
int get_term_width() const
Definition: tnconfig.h:56
unsigned char defaultbg
Definition: tconsole.h:153
void SetWindowSize(int width, int height)
Definition: tconsole.cpp:93
bool reverse
Definition: tconsole.h:158
bool blink
Definition: tconsole.h:156
unsigned char defaultfg
Definition: tconsole.h:153
bool underline
Definition: tconsole.h:157
unsigned char origfg
Definition: tconsole.h:154
int iScrollEnd
Definition: tconsole.h:161
unsigned char origbg
Definition: tconsole.h:154
HANDLE hConsole
Definition: tconsole.h:147
CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
Definition: tconsole.h:149
int insert_mode
Definition: tconsole.h:162
int iScrollStart
Definition: tconsole.h:160
unsigned char wAttributes
Definition: tconsole.h:151
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
TConfig ini
Definition: tnconfig.cpp:45

◆ ~TConsole()

TConsole::~TConsole ( )

Definition at line 85 of file tconsole.cpp.

85 {
86 wAttributes = origfg | (origbg << 4);
89 WriteCtrlChar('\x0a');
90}
void SetCursorPosition(int x, int y)
Definition: tconsole.cpp:885
unsigned long WriteCtrlChar(char c)
Definition: tconsole.cpp:557
#define CON_HEIGHT
Definition: tconsole.h:51

Member Function Documentation

◆ Beep()

void TConsole::Beep ( )

Definition at line 922 of file tconsole.cpp.

922 {
923 if(ini.get_do_beep()) {
924 if(!ini.get_speaker_beep()) printit("\a");
925 else ::Beep(400, 100);
926 }
927}
bool get_speaker_beep() const
Definition: tnconfig.h:49
bool get_do_beep() const
Definition: tnconfig.h:50
int printit(const char *it)
Definition: tnerror.cpp:58

Referenced by TANSIParser::ParseANSIBuffer(), TANSIParser::ParseEscape(), and TANSIParser::ParseEscapeANSI().

◆ BlinkOff()

void TConsole::BlinkOff ( )

Definition at line 176 of file tconsole.cpp.

176 {
177 blink = 0;
178 if(underline) {
179 UlBlinkOff();
180 } else {
181 if(ini.get_blink_bg() != -1) {
182 wAttributes &= 0x8f; // turn off bg
183 wAttributes |= defaultbg << 4;
184 }
185 if(ini.get_blink_fg() != -1) {
186 wAttributes &= 0xf8; // turn off fg
188 }
189 if(ini.get_blink_bg() == -1 && ini.get_blink_fg() == -1)
190 wAttributes &= 0x7f;
191 }
192}
int get_blink_fg() const
Definition: tnconfig.h:66
int get_blink_bg() const
Definition: tnconfig.h:65
void UlBlinkOff()
Definition: tconsole.cpp:247

Referenced by TANSIParser::ConSetAttribute(), and Normal().

◆ BlinkOn()

void TConsole::BlinkOn ( )

Definition at line 157 of file tconsole.cpp.

157 {
158 blink = 1;
159 if(underline) {
160 UlBlinkOn();
161 } else {
162 if(ini.get_blink_bg() != -1) {
163 wAttributes &= 0x8f; // turn off bg
164 wAttributes |= ini.get_blink_bg() << 4;
165 }
166 if(ini.get_blink_fg() != -1) {
167 wAttributes &= 0xf8; // turn off fg
169 }
170 if(ini.get_blink_bg() == -1 && ini.get_blink_fg() == -1)
171 wAttributes |= 0x80;
172 }
173}
void UlBlinkOn()
Definition: tconsole.cpp:233

Referenced by TANSIParser::ConSetAttribute(), and UlBlinkOff().

◆ ClearBOLine()

void TConsole::ClearBOLine ( char  c = ' ')

Definition at line 754 of file tconsole.cpp.

755{
756 DWORD dwWritten;
757 COORD Coord = {CON_LEFT, CON_TOP + CON_CUR_Y};
759 &dwWritten);
761 Coord, &dwWritten);
763}
BOOL WINAPI FillConsoleOutputAttribute(IN HANDLE hConsoleOutput, IN WORD wAttribute, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfAttrsWritten)
Definition: console.c:525
unsigned long DWORD
Definition: ntddk_ex.h:95
const GLubyte * c
Definition: glext.h:8905
Definition: bl.h:1338
#define CON_TOP
Definition: tconsole.h:45
#define CON_LEFT
Definition: tconsole.h:48
#define CON_CUR_Y
Definition: tconsole.h:57
#define CON_CUR_X
Definition: tconsole.h:56
#define FillConsoleOutputCharacter
Definition: wincon.h:788

Referenced by ClearBOScreen(), and TANSIParser::ParseEscapeANSI().

◆ ClearBOScreen()

void TConsole::ClearBOScreen ( char  c = ' ')

Definition at line 721 of file tconsole.cpp.

722{
723 DWORD dwWritten;
724 COORD Coord = {CON_LEFT, CON_TOP};
726 (DWORD)(CON_CUR_Y), Coord, &dwWritten);
728 (DWORD)(CON_CUR_Y), Coord, &dwWritten);
729 ClearBOLine();
730}
void ClearBOLine(char c=' ')
Definition: tconsole.cpp:754
#define CON_COLS
Definition: tconsole.h:54

Referenced by TANSIParser::ParseEscapeANSI().

◆ ClearEOLine()

void TConsole::ClearEOLine ( char  c = ' ')

Definition at line 743 of file tconsole.cpp.

744{
745 DWORD dwWritten;
748 (DWORD)(CON_RIGHT - CON_CUR_X) +1, Coord, &dwWritten);
750 Coord, &dwWritten);
752}
#define CON_RIGHT
Definition: tconsole.h:49

Referenced by ClearEOScreen(), DeleteCharacter(), InsertCharacter(), TANSIParser::ParseEscape(), and TANSIParser::ParseEscapeANSI().

◆ ClearEOScreen()

void TConsole::ClearEOScreen ( char  c = ' ')

Definition at line 709 of file tconsole.cpp.

710{
711 DWORD dwWritten;
712 COORD Coord = {CON_LEFT, CON_TOP + CON_CUR_Y + 1};
714 (DWORD)(CON_HEIGHT - CON_CUR_Y), Coord, &dwWritten);
716 (DWORD)(CON_LINES - CON_CUR_Y), Coord, &dwWritten);
717 ClearEOLine();
718}
void ClearEOLine(char c=' ')
Definition: tconsole.cpp:743
#define CON_LINES
Definition: tconsole.h:53

Referenced by InsertLine(), TANSIParser::ParseEscape(), and TANSIParser::ParseEscapeANSI().

◆ ClearLine()

void TConsole::ClearLine ( char  c = ' ')

Definition at line 732 of file tconsole.cpp.

733{
734 DWORD dwWritten;
735 COORD Coord = {CON_LEFT, CON_TOP + CON_CUR_Y};
737 Coord, &dwWritten);
739 Coord, &dwWritten);
741}

Referenced by index(), and TANSIParser::ParseEscapeANSI().

◆ ClearScreen()

void TConsole::ClearScreen ( char  c = ' ')

Definition at line 689 of file tconsole.cpp.

689 {
690 DWORD dwWritten;
691 COORD Coord = {CON_LEFT, CON_TOP};
693 (DWORD)(CON_LINES), Coord, &dwWritten);
695 (DWORD)(CON_LINES), Coord, &dwWritten);
696}

Referenced by TANSIParser::ParseANSIBuffer(), TANSIParser::ParseEscape(), TANSIParser::ParseEscapeANSI(), and TANSIParser::ResetTerminal().

◆ ClearWindow()

void TConsole::ClearWindow ( int  start,
int  end,
char  c = ' ' 
)

Definition at line 699 of file tconsole.cpp.

699 {
700 DWORD dwWritten;
701 COORD Coord = {CON_LEFT, CON_TOP + iStartRow};
703 (DWORD)(iEndRow-iStartRow+1), Coord, &dwWritten);
705 (DWORD)(CON_LINES), Coord, &dwWritten);
706}

Referenced by ScrollDown().

◆ Darkbg()

void TConsole::Darkbg ( )

Definition at line 284 of file tconsole.cpp.

284 {
285 WORD *pAttributes = new WORD[CON_COLS];
287
288 // Paul Brannan 8/5/98
289 // Correction: processing more than one line at a time causes a segfault
290 // if the screen width != 80
291 for(int i = CON_TOP; i <= CON_BOTTOM; i++) {
292 COORD Coord = {CON_LEFT, i};
293
295 Coord, &Result);
296
297 for(DWORD j = 0; j < Result; j++) pAttributes[j] &= 0x7f;
298
299 WriteConsoleOutputAttribute(hConsole, pAttributes, Result, Coord,
300 &Result);
301 }
302
303 delete[] pAttributes; // clean up
304
305
306 wAttributes &= (unsigned char)0x7f;
307 bg &= 7;
308}
unsigned char bg
Definition: tconsole.h:152
BOOL WINAPI DECLSPEC_HOTPATCH ReadConsoleOutputAttribute(IN HANDLE hConsoleOutput, OUT LPWORD lpAttribute, IN DWORD nLength, IN COORD dwReadCoord, OUT LPDWORD lpNumberOfAttrsRead)
Definition: readwrite.c:1422
BOOL WINAPI DECLSPEC_HOTPATCH WriteConsoleOutputAttribute(IN HANDLE hConsoleOutput, IN CONST WORD *lpAttribute, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfAttrsWritten)
Definition: readwrite.c:1653
unsigned char
Definition: typeof.h:29
unsigned short WORD
Definition: ntddk_ex.h:93
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define CON_BOTTOM
Definition: tconsole.h:46
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by TANSIParser::ParseEscapeANSI().

◆ DeleteCharacter()

void TConsole::DeleteCharacter ( int  numchar)

Definition at line 832 of file tconsole.cpp.

833{
834 int actx;
836 SMALL_RECT clip;
837 COORD to;
839
840 if ( (actx = GetCursorX()) >= CON_COLS - numchar ) {
841 ClearEOLine();
842 return;
843 } /* IF */
844
845 from.Left = CON_LEFT + (SHORT)actx;
847 from.Right = CON_LEFT + (SHORT)CON_COLS;
848 from.Bottom = CON_TOP + from.Top;
849
850 clip = from;
851 to.X = (SHORT)(actx - numchar);
852 to.Y = from.Top;
853
854 fill.Char.AsciiChar = ' ';
855 fill.Attributes = wAttributes; // WHICH ATTRIBUTES TO TAKE FOR BLANK CHAR ??
856
858} /* DeleteCharacter */
_STLP_MOVE_TO_STD_NAMESPACE void fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val)
Definition: _algobase.h:449
Card Top()
Definition: cardregion.h:94
int GetCursorX()
Definition: tconsole.h:69
int GetCursorY()
Definition: tconsole.h:70
short SHORT
Definition: pedump.c:59
CardRegion * from
Definition: spigame.cpp:19
ULONG Y
Definition: bl.h:1340
ULONG X
Definition: bl.h:1339
#define ScrollConsoleScreenBuffer
Definition: wincon.h:782

Referenced by TANSIParser::ParseEscapeANSI().

◆ GetAttrib()

unsigned char TConsole::GetAttrib ( )
inline

Definition at line 89 of file tconsole.h.

89{return wAttributes;}

Referenced by TANSIParser::ParseEscape().

◆ GetCursorX()

int TConsole::GetCursorX ( )
inline

◆ GetCursorY()

int TConsole::GetCursorY ( )
inline

Definition at line 70 of file tconsole.h.

70 {
71 if(iScrollStart != -1)
72 return CON_CUR_Y - iScrollStart;
73 return GetRawCursorY();
74 }
int GetRawCursorY()
Definition: tconsole.h:68

Referenced by DeleteCharacter(), InsertCharacter(), InsertLine(), TANSIParser::ParseANSIBuffer(), and TANSIParser::ParseEscapeANSI().

◆ GetHeight()

int TConsole::GetHeight ( )
inline

Definition at line 82 of file tconsole.h.

82{return CON_LINES;}

Referenced by TTelnetHandler::ParseIAC().

◆ getLineWrap()

bool TConsole::getLineWrap ( )
inline

Definition at line 135 of file tconsole.h.

135{return ini.get_wrapline();}
bool get_wrapline() const
Definition: tnconfig.h:52

Referenced by WriteString(), and WriteStringFast().

◆ GetRawCursorX()

int TConsole::GetRawCursorX ( )
inline

Definition at line 67 of file tconsole.h.

67{return CON_CUR_X;}

Referenced by TANSIParser::ParseEscape(), and TANSIParser::ParseEscapeANSI().

◆ GetRawCursorY()

int TConsole::GetRawCursorY ( )
inline

Definition at line 68 of file tconsole.h.

68{return CON_CUR_Y;}

Referenced by GetCursorY(), TANSIParser::ParseEscape(), and TANSIParser::ParseEscapeANSI().

◆ GetWidth()

int TConsole::GetWidth ( )
inline

Definition at line 81 of file tconsole.h.

81{return CON_COLS;}

Referenced by TANSIParser::ParseEscapeANSI(), and TTelnetHandler::ParseIAC().

◆ HighVideo()

void TConsole::HighVideo ( )

Definition at line 113 of file tconsole.cpp.

113 {
114 wAttributes = wAttributes | (unsigned char) 8;
115}

Referenced by TANSIParser::ConSetAttribute().

◆ index()

void TConsole::index ( )

Definition at line 589 of file tconsole.cpp.

589 {
590 // if on the last line scroll up
591 // This must work with scrolling (Paul Brannan 5/13/98)
592 if(iScrollEnd != -1 && (signed)CON_CUR_Y >= iScrollEnd) {
594 } else if ((iScrollEnd == -1 && (signed)CON_CUR_Y >= (signed)CON_HEIGHT)) {
596 WriteConsole(hConsole, "\n", 1, &Result, NULL);
597
598 // If we aren't at the bottom of the buffer, then we need to
599 // scroll down (Paul Brannan 4/14/2000)
604 // SetConsoleWindowInfo(hConsole, TRUE, &ConsoleInfo.srWindow);
605 } else {
606 ClearLine();
607 }
608 } else { // else move cursor down to the next line
610 }
611}
void ClearLine(char c=' ')
Definition: tconsole.cpp:732
void ScrollDown(int iStartRow, int iEndRow, int bUp)
Definition: tconsole.cpp:625
#define NULL
Definition: types.h:112
SHORT Y
Definition: blue.h:27
SHORT Top
Definition: blue.h:33
SHORT Bottom
Definition: blue.h:35
#define WriteConsole
Definition: wincon.h:784

Referenced by TANSIParser::ParseEscape(), WriteCtrlChar(), and WriteString().

◆ InsertCharacter()

void TConsole::InsertCharacter ( int  numchar)

Definition at line 800 of file tconsole.cpp.

801{
802 int actx;
804 SMALL_RECT clip;
805 COORD to;
807
808 if ( (actx = GetCursorX()) >= CON_COLS - numchar ) {
809 ClearEOLine();
810 return;
811 } /* IF */
812
813 from.Left = CON_LEFT + (SHORT)actx;
815 from.Right = CON_LEFT + (SHORT)CON_COLS;
816 from.Bottom = CON_TOP + (SHORT)from.Top;
817
818 clip = from;
819 to.X = (SHORT)(actx + numchar);
820 to.Y = from.Top;
821
822 fill.Char.AsciiChar = ' ';
823 fill.Attributes = wAttributes; // WHICH ATTRIBUTES TO TAKE FOR BLANK CHAR ??
824
826} /* InsertCharacter */

Referenced by TANSIParser::ParseEscapeANSI(), and WriteText().

◆ InsertLine()

void TConsole::InsertLine ( int  numlines)

Definition at line 768 of file tconsole.cpp.

769{
770 COORD to;
772 SMALL_RECT clip;
774 int acty;
775
776 // Rest of screen would be deleted
777 if ( (acty = GetCursorY()) >= CON_LINES - numlines ) {
778 ClearEOScreen(); // delete rest of screen
779 return;
780 } /* IF */
781
782 // Else scroll down the part of the screen which is below the
783 // cursor.
784 from.Left = CON_LEFT;
785 from.Top = CON_TOP + (SHORT)acty;
786 from.Right = CON_LEFT + (SHORT)CON_COLS;
787 from.Bottom = CON_TOP + (SHORT)CON_LINES;
788
789 clip = from;
790 to.X = 0;
791 to.Y = (SHORT)(from.Top + numlines);
792
793 fill.Char.AsciiChar = ' ';
794 fill.Attributes = 7; // WHICH ATTRIBUTES TO TAKE FOR BLANK LINE ??
795
797} /* InsertLine */
void ClearEOScreen(char c=' ')
Definition: tconsole.cpp:709

◆ InsertMode()

void TConsole::InsertMode ( int  i)
inline

Definition at line 141 of file tconsole.h.

141{insert_mode = i;}

Referenced by TANSIParser::ParseEscapeANSI().

◆ Lightbg()

void TConsole::Lightbg ( )

Definition at line 258 of file tconsole.cpp.

258 {
259 WORD *pAttributes = new WORD[CON_COLS];
261
262 // Paul Brannan 8/5/98
263 // Correction: processing more than one line at a time causes a segfault
264 // if the screen width != 80
265 for(int i = CON_TOP; i <= CON_BOTTOM; i++) {
266 COORD Coord = {CON_LEFT, i};
267
269 Coord, &Result);
270
271 for(DWORD j = 0; j < Result; j++) pAttributes[j] |= 0x80;
272
273 WriteConsoleOutputAttribute(hConsole, pAttributes, Result, Coord,
274 &Result);
275 }
276
277 delete[] pAttributes; // clean up
278
279 wAttributes |= (unsigned char)0x80;
280 bg |= 8;
281}

Referenced by TANSIParser::ParseEscapeANSI().

◆ LowVideo()

void TConsole::LowVideo ( )

Definition at line 117 of file tconsole.cpp.

117 {
118 wAttributes = wAttributes & (unsigned char) (0xff-8);
119}

Referenced by TANSIParser::ConSetAttribute(), and Normal().

◆ MoveCursorPosition()

void TConsole::MoveCursorPosition ( int  x,
int  y 
)

Definition at line 907 of file tconsole.cpp.

907 {
909}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

Referenced by TANSIParser::ParseEscape(), TANSIParser::ParseEscapeANSI(), and WriteCtrlChar().

◆ NetWriteString()

unsigned long TConsole::NetWriteString ( const char pszString,
unsigned long  cbString 
)

◆ Normal()

void TConsole::Normal ( )

Definition at line 121 of file tconsole.cpp.

121 {
122 // I.Ioannou 11 May 1997
123 // Color 7 is correct on some systems (for example Linux)
124 // but not with others (for example SCO)
125 // we must preserve the colors :
126 // 06/04/98 thanks to Paul a .ini parameter from now on
127
128 BlinkOff();
129 UnderlineOff();
131 ReverseOff();
132 LowVideo();
133 } else {
134 fg = defaultfg;
135 bg = defaultbg;
136 wAttributes = (unsigned char)fg | (bg << 4);
137 reverse = false;
138 }
139}
bool get_preserve_colors() const
Definition: tnconfig.h:51
void LowVideo()
Definition: tconsole.cpp:117
unsigned char fg
Definition: tconsole.h:152
void UnderlineOff()
Definition: tconsole.cpp:214
void BlinkOff()
Definition: tconsole.cpp:176
void ReverseOff()
Definition: tconsole.cpp:328

Referenced by TANSIParser::ConSetAttribute(), TANSIParser::Init(), TANSIParser::ParseEscapeANSI(), and UlBlinkOff().

◆ reverse_index()

void TConsole::reverse_index ( )

Definition at line 613 of file tconsole.cpp.

613 {
614 // if on the top line scroll down
615 // This must work with scrolling (Paul Brannan 5/13/98)
616 // We should be comparing against iScrollStart, not iScrollEnd (PB 12/2/98)
617 if (iScrollStart == -1 && (signed)CON_CUR_Y <= 0) {
618 ScrollDown(iScrollStart, -1, 1);
619 } else if (iScrollStart != -1 && (signed)CON_CUR_Y <= iScrollStart) {
621 } else // else move cursor up to the previous line
623}

Referenced by TANSIParser::ParseEscape().

◆ ReverseOff()

void TConsole::ReverseOff ( )

Definition at line 328 of file tconsole.cpp.

328 {
329 if (reverse) {
330 reverse = false;
331 wAttributes = fg | (bg << 4);
332 }
333}

Referenced by TANSIParser::ConSetAttribute(), and Normal().

◆ ReverseOn()

void TConsole::ReverseOn ( )

Definition at line 311 of file tconsole.cpp.

311 {
312 if (!reverse) {
313 reverse = true;
314
315 // atl : forground attributes without the intensity
316 // ath : backgound attributes without the blink
317 // bl : the blink state
318 // ints : the intensity
319 unsigned char atl = wAttributes & (unsigned char) 0x07;
320 unsigned char ath = wAttributes & (unsigned char) 0x70;
321 unsigned char bl = wAttributes & (unsigned char) 0x80;
322 unsigned char ints = wAttributes & (unsigned char) 0x08;
323 wAttributes = bl | (atl << 4) | ints | (ath >> 4);
324 }
325}
static const struct encodedInt ints[]
Definition: encode.c:48

Referenced by TANSIParser::ConSetAttribute().

◆ ScrollAll()

void TConsole::ScrollAll ( int  bUp)
inline

Definition at line 128 of file tconsole.h.

◆ ScrollDown()

void TConsole::ScrollDown ( int  iStartRow,
int  iEndRow,
int  bUp 
)

Definition at line 625 of file tconsole.cpp.

625 {
626 CHAR_INFO ciChar;
627 SMALL_RECT srScrollWindow;
628
629 // Correction from I.Ioannou 11 May 1997
630 // check the scroll region
631 if (iStartRow < iScrollStart) iStartRow = iScrollStart;
632
633 // Correction from I.Ioannou 11 May 1997
634 // this will make Top the CON_TOP
635 if ( iStartRow == -1) iStartRow = 0;
636
637 // Correction from I.Ioannou 18 Aug 97
638 if ( iEndRow == -1) {
639 if ( iScrollEnd == -1 )
640 iEndRow = CON_HEIGHT;
641 else
642 iEndRow = ((CON_HEIGHT <= iScrollEnd) ? CON_HEIGHT : iScrollEnd);
643 }
644 //
645
646 if ( iStartRow > CON_HEIGHT) iStartRow = CON_HEIGHT;
647 if ( iEndRow > CON_HEIGHT) iEndRow = CON_HEIGHT;
648
649 srScrollWindow.Left = (CON_LEFT);
650 srScrollWindow.Right = (SHORT) (CON_RIGHT);
651 srScrollWindow.Top = (SHORT) (CON_TOP + iStartRow );
652 srScrollWindow.Bottom = (SHORT) (CON_TOP + iEndRow); // don't subtract 1 (PB 5/28)
653
654 ciChar.Char.AsciiChar = ' '; // fill with spaces
655 ciChar.Attributes = wAttributes; // fill with current attrib
656
657 // This should speed things up (Paul Brannan 9/2/98)
658 COORD dwDestOrg = {srScrollWindow.Left, srScrollWindow.Top + bUp};
659
660 // Note that iEndRow and iStartRow had better not be equal to -1 at this
661 // point. There are four cases to consider for out of bounds. Two of
662 // these cause the scroll window to be cleared; the others cause the
663 // scroll region to be modified. (Paul Brannan 12/3/98)
664 if(dwDestOrg.Y > CON_TOP + iEndRow) {
665 // We are scrolling past the end of the scroll region, so just
666 // clear the window instead (Paul Brannan 12/3/98)
667 ClearWindow(CON_TOP + iStartRow, CON_TOP + iEndRow);
668 return;
669 } else if(dwDestOrg.Y + (iEndRow-iStartRow+1) < CON_TOP + iStartRow) {
670 // We are scrolling past the end of the scroll region, so just
671 // clear the window instead (Paul Brannan 12/3/98)
672 ClearWindow(CON_TOP + iStartRow, CON_TOP + iEndRow);
673 return;
674 } else if(dwDestOrg.Y < CON_TOP + iStartRow) {
675 // Modify the scroll region (Paul Brannan 12/3/98)
676 dwDestOrg.Y = CON_TOP + iStartRow;
677 srScrollWindow.Top -= bUp;
678 } else if(dwDestOrg.Y + (iEndRow-iStartRow+1) > CON_TOP + iEndRow) {
679 // Modify the scroll region (Paul Brannan 12/3/98)
680 srScrollWindow.Bottom -= bUp;
681 }
682
683 ScrollConsoleScreenBuffer(hConsole, &srScrollWindow,
684 0, dwDestOrg, &ciChar);
685}
void ClearWindow(int start, int end, char c=' ')
Definition: tconsole.cpp:699
CHAR AsciiChar
Definition: wincon.h:185
WORD Attributes
Definition: wincon.h:187
union _CHAR_INFO::@3290 Char
SHORT Top
Definition: tui.c:25
SHORT Right
Definition: tui.c:26
SHORT Left
Definition: tui.c:24
SHORT Bottom
Definition: tui.c:27

Referenced by index(), TANSIParser::ParseEscapeANSI(), reverse_index(), and ScrollAll().

◆ SetAttrib()

void TConsole::SetAttrib ( unsigned char  wAttr)
inline

Definition at line 88 of file tconsole.h.

88{wAttributes = wAttr;}

Referenced by TANSIParser::ParseEscape().

◆ SetBackground()

void TConsole::SetBackground ( unsigned char  wAttrib)

Definition at line 147 of file tconsole.cpp.

147 {
148 if(reverse) fg = wAttrib; else bg = wAttrib;
149 wAttributes = (wAttributes & (unsigned char)0x88) |
150 (unsigned char)fg | (bg << 4);
151}

Referenced by TANSIParser::ConSetAttribute().

◆ SetCursorPosition()

void TConsole::SetCursorPosition ( int  x,
int  y 
)

Definition at line 885 of file tconsole.cpp.

885 {
886 if (x > CON_WIDTH) x = CON_WIDTH;
887 if (x < 0) x = 0;
888 if(iScrollEnd != -1) {
889 if(y > iScrollEnd) y = iScrollEnd;
890 } else {
891 if(y > CON_HEIGHT) y = CON_HEIGHT;
892 }
893 if(iScrollStart != -1) {
895 } else {
896 if(y < 0) y = 0;
897 }
898
899 COORD Coord = {(short)(CON_LEFT + x), (short)(CON_TOP + y)};
901
902 // Update the ConsoleInfo struct
905}
BOOL WINAPI SetConsoleCursorPosition(IN HANDLE hConsoleOutput, IN COORD dwCursorPosition)
Definition: console.c:641
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
SHORT X
Definition: blue.h:26
#define CON_WIDTH
Definition: tconsole.h:52

Referenced by TANSIParser::ConSetCursorPos(), index(), MoveCursorPosition(), TANSIParser::ParseANSIBuffer(), TANSIParser::ParseEscapeANSI(), reverse_index(), WriteCtrlChar(), and ~TConsole().

◆ SetCursorSize()

void TConsole::SetCursorSize ( int  pct)

Definition at line 929 of file tconsole.cpp.

929 {
930 CONSOLE_CURSOR_INFO ci = {(pct != 0)?pct:1, pct != 0};
932}
BOOL WINAPI SetConsoleCursorInfo(IN HANDLE hConsoleOutput, IN const CONSOLE_CURSOR_INFO *lpConsoleCursorInfo)
Definition: console.c:618

Referenced by TANSIParser::ParseEscapeANSI().

◆ setDefaultBg()

void TConsole::setDefaultBg ( unsigned char  u)
inline

Definition at line 106 of file tconsole.h.

106{defaultbg = u;}
GLsizei GLenum const GLvoid GLsizei GLenum 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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240

Referenced by TANSIParser::ParseEscapeANSI().

◆ setDefaultFg()

void TConsole::setDefaultFg ( unsigned char  u)
inline

Definition at line 105 of file tconsole.h.

105{defaultfg = u;}

Referenced by TANSIParser::ParseEscapeANSI().

◆ SetExtendedMode()

void TConsole::SetExtendedMode ( int  iFunction,
BOOL  bEnable 
)

Definition at line 911 of file tconsole.cpp.

912{
913 // Probably should do something here...
914 // Should change the screen mode, but do we need this?
915}

◆ SetForeground()

void TConsole::SetForeground ( unsigned char  wAttrib)

Definition at line 141 of file tconsole.cpp.

141 {
142 if(reverse) bg = wAttrib; else fg = wAttrib;
143 wAttributes = (wAttributes & (unsigned char)0x88) |
144 (unsigned char)fg | (bg << 4);
145}

Referenced by TANSIParser::ConSetAttribute().

◆ setLineWrap()

void TConsole::setLineWrap ( bool  bEnabled)
inline

Definition at line 131 of file tconsole.h.

131 {
133 ini.set_value("Wrap_Line", bEnabled ? "true" : "false");
134 }
bool get_lock_linewrap() const
Definition: tnconfig.h:54
bool set_value(const char *var, const char *value)
Definition: tnconfig.cpp:442

Referenced by TANSIParser::ParseEscapeANSI().

◆ SetRawCursorPosition()

void TConsole::SetRawCursorPosition ( int  x,
int  y 
)

Definition at line 860 of file tconsole.cpp.

860 {
861 if (x > CON_WIDTH) x = CON_WIDTH;
862 if (x < 0) x = 0;
863 if (y > CON_HEIGHT) y = CON_HEIGHT;
864 if (y < 0) y = 0;
865 COORD Coord = {(short)(CON_LEFT + x), (short)(CON_TOP + y)};
867
868 // Update the ConsoleInfo struct (Paul Brannan 5/9/98)
871
872 // bug fix in case we went too far (Paul Brannan 5/25/98)
881}

Referenced by TANSIParser::ConSetCursorPos(), TANSIParser::ParseANSIBuffer(), TANSIParser::ParseEscape(), TANSIParser::ParseEscapeANSI(), and TANSIParser::ResetTerminal().

◆ SetScroll()

void TConsole::SetScroll ( int  start,
int  end 
)

Definition at line 917 of file tconsole.cpp.

917 {
919 iScrollEnd = end;
920}
GLuint start
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545

Referenced by TANSIParser::Init(), and TANSIParser::ParseEscapeANSI().

◆ SetWindowSize()

void TConsole::SetWindowSize ( int  width,
int  height 
)

Definition at line 93 of file tconsole.cpp.

93 {
94 SMALL_RECT sr = {
96 CON_TOP,
97 (width == -1) ? CON_RIGHT : CON_LEFT + width - 1,
98 (height == -1) ? CON_BOTTOM : CON_TOP + height - 1
99 };
105 sync();
106}
void sync()
Definition: tconsole.cpp:109
#define TRUE
Definition: types.h:120
BOOL WINAPI SetConsoleWindowInfo(HANDLE hConsoleOutput, BOOL bAbsolute, CONST SMALL_RECT *lpConsoleWindow)
Definition: console.c:1970
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleScreenBufferSize(HANDLE hConsoleOutput, COORD dwSize)
Definition: console.c:1855
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546

Referenced by TANSIParser::ParseEscapeANSI(), and TConsole().

◆ sync()

void TConsole::sync ( )

◆ UlBlinkOff()

void TConsole::UlBlinkOff ( )

Definition at line 247 of file tconsole.cpp.

247 {
248 if(blink) {
249 BlinkOn();
250 } else if(underline) {
251 UnderlineOn();
252 } else {
253 Normal();
254 }
255}
void Normal()
Definition: tconsole.cpp:121
void UnderlineOn()
Definition: tconsole.cpp:195
void BlinkOn()
Definition: tconsole.cpp:157

Referenced by BlinkOff(), and UnderlineOff().

◆ UlBlinkOn()

void TConsole::UlBlinkOn ( )

Definition at line 233 of file tconsole.cpp.

233 {
234 if(ini.get_ulblink_bg() != -1) {
235 wAttributes &= 0x8f; // turn off bg
237 }
238 if(ini.get_ulblink_fg() != -1) {
239 wAttributes &= 0xf8; // turn off fg
241 }
242 if(ini.get_ulblink_bg() == -1 && ini.get_ulblink_fg() == -1)
243 wAttributes |= 0x80;
244}
int get_ulblink_fg() const
Definition: tnconfig.h:70
int get_ulblink_bg() const
Definition: tnconfig.h:69

Referenced by BlinkOn(), and UnderlineOn().

◆ UnderlineOff()

void TConsole::UnderlineOff ( )

Definition at line 214 of file tconsole.cpp.

214 {
215 underline = 0;
216 if(blink) {
217 UlBlinkOff();
218 } else {
219 if(ini.get_blink_bg() != -1) {
220 wAttributes &= 0x8f; // turn off bg
221 wAttributes |= defaultbg << 4;
222 }
223 if(ini.get_blink_fg() != -1) {
224 wAttributes &= 0xf8; // turn off fg
226 }
227 if(ini.get_blink_bg() == -1 && ini.get_blink_fg() == -1)
228 wAttributes &= 0x7f;
229 }
230}

Referenced by TANSIParser::ConSetAttribute(), and Normal().

◆ UnderlineOn()

void TConsole::UnderlineOn ( )

Definition at line 195 of file tconsole.cpp.

195 {
196 underline = 1;
197 if(blink) {
198 UlBlinkOn();
199 } else {
200 if(ini.get_underline_bg() != -1) {
201 wAttributes &= 0x8f; // turn off bg
203 }
204 if(ini.get_underline_fg() != -1) {
205 wAttributes &= 0xf8; // turn off fg
207 }
208 if(ini.get_underline_bg() == -1 && ini.get_underline_fg() == -1)
209 wAttributes |= 0x80;
210 }
211}
int get_underline_bg() const
Definition: tnconfig.h:67
int get_underline_fg() const
Definition: tnconfig.h:68

Referenced by TANSIParser::ConSetAttribute(), and UlBlinkOff().

◆ WriteCtrlChar()

unsigned long TConsole::WriteCtrlChar ( char  c)

Definition at line 557 of file tconsole.cpp.

557 {
558 // The console does not handel the CR/LF chars as we might expect
559 // when using color. The attributes are not set correctly, so we
560 // must interpret them manualy to preserve the colors on the screen.
561
562 unsigned long Result = 0; // just in case (Paul Brannan 6/26/98)
563 switch (c) {
564 case '\x09': // horizontal tab
566 Result = 1;
567 break;
568
569 case '\x0a': // line feed
570 index();
571 Result = 1;
572 break;
573 case '\x0d': // carrage return
574 SetCursorPosition(CON_LEFT, CON_CUR_Y); // move to beginning of line
575 Result = 1;
576 break;
577 case '\b': // backspace
578 // Added support for backspace so the cursor position can be changed
579 // (Paul Brannan 5/25/98)
580 MoveCursorPosition(-1, 0);
581 Result = 1;
582 default : // else just write it like normal
583 break;
584 }
585
586 return Result;
587}
void index()
Definition: tconsole.cpp:589
void MoveCursorPosition(int x, int y)
Definition: tconsole.cpp:907

Referenced by TANSIParser::ParseANSIBuffer(), TANSIParser::ParseEscapeANSI(), WriteCtrlString(), and ~TConsole().

◆ WriteCtrlString()

unsigned long TConsole::WriteCtrlString ( const char pszString,
unsigned long  cbString 
)

Definition at line 542 of file tconsole.cpp.

542 {
543 unsigned long total = 0;
544 while(total < cbString) {
545 unsigned long Result = WriteCtrlChar(*(pszString + total));
546 if(Result == 0) {
548 if(Result == 0) return total;
549 }
550 total += Result;
551 }
552 return total;
553}
unsigned long WriteStringFast(const char *pszString, unsigned long cbString)
Definition: tconsole.cpp:350
size_t total
_In_ DWORD _In_ DWORD _Out_writes_to_opt_ pcchString LPSTR pszString
Definition: wincrypt.h:4505

Referenced by TANSIParser::ParseEscape().

◆ WriteString()

unsigned long TConsole::WriteString ( const char pszString,
unsigned long  cbString 
)

Definition at line 473 of file tconsole.cpp.

473 {
474 DWORD Result = 0;
475
477
478 //check to see if the line is longer than the display
479 if (!getLineWrap()){
480 unsigned long iFakeResult = cbString;
481 if((CON_CUR_X + cbString) >= (unsigned int)CON_COLS)
482 cbString = CON_COLS - CON_CUR_X;
483 if(cbString > 0)
484 Result = WriteText(pszString, cbString);
485
486 // We need to update the ConsoleInfo struct now (Paul Brannan 5/9/98)
489
490 return iFakeResult; // Skip the chars that did not fit
491 } else {
492 // Write up to the end of the line
493 unsigned long temp = cbString;
494 if((CON_CUR_X + temp) > (unsigned int)CON_COLS) {
496 } else {
500 return Result;
501 }
502 if(temp > 0) {
505 temp = (unsigned short)Result;
506 }
507
508 // keep writing lines until we get to less than 80 chars left
509 while((temp + (unsigned int)CON_COLS) < cbString) {
510 index(); // LF
513 temp += (unsigned short)Result;
514 }
515
516 // write out the last bit
517 if(temp < cbString) {
518 index();
520 Result = WriteText(&pszString[temp], cbString - temp);
521 temp += (unsigned short)Result;
522 }
523
524 // Apparently VT100 terminals have an invisible "81st" column that
525 // can hold a cursor until another character is printed. I'm not sure
526 // exactly how to handle this, but here's a hack (Paul Brannan 5/28/98)
528 == (unsigned int)CON_COLS) {
529 index();
531 }
532
534
535 return temp;
536 }
537
538 return 0;
539}
bool get_vt100_mode() const
Definition: tnconfig.h:47
bool getLineWrap()
Definition: tconsole.h:135
unsigned long WriteText(const char *pszString, unsigned long cbString)
Definition: tconsole.cpp:335
static unsigned(__cdecl *hash_bstr)(bstr_t s)
static calc_node_t temp
Definition: rpn_ieee.c:38

Referenced by TANSIParser::ParseANSIBuffer(), TANSIParser::ParseEscapeANSI(), and WriteStringFast().

◆ WriteStringFast()

unsigned long TConsole::WriteStringFast ( const char pszString,
unsigned long  cbString 
)

Definition at line 350 of file tconsole.cpp.

350 {
352
354
355 //check to see if the line is longer than the display
356 if (!getLineWrap() && ((unsigned)CON_CUR_X + cbString) >= (unsigned)CON_COLS) {
357 // Take care of the last line last colum exception...
358 // The display scrolls up if you use the normal char out
359 // function even if you only write to the last place
360 // on the line. :-(
361 if ((unsigned)CON_CUR_Y >= (unsigned)CON_HEIGHT) {
362 unsigned long iFakeResult = cbString;
363 cbString = CON_COLS - CON_CUR_X - 1;
364
365 // FIX ME !!! This will avoid the exception when cbString
366 // is <= 0 but still doesn't work :-(
367 if (cbString > 0)
368 WriteConsole(hConsole, pszString, cbString, &Result, 0);
369
370 COORD dwBufferCoord;
371 dwBufferCoord.X = 0;
372 dwBufferCoord.Y = 0;
373
374 CHAR_INFO ciBuffer;
375 ciBuffer.Char.AsciiChar = *(pszString+cbString);
376 ciBuffer.Attributes = wAttributes;
377 SMALL_RECT srWriteRegion;
378 srWriteRegion.Top = (SHORT) CON_BOTTOM;
379 srWriteRegion.Bottom = (SHORT) CON_BOTTOM;
380 srWriteRegion.Left = (SHORT) CON_RIGHT;
381 srWriteRegion.Right = (SHORT) CON_RIGHT;
382
383 COORD bufSize = {1,1};
384
386 dwBufferCoord, &srWriteRegion);
387
388 // We need to update the ConsoleInfo struct now (Paul Brannan 5/9/98)
390
391 return iFakeResult; // Skip the chars that did not fit
392 }
393 // just write the line up to the end
394 else {
395 int iFakeResult = cbString;
396 cbString = CON_COLS - CON_CUR_X;
397
398 if(cbString > 0) {
399 WriteConsole(hConsole, pszString, cbString, &Result, 0);
400
401 // We need to update the ConsoleInfo struct now (Paul Brannan 5/9/98)
403 }
404
405 return iFakeResult; // Skip the chars that did not fit
406 }
407 } else {
408 // If custom scrolling is enabled we must take care of it
409 if(iScrollStart != -1 || iScrollEnd != -1) {
410 return WriteString(pszString, cbString);
411 }
412
413 // Apparently VT100 terminals have an invisible "81st" column that
414 // can hold a cursor until another character is printed. I'm not sure
415 // exactly how to handle this, but here's a hack (Paul Brannan 5/28/98)
416 if(ini.get_vt100_mode() && cbString + (unsigned)CON_CUR_X == (unsigned)CON_COLS) {
417
418 cbString--;
419 if((long)cbString >= 0) WriteConsole(hConsole, pszString, cbString, &Result, 0);
420
421 COORD dwBufferCoord;
422 dwBufferCoord.X = 0;
423 dwBufferCoord.Y = 0;
424
425 CHAR_INFO ciBuffer;
426 ciBuffer.Char.AsciiChar = *(pszString+cbString);
427 ciBuffer.Attributes = wAttributes;
428 SMALL_RECT srWriteRegion;
429 srWriteRegion.Top = (SHORT) ConsoleInfo.dwCursorPosition.Y;
430 srWriteRegion.Bottom = (SHORT) ConsoleInfo.dwCursorPosition.Y;
431 srWriteRegion.Left = (SHORT) CON_RIGHT;
432 srWriteRegion.Right = (SHORT) CON_RIGHT;
433
434 COORD bufSize = {1,1};
435
437 dwBufferCoord, &srWriteRegion);
438
439 // Update the ConsoleInfo struct
441
442 return Result + 1;
443 }
444
445 // normal line will wrap normally or not to the end of buffer
446 WriteConsole(hConsole, pszString, cbString, &Result, 0);
447
448 // We need to update the ConsoleInfo struct now (Paul Brannan 5/9/98)
449 // FIX ME!!! This is susceptible to the same problem as above.
450 // (e.g. we write out 160 characters)
452 while(CON_CUR_X > CON_WIDTH) {
454 if((unsigned)CON_CUR_Y < (unsigned)CON_HEIGHT) {
456 } else {
457 // If we aren't at the bottom of the window, then we need to
458 // scroll down (Paul Brannan 4/14/2000)
464 }
465 }
466 }
467 }
468
469 return Result;
470
471}
unsigned long WriteString(const char *pszString, unsigned long cbString)
Definition: tconsole.cpp:473
GLuint GLsizei bufSize
Definition: glext.h:6040
#define WriteConsoleOutput
Definition: wincon.h:787

Referenced by TANSIParser::ParseANSIBuffer(), TANSIParser::ParseEscapeANSI(), and WriteCtrlString().

◆ WriteText()

unsigned long TConsole::WriteText ( const char pszString,
unsigned long  cbString 
)

Definition at line 335 of file tconsole.cpp.

335 {
337
338 if(insert_mode) {
339 InsertCharacter(cbString);
340 }
341
346 return Result;
347}
void InsertCharacter(int numchar)
Definition: tconsole.cpp:800
#define WriteConsoleOutputCharacter
Definition: wincon.h:789

Referenced by WriteString().

Member Data Documentation

◆ bg

unsigned char TConsole::bg
protected

Definition at line 152 of file tconsole.h.

Referenced by Darkbg(), Lightbg(), Normal(), ReverseOff(), SetBackground(), and SetForeground().

◆ blink

bool TConsole::blink
protected

Definition at line 156 of file tconsole.h.

Referenced by BlinkOff(), BlinkOn(), TConsole(), UlBlinkOff(), UnderlineOff(), and UnderlineOn().

◆ ConsoleInfo

◆ defaultbg

unsigned char TConsole::defaultbg
protected

Definition at line 153 of file tconsole.h.

Referenced by BlinkOff(), Normal(), setDefaultBg(), TConsole(), and UnderlineOff().

◆ defaultfg

unsigned char TConsole::defaultfg
protected

Definition at line 153 of file tconsole.h.

Referenced by BlinkOff(), Normal(), setDefaultFg(), TConsole(), and UnderlineOff().

◆ fg

unsigned char TConsole::fg
protected

Definition at line 152 of file tconsole.h.

Referenced by Normal(), ReverseOff(), SetBackground(), and SetForeground().

◆ hConsole

◆ insert_mode

int TConsole::insert_mode
protected

Definition at line 162 of file tconsole.h.

Referenced by InsertMode(), TConsole(), and WriteText().

◆ iScrollEnd

int TConsole::iScrollEnd
protected

◆ iScrollStart

int TConsole::iScrollStart
protected

◆ origbg

unsigned char TConsole::origbg
protected

Definition at line 154 of file tconsole.h.

Referenced by TConsole(), and ~TConsole().

◆ origfg

unsigned char TConsole::origfg
protected

Definition at line 154 of file tconsole.h.

Referenced by TConsole(), and ~TConsole().

◆ reverse

bool TConsole::reverse
protected

Definition at line 158 of file tconsole.h.

Referenced by Normal(), ReverseOff(), ReverseOn(), SetBackground(), SetForeground(), and TConsole().

◆ underline

bool TConsole::underline
protected

Definition at line 157 of file tconsole.h.

Referenced by BlinkOff(), BlinkOn(), TConsole(), UlBlinkOff(), UnderlineOff(), and UnderlineOn().

◆ wAttributes


The documentation for this class was generated from the following files: