ReactOS 0.4.16-dev-257-g6aa11ac
TANSIParser Class Reference

#include <ansiprsr.h>

Inheritance diagram for TANSIParser:
Collaboration diagram for TANSIParser:

Public Member Functions

 TANSIParser (TConsole &Console, KeyTranslator &RefKeyTrans, TScroller &RefScroller, TNetwork &NetHandler, TCharmap &RefCharmap)
 
 ~TANSIParser ()
 
charParseBuffer (char *pszBuffer, char *pszBufferEnd)
 
- Public Member Functions inherited from TParser
 TParser (TConsole &RefConsole, KeyTranslator &RefKeyTrans, TScroller &RefScroller, TNetwork &RefNetwork, TCharmap &RefCharmap)
 
virtual ~TParser ()
 
virtual charParseBuffer (char *pszBuffer, char *pszBufferEnd)=0
 
virtual void Init ()=0
 

Static Public Member Functions

static int StripBuffer (char *pszBuffer, char *pszBufferEnd, int width)
 

Private Member Functions

charParseEscapeANSI (char *pszBuffer, char *pszBufferEnd)
 
charParseANSIBuffer (char *pszBuffer, char *pszBufferEnd)
 
charParseEscape (char *pszBuffer, char *pszBufferEnd)
 
charPrintBuffer (char *pszBuffer, char *pszBufferEnd)
 
charPrintGoodChars (char *pszHead, char *pszTail)
 
charParseEscapeMTE (char *pszBuffer, char *pszBufferEnd)
 
void ConSetAttribute (unsigned char wAttr)
 
const charGetTerminalID ()
 
void ConSetCursorPos (int x, int y)
 
void ResetTerminal ()
 
void Init ()
 
void SaveCurX (int iX)
 
void SaveCurY (int iY)
 
void resetTabStops ()
 

Private Attributes

short int mteRegionXF
 
short int mteRegionYF
 
int iSavedCurX
 
int iSavedCurY
 
unsigned char iSavedAttributes
 
FILEdumpfile
 
FILEprintfile
 
char InPrintMode
 
int inGraphMode
 
char last_char
 
char map_G0
 
char map_G1
 
int current_map
 
bool vt52_mode
 
bool print_ctrl
 
bool ignore_margins
 
bool fast_write
 
bool newline_mode
 
int tab_stops [MAX_TAB_POSITIONS]
 

Additional Inherited Members

- Protected Attributes inherited from TParser
TConsoleConsole
 
KeyTranslatorKeyTrans
 
TScrollerScroller
 
TNetworkNetwork
 
TCharmapCharmap
 

Detailed Description

Definition at line 19 of file ansiprsr.h.

Constructor & Destructor Documentation

◆ TANSIParser()

TANSIParser::TANSIParser ( TConsole Console,
KeyTranslator RefKeyTrans,
TScroller RefScroller,
TNetwork NetHandler,
TCharmap RefCharmap 
)

Definition at line 58 of file ansiprsr.cpp.

60 :
61TParser(RefConsole, RefKeyTrans, RefScroller, RefNetwork, RefCharmap) {
62 Init();
63 iSavedAttributes = (unsigned char) 7;
64 // must also check to make sure the string is non-NULL
65 // (Paul Brannan 5/8/98)
66 if ((ini.get_dumpfile() != NULL) && (*ini.get_dumpfile() != '\0')){
67 dumpfile = fopen(ini.get_dumpfile(), "wb");
68 }else {
69 dumpfile = NULL;
70 }
71 InPrintMode = 0;
73
74 fast_write = ini.get_fast_write(); // Paul Brannan 6/28/98
76}
bool fast_write
Definition: ansiprsr.h:62
void Init()
Definition: ansiprsr.cpp:86
FILE * printfile
Definition: ansiprsr.h:51
static int StripBuffer(char *pszBuffer, char *pszBufferEnd, int width)
Definition: ansiprsr.cpp:1164
unsigned char iSavedAttributes
Definition: ansiprsr.h:47
char InPrintMode
Definition: ansiprsr.h:52
FILE * dumpfile
Definition: ansiprsr.h:48
const char * get_dumpfile() const
Definition: tnconfig.h:36
bool get_fast_write() const
Definition: tnconfig.h:53
TScroller & Scroller
Definition: tparser.h:43
void init(stripfunc *s)
Definition: tscroll.cpp:72
#define NULL
Definition: types.h:112
unsigned char
Definition: typeof.h:29
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
TConfig ini
Definition: tnconfig.cpp:45

◆ ~TANSIParser()

TANSIParser::~TANSIParser ( )

Definition at line 78 of file ansiprsr.cpp.

78 {
80 // Added I.Ioannou 06 April, 1997
82}
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)

Member Function Documentation

◆ ConSetAttribute()

void TANSIParser::ConSetAttribute ( unsigned char  wAttr)
private

Definition at line 128 of file ansiprsr.cpp.

128 {
129 // Paul Brannan 5/8/98
130 // Made this go a little bit faster by changing from switch{} to an array
131 // for the colors
132 if(TextAttrib >= 30) {
133 if(TextAttrib <= 37) {
134 Console.SetForeground(ANSIColors[TextAttrib-30]);
135 return;
136 } else if((TextAttrib >= 40) && (TextAttrib <= 47)) {
137 Console.SetBackground(ANSIColors[TextAttrib-40]);
138 return;
139 }
140 }
141
142 switch (TextAttrib){
143 // Text Attributes
144 case 0: Console.Normal(); break; // Normal video
145 case 1: Console.HighVideo(); break; // High video
146 case 2: Console.LowVideo(); break; // Low video
147 case 4: Console.UnderlineOn(); break; // Underline on (I.Ioannou)
148 case 5: Console.BlinkOn(); break; // Blink video
149 // Corrected by I.Ioannou 11 May, 1997
150 case 7: Console.ReverseOn(); break; // Reverse video
151 case 8: break; // hidden
152 // All from 10 thru 27 are hacked from linux kernel
153 // I.Ioannou 06 April, 1997
154 case 10:
155 // I.Ioannou 04 Sep 1997 turn on/off high bit
156 inGraphMode = 0;
157 print_ctrl = 0;
158 Charmap.setmap(current_map ? map_G1:map_G0); // Paul Brannan 6/25/98
159 break; // ANSI X3.64-1979 (SCO-ish?)
160 // Select primary font,
161 // don't display control chars
162 // if defined, don't set
163 // bit 8 on output (normal)
164 case 11:
165 inGraphMode = 0;
166 print_ctrl = 1;
167 Charmap.setmap(0); // Paul Brannan 6/25/98
168 break; // ANSI X3.64-1979 (SCO-ish?)
169 // Select first alternate font,
170 // let chars < 32 be displayed
171 // as ROM chars
172 case 12:
173 inGraphMode = 1;
174 print_ctrl = 1;
175 Charmap.setmap(0); // Paul Brannan 6/25/98
176 break; // ANSI X3.64-1979 (SCO-ish?)
177 // Select second alternate font,
178 // toggle high bit before
179 // displaying as ROM char.
180
181 case 21: // not really Low video
182 case 22: Console.LowVideo(); break; // but this works good also
183 case 24: Console.UnderlineOff(); break; // Underline off
184 case 25: Console.BlinkOff(); break; // blink off
185 // Corrected by I.Ioannou 11 May, 1997
186 case 27: Console.ReverseOff(); break; //Reverse video off
187
188 // Mutt needs this (Paul Brannan, Peter Jordan 12/31/98)
189 // This is from the Linux kernel source
190 case 38: /* ANSI X3.64-1979 (SCO-ish?)
191 * Enables underscore, white foreground
192 * with white underscore (Linux - use
193 * default foreground).
194 */
197 break;
198 case 39: /* ANSI X3.64-1979 (SCO-ish?)
199 * Disable underline option.
200 * Reset colour to default? It did this
201 * before...
202 */
205 break;
206 case 49:
208 break;
209
210 }
211}
const int ANSIColors[]
Definition: ansiprsr.cpp:54
int inGraphMode
Definition: ansiprsr.h:53
int current_map
Definition: ansiprsr.h:58
char map_G0
Definition: ansiprsr.h:57
char map_G1
Definition: ansiprsr.h:57
bool print_ctrl
Definition: ansiprsr.h:60
void setmap(char mapchar)
Definition: tcharmap.h:24
int get_normal_fg() const
Definition: tnconfig.h:72
int get_normal_bg() const
Definition: tnconfig.h:71
void HighVideo()
Definition: tconsole.cpp:113
void Normal()
Definition: tconsole.cpp:121
void LowVideo()
Definition: tconsole.cpp:117
void SetBackground(unsigned char wAttrib)
Definition: tconsole.cpp:147
void UnderlineOff()
Definition: tconsole.cpp:214
void UnderlineOn()
Definition: tconsole.cpp:195
void ReverseOn()
Definition: tconsole.cpp:311
void SetForeground(unsigned char wAttrib)
Definition: tconsole.cpp:141
void BlinkOff()
Definition: tconsole.cpp:176
void ReverseOff()
Definition: tconsole.cpp:328
void BlinkOn()
Definition: tconsole.cpp:157
TConsole & Console
Definition: tparser.h:41
TCharmap & Charmap
Definition: tparser.h:45

