mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-01 14:18:15 +00:00
For now, there are four hard-coded PTYs: /dev/pt{m,s}[0123]
Use this in the Terminal to open a pty pair and spawn a shell.
27 lines
715 B
C++
27 lines
715 B
C++
#pragma once
|
|
|
|
#include <VirtualFileSystem/CharacterDevice.h>
|
|
#include "DoubleBuffer.h"
|
|
|
|
class SlavePTY;
|
|
|
|
class MasterPTY final : public CharacterDevice {
|
|
public:
|
|
explicit MasterPTY(unsigned index);
|
|
virtual ~MasterPTY() override;
|
|
void set_slave(SlavePTY& slave) { m_slave = &slave; }
|
|
|
|
virtual ssize_t read(byte*, size_t) override;
|
|
virtual ssize_t write(const byte*, size_t) override;
|
|
virtual bool has_data_available_for_reading(Process&) const override;
|
|
virtual bool is_master_pty() const override { return true; }
|
|
|
|
String pts_name() const;
|
|
void on_slave_write(const byte*, size_t);
|
|
|
|
private:
|
|
unsigned m_index;
|
|
SlavePTY* m_slave { nullptr };
|
|
DoubleBuffer m_buffer;
|
|
};
|