3 * - By John Hodge (thePowersGang)
6 * - Virtual Terminal - Common
12 #include <api_drv_video.h> // tVT_Char
13 #include <api_drv_terminal.h>
17 #define MAX_INPUT_CHARS32 64
18 #define MAX_INPUT_CHARS8 (MAX_INPUT_CHARS32*4)
19 #define DEFAULT_COLOUR (VT_COL_BLACK|(0xAAA<<16))
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
34 VT_INMODE_TEXT8, // UTF-8 Text Mode (VT100/xterm Emulation)
35 VT_INMODE_TEXT32, // UTF-32 Text Mode (Acess Native)
41 typedef struct sVTerm tVTerm;
46 int Mode; //!< Current Mode (see ::eTplTerminal_Modes)
47 int Flags; //!< Flags (see VT_FLAG_*)
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
56 Uint32 CurColour; //!< Current Text Colour
58 int ViewPos; //!< View Buffer Offset (Text Only)
59 int WritePos; //!< Write Buffer Offset (Text Only)
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
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;
78 tPGID OwningProcessGroup; //!< The process group that owns the terminal
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;
87 char Name[2]; //!< Name of the terminal
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;
102 extern void VT_SetResolution(int Width, int Height);
103 extern void VT_SetTerminal(int ID);
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 );
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);