Referenced by ParseEscapeANSI().

◆ ConSetCursorPos()

void TANSIParser::ConSetCursorPos ( int  x,
int  y 
)
private

Definition at line 213 of file ansiprsr.cpp.

213 {
216 else
218}
bool ignore_margins
Definition: ansiprsr.h:61
void SetCursorPosition(int x, int y)
Definition: tconsole.cpp:885
void SetRawCursorPosition(int x, int y)
Definition: tconsole.cpp:860
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

Referenced by ParseEscape(), and ParseEscapeANSI().

◆ GetTerminalID()

const char * TANSIParser::GetTerminalID ( )
private

Definition at line 220 of file ansiprsr.cpp.

221{
222 return "\033[?1;2c";
223}

Referenced by ParseEscape(), and ParseEscapeANSI().

◆ Init()

void TANSIParser::Init ( )
privatevirtual

Implements TParser.

Definition at line 86 of file ansiprsr.cpp.

86 {
87 // Paul Brannan 6/25/98
88 map_G0 = 'B'; map_G1 = 'B';
90 current_map = 'B';
91
93 vt52_mode = 0;
94 print_ctrl = 0;
95 newline_mode = false;
96
98
99 iSavedCurY = 0; // Reset Variables
100 iSavedCurX = 0;
101 inGraphMode = 0;
102 Console.SetScroll(-1, -1);
103 Console.Normal(); // Reset Attributes
104
105 // Set tabs stops
107}
void clear_ext_mode()
Definition: keytrans.h:76
int iSavedCurY
Definition: ansiprsr.h:46
int iSavedCurX
Definition: ansiprsr.h:45
void resetTabStops()
Definition: ansiprsr.cpp:122
bool vt52_mode
Definition: ansiprsr.h:59
bool newline_mode
Definition: ansiprsr.h:63
void SetScroll(int start, int end)
Definition: tconsole.cpp:917
KeyTranslator & KeyTrans
Definition: tparser.h:42

Referenced by ResetTerminal(), and TANSIParser().

◆ ParseANSIBuffer()

char * TANSIParser::ParseANSIBuffer ( char pszBuffer,
char pszBufferEnd 
)
private

Definition at line 1212 of file ansiprsr.cpp.

