2018-10-21 21:59:43 +02:00
|
|
|
#pragma once
|
|
|
|
|
2018-10-26 22:32:35 +02:00
|
|
|
#include <AK/Compiler.h>
|
2018-10-27 23:42:20 +02:00
|
|
|
#include <AK/Vector.h>
|
2018-10-21 21:59:43 +02:00
|
|
|
#include <VirtualFileSystem/CharacterDevice.h>
|
|
|
|
|
2018-10-30 13:59:29 +01:00
|
|
|
class ConsoleImplementation {
|
|
|
|
public:
|
|
|
|
virtual ~ConsoleImplementation();
|
2018-12-03 00:39:25 +01:00
|
|
|
virtual void on_sysconsole_receive(byte) = 0;
|
2018-10-30 13:59:29 +01:00
|
|
|
};
|
|
|
|
|
2018-10-21 21:59:43 +02:00
|
|
|
class Console final : public CharacterDevice {
|
2018-10-31 23:19:15 +01:00
|
|
|
AK_MAKE_ETERNAL
|
2018-10-21 21:59:43 +02:00
|
|
|
public:
|
2018-10-26 18:43:25 +02:00
|
|
|
static Console& the() PURE;
|
2018-10-21 21:59:43 +02:00
|
|
|
|
|
|
|
Console();
|
|
|
|
virtual ~Console() override;
|
|
|
|
|
2019-01-14 14:21:51 +01:00
|
|
|
virtual bool has_data_available_for_reading(Process&) const override;
|
2019-01-15 09:17:22 +01:00
|
|
|
virtual bool can_write(Process&) const override { return true; }
|
2018-10-21 21:59:43 +02:00
|
|
|
virtual ssize_t read(byte* buffer, size_t size) override;
|
|
|
|
virtual ssize_t write(const byte* data, size_t size) override;
|
|
|
|
|
2018-10-30 13:59:29 +01:00
|
|
|
void setImplementation(ConsoleImplementation* implementation) { m_implementation = implementation; }
|
|
|
|
|
2018-12-03 01:38:22 +01:00
|
|
|
void put_char(char);
|
2018-10-21 22:11:46 +02:00
|
|
|
|
2018-10-23 15:19:02 +02:00
|
|
|
private:
|
2018-10-30 13:59:29 +01:00
|
|
|
ConsoleImplementation* m_implementation { nullptr };
|
2018-10-21 21:59:43 +02:00
|
|
|
};
|
|
|
|
|