summaryrefslogtreecommitdiffhomepage
path: root/src/internal/ptycon_bridge_impl.h
blob: 49c1cad0a97d6c8f520fa6b4aeecd72c307905ee (plain)
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
#ifndef PTYCON_BRIDGE_IMPL_H
#define PTYCON_BRIDGE_IMPL_H

#include <psxtypes/psxtypes.h>
#include <ntcon/ntcon.h>

enum ptyc_ctrl_state {
	PTYC_CTRL_STATE_ESI,
	PTYC_CTRL_STATE_PARAM_HANDLERS,
	PTYC_CTRL_STATE_COMMAND_HANDLERS,
	PTYC_CTRL_STATE_CAP
};

#define PTYC_BUFFER_ELEMENTS	0x8000
#define PTYC_RAW_EVENTS		0x400
#define PTYC_CTRL_PARAMS	0x20

#define PTYC_ESI_ARRAY_SIZE	0x5F
#define PTYC_CSI_ARRAY_SIZE	0x6F
#define PTYC_SGR_ARRAY_SIZE	0x6D


struct ptyc_term_data {
	uintptr_t	in	[PTYC_BUFFER_ELEMENTS/sizeof(uintptr_t)];
	wchar16_t	out	[PTYC_BUFFER_ELEMENTS];
	wchar16_t	screen	[PTYC_BUFFER_ELEMENTS];
};

struct ptyc_term_input {
	nt_input_record	events	[PTYC_RAW_EVENTS];
	unsigned char	stream	[PTYC_RAW_EVENTS*4];
};

struct ptyc_vkcode {
	const unsigned char const *	mbstr;
	uint16_t			mblen;
};

struct ptyc_term_ctx;

typedef void * __fastcall ptyc_term_handler (struct ptyc_term_ctx *);

struct ptyc_term_ctx {
	void *				hin;
	void *				hout;
	wchar16_t *			wch_pty;
	wchar16_t *			wch_con;
	unsigned char *			ctrl;
	uint32_t			ctrl_cap;
	uint32_t *			ctrl_mark;
	uint32_t			ctrl_state;
	uint32_t *			ctrl_param;
	uint32_t			ctrl_params[PTYC_CTRL_PARAMS];
	ptyc_term_handler *		handler;
	ptyc_term_handler *		char_handler;
	ptyc_term_handler *		ctrl_handler;
	ptyc_term_handler * const *	ctrl_handlers[PTYC_CTRL_STATE_CAP];
	ptyc_term_handler *		ctrl_command;
	uint64_t			drvflags;
	uint16_t			foreground;
	uint16_t			background;
	nt_coord			screen_size;
	nt_coord			window_size;
	nt_console_screen_buffer_info	screen_info;
	nt_console_cursor_info		cursor_info;
	struct ptyc_term_data		data;
	struct ptyc_term_input		input;
};

extern ptyc_term_handler * const ptyc_esi_handlers[];
extern ptyc_term_handler * const ptyc_cmd_handlers[];
extern ptyc_term_handler * const ptyc_csi_handlers[];
extern ptyc_term_handler * const ptyc_sgr_handlers[];

#endif