1213{
1214 if(InPrintMode) {
1215 return PrintBuffer(pszBuffer, pszBufferEnd);
1216 }
1217
1218 unsigned char tmpc = *(unsigned char *)pszBuffer;
1219
1220 if(tmpc == 27) {
1221 return ParseEscape(pszBuffer, pszBufferEnd);
1222 }
1223
1224// if((fast_write && tmpc < 32) ||
1225// !print_ctrl && (tmpc < 32 || (EightBit_Ansi &&
1226// (tmpc > 128 && tmpc < 128 + ' ')))) {
1227
1228 // We shouldn't print ctrl characters when fast write is enabled
1229 // and ctrl chars are disabled (Paul Brannan 9/1/98)
1230 if(tmpc < 32) {
1231 // From the Linux kernel (Paul Brannan 12/5/98):
1232 /* A bitmap for codes <32. A bit of 1 indicates that the code
1233 * corresponding to that bit number invokes some special action
1234 * (such as cursor movement) and should not be displayed as a
1235 * glyph unless the disp_ctrl mode is explicitly enabled.
1236 */
1237 const long CTRL_ACTION = 0x0d00ff81;
1238 const long CTRL_ALWAYS = 0x0800f501;
1239 if(!(((print_ctrl?CTRL_ALWAYS:CTRL_ACTION)>>tmpc)&1)) {
1240
1241 Console.WriteString((char *)&tmpc, 1);
1242 pszBuffer++;
1243 return pszBuffer;
1244 }
1245
1246 switch (tmpc) {
1247 case 0:
1248 pszBuffer++;
1249 break;
1250
1251 // I.Ioannou 5/30/98
1252 case 7:
1253 Console.Beep();
1254 pszBuffer++;
1255 break;
1256
1257 // destructive backspace
1258 case 8:
1259 // Added option for destructive backspace (Paul Brannan 5/13/98)
1260 // Changed to ConWriteCtrlString so that the cursor position can be
1261 // updated (Paul Brannan 5/25/98)
1262 if(ini.get_dstrbksp()) {
1263 Console.WriteCtrlChar('\b');
1264 Console.WriteString(" ", 1);
1265 Console.WriteCtrlChar('\b');
1266 }
1267 else Console.WriteCtrlChar('\b');
1268 pszBuffer++;
1269 break;
1270
1271 // horizontal tab
1272 case 9:
1273 {
1274 pszBuffer++;
1275 int x = Console.GetCursorX();
1276 if(x != -1)
1278 }
1279 break;
1280
1281 // Line Feed Char
1282 case 10:
1283 // Test for local echo (Paul Brannan 8/25/98)
1284 if(Network.get_local_echo() || newline_mode) // &&
1285 Console.WriteCtrlChar('\x0d');
1286 Console.WriteCtrlChar('\x0a');
1287 pszBuffer++;
1288 break;
1289
1290 // form feed
1291 case 12:
1292 pszBuffer++;
1294 Console.SetRawCursorPosition(Console.GetCursorX(), 1); // changed fm 1
1295 break;
1296
1297 case 13:
1298 Console.WriteCtrlChar('\x0d');
1299 pszBuffer++;
1300
1301 break;
1302
1303 case 14: // shift out of alternate chararcter set
1304 pszBuffer++;
1305 Charmap.setmap(map_G1); // Paul Brannan 6/25/98
1306 current_map = 1;
1307 break;
1308
1309 case 15: // shift in
1310 pszBuffer++;
1311 Charmap.setmap(map_G0); // Paul Brannan 6/25/98
1312 current_map = 0;
1313 break;
1314
1315 // Paul Brannan 9/1/98 - Is this okay?
1316 default:
1317 pszBuffer++;
1318 }
1319
1320 return pszBuffer;
1321 }
1322
1323 // added by I.Ioannou 06 April, 1997
1324 // In 8 bit systems the server may send 0x9b instead of ESC[
1325 // Well, this will produce troubles in Greek 737 Code page
1326 // which uses 0x9b as the small "delta" - and I thing that there
1327 // is another European country with the same problem.
1328 // If we have to stay 8-bit clean we may have to
1329 // give the ability of ROM characters (ESC[11m),
1330 // for striped 8'th bit (ESC[12m) as SCO does,
1331 // or a parameter at compile (or run ?) time.
1332 // We now check for a flag in the ini file (Paul Brannan 5/13/98)
1333 // We also handle any 8-bit ESC sequence (Paul Brannan 6/28/98)
1334 if(ini.get_eightbit_ansi() && (tmpc > 128 && tmpc < 128 + ' ')) {
1335 // There's a chance the sequence might not parse. If this happens
1336 // then pszBuffer will be one character too far back, since
1337 // ParseEscape is expecting two characters, not one.
1338 // In that case we must handle it.
1339 char *pszCurrent = pszBuffer;
1340 pszBuffer = ParseEscape(pszBuffer, pszBufferEnd);
1341 if(pszBuffer < pszCurrent) pszBuffer = pszCurrent;
1342 }
1343
1344 char* pszCurrent = pszBuffer + 1;
1345 // I.Ioannou 04 Sep 1997 FIXME with ESC[11m must show chars < 32
1346 // Fixed (Paul Brannan 6/28/98)
1347 while ((pszCurrent < pszBufferEnd) && (!iscntrl(*pszCurrent))) {
1348 // I.Ioannou 04 Sep 1997 strip on high bit
1349 if ( (inGraphMode) && (*pszCurrent > (char)32) )
1350 *pszCurrent |= 0x80 ;
1351 pszCurrent++;
1352 }
1353
1354 // Note that this may break dumpfiles slightly.
1355 // If 'B' is set to anything other than ASCII, this will cause problems
1356 // (Paul Brannan 6/28/98)
1357 if(current_map != 'B' && Charmap.enabled)
1358 Charmap.translate_buffer(pszBuffer, pszCurrent);
1359
1360 last_char = *(pszCurrent-1); // TITUS++: Remember last char
1361
1362 if(fast_write) {
1363 pszBuffer += Console.WriteStringFast(pszBuffer,
1364 pszCurrent - pszBuffer);
1365 } else {
1366 pszBuffer += Console.WriteString(pszBuffer,
1367 pszCurrent - pszBuffer);
1368 }
1369
1370 return pszBuffer;
1371}
char * PrintBuffer(char *pszBuffer, char *pszBufferEnd)
Definition: ansiprsr.cpp:1375
char last_char
Definition: ansiprsr.h:55
int tab_stops[MAX_TAB_POSITIONS]
Definition: ansiprsr.h:65
char * ParseEscape(char *pszBuffer, char *pszBufferEnd)
Definition: ansiprsr.cpp:916
int enabled
Definition: tcharmap.h:37
void translate_buffer(char *start, char *end)
Definition: tcharmap.h:28
bool get_dstrbksp() const
Definition: tnconfig.h:45
bool get_eightbit_ansi() const
Definition: tnconfig.h:46
unsigned long WriteCtrlChar(char c)
Definition: tconsole.cpp:557
int GetCursorX()
Definition: tconsole.h:69
unsigned long WriteString(const char *pszString, unsigned long cbString)
Definition: tconsole.cpp:473
int GetCursorY()
Definition: tconsole.h:70
unsigned long WriteStringFast(const char *pszString, unsigned long cbString)
Definition: tconsole.cpp:350
void Beep()
Definition: tconsole.cpp:922
void ClearScreen(char c=' ')
Definition: tconsole.cpp:689
BOOL get_local_echo()
Definition: tnetwork.h:40
TNetwork & Network
Definition: tparser.h:44
_Check_return_ _CRTIMP int __cdecl iscntrl(_In_ int _C)

Referenced by ParseBuffer().

◆ ParseBuffer()

char * TANSIParser::ParseBuffer ( char pszBuffer,
char pszBufferEnd 
)
virtual

Implements TParser.

Definition at line 1127 of file ansiprsr.cpp.

1127 {
1128 // copy into ANSI buffer
1129 char * pszResult;
1130
1131 // Parse the buffer for ANSI or display
1132 while (pszHead < pszTail) {
1133 if(!ini.get_output_redir()) {
1134 pszResult = ParseANSIBuffer(pszHead, pszTail);
1135 } else {
1136 // Output is being redirected
1137 if(ini.get_strip_redir()) {
1138 // Skip the WriteFile() altogether and pass the buffer to a filter
1139 // Mark Miesfield 09/24/2000
1140 pszResult = PrintGoodChars(pszHead, pszTail);
1141 } else {
1142 DWORD Result;
1143 // Paul Brannan 7/29/98
1144 // Note that this has the unforunate effect of printing out
1145 // NULL (ascii 0) characters onto the screen
1147 pszTail - pszHead, &Result, NULL)) pszResult = pszHead;
1148 pszResult = pszHead + Result;
1149 }
1150 }
1151 if (dumpfile)
1152 fwrite( pszHead, sizeof (char), pszResult-pszHead, dumpfile);
1153 if(ini.get_scroll_enable()) Scroller.update(pszHead, pszResult);
1154 if (pszResult == pszHead) break;
1155 pszHead = pszResult;
1156 }
1157 // return the new head to the buffer
1158 return pszHead;
1159}
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:203
char * ParseANSIBuffer(char *pszBuffer, char *pszBufferEnd)
Definition: ansiprsr.cpp:1212
char * PrintGoodChars(char *pszHead, char *pszTail)
Definition: ansiprsr.cpp:1431
bool get_strip_redir() const
Definition: tnconfig.h:44
int get_output_redir() const
Definition: tnconfig.h:43
bool get_scroll_enable() const
Definition: tnconfig.h:90
void update(const char *pszBegin, const char *pszEnd)
Definition: tscroll.cpp:78
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
unsigned long DWORD
Definition: ntddk_ex.h:95
_Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_Size *_Count) const void *_Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE *_File)
#define STD_OUTPUT_HANDLE
Definition: winbase.h:294
_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

◆ ParseEscape()

char * TANSIParser::ParseEscape ( char pszBuffer,
char pszBufferEnd 
)
private

Definition at line 916 of file ansiprsr.cpp.

