Compare commits
No commits in common. "cda036ce701e353da6e10899e55d4423cc629fc5" and "6f14bf553f666df3a13ea3e772b5baa900753105" have entirely different histories.
cda036ce70
...
6f14bf553f
@ -2,7 +2,6 @@
|
|||||||
#include "video/TextConsole.h"
|
#include "video/TextConsole.h"
|
||||||
#include <luna/Buffer.h>
|
#include <luna/Buffer.h>
|
||||||
#include <luna/CString.h>
|
#include <luna/CString.h>
|
||||||
#include <luna/Vector.h>
|
|
||||||
|
|
||||||
static Buffer g_console_input;
|
static Buffer g_console_input;
|
||||||
|
|
||||||
@ -35,24 +34,7 @@ bool ConsoleDevice::blocking() const
|
|||||||
return g_console_input.size() == 0;
|
return g_console_input.size() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Vector<u8> g_temp_input;
|
|
||||||
|
|
||||||
void ConsoleDevice::did_press_key(char key)
|
void ConsoleDevice::did_press_key(char key)
|
||||||
{
|
{
|
||||||
if (key == '\b')
|
*g_console_input.slice_at_end(1).value() = (u8)key;
|
||||||
{
|
|
||||||
if (g_temp_input.try_pop().has_value()) TextConsole::putwchar(L'\b');
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_temp_input.try_append(key).value();
|
|
||||||
|
|
||||||
if (key == '\n')
|
|
||||||
{
|
|
||||||
g_console_input.append_data(g_temp_input.data(), g_temp_input.size()).value();
|
|
||||||
g_temp_input.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
TextConsole::putchar(key);
|
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,6 @@ class Buffer
|
|||||||
|
|
||||||
Result<u8*> slice(usize offset, usize size);
|
Result<u8*> slice(usize offset, usize size);
|
||||||
|
|
||||||
Result<void> append_data(u8* data, usize size);
|
|
||||||
|
|
||||||
u8* data()
|
u8* data()
|
||||||
{
|
{
|
||||||
return m_data;
|
return m_data;
|
||||||
|
@ -160,12 +160,6 @@ template <typename T> class Vector
|
|||||||
return m_size;
|
return m_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear()
|
|
||||||
{
|
|
||||||
m_size = m_capacity = 0;
|
|
||||||
free_impl(m_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T* m_data { nullptr };
|
T* m_data { nullptr };
|
||||||
usize m_capacity { 0 };
|
usize m_capacity { 0 };
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include <luna/Buffer.h>
|
#include <luna/Buffer.h>
|
||||||
#include <luna/CString.h>
|
|
||||||
#include <luna/Heap.h>
|
#include <luna/Heap.h>
|
||||||
|
|
||||||
Buffer::Buffer()
|
Buffer::Buffer()
|
||||||
@ -45,10 +44,3 @@ Result<u8*> Buffer::slice(usize offset, usize size)
|
|||||||
if (offset + size > m_size) { TRY(try_resize(offset + size)); }
|
if (offset + size > m_size) { TRY(try_resize(offset + size)); }
|
||||||
return m_data + offset;
|
return m_data + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<void> Buffer::append_data(u8* data, usize size)
|
|
||||||
{
|
|
||||||
memcpy(TRY(slice_at_end(size)), data, size);
|
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user