summaryrefslogtreecommitdiff
path: root/Kernel/TTY.h
blob: a54a7a1f4244269f8ee04f3f746d1b9ca6e59c14 (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
#pragma once

#include <VirtualFileSystem/CharacterDevice.h>

class TTY : public CharacterDevice {
public:
    virtual ~TTY() override;

    virtual ssize_t read(byte*, size_t) override;
    virtual ssize_t write(const byte*, size_t) override;
    virtual bool hasDataAvailableForRead() const override;

    virtual String ttyName() const = 0;

    void set_pgid(pid_t pgid) { m_pgid = pgid; }
    pid_t pgid() const { return m_pgid; }

protected:
    virtual bool isTTY() const final override { return true; }

    TTY(unsigned major, unsigned minor);
    void emit(byte);

    virtual void onTTYWrite(const byte*, size_t) = 0;

    void interrupt();

private:
    Vector<byte> m_buffer;
    pid_t m_pgid { 0 };
};