916 {
917 char *pszChar;
918
919 // Check if we have enough characters in buffer.
920 if ((pszBufferEnd - pszBuffer) < 2)
921 return pszBuffer;
922
923 // I.Ioannou 04 Sep 1997
924 // there is no need for pszBuffer++; after each command
925
926 // Decode the command.
927 pszBuffer++;
928
929 switch (*pszBuffer++) {
930 case 'A': // Cursor up
932 break;
933 // Cursor down
934 case 'B':
936 break;
937 // Cursor right
938 case 'C':
940 break;
941 // LF *or* cursor left (Paul Brannan 6/27/98)
942 case 'D':
943 if(vt52_mode)
945 else
946 Console.index();
947 break;
948 // CR/LF (Paul Brannan 6/26/98)
949 case 'E':
950 Console.WriteCtrlString("\r\n", 2);
951 break;
952 // Special graphics char set (Paul Brannan 6/27/98)
953 case 'F':
954 Charmap.setmap('0');
955 break;
956 // ASCII char set (Paul Brannan 6/27/98)
957 case 'G':
958 Charmap.setmap('B');
959 break;
960 // Home cursor/tab set
961 case 'H':
962 if(ini.get_vt100_mode()) {
963 int x = Console.GetCursorX();
964 if(x != 0) {
965 int t = tab_stops[x - 1];
966 for(int j = x - 1; j >= 0 && tab_stops[j] == t; j--)
967 tab_stops[j] = x;
968 }
969 } else {
970 // I.Ioannou 04 Sep 1997 (0,0) not (1,1)
971 ConSetCursorPos(0, 0);
972 }
973 break;
974 // Reverse line feed (Paul Brannan 6/27/98)
975 // FIX ME!!! reverse_index is wrong to be calling here
976 // (Paul Brannan 12/2/98)
977 case 'I':
979 break;
980 // Erase end of screen
981 case 'J':
983 break;
984 // Erase EOL
985 case 'K':
987 break;
988 // Scroll Up one line //Reverse index
989 case 'M':
991 break;
992 // Direct cursor addressing
993 case 'Y':
994 if ((pszBufferEnd - pszBuffer) >= 2){
995 // if we subtract '\x1F', then we may end up with a negative
996 // cursor position! (Paul Brannan 6/26/98)
997 ConSetCursorPos(pszBuffer[1] - ' ', pszBuffer[0] - ' ');
998 pszBuffer+=2;
999 } else {
1000 pszBuffer--; // Paul Brannan 6/26/98
1001 }
1002 break;
1003 // Terminal ID Request
1004 case 'Z':
1005 {
1006 const char* szTerminalId = GetTerminalID();
1007 Network.WriteString(szTerminalId, strlen(szTerminalId));
1008 break;
1009 }
1010 // reset terminal to defaults
1011 case 'c':
1012 ResetTerminal();
1013 break;
1014 // Enter alternate keypad mode
1015 case '=':
1017 break;
1018 // Exit alternate keypad mode
1019 case '>':
1021 break;
1022 // Enter ANSI mode
1023 case '<':
1024 KeyTrans.unset_ext_mode(APP2_KEY); // exit vt52 mode
1025 break;
1026 // Graphics processor on (See note 3)
1027 case '1':
1028 break;
1029 // Line size commands
1030 case '#': //Line size commands
1031 // (Paul Brannan 6/26/98)
1032 if(pszBuffer < pszBufferEnd) {
1033 switch(*pszBuffer++) {
1034 case '3': break; // top half of a double-height line
1035 case '4': break; // bottom half of a double-height line
1036 case '6': break; // current line becomes double-width
1037 case '8': Console.ClearScreen('E'); break;
1038 }
1039 } else {
1040 pszBuffer--;
1041 }
1042 break;
1043 // Graphics processor off (See note 3)
1044 case '2':
1045 break;
1046 // Save cursor and attribs
1047 case '7':
1051 break;
1052 // Restore cursor position and attribs
1053 case '8':
1056 break;
1057 // Set G0 map (Paul Brannan 6/25/98)
1058 case '(':
1059 if (pszBuffer < pszBufferEnd) {
1060 map_G0 = *pszBuffer;
1061 if(current_map == 0) Charmap.setmap(map_G0);
1062 pszBuffer++;
1063 } else {
1064 pszBuffer--;
1065 }
1066 break;
1067 // Set G1 map (Paul Brannan 6/25/98)
1068 case ')':
1069 if (pszBuffer < pszBufferEnd) {
1070 map_G1 = *pszBuffer;
1071 if(current_map == 1) Charmap.setmap(map_G1);
1072 pszBuffer++;
1073 } else {
1074 pszBuffer--;
1075 }
1076 break;
1077 // This doesn't do anything, as far as I can tell, but it does take
1078 // a parameter (Paul Brannan 6/27/98)
1079 case '%':
1080 if (pszBuffer < pszBufferEnd) {
1081 pszBuffer++;
1082 } else {
1083 pszBuffer--;
1084 }
1085 break;
1086 // ANSI escape sequence
1087 case '[':
1088 // Check if we have whole escape sequence in buffer.
1089 // This should not be isalpha anymore (Paul Brannan 9/1/98)
1090 pszChar = pszBuffer;
1091 while ((pszChar < pszBufferEnd) && (*pszChar <= '?'))
1092 pszChar++;
1093 if (pszChar == pszBufferEnd)
1094 pszBuffer -= 2;
1095 else
1096 pszBuffer = ParseEscapeANSI(pszBuffer, pszBufferEnd);
1097 break;
1098#ifdef MTE_SUPPORT
1099 case '~':
1100 // Frediano Ziglio, 5/31/2000
1101 // Meridian Terminal Emulator extension
1102 // !!! same as ANSI
1103 // !!! should put in MTE procedure
1104 pszChar = pszBuffer;
1105 while ((pszChar < pszBufferEnd) && (*pszChar <= '?'))
1106 pszChar++;
1107 if (pszChar == pszBufferEnd)
1108 pszBuffer -= 2;
1109 else
1110 pszBuffer = ParseEscapeMTE(pszBuffer, pszBufferEnd);
1111 break;
1112#endif
1113 default:
1114#ifdef DEBUG
1115 Console.Beep();
1116#endif
1117 break;
1118 }
1119
1120 return pszBuffer;
1121}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define APP3_KEY
Definition: keytrans.h:39
#define APP2_KEY
Definition: keytrans.h:40
void unset_ext_mode(DWORD mode)
Definition: keytrans.h:75
void set_ext_mode(DWORD mode)
Definition: keytrans.h:74
void ConSetCursorPos(int x, int y)
Definition: ansiprsr.cpp:213
char * ParseEscapeANSI(char *pszBuffer, char *pszBufferEnd)
Definition: ansiprsr.cpp:246
void SaveCurX(int iX)
Definition: ansiprsr.cpp:118
void ResetTerminal()
Definition: ansiprsr.cpp:109
void SaveCurY(int iY)
Definition: ansiprsr.cpp:114
char * ParseEscapeMTE(char *pszBuffer, char *pszBufferEnd)
const char * GetTerminalID()
Definition: ansiprsr.cpp:220
bool get_vt100_mode() const
Definition: tnconfig.h:47
int GetRawCursorX()
Definition: tconsole.h:67
void index()
Definition: tconsole.cpp:589
int GetRawCursorY()
Definition: tconsole.h:68
unsigned long WriteCtrlString(const char *pszString, unsigned long cbString)
Definition: tconsole.cpp:542
void reverse_index()
Definition: tconsole.cpp:613
void ClearEOScreen(char c=' ')
Definition: tconsole.cpp:709
unsigned char GetAttrib()
Definition: tconsole.h:89
void MoveCursorPosition(int x, int y)
Definition: tconsole.cpp:907
void SetAttrib(unsigned char wAttr)
Definition: tconsole.h:88
void ClearEOLine(char c=' ')
Definition: tconsole.cpp:743
int WriteString(const char *str, const int length)
Definition: tnetwork.cpp:53
GLdouble GLdouble t
Definition: gl.h:2047
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

Referenced by ParseANSIBuffer().

◆ ParseEscapeANSI()

char * TANSIParser::ParseEscapeANSI ( char pszBuffer,
char pszBufferEnd 
)
private

