#pragma once
/*
Terminal
by John Ryland
Copyright (c) 2023
*/
////////////////////////////////////////////////////////////////////////////////////
// Terminal Process
#include <cstdint>
namespace Terminal {
class TerminalProcess
{
public:
TerminalProcess();
virtual ~TerminalProcess();
virtual void Initialize();
virtual void Shutdown();
virtual void Update();
// If returns true, there is data available and then the parameters are
// modified so that it returns in to the buffer parameter a pointer to an
// array of bytes and the bytesAvailable parameter is modified to contain
// number of bytes in buffer.
// If it returns false, then there is no data available or the process has
// exited. Check by calling HasExited() to query if still running.
virtual bool GetAvailableData(uint8_t*& buffer, uint32_t& bytesAvailable);
virtual bool HasExited();
// Write bytes to the process
virtual bool SendBytes(const char* buffer, uint32_t bytesToWrite);
virtual void UpdateSize(int rows, int cols);
private:
static const int BUFFER_SIZE = 1024; // 1kb read buffer
uint8_t m_buffer[BUFFER_SIZE];
int m_terminalFd;
bool m_exited;
};
} // Terminal namespace