-
Notifications
You must be signed in to change notification settings - Fork 15
/
Display.h
96 lines (79 loc) · 2.34 KB
/
Display.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
*--------------------------------------------------------------------
* Project: VM65 - Virtual Machine/CPU emulator programming
* framework.
*
* File: Display.h
*
* Purpose: Prototype of Display class and all supportig data
* structures, enumerations, constants and macros.
*
* Date: 8/25/2016
*
* Copyright: (C) by Marek Karcz 2016. All rights reserved.
*
* Contact: [email protected]
*
* License Agreement and Warranty:
This software is provided with No Warranty.
I (Marek Karcz) will not be held responsible for any damage to
computer systems, data or user's health resulting from use.
Please proceed responsibly and apply common sense.
This software is provided in hope that it will be useful.
It is free of charge for non-commercial and educational use.
Distribution of this software in non-commercial and educational
derivative work is permitted under condition that original
copyright notices and comments are preserved. Some 3-rd party work
included with this project may require separate application for
permission from their respective authors/copyright owners.
*--------------------------------------------------------------------
*/
#ifndef DISPLAY_H
#define DISPLAY_H
#include "system.h"
#include "ConsoleIO.h"
#define DISP_TABSIZE 4
namespace MKBasic {
enum eScreenDimensions {
SCREENDIM_COL = 80,
SCREENDIM_ROW = 24
};
enum eScreenSpecChars {
SCREENSPECCHARS_NL = (int)'\n', // new line
SCREENSPECCHARS_CR = (int)'\r', // caret
SCREENSPECCHARS_TB = (int)'\t', // tab
SCREENSPECCHARS_BS = (int)'\b', // backspace
SCREENSPECCHARS_BE = (int)'\a' // bell
};
struct CursorCoord {
unsigned int row;
unsigned int col;
};
class Display
{
public:
Display();
~Display();
void GotoXY(unsigned int col, unsigned int row);
void PutChar(char c);
void ClrScr();
char GetCharAt(unsigned int col, unsigned int row);
void ShowScr();
CursorCoord *GetCursorCoord();
char GetLastChar();
protected:
private:
char mScreen[SCREENDIM_ROW][SCREENDIM_COL];
char mLastChar;
CursorCoord mCursorCoord;
unsigned int mShellConsoleWidth;
unsigned int mScrLines;
unsigned int mScrColumns;
ConsoleIO *mpConIO;
void InitScr();
void ScrollUp();
bool IsSpecChar(char c);
int GetConsoleWidth();
};
} // namespace MKBasic
#endif