#ifndef TERMINAL_H
#define TERMINAL_H

#include <event2/util.h>
#include <openssl/ssl.h>

#include <cstddef>
#include <cstdint>
#include <string>
#include <string_view>
#include <vector>

struct event_base;

bool terminal_init(struct event_base *main_base);
void terminal_shutdown();

uint64_t terminal_next_session_id();
bool terminal_attach(uint64_t session_id, int connection_type, evutil_socket_t fd, SSL *ssl);
bool terminal_write(uint64_t session_id, std::string_view data);
void terminal_flush(uint64_t session_id);
void terminal_close(uint64_t session_id);
void terminal_abort(uint64_t session_id);
void terminal_set_editor(uint64_t session_id, bool enabled);
void terminal_set_echo(uint64_t session_id, bool enabled);
void terminal_begin_compress(uint64_t session_id);
bool terminal_start_pty(uint64_t session_id, std::string executable,
                        std::vector<std::string> arguments, unsigned short width,
                        unsigned short height);
void terminal_resize_pty(uint64_t session_id, unsigned short width, unsigned short height);
void terminal_signal_pty(uint64_t session_id, int signal_number);
void terminal_stop_pty(uint64_t session_id);

#endif