Definition at line 246 of file ansiprsr.cpp.

247{
248
249 // The buffer contains something like <ESC>[pA
250 // where p is an optional decimal number specifying the count by which the
251 // appropriate action should take place.
252 // The pointer pszBuffer points us to the p, <ESC> and [ are
253 // already 'consumed'
254
255 // TITUS: Simplification of the code: Assume default count of 1 in case
256 // there are no parameters.
257 char tmpc;
258 const int nParam = 10; // Maximum number of parameters
259 int iParam[nParam] = {1, 0, 0, 0, 0}; // Assume 1 Parameter, Default 1
260 int iCurrentParam = 0;
261 DWORD flag = 0;
262 int missing_param = 0;
263
264 // Get parameters from escape sequence.
265 while ((tmpc = *pszBuffer) <= '?') {
266
267 if(tmpc < '0' || tmpc > '9') {
268 // Check for parameter delimiter.
269 if(tmpc == ';') {
270 // This is a hack (Paul Brannan 6/27/98)
271 if(*(pszBuffer - 1) == '[') missing_param = iCurrentParam+1;
272 pszBuffer++;
273 continue;
274 }
275
276 // It is legal to have control characters inside ANSI sequences
277 // (Paul Brannan 6/26/98)
278 if(tmpc < ' ') {
280 pszBuffer++;
281 continue;
282 }
283
284 // A new way of handling flags (Paul Brannan 12/2/98)
285 switch(tmpc) {
286 case '$': flag |= FLAG_DOLLAR; break;
287 case '?': flag |= FLAG_QMARK; break;
288 case '>': flag |= FLAG_GREATER; break;
289 case '<': flag |= FLAG_LESS; break;
290 case '!': flag |= FLAG_EXCLAM; break;
291 case '&': flag |= FLAG_AMPERSAND; break;
292 case '/': flag |= FLAG_SLASH; break;
293 case '=': flag |= FLAG_EQUAL; break;
294 case '\"': flag |= FLAG_QUOTE; break;
295 default: flag |= FLAG_OTHER; break;
296 }
297
298 pszBuffer++;
299 }
300
301 // Got Numerical Parameter.
302 iParam[iCurrentParam] = strtoul(pszBuffer, &pszBuffer, 10);
303 if (iCurrentParam < nParam)
304 iCurrentParam++;
305 }
306
307 //~~~ TITUS: Apparently the digit is optional (look at termcap or terminfo)
308 // So: If there is no digit, assume a count of 1
309
310 switch ((unsigned char)*pszBuffer++) {
311 // Insert Character
312 case '@':
313 if(iParam[0] == 0) iParam[0] = 1; // Paul Brannan 9/1/98
314 Console.InsertCharacter(iParam[0]); break;
315 // Move cursor up.
316 case 'A':
317 if(iParam[0] == 0) iParam[0] = 1;
318 Console.MoveCursorPosition(0, -iParam[0]); break;
319 // Move cursor down.
320 // Added by I.Ioannou 06 April, 1997
321 case 'B':
322 case 'e':
323 if(iParam[0] == 0) iParam[0] = 1;
324 Console.MoveCursorPosition(0, iParam[0]);
325 break;
326 // Move cursor right.
327 // Added by I.Ioannou 06 April, 1997
328 case 'C':
329 case 'a':
330 // Handle cursor size sequences (Jose Cesar Otero Rodriquez and
331 // Paul Brannan, 3/27/1999)
332 if(flag & FLAG_EQUAL) {
333 switch(iParam[0]) {
334 case 7: Console.SetCursorSize(50); break;
335 case 11: Console.SetCursorSize(6); break;
336 case 32: Console.SetCursorSize(0); break;
337 default: Console.SetCursorSize(13);
338 }
339 } else {
340 if(iParam[0] == 0) iParam[0] = 1;
341 Console.MoveCursorPosition(iParam[0], 0);
342 break;
343 }
344 // Move cursor left.
345 case 'D':
346 if(iParam[0] == 0) iParam[0] = 1;
347 Console.MoveCursorPosition(-iParam[0], 0);
348 break;
349 // Move cursor to beginning of line, p lines down.
350 // Added by I.Ioannou 06 April, 1997
351 case 'E':
353 break;
354 // Moves active position to beginning of line, p lines up
355 // Added by I.Ioannou 06 April, 1997
356 // With '=' this changes the default fg color (Paul Brannan 6/27/98)
357 case 'F':
358 if(flag & FLAG_EQUAL)
359 Console.setDefaultFg(iParam[0]);
360 else
362 break;
363 // Go to column p
364 // Added by I.Ioannou 06 April, 1997
365 // With '=' this changes the default bg color (Paul Brannan 6/27/98)
366 case '`':
367 case 'G': // 'G' is from Linux kernel sources
368 if(flag & FLAG_EQUAL) {
369 Console.setDefaultBg(iParam[0]);
370 } else {
371 if (iCurrentParam < 1) // Alter Default
372 iParam[0] = 0;
373 // this was backward, and we should subtract 1 from x
374 // (Paul Brannan 5/27/98)
375 ConSetCursorPos(iParam[0] - 1, Console.GetCursorY());
376 }
377 break;
378 // Set cursor position.
379 case 'f':
380 case 'H':
381 if (iCurrentParam < 2 || iParam[1] < 1)
382 iParam[1] = 1;
383 ConSetCursorPos(iParam[1] - 1, iParam[0] - 1);
384 break;
385 // Clear screen
386 case 'J':
387 if ( iCurrentParam < 1 ) iParam[0] = 0; // Alter Default
388 switch (iParam[0]) {
389 case 0: Console.ClearEOScreen(); break;
390 case 1: Console.ClearBOScreen(); break;
391 case 2:
394 break;
395 }
396 break;
397 // Clear line
398 case 'K':
399 if (iCurrentParam < 1) // Alter Default
400 iParam[0] = 0;
401 switch (iParam[0]) {
402 case 0: Console.ClearEOLine(); break;
403 case 1: Console.ClearBOLine(); break;
404 case 2: Console.ClearLine(); break;
405 }
406 break;
407 // Insert p new, blank lines.
408 // Added by I.Ioannou 06 April, 1997
409 case 'L':
410 {
411 // for (int i = 1; i <= iParam[0]; i++)
412 // This should speed things up a bit (Paul Brannan 9/2/98)
413 Console.ScrollDown(Console.GetRawCursorY(), -1, iParam[0]);
414 break;
415 }
416 // Delete p lines.
417 // Added by I.Ioannou 06 April, 1997
418 case 'M':
419 {
420 for (int i = 1; i <= iParam[0]; i++)
421 // This should speed things up a bit (Paul Brannan 9/2/98)
423 break;
424 }
425 // DELETE CHAR
426 case 'P':
427 Console.DeleteCharacter(iParam[0]);
428 break;
429 // Scrolls screen up (down? -- PB) p lines,
430 // Added by I.Ioannou 06 April, 1997
431 // ANSI X3.64-1979 references this but I didn't
432 // found it in any telnet implementation
433 // note 05 Oct 97 : but SCO terminfo uses them, so uncomment them !!
434 case 'S':
435 {
436 //for (int i = 1; i <= iParam[0]; i++)
437 // This should speed things up a bit (Paul Brannan 9/2/98)
438 Console.ScrollDown(-1, -1, -iParam[0]);
439 break;
440 }
441 // Scrolls screen up p lines,
442 // Added by I.Ioannou 06 April, 1997
443 // ANSI X3.64-1979 references this but I didn't
444 // found it in any telnet implementation
445 // note 05 Oct 97 : but SCO terminfo uses them, so uncomment them !!
446 case 'T':
447 {
448 // for (int i = 1; i <= iParam[0]; i++)
449 // This should speed things up a bit (Paul Brannan 9/2/98)
450 Console.ScrollDown(-1, -1, iParam[0]);
451 break;
452 }
453 // Erases p characters up to the end of line
454 // Added by I.Ioannou 06 April, 1997
455 case 'X':
456 {
457 int iKeepX = Console.GetRawCursorX();
458 int iKeepY = Console.GetRawCursorY();
459 if (iParam[0] > Console.GetWidth())
460 iParam[0] = Console.GetWidth(); // up to the end of line
461 for ( int i = 1; i <= iParam[0]; i++ )
462 Console.WriteString(" ", 1);
463 Console.SetRawCursorPosition(iKeepX , iKeepY);
464 break;
465 }
466 // Go back p tab stops
467 // Added by I.Ioannou 06 April, 1997
468 // Implemented by Paul Brannan, 4/13/2000
469 case 'Z':
470 {
471 int x = Console.GetCursorX();
472 for(int j = 0; x > 0 && j < iParam[0]; j++)
473 while(x > 0 && tab_stops[j] == tab_stops[x]) x--;
475 }
476 break;
477 // Get Terminal ID
478 case 'c':
479 {
480 const char* szTerminalId = GetTerminalID();
481 Network.WriteString(szTerminalId, strlen(szTerminalId));
482 break;
483 }
484 // TITUS++ 2. November 1998: Repeat Character.
485 case 'b':
486 // isprint may be causing problems (Paul Brannan 3/27/99)
487 // if ( isprint(last_char) ) {
488 char buf[150]; // at most 1 line (max 132 chars)
489
490 if ( iParam[0] > 149 ) iParam[0] = 149;
491 memset(buf, last_char, iParam[0]);
492 buf[iParam[0]] = 0;
493 if ( fast_write )
494 Console.WriteStringFast(buf, iParam[0]);
495 else
496 Console.WriteString(buf, iParam[0]);
497 // } /* IF */
498 break;
499 // Go to line p
500 // Added by I.Ioannou 06 April, 1997
501 case 'd':
502 if (iCurrentParam < 1) // Alter Default
503 iParam[0] = 0;
504 // this was backward, and we should subtract 1 from y
505 // (Paul Brannan 5/27/98)
506 ConSetCursorPos(Console.GetCursorX(), iParam[0] - 1);
507 break;
508 // iBCS2 tab erase
509 // Added by I.Ioannou 06 April, 1997
510 case 'g':
511 if (iCurrentParam < 1) // Alter Default
512 iParam[0] = 0;
513 switch (iParam[0]) {
514 case 0:
515 {
516 // Clear the horizontal tab stop at the current active position
517 for(int j = 0; j < MAX_TAB_POSITIONS; j++) {
518 int x = Console.GetCursorX();
519 if(tab_stops[j] == x) tab_stops[j] = tab_stops[x + 1];
520 }
521 }
522 break;
523 case 2:
524 // I think this might be "set as default?"
525 break;
526 case 3:
527 {
528 // Clear all tab stops
529 for(int j = 0; j < MAX_TAB_POSITIONS; j++)
530 tab_stops[j] = -1;
531 }
532 break;
533 }
534 break;
535 // Set extended mode
536 case 'h':
537 {
538 for (int i = 0; i < iCurrentParam; i++) {
539 // Changed to a switch statement (Paul Brannan 5/27/98)
540 if(flag & FLAG_QMARK) {
541 switch(iParam[i]) {
542 case 1: // App cursor keys
544 break;
545 case 2: // VT102 mode
546 vt52_mode = 0;
548 break;
549 case 3: // 132 columns
550 if(ini.get_wide_enable()) {
551 Console.SetWindowSize(132, -1);
552 }
553 break;
554 case 4: // smooth scrolling
555 break;
556 case 5: // Light background
558 break;
559 case 6: // Stay in margins
560 ignore_margins = 0;
561 break;
562 case 7:
563 Console.setLineWrap(true);
564 break;
565 case 8: // Auto-repeat keys
566 break;
567 case 18: // Send FF to printer
568 break;
569 case 19: // Entire screen legal for printer
570 break;
571 case 25: // Visible cursor
572 break;
573 case 66: // Application numeric keypad
574 break;
575 default:
576#ifdef DEBUG
577 Console.Beep();
578#endif
579 break;
580 }
581 } else {
582 switch(iParam[i]) {
583 case 2: // Lock keyboard
584 break;
585 case 3: // Act upon control codes (PB 12/5/98)
586 print_ctrl = 0;
587 break;
588 case 4: // Set insert mode
590 break;
591 case 12: // Local echo off
592 break;
593 case 20: // Newline sends cr/lf
595 newline_mode = true;
596 break;
597 default:
598#ifdef DEBUG
599 Console.Beep();
600#endif
601 break;
602 }
603 }
604 }
605 }
606 break;
607 // Print Screen
608 case 'i':
609 if (iCurrentParam < 1)
610 iParam[0]=0;
611 switch (iParam[0]){
612 case 0: break; // Print Screen
613 case 1: break; // Print Line
614 // Added I.Ioannou 06 April, 1997
615 case 4:
616 // Stop Print Log
617 InPrintMode = 0;
618 if ( printfile != NULL )
620 break;
621 case 5:
622 // Start Print Log
624 if (printfile != NULL) InPrintMode = 1;
625 break;
626 }
627 break;
628 // Unset extended mode
629 case 'l':
630 {
631 for (int i = 0; i < iCurrentParam; i++) {
632 // Changed to a switch statement (Paul Brannan 5/27/98)
633 if(flag & FLAG_QMARK) {
634 switch(iParam[i]) {
635 case 1: // Numeric cursor keys
637 break;
638 case 2: // VT52 mode
639 vt52_mode = 1;
641 break;
642 case 3: // 80 columns
643 if(ini.get_wide_enable()) {
644 Console.SetWindowSize(80, -1);
645 }
646 break;
647 case 4: // jump scrolling
648 break;
649 case 5: // Dark background
650 Console.Darkbg();
651 break;
652 case 6: // Ignore margins
653 ignore_margins = 1;
654 break;
655 case 7:
656 Console.setLineWrap(false);
657 break;
658 case 8: // Auto-repeat keys
659 break;
660 case 19: // Only send scrolling region to printer
661 break;
662 case 25: // Invisible cursor
663 break;
664 case 66: // Numeric keypad
665 break;
666 default:
667#ifdef DEBUG
668 Console.Beep();
669#endif
670 break;
671 }
672 } else {
673 switch(iParam[i]) {
674 case 2: // Unlock keyboard
675 break;
676 case 3: // Display control codes (PB 12/5/98)
677 print_ctrl = 1;
678 break;
679 case 4: // Set overtype mode
681 break;
682 case 12: // Local echo on
683 break;
684 case 20: // sends lf only
686 newline_mode = false;
687 break;
688 default:
689#ifdef DEBUG
690 Console.Beep();
691#endif
692 break;
693 }
694 }
695 }
696 }
697 break;
698 // Set color
699 case 'm':
700 if(missing_param) Console.Normal();
701 if(iCurrentParam == 0) {
702 Console.Normal();
703 } else {
704 for(int i = 0; i < iCurrentParam; i++)
705 ConSetAttribute(iParam[i]);
706 }
707 break;
708 // report cursor position Row X Col
709 case 'n':
710 if (iCurrentParam == 1 && iParam[0]==5) {
711 // report the cursor position
712 Network.WriteString("\x1B[0n", 4);
713 break;
714 }
715 if (iCurrentParam == 1 && iParam[0]==6){
716 // report the cursor position
717 // The cursor position needs to be sent as a single string
718 // (Paul Brannan 6/27/98)
719 char szCursorReport[40] = "\x1B[";
720
721 itoa(Console.GetCursorY() + 1,
722 &szCursorReport[strlen(szCursorReport)], 10);
723 strcat(szCursorReport, ";");
724 itoa(Console.GetCursorX() + 1,
725 &szCursorReport[strlen(szCursorReport)], 10);
726 strcat(szCursorReport, "R");
727
728 Network.WriteString(szCursorReport, strlen(szCursorReport));
729
730 }
731 break;
732 // Miscellaneous weird sequences (Paul Brannan 6/27/98)
733 case 'p':
734 // Set conformance level
735 if(flag & FLAG_QUOTE) {
736 break;
737 }
738 // Soft terminal reset
739 if(flag & FLAG_EXCLAM) {
740 break;
741 }
742 // Report mode settings
743 if(flag & FLAG_DOLLAR) {
744 break;
745 }
746 break;
747 // Scroll Screen
748 case 'r':
749 if (iCurrentParam < 1) {
750 // Enable scrolling for entire display
751 Console.SetScroll(-1, -1);
752 break;
753 }
754 if (iCurrentParam >1) {
755 // Enable scrolling from row1 to row2
756 Console.SetScroll(iParam[0] - 1, iParam[1] - 1);
757 // If the cursor is outside the scrolling range, fix it
758 // (Paul Brannan 6/26/98)
759 // if(Console.GetRawCursorY() < iParam[0] - 1) {
760 // Console.SetRawCursorPosition(Console.GetCursorX(),
761 // iParam[0] - 1);
762 // }
763 // if(Console.GetRawCursorY() > iParam[1] - 1) {
764 // Console.SetRawCursorPosition(Console.GetCursorX(),
765 // iParam[1] - 1);
766 // }
767 }
768 // Move the cursor to the home position (Paul Brannan 12/2/98)
770 break;
771 // Save cursor position
772 case 's':
775 break;
776 // Restore cursor position
777 case 'u':
779 break;
780 // DEC terminal report (Paul Brannan 6/28/98)
781 case 'x':
782 if(iParam[0])
783 Network.WriteString("\033[3;1;1;128;128;1;0x", 20);
784 else
785 Network.WriteString("\033[2;1;1;128;128;1;0x", 20);
786 break;
787 default:
788#ifdef DEBUG
789 Console.Beep();
790#endif
791 break;
792 }
793
794 return pszBuffer;
795}
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
Definition: utclib.c:696
#define FLAG_LESS
Definition: ansiprsr.cpp:238
#define FLAG_GREATER
Definition: ansiprsr.cpp:237
#define FLAG_QUOTE
Definition: ansiprsr.cpp:243
#define FLAG_SLASH
Definition: ansiprsr.cpp:241
#define FLAG_EQUAL
Definition: ansiprsr.cpp:242
#define FLAG_QMARK
Definition: ansiprsr.cpp:236
#define FLAG_DOLLAR
Definition: ansiprsr.cpp:235
#define FLAG_OTHER
Definition: ansiprsr.cpp:244
#define FLAG_AMPERSAND
Definition: ansiprsr.cpp:240
#define FLAG_EXCLAM
Definition: ansiprsr.cpp:239
#define MAX_TAB_POSITIONS
Definition: ansiprsr.h:9
#define APP4_KEY
Definition: keytrans.h:38
#define APP_KEY
Definition: keytrans.h:41
void ConSetAttribute(unsigned char wAttr)
Definition: ansiprsr.cpp:128
const char * get_printer_name() const
Definition: tnconfig.h:38
bool get_wide_enable() const
Definition: tnconfig.h:60
void SetWindowSize(int width, int height)
Definition: tconsole.cpp:93
void setDefaultFg(unsigned char u)
Definition: tconsole.h:105
int GetWidth()
Definition: tconsole.h:81
void ClearLine(char c=' ')
Definition: tconsole.cpp:732
void Darkbg()
Definition: tconsole.cpp:284
void setLineWrap(bool bEnabled)
Definition: tconsole.h:131
void InsertCharacter(int numchar)
Definition: tconsole.cpp:800
void ScrollDown(int iStartRow, int iEndRow, int bUp)
Definition: tconsole.cpp:625
void DeleteCharacter(int numchar)
Definition: tconsole.cpp:832
void ClearBOScreen(char c=' ')
Definition: tconsole.cpp:721
void InsertMode(int i)
Definition: tconsole.h:141
void ClearBOLine(char c=' ')
Definition: tconsole.cpp:754
void setDefaultBg(unsigned char u)
Definition: tconsole.h:106
void SetCursorSize(int pct)
Definition: tconsole.cpp:929
void Lightbg()
Definition: tconsole.cpp:258
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
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 flag
Definition: glfuncs.h:52
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
_CRTIMP char *__cdecl itoa(_In_ int _Val, _Pre_notnull_ _Post_z_ char *_DstBuf, _In_ int _Radix)
#define memset(x, y, z)
Definition: compat.h:39

