Kernel - Integrated PTY with VTerm, userland currently broken
[tpg/acess2.git] / KernelLand / Kernel / drv / vterm.h
1 /*
2  * Acess2 Kernel
3  * - By John Hodge (thePowersGang)
4  *
5  * drv/vterm.h
6  * - Virtual Terminal - Common
7  */
8 #ifndef _VTERM_H_
9 #define _VTERM_H_
10
11 #include <acess.h>
12 #include <api_drv_video.h>      // tVT_Char
13 #include <api_drv_terminal.h>
14 #include <vfs.h>
15 #include <drv_pty.h>
16
17 // === CONSTANTS ===
18 #define MAX_INPUT_CHARS32       64
19 #define MAX_INPUT_CHARS8        (MAX_INPUT_CHARS32*4)
20 #define DEFAULT_COLOUR  (VT_COL_BLACK|(0xAAA<<16))
21
22 /**
23  * \{
24  */
25 #define VT_FLAG_HIDECSR 0x01    //!< Hide the cursor
26 #define VT_FLAG_ALTBUF  0x02    //!< Alternate screen buffer
27 #define VT_FLAG_RAWIN   0x04    //!< Don't handle ^Z/^C/^V
28 #define VT_FLAG_HASFB   0x10    //!< Set if the VTerm has requested the Framebuffer
29 #define VT_FLAG_SHOWCSR 0x20    //!< Always show the text cursor
30 /**
31  * \}
32  */
33
34 enum eVT_InModes {
35         VT_INMODE_TEXT8,        // UTF-8 Text Mode (VT100/xterm Emulation)
36         VT_INMODE_TEXT32,       // UTF-32 Text Mode (Acess Native)
37         NUM_VT_INMODES
38 };
39
40
41 // === TYPES ==
42 typedef struct sVTerm   tVTerm;
43
44 // === STRUCTURES ===
45 struct sVTerm
46 {
47          int    Mode;   //!< Current Mode (see ::eTplTerminal_Modes)
48          int    Flags;  //!< Flags (see VT_FLAG_*)
49         
50         short   Width;  //!< Virtual Width
51         short   Height; //!< Virtual Height
52         short   TextWidth;      //!< Text Virtual Width
53         short   TextHeight;     //!< Text Virtual Height
54         
55         Uint32  CurColour;      //!< Current Text Colour
56         
57          int    ViewPos;        //!< View Buffer Offset (Text Only)
58          int    WritePos;       //!< Write Buffer Offset (Text Only)
59         tVT_Char        *Text;
60         
61         tVT_Char        *AltBuf;        //!< Alternate Screen Buffer
62          int    AltWritePos;    //!< Alternate write position
63         short   ScrollTop;      //!< Top of scrolling region (smallest)
64         short   ScrollHeight;   //!< Length of scrolling region
65
66         char    EscapeCodeCache[16];
67         size_t  EscapeCodeLen;
68
69          int    VideoCursorX;
70          int    VideoCursorY;
71         
72         Uint32  RawScancode;    //!< last raw scancode recieved
73         
74         Uint32          *Buffer;
75
76         // TODO: Do I need to keep this about?
77         // When should it be deallocated? on move to text mode, or some other time
78         // Call set again, it's freed, and if NULL it doesn't get reallocated.
79         tVideo_IOCtl_Bitmap     *VideoCursor;
80
81         tPTY    *PTY;
82 };
83
84 // === GOBALS ===
85 extern tVTerm   *gpVT_CurTerm;
86 extern int      giVT_Scrollback;
87 extern short    giVT_RealWidth; //!< Screen Width
88 extern short    giVT_RealHeight;        //!< Screen Width
89 extern char     *gsVT_OutputDevice;
90 extern char     *gsVT_InputDevice;
91 extern int      giVT_OutputDevHandle;
92 extern int      giVT_InputDevHandle;
93
94 // === FUNCTIONS ===
95 extern void     VT_SetResolution(int Width, int Height);
96 extern void     VT_SetTerminal(int ID);
97 // --- Output ---
98 extern void     VT_InitOutput(void);
99 extern void     VT_SetMode(int Mode);
100 extern void     VT_int_ScrollFramebuffer( tVTerm *Term, int Count );
101 extern void     VT_int_UpdateCursor( tVTerm *Term, int bShow );
102 extern void     VT_int_UpdateScreen( tVTerm *Term, int UpdateAll );
103 // --- Input ---
104 extern void     VT_InitInput(void);
105 extern void     VT_KBCallBack(Uint32 Codepoint);
106 // --- VT100 Emulation ---
107 extern void     VT_int_ParseEscape_StandardLarge(tVTerm *Term, char CmdChar, int argc, int *args);
108 extern int      VT_int_ParseEscape(tVTerm *Term, const char *Buffer, size_t Bytes);
109 // --- Terminal Buffer ---
110 extern void     VT_int_PutString(tVTerm *Term, const Uint8 *Buffer, Uint Count);
111 extern void     VT_int_PutChar(tVTerm *Term, Uint32 Ch);
112 extern void     VT_int_ScrollText(tVTerm *Term, int Count);
113 extern void     VT_int_ClearLine(tVTerm *Term, int Num);
114 extern void     VT_int_Resize(tVTerm *Term, int NewWidth, int NewHeight);
115 extern void     VT_int_ToggleAltBuffer(tVTerm *Term, int Enabled);
116
117 #endif
118

UCC git Repository :: git.ucc.asn.au