libroot_debug: Merge guarded heap into libroot_debug.
[haiku.git] / src / tests / apps / miniterminal / Console.h
blobe12357c5d64e355513929cb40750ef8eca318f54
1 #ifndef _CONSOLE_H_
2 #define _CONSOLE_H_
4 #include <SupportDefs.h>
6 #define TAB_SIZE 8
7 #define TAB_MASK 7
9 #define FMASK 0x0f
10 #define BMASK 0x70
12 typedef enum {
13 CONSOLE_STATE_NORMAL = 0,
14 CONSOLE_STATE_GOT_ESCAPE,
15 CONSOLE_STATE_SEEN_BRACKET,
16 CONSOLE_STATE_NEW_ARG,
17 CONSOLE_STATE_PARSING_ARG,
18 } console_state;
20 typedef enum {
21 SCREEN_ERASE_WHOLE,
22 SCREEN_ERASE_UP,
23 SCREEN_ERASE_DOWN
24 } erase_screen_mode;
26 typedef enum {
27 LINE_ERASE_WHOLE,
28 LINE_ERASE_LEFT,
29 LINE_ERASE_RIGHT
30 } erase_line_mode;
32 #define MAX_ARGS 8
34 class ViewBuffer;
36 class Console {
37 public:
38 Console(ViewBuffer *output);
39 ~Console();
41 void ResetConsole();
43 void SetScrollRegion(int top, int bottom);
44 void ScrollUp();
45 void ScrollDown();
47 void LineFeed();
48 void RLineFeed();
49 void CariageReturn();
51 void Delete();
52 void Tab();
54 void EraseLine(erase_line_mode mode);
55 void EraseScreen(erase_screen_mode mode);
57 void SaveCursor(bool save_attrs);
58 void RestoreCursor(bool restore_attrs);
59 void UpdateCursor(int x, int y);
60 void GotoXY(int new_x, int new_y);
62 void PutChar(const char c);
64 void SetVT100Attributes(int32 *args, int32 argCount);
65 bool ProcessVT100Command(const char c, bool seen_bracket, int32 *args, int32 argCount);
67 void Write(const void *buf, size_t len);
69 private:
70 static void ResizeCallback(int32 width, int32 height, void *data);
72 int32 fLines;
73 int32 fColumns;
75 uint8 fAttr;
76 uint8 fSavedAttr;
77 bool fBrightAttr;
78 bool fReverseAttr;
80 int32 fX; // current x coordinate
81 int32 fY; // current y coordinate
82 int32 fSavedX; // used to save x and y
83 int32 fSavedY;
85 int32 fScrollTop; // top of the scroll region
86 int32 fScrollBottom; // bottom of the scroll region
88 /* state machine */
89 console_state fState;
90 int32 fArgCount;
91 int32 fArgs[MAX_ARGS];
93 ViewBuffer *fOutput;
96 #endif