Referenced by ParseEscape().

◆ ParseEscapeMTE()

char * TANSIParser::ParseEscapeMTE ( char pszBuffer,
char pszBufferEnd 
)
private

Referenced by ParseEscape().

◆ PrintBuffer()

char * TANSIParser::PrintBuffer ( char pszBuffer,
char pszBufferEnd 
)
private

Definition at line 1375 of file ansiprsr.cpp.

1375 {
1376 // Check if we have enough characters in buffer.
1377 if ((pszBufferEnd - pszBuffer) < 4)
1378 return pszBuffer;
1379 char *tmpChar;
1380
1381 tmpChar = pszBuffer;
1382 if ( *tmpChar == 27 ) {
1383 tmpChar++;
1384 if ( *tmpChar == '[' ) {
1385 tmpChar++;
1386 if ( *tmpChar == '4' ) {
1387 tmpChar++;
1388 if ( *tmpChar == 'i' ) {
1389 InPrintMode = 0; // Stop Print Log
1390 if ( printfile != NULL )
1392 pszBuffer += 4;
1393 return pszBuffer;
1394 }
1395 }
1396 }
1397 }
1398
1399 if (printfile != NULL) {
1400 fputc( *pszBuffer, printfile);
1401 pszBuffer++;
1402 } else
1403 InPrintMode = 0;
1404
1405 return pszBuffer;
1406}
_Check_return_opt_ _CRTIMP int __cdecl fputc(_In_ int _Ch, _Inout_ FILE *_File)

