1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:38:12 +00:00

Virtual consoles kinda work!

We now make three VirtualConsoles at boot: tty0, tty1, and tty2.
We launch an instance of /bin/sh in each one.
You switch between them with Alt+1/2/3

How very very cool :^)
This commit is contained in:
Andreas Kling 2018-10-30 15:33:37 +01:00
parent 68739dc43e
commit 7a7956a595
24 changed files with 251 additions and 103 deletions

View file

@ -11,15 +11,30 @@ TTY::~TTY()
ssize_t TTY::read(byte* buffer, size_t size)
{
return 0;
ssize_t nread = min(m_buffer.size(), size);
memcpy(buffer, m_buffer.data(), nread);
if (nread == m_buffer.size())
m_buffer.clear();
else {
dbgprintf("had %u, read %u\n", m_buffer.size(), nread);
ASSERT_NOT_REACHED();
}
return nread;
}
ssize_t TTY::write(const byte* buffer, size_t size)
{
for (size_t i = 0; i < size; ++i)
onTTYWrite(buffer[i]);
return 0;
}
bool TTY::hasDataAvailableForRead() const
{
return false;
return !m_buffer.isEmpty();
}
void TTY::emit(byte ch)
{
m_buffer.append(ch);
}