ReactOS 0.4.15-dev-6073-g59e7458
tconsole.cpp
Go to the documentation of this file.
1
2//Telnet Win32 : an ANSI telnet client.
3//Copyright (C) 1998-2000 Paul Brannan
4//Copyright (C) 1998 I.Ioannou
5//Copyright (C) 1997 Brad Johnson
6//
7//This program is free software; you can redistribute it and/or
8//modify it under the terms of the GNU General Public License
9//as published by the Free Software Foundation; either version 2
10//of the License, or (at your option) any later version.
11//
12//This program is distributed in the hope that it will be useful,
13//but WITHOUT ANY WARRANTY; without even the implied warranty of
14//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15//GNU General Public License for more details.
16//
17//You should have received a copy of the GNU General Public License
18//along with this program; if not, write to the Free Software
19//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20//
21//I.Ioannou
22//roryt@hol.gr
23//
25
27//
28// Module: tconsole.cpp
29//
30// Contents: screen functions
31//
32// Product: telnet
33//
34//
35// Revisions: Mar. 29, 2000 pbranna@clemson (Paul Brannan)
36// June 15, 1998 pbranna@clemson.edu
37// May 16, 1998 pbranna@clemson.edu
38// 05. Sep.1997 roryt@hol.gr (I.Ioannou)
39// 11.May,1997 roryt@hol.gr
40// 06.April,1997 roryt@hol.gr
41// 30.Mrz.1997 Titus_Boxberg@public.uni-hamburg.de
42// 5.Dec.1996 jbj@nounname.com
43// Version 2.0
44// 02.Apr.1995 igor.milavec@uni-lj.si
45// Original code
46//
48
49#include "precomp.h"
50
51// argsused doesn't work on MSVC++
52#ifdef __BORLANDC__
53#pragma argsused
54#endif
55
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}
84
86 wAttributes = origfg | (origbg << 4);
89 WriteCtrlChar('\x0a');
90}
91
92// Paul Brannan 8/2/98
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}
107
108// Paul Brannan 5/15/98
111}
112
114 wAttributes = wAttributes | (unsigned char) 8;
115}
116
118 wAttributes = wAttributes & (unsigned char) (0xff-8);
119}
120
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}
140
141void TConsole::SetForeground(unsigned char wAttrib) {
142 if(reverse) bg = wAttrib; else fg = wAttrib;
143 wAttributes = (wAttributes & (unsigned char)0x88) |
144 (unsigned char)fg | (bg << 4);
145}
146
147void TConsole::SetBackground(unsigned char wAttrib) {
148 if(reverse) fg = wAttrib; else bg = wAttrib;
149 wAttributes = (wAttributes & (unsigned char)0x88) |
150 (unsigned char)fg | (bg << 4);
151}
152
153// As far as I can tell, there's no such thing as blink in Windows Console.
154// I tried using some inline asm to turn off high-intensity backgrounds,
155// but I got a BSOD. Perhaps there is an undocumented function?
156// (Paul Brannan 6/27/98)
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}
174
175// Added by I.Ioannou 06 April, 1997
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}
193
194// Paul Brannan 6/27/98
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}
212
213// Paul Brannan 6/27/98
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}
231
232// Paul Brannan 6/27/98
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}
245
246// Paul Brannan 6/27/98
248 if(blink) {
249 BlinkOn();
250 } else if(underline) {
251 UnderlineOn();
252 } else {
253 Normal();
254 }
255}
256
257// Paul Brannan 6/26/98
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}
282
283// Paul Brannan 6/26/98
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}
309
310// Added by I.Ioannou 11.May,1997
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}
326
327// Added by I.Ioannou 11.May,1997
329 if (reverse) {
330 reverse = false;
331 wAttributes = fg | (bg << 4);
332 }
333}
334
335unsigned long TConsole::WriteText(const char *pszString, unsigned long cbString) {
337
338 if(insert_mode) {
339 InsertCharacter(cbString);
340 }
341
346 return Result;
347}
348
349// Formerly ConWriteString (Paul Brannan 6/28/98)
350unsigned long TConsole::WriteStringFast(const char* pszString, unsigned long cbString) {
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}
472
473unsigned long TConsole::WriteString(const char* pszString, unsigned long cbString) {
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}
540
541// This is for multi-character control strings (Paul Brannan 6/26/98)
542unsigned long TConsole::WriteCtrlString(const char *pszString, unsigned long cbString) {
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}
554
555// This is for printing single control characters
556// WriteCtrlString uses this (Paul Brannan 6/26/98)
557unsigned long TConsole::WriteCtrlChar(char c) {
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}
588
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}
612
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}
624
625void TConsole::ScrollDown( int iStartRow , int iEndRow, int bUp ){
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}
686
687// This allows us to clear the screen with an arbitrary character
688// (Paul Brannan 6/26/98)
690 DWORD dwWritten;
691 COORD Coord = {CON_LEFT, CON_TOP};
693 (DWORD)(CON_LINES), Coord, &dwWritten);
695 (DWORD)(CON_LINES), Coord, &dwWritten);
696}
697
698// Same as clear screen, but only affects the scroll region
699void TConsole::ClearWindow(int iStartRow, int iEndRow, char c) {
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}
707
708// Clear from cursor to end of screen
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}
719
720// Clear from beginning of screen to cursor
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}
731
733{
734 DWORD dwWritten;
735 COORD Coord = {CON_LEFT, CON_TOP + CON_CUR_Y};
737 Coord, &dwWritten);
739 Coord, &dwWritten);
741}
742
744{
745 DWORD dwWritten;
748 (DWORD)(CON_RIGHT - CON_CUR_X) +1, Coord, &dwWritten);
750 Coord, &dwWritten);
752}
753
755{
756 DWORD dwWritten;
757 COORD Coord = {CON_LEFT, CON_TOP + CON_CUR_Y};
759 &dwWritten);
761 Coord, &dwWritten);
763}
764
765
766// Inserts blank lines to the cursor-y-position
767// scrolls down the rest. CURSOR MOVEMENT (to Col#1) ???
768void TConsole::InsertLine(int numlines)
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 */
798
799// Inserts blank characters under the cursor
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 */
827
828// Deletes characters under the cursor
829// Note that there are cases in which all the following lines should shift by
830// a character, but we don't handle these. This could break some
831// VT102-applications, but it shouldn't be too much of an issue.
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 */
859
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}
882
883// The new SetCursorPosition takes scroll regions into consideration
884// (Paul Brannan 6/27/98)
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}
906
909}
910
912{
913 // Probably should do something here...
914 // Should change the screen mode, but do we need this?
915}
916
919 iScrollEnd = end;
920}
921
923 if(ini.get_do_beep()) {
924 if(!ini.get_speaker_beep()) printit("\a");
925 else ::Beep(400, 100);
926 }
927}
928
930 CONSOLE_CURSOR_INFO ci = {(pct != 0)?pct:1, pct != 0};
932}
933
934void saveScreen(CHAR_INFO *chiBuffer) {
937 SMALL_RECT srctReadRect;
938 COORD coordBufSize;
939 COORD coordBufCoord;
940
943
944 srctReadRect.Top = CON_TOP; /* top left: row 0, col 0 */
945 srctReadRect.Left = CON_LEFT;
946 srctReadRect.Bottom = CON_BOTTOM; /* bot. right: row 1, col 79 */
947 srctReadRect.Right = CON_RIGHT;
948
949 coordBufSize.Y = CON_BOTTOM-CON_TOP+1;
950 coordBufSize.X = CON_RIGHT-CON_LEFT+1;
951
952 coordBufCoord.X = CON_TOP;
953 coordBufCoord.Y = CON_LEFT;
954
956 hStdout, /* screen buffer to read from */
957 chiBuffer, /* buffer to copy into */
958 coordBufSize, /* col-row size of chiBuffer */
959
960 coordBufCoord, /* top left dest. cell in chiBuffer */
961 &srctReadRect); /* screen buffer source rectangle */
962}
963
964void restoreScreen(CHAR_INFO *chiBuffer) {
967 SMALL_RECT srctReadRect;
968 COORD coordBufSize;
969 COORD coordBufCoord;
970
973
974 // restore screen
975 srctReadRect.Top = CON_TOP; /* top left: row 0, col 0 */
976 srctReadRect.Left = CON_LEFT;
977 srctReadRect.Bottom = CON_BOTTOM; /* bot. right: row 1, col 79 */
978 srctReadRect.Right = CON_RIGHT;
979
980 coordBufSize.Y = CON_BOTTOM-CON_TOP+1;
981 coordBufSize.X = CON_RIGHT-CON_LEFT+1;
982
983 coordBufCoord.X = CON_TOP;
984 coordBufCoord.Y = CON_LEFT;
986 hStdout, /* screen buffer to write to */
987 chiBuffer, /* buffer to copy from */
988 coordBufSize, /* col-row size of chiBuffer */
989 coordBufCoord, /* top left src cell in chiBuffer */
990 &srctReadRect); /* dest. screen buffer rectangle */
991 // end restore screen
992
993}
994
999 CHAR_INFO * chiBuffer;
1000 chiBuffer = new CHAR_INFO[(CON_BOTTOM-CON_TOP+1)*(CON_RIGHT-CON_LEFT+1)];
1001 return chiBuffer;
1002}
1003
1004void deleteBuffer(CHAR_INFO* chiBuffer) {
1005 delete[] chiBuffer;
1006}
1007
_STLP_MOVE_TO_STD_NAMESPACE void fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val)
Definition: _algobase.h:449
BOOL WINAPI SetConsoleCursorPosition(IN HANDLE hConsoleOutput, IN COORD dwCursorPosition)
Definition: console.c:641
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
Definition: console.c:203
BOOL WINAPI SetConsoleTextAttribute(IN HANDLE hConsoleOutput, IN WORD wAttributes)
Definition: console.c:672
BOOL WINAPI SetConsoleCursorInfo(IN HANDLE hConsoleOutput, IN const CONSOLE_CURSOR_INFO *lpConsoleCursorInfo)
Definition: console.c:618
BOOL WINAPI FillConsoleOutputAttribute(IN HANDLE hConsoleOutput, IN WORD wAttribute, IN DWORD nLength, IN COORD dwWriteCoord, OUT LPDWORD lpNumberOfAttrsWritten)
Definition: console.c:525
BOOL WINAPI GetConsoleScreenBufferInfo(IN HANDLE hConsoleOutput, OUT PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo)
Definition: console.c:595
Card Top()
Definition: cardregion.h:94
int get_normal_fg() const
Definition: tnconfig.h:72
int get_term_height() const
Definition: tnconfig.h:57
bool get_vt100_mode() const
Definition: tnconfig.h:47
int get_normal_bg() const
Definition: tnconfig.h:71
int get_ulblink_fg() const
Definition: tnconfig.h:70
int get_underline_bg() const
Definition: tnconfig.h:67
int get_underline_fg() const
Definition: tnconfig.h:68
int get_ulblink_bg() const
Definition: tnconfig.h:69
int get_term_width() const
Definition: tnconfig.h:56
bool get_speaker_beep() const
Definition: tnconfig.h:49
int get_blink_fg() const
Definition: tnconfig.h:66
bool get_do_beep() const
Definition: tnconfig.h:50
int get_blink_bg() const
Definition: tnconfig.h:65
bool get_preserve_colors() const
Definition: tnconfig.h:51
unsigned char defaultbg
Definition: tconsole.h:153
void SetWindowSize(int width, int height)
Definition: tconsole.cpp:93
bool reverse
Definition: tconsole.h:158
void ClearLine(char c=' ')
Definition: tconsole.cpp:732
void Darkbg()
Definition: tconsole.cpp:284
unsigned char bg
Definition: tconsole.h:152
void SetCursorPosition(int x, int y)
Definition: tconsole.cpp:885
unsigned long WriteCtrlChar(char c)
Definition: tconsole.cpp:557
bool getLineWrap()
Definition: tconsole.h:135
void InsertLine(int numlines)
Definition: tconsole.cpp:768
void HighVideo()
Definition: tconsole.cpp:113
void SetExtendedMode(int iFunction, BOOL bEnable)
Definition: tconsole.cpp:911
void InsertCharacter(int numchar)
Definition: tconsole.cpp:800
void index()
Definition: tconsole.cpp:589
void ScrollDown(int iStartRow, int iEndRow, int bUp)
Definition: tconsole.cpp:625
void Normal()
Definition: tconsole.cpp:121
void SetScroll(int start, int end)
Definition: tconsole.cpp:917
unsigned long WriteCtrlString(const char *pszString, unsigned long cbString)
Definition: tconsole.cpp:542
int GetCursorX()
Definition: tconsole.h:69
void LowVideo()
Definition: tconsole.cpp:117
bool blink
Definition: tconsole.h:156
void reverse_index()
Definition: tconsole.cpp:613
unsigned long WriteString(const char *pszString, unsigned long cbString)
Definition: tconsole.cpp:473
~TConsole()
Definition: tconsole.cpp:85
void ClearWindow(int start, int end, char c=' ')
Definition: tconsole.cpp:699
void SetBackground(unsigned char wAttrib)
Definition: tconsole.cpp:147
int GetCursorY()
Definition: tconsole.h:70
unsigned char defaultfg
Definition: tconsole.h:153
void ClearEOScreen(char c=' ')
Definition: tconsole.cpp:709
bool underline
Definition: tconsole.h:157
unsigned char origfg
Definition: tconsole.h:154
int iScrollEnd
Definition: tconsole.h:161
void DeleteCharacter(int numchar)
Definition: tconsole.cpp:832
void ClearBOScreen(char c=' ')
Definition: tconsole.cpp:721
unsigned char fg
Definition: tconsole.h:152
unsigned char origbg
Definition: tconsole.h:154
unsigned long WriteText(const char *pszString, unsigned long cbString)
Definition: tconsole.cpp:335
HANDLE hConsole
Definition: tconsole.h:147
CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
Definition: tconsole.h:149
void UnderlineOff()
Definition: tconsole.cpp:214
unsigned long WriteStringFast(const char *pszString, unsigned long cbString)
Definition: tconsole.cpp:350
void UnderlineOn()
Definition: tconsole.cpp:195
void sync()
Definition: tconsole.cpp:109
void ClearBOLine(char c=' ')
Definition: tconsole.cpp:754
void UlBlinkOn()
Definition: tconsole.cpp:233
int insert_mode
Definition: tconsole.h:162
void SetCursorSize(int pct)
Definition: tconsole.cpp:929
int iScrollStart
Definition: tconsole.h:160
void SetRawCursorPosition(int x, int y)
Definition: tconsole.cpp:860
void ReverseOn()
Definition: tconsole.cpp:311
void Lightbg()
Definition: tconsole.cpp:258
void Beep()
Definition: tconsole.cpp:922
void MoveCursorPosition(int x, int y)
Definition: tconsole.cpp:907
void SetForeground(unsigned char wAttrib)
Definition: tconsole.cpp:141
unsigned char wAttributes
Definition: tconsole.h:151
void BlinkOff()
Definition: tconsole.cpp:176
void ClearScreen(char c=' ')
Definition: tconsole.cpp:689
void ReverseOff()
Definition: tconsole.cpp:328
void UlBlinkOff()
Definition: tconsole.cpp:247
void BlinkOn()
Definition: tconsole.cpp:157
TConsole(HANDLE hConsole)
Definition: tconsole.cpp:56
void ClearEOLine(char c=' ')
Definition: tconsole.cpp:743
HANDLE hStdout
Definition: ctm.c:56
#define NULL
Definition: types.h:112
#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
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(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
size_t total
GLuint start
Definition: gl.h:1545
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLuint GLuint end
Definition: gl.h:1545
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
const GLubyte * c
Definition: glext.h:8905
GLuint GLsizei bufSize
Definition: glext.h:6040
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
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
static const struct encodedInt ints[]
Definition: encode.c:48
static unsigned(__cdecl *hash_bstr)(bstr_t s)
short SHORT
Definition: pedump.c:59
static calc_node_t temp
Definition: rpn_ieee.c:38
CardRegion * from
Definition: spigame.cpp:19
CHAR AsciiChar
Definition: wincon.h:185
union _CHAR_INFO::@3257 Char
WORD Attributes
Definition: wincon.h:187
Definition: bl.h:1338
ULONG Y
Definition: bl.h:1340
ULONG X
Definition: bl.h:1339
SHORT Y
Definition: blue.h:27
SHORT X
Definition: blue.h:26
SHORT Right
Definition: blue.h:34
SHORT Left
Definition: blue.h:32
SHORT Top
Definition: blue.h:33
SHORT Bottom
Definition: blue.h:35
static CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
Definition: video.c:47
void saveScreen(CHAR_INFO *chiBuffer)
Definition: tconsole.cpp:934
void restoreScreen(CHAR_INFO *chiBuffer)
Definition: tconsole.cpp:964
void deleteBuffer(CHAR_INFO *chiBuffer)
Definition: tconsole.cpp:1004
CHAR_INFO * newBuffer()
Definition: tconsole.cpp:995
#define CON_TOP
Definition: tconsole.h:45
#define CON_LEFT
Definition: tconsole.h:48
#define CON_CUR_Y
Definition: tconsole.h:57
#define CON_HEIGHT
Definition: tconsole.h:51
#define CON_RIGHT
Definition: tconsole.h:49
#define CON_COLS
Definition: tconsole.h:54
#define CON_LINES
Definition: tconsole.h:53
#define CON_WIDTH
Definition: tconsole.h:52
#define CON_CUR_X
Definition: tconsole.h:56
#define CON_BOTTOM
Definition: tconsole.h:46
TConfig ini
Definition: tnconfig.cpp:45
int printit(const char *it)
Definition: tnerror.cpp:58
#define STD_OUTPUT_HANDLE
Definition: winbase.h:268
#define WriteConsoleOutputCharacter
Definition: wincon.h:789
#define ReadConsoleOutput
Definition: wincon.h:780
#define ScrollConsoleScreenBuffer
Definition: wincon.h:782
#define WriteConsoleOutput
Definition: wincon.h:787
#define WriteConsole
Definition: wincon.h:784
#define FillConsoleOutputCharacter
Definition: wincon.h:788
_In_ DWORD _In_ DWORD _Out_writes_to_opt_ pcchString LPSTR pszString
Definition: wincrypt.h:4505
_In_ BOOL bEnable
Definition: winddi.h:3426
_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:426