TESTING - Patches to implement Ctrl-C in VTerm
[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
16 // === CONSTANTS ===
17 #define MAX_INPUT_CHARS32       64
18 #define MAX_INPUT_CHARS8        (MAX_INPUT_CHARS32*4)
19 #define DEFAULT_COLOUR  (VT_COL_BLACK|(0xAAA<<16))
20
21 /**
22  * \{
23  */
24 #define VT_FLAG_HIDECSR 0x01    //!< Hide the cursor
25 #define VT_FLAG_ALTBUF  0x02    //!< Alternate screen buffer
26 #define VT_FLAG_RAWIN   0x04    //!< Don't handle ^Z/^C/^V
27 #define VT_FLAG_HASFB   0x10    //!< Set if the VTerm has requested the Framebuffer
28 #define VT_FLAG_SHOWCSR 0x20    //!< Always show the text cursor
29 /**
30  * \}
31  */
32
33 enum eVT_InModes {
34         VT_INMODE_TEXT8,        // UTF-8 Text Mode (VT100/xterm Emulation)
35         VT_INMODE_TEXT32,       // UTF-32 Text Mode (Acess Native)
36         NUM_VT_INMODES
37 };
38
39
40 // === TYPES ==
41 typedef struct sVTerm   tVTerm;
42
43 // === STRUCTURES ===
44 struct sVTerm
45 {
46          int    Mode;   //!< Current Mode (see ::eTplTerminal_Modes)
47          int    Flags;  //!< Flags (see VT_FLAG_*)
48         
49         short   NewWidth;       //!< Un-applied dimensions (Width)
50         short   NewHeight;      //!< Un-applied dimensions (Height)
51         short   Width;  //!< Virtual Width
52         short   Height; //!< Virtual Height
53         short   TextWidth;      //!< Text Virtual Width
54         short   TextHeight;     //!< Text Virtual Height
55         
56         Uint32  CurColour;      //!< Current Text Colour
57         
58          int    ViewPos;        //!< View Buffer Offset (Text Only)
59          int    WritePos;       //!< Write Buffer Offset (Text Only)
60         tVT_Char        *Text;
61         
62         tVT_Char        *AltBuf;        //!< Alternate Screen Buffer
63          int    AltWritePos;    //!< Alternate write position
64         short   ScrollTop;      //!< Top of scrolling region (smallest)
65         short   ScrollHeight;   //!< Length of scrolling region
66
67          int    VideoCursorX;
68          int    VideoCursorY;
69         
70         tMutex  ReadingLock;    //!< Lock the VTerm when a process is reading from it
71         tTID    ReadingThread;  //!< Owner of the lock
72          int    InputRead;      //!< Input buffer read position
73          int    InputWrite;     //!< Input buffer write position
74         char    InputBuffer[MAX_INPUT_CHARS8];
75         Uint32  RawScancode;    //!< last raw scancode recieved
76 //      tSemaphore      InputSemaphore;
77         
78         tPGID   OwningProcessGroup;     //!< The process group that owns the terminal
79
80         Uint32          *Buffer;
81
82         // TODO: Do I need to keep this about?
83         // When should it be deallocated? on move to text mode, or some other time
84         // Call set again, it's freed, and if NULL it doesn't get reallocated.
85         tVideo_IOCtl_Bitmap     *VideoCursor;
86         
87         char    Name[2];        //!< Name of the terminal
88         tVFS_Node       Node;
89 };
90
91 // === GOBALS ===
92 extern tVTerm   *gpVT_CurTerm;
93 extern int      giVT_Scrollback;
94 extern short    giVT_RealWidth; //!< Screen Width
95 extern short    giVT_RealHeight;        //!< Screen Width
96 extern char     *gsVT_OutputDevice;
97 extern char     *gsVT_InputDevice;
98 extern int      giVT_OutputDevHandle;
99 extern int      giVT_InputDevHandle;
100
101 // === FUNCTIONS ===
102 extern void     VT_SetResolution(int Width, int Height);
103 extern void     VT_SetTerminal(int ID);
104 // --- Output ---
105 extern void     VT_InitOutput(void);
106 extern void     VT_SetMode(int Mode);
107 extern void     VT_int_ScrollFramebuffer( tVTerm *Term, int Count );
108 extern void     VT_int_UpdateCursor( tVTerm *Term, int bShow );
109 extern void     VT_int_UpdateScreen( tVTerm *Term, int UpdateAll );
110 // --- Input ---
111 extern void     VT_InitInput(void);
112 extern void     VT_KBCallBack(Uint32 Codepoint);
113 // --- VT100 Emulation ---
114 extern void     VT_int_ParseEscape_StandardLarge(tVTerm *Term, char CmdChar, int argc, int *args);
115 extern int      VT_int_ParseEscape(tVTerm *Term, const char *Buffer);
116 // --- Terminal Buffer ---
117 extern void     VT_int_PutString(tVTerm *Term, const Uint8 *Buffer, Uint Count);
118 extern void     VT_int_PutChar(tVTerm *Term, Uint32 Ch);
119 extern void     VT_int_ScrollText(tVTerm *Term, int Count);
120 extern void     VT_int_ClearLine(tVTerm *Term, int Num);
121 extern void     VT_int_ChangeMode(tVTerm *Term, int NewMode, int NewWidth, int NewHeight);
122 extern void     VT_int_ToggleAltBuffer(tVTerm *Term, int Enabled);
123
124 #endif
125

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