Referenced by ParseANSIBuffer().

◆ PrintGoodChars()

char * TANSIParser::PrintGoodChars ( char pszHead,
char pszTail 
)
private

Definition at line 1431 of file ansiprsr.cpp.

1431 {
1432
1433 while ( pszHead < pszTail ) {
1434 if ( iscntrl( *pszHead ) ) {
1435 switch ( *(pszHead++) ) {
1436 case 10 :
1437 putc( 10, stdout );
1438 break;
1439
1440 case 13 :
1441 putc( 13, stdout );
1442 break;
1443
1444 case 27:
1445 switch ( *(pszHead++) ) {
1446 case 'Y':
1447 pszHead += 2;
1448 break;
1449
1450 case '#':
1451 case '(':
1452 case ')':
1453 case '%': pszHead++; break;
1454 case '[':
1455 while ( (pszHead < pszTail) && (*pszHead < '?') )
1456 pszHead++;
1457 pszHead++;
1458 break;
1459
1460 default :
1461 break;
1462 }
1463 break;
1464
1465 default :
1466 break;
1467 }
1468 }
1469 else
1470 putc( *(pszHead++), stdout );
1471 }
1472 return ( pszTail );
1473}
#define stdout
Definition: stdio.h:99
_Check_return_opt_ _CRTIMP int __cdecl putc(_In_ int _Ch, _Inout_ FILE *_File)

