Add command buffer pane
This commit is contained in:
parent
16d4b1e21b
commit
212215bf4d
@ -9,6 +9,8 @@ BufferPane::BufferPane(Window * window, std::shared_ptr<Buffer> buffer)
|
||||
m_target_column = 0;
|
||||
m_cursor_virtual_column = 0;
|
||||
m_show_status_bar = true;
|
||||
m_command_mode = false;
|
||||
m_focused = false;
|
||||
}
|
||||
|
||||
void BufferPane::resize(int width, int height)
|
||||
@ -393,6 +395,10 @@ void BufferPane::draw_buffer_character(int screen_column, int screen_row, uint32
|
||||
|
||||
void BufferPane::draw_cursor(int x, int y)
|
||||
{
|
||||
if (m_command_mode && (!m_focused))
|
||||
{
|
||||
return;
|
||||
}
|
||||
int width = m_window->font()->get_advance();
|
||||
int height = m_window->font()->get_line_height();
|
||||
if (insert_mode())
|
||||
@ -721,3 +727,9 @@ void BufferPane::redo()
|
||||
m_buffer->redo();
|
||||
m_window->request_redraw();
|
||||
}
|
||||
|
||||
void BufferPane::set_command_mode()
|
||||
{
|
||||
m_command_mode = true;
|
||||
set_show_status_bar(false);
|
||||
}
|
||||
|
@ -29,6 +29,8 @@ public:
|
||||
{
|
||||
m_show_status_bar = show_status_bar;
|
||||
}
|
||||
void set_command_mode();
|
||||
void set_focused(bool focused);
|
||||
|
||||
protected:
|
||||
int effective_scroll_offset()
|
||||
@ -77,6 +79,8 @@ protected:
|
||||
std::list<std::pair<int, Buffer::Iterator>> m_screen_lines;
|
||||
int m_target_column;
|
||||
bool m_show_status_bar;
|
||||
bool m_command_mode;
|
||||
bool m_focused;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -121,6 +121,9 @@ bool Window::create(std::shared_ptr<Buffer> buffer)
|
||||
glClearColor (0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
m_buffer_pane = std::make_shared<BufferPane>(this, buffer);
|
||||
m_command_buffer = std::make_shared<Buffer>();
|
||||
m_command_buffer_pane = std::make_shared<BufferPane>(this, m_command_buffer);
|
||||
m_command_buffer_pane->set_command_mode();
|
||||
|
||||
resize();
|
||||
|
||||
@ -365,8 +368,11 @@ void Window::resize()
|
||||
SDL_GetWindowSize(m_window, &m_width, &m_height);
|
||||
glViewport(0, 0, m_width, m_height);
|
||||
m_gl->resize(m_width, m_height);
|
||||
m_buffer_pane->move(0, 0);
|
||||
m_buffer_pane->resize(m_width, m_height);
|
||||
int line_height = m_font->get_line_height();
|
||||
m_buffer_pane->move(0, line_height + 1);
|
||||
m_buffer_pane->resize(m_width, m_height - line_height - 1);
|
||||
m_command_buffer_pane->resize(m_width, line_height);
|
||||
m_command_buffer_pane->move(0, 0);
|
||||
}
|
||||
|
||||
void Window::redraw()
|
||||
@ -374,6 +380,8 @@ void Window::redraw()
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
m_buffer_pane->draw();
|
||||
m_gl->draw_rect(0, m_font->get_line_height(), m_width, 1, 0.5, 0.5, 0.5, 1.0);
|
||||
m_command_buffer_pane->draw();
|
||||
|
||||
SDL_GL_SwapWindow(m_window);
|
||||
}
|
||||
|
@ -85,6 +85,8 @@ protected:
|
||||
std::shared_ptr<GL> m_gl;
|
||||
|
||||
std::shared_ptr<BufferPane> m_buffer_pane;
|
||||
std::shared_ptr<Buffer> m_command_buffer;
|
||||
std::shared_ptr<BufferPane> m_command_buffer_pane;
|
||||
|
||||
Uint16 m_keymod;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user