#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_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;
uint16_t foreground;
uint16_t background;
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