Draw command characters as they are input

This commit is contained in:
Josh Holtrop 2017-11-14 20:40:50 -05:00
parent 2dcf13c8fa
commit c2b50a3f4f
2 changed files with 31 additions and 1 deletions

View File

@ -135,6 +135,7 @@ bool Window::create(std::shared_ptr<Buffer> buffer)
m_command_buffer_pane = std::make_shared<BufferPane>(this, m_command_buffer);
m_command_buffer_pane->set_command_mode();
m_command_buffer_screen_rows = 1;
m_command_invalid = false;
resize(INITIAL_WIDTH, INITIAL_HEIGHT);
@ -456,11 +457,39 @@ void Window::redraw()
m_buffer_pane->draw();
m_gl->draw_rect(0, m_command_buffer_screen_rows * m_font->get_line_height(), m_width, 1, 0.5, 0.5, 0.5, 1.0);
if (m_focused_buffer_pane->insert_mode())
{
m_command_buffer_pane->draw();
}
else
{
draw_command_input();
}
Jtk_SwapBuffers(m_window);
}
void Window::draw_command_input()
{
int x = 0;
float g, b;
if (m_command_invalid)
{
g = 0.0;
b = 0.0;
}
else
{
g = 1.0;
b = 1.0;
}
for (size_t i = 0u, length = m_command_input.size(); i < length; i++)
{
m_gl->draw_character(x, 0, m_command_input[i], *m_font, 1.0, g, b, 1.0);
x += m_font->get_advance();
}
}
void Window::change_focus(std::shared_ptr<BufferPane> buffer_pane)
{
m_focused_buffer_pane->set_focused(false);

View File

@ -51,6 +51,7 @@ protected:
void handle_command(const EncodedString & command);
void evaluate_command_input();
void execute_command(const Command & command);
void draw_command_input();
void command_write_file(const CommandParser & cp);
void command_quit(const CommandParser & cp);