Referenced by ParseBuffer().

◆ resetTabStops()

void TANSIParser::resetTabStops ( )
private

Definition at line 122 of file ansiprsr.cpp.

122 {
123 for(int j = 0; j < MAX_TAB_POSITIONS; j++) {
124 tab_stops[j] = 8 + j - (j%8);
125 }
126}

Referenced by Init().

◆ ResetTerminal()

void TANSIParser::ResetTerminal ( )
private

Definition at line 109 of file ansiprsr.cpp.

109 {
110 Init();
111 Console.ClearScreen(); // Clear Screen
112 Console.SetRawCursorPosition(0,0); // Home Cursor
113}

Referenced by ParseEscape().

◆ SaveCurX()

void TANSIParser::SaveCurX ( int  iX)
private

Definition at line 118 of file ansiprsr.cpp.

118 {
119 iSavedCurX=iX;
120}

Referenced by ParseEscape(), and ParseEscapeANSI().

◆ SaveCurY()

void TANSIParser::SaveCurY ( int  iY)
private

Definition at line 114 of file ansiprsr.cpp.

114 {
115 iSavedCurY=iY;
116}

Referenced by ParseEscape(), and ParseEscapeANSI().

◆ StripBuffer()

int TANSIParser::StripBuffer ( char pszBuffer,
char pszBufferEnd,
int  width 
)
static

Definition at line 1164 of file ansiprsr.cpp.

1164 {
1165 int lines = 0, c = 0;
1166 char *pszBuf = pszHead;
1167
1168 while(pszHead < pszTail) {
1169 if(iscntrl(*pszHead)) {
1170 switch(*(pszHead++)) {
1171 case 8:
1172 case 127:
1173 if(c>0) {
1174 if(!(c%width)) lines--;
1175 c--;
1176 pszBuf--;
1177 }
1178 break;
1179 case 10: lines++;
1180 case 13:
1181 *(pszBuf++) = *(pszHead - 1);
1182 c = 0;
1183 break;
1184 case 27:
1185 switch(*(pszHead++)) {
1186 case 'Y': pszHead += 2; break;
1187 case '#':
1188 case '(':
1189 case ')':
1190 case '%': pszHead++; break;
1191 case '[':
1192 while((pszHead < pszTail) && (*pszHead < '?'))
1193 pszHead++;
1194 pszHead++;
1195 break;
1196 }
1197 }
1198 } else {
1199 *(pszBuf++) = *(pszHead++);
1200 c++;
1201 }
1202 if(c != 0 && !(c%width))
1203 lines++;
1204 }
1205
1206 // Fill in the end of the buffer with blanks
1207 while(pszBuf <= pszTail) *pszBuf++ = ' ';
1208
1209 return lines;
1210}
GLint GLint GLsizei width
Definition: gl.h:1546
const GLubyte * c
Definition: glext.h:8905
eMaj lines
Definition: tritemp.h:206

Referenced by TANSIParser().

Member Data Documentation

◆ current_map

int TANSIParser::current_map
private

Definition at line 58 of file ansiprsr.h.

Referenced by ConSetAttribute(), Init(), ParseANSIBuffer(), and ParseEscape().

◆ dumpfile

FILE* TANSIParser::dumpfile
private

Definition at line 48 of file ansiprsr.h.

Referenced by ParseBuffer(), TANSIParser(), and ~TANSIParser().

◆ fast_write

bool TANSIParser::fast_write
private

Definition at line 62 of file ansiprsr.h.

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

◆ ignore_margins

bool TANSIParser::ignore_margins
private

Definition at line 61 of file ansiprsr.h.

Referenced by ConSetCursorPos(), Init(), and ParseEscapeANSI().

◆ inGraphMode

int TANSIParser::inGraphMode
private

Definition at line 53 of file ansiprsr.h.

Referenced by ConSetAttribute(), Init(), and ParseANSIBuffer().

◆ InPrintMode

char TANSIParser::InPrintMode
private

Definition at line 52 of file ansiprsr.h.

Referenced by ParseANSIBuffer(), ParseEscapeANSI(), PrintBuffer(), and TANSIParser().

◆ iSavedAttributes

unsigned char TANSIParser::iSavedAttributes
private

Definition at line 47 of file ansiprsr.h.

Referenced by ParseEscape(), and TANSIParser().

◆ iSavedCurX

int TANSIParser::iSavedCurX
private

Definition at line 45 of file ansiprsr.h.

Referenced by Init(), ParseEscape(), ParseEscapeANSI(), and SaveCurX().

◆ iSavedCurY

int TANSIParser::iSavedCurY
private

Definition at line 46 of file ansiprsr.h.

Referenced by Init(), ParseEscape(), ParseEscapeANSI(), and SaveCurY().

◆ last_char

char TANSIParser::last_char
private

Definition at line 55 of file ansiprsr.h.

Referenced by ParseANSIBuffer(), and ParseEscapeANSI().

◆ map_G0

char TANSIParser::map_G0
private

Definition at line 57 of file ansiprsr.h.

Referenced by ConSetAttribute(), Init(), ParseANSIBuffer(), and ParseEscape().

◆ map_G1

char TANSIParser::map_G1
private

Definition at line 57 of file ansiprsr.h.

Referenced by ConSetAttribute(), Init(), ParseANSIBuffer(), and ParseEscape().

◆ mteRegionXF

short int TANSIParser::mteRegionXF
private

Definition at line 31 of file ansiprsr.h.

◆ mteRegionYF

short int TANSIParser::mteRegionYF
private

Definition at line 31 of file ansiprsr.h.

◆ newline_mode

bool TANSIParser::newline_mode
private

Definition at line 63 of file ansiprsr.h.

Referenced by Init(), ParseANSIBuffer(), and ParseEscapeANSI().

◆ print_ctrl

bool TANSIParser::print_ctrl
private

Definition at line 60 of file ansiprsr.h.

Referenced by ConSetAttribute(), Init(), ParseANSIBuffer(), and ParseEscapeANSI().

◆ printfile

FILE* TANSIParser::printfile
private

Definition at line 51 of file ansiprsr.h.

Referenced by ParseEscapeANSI(), PrintBuffer(), TANSIParser(), and ~TANSIParser().

◆ tab_stops

int TANSIParser::tab_stops[MAX_TAB_POSITIONS]
private

Definition at line 65 of file ansiprsr.h.

Referenced by ParseANSIBuffer(), ParseEscape(), ParseEscapeANSI(), and resetTabStops().

◆ vt52_mode

bool TANSIParser::vt52_mode
private

Definition at line 59 of file ansiprsr.h.

Referenced by Init(), ParseEscape(), and ParseEscapeANSI().


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