diff --git a/src/gui/Window.cc b/src/gui/Window.cc index 02adeaa..574f9aa 100644 --- a/src/gui/Window.cc +++ b/src/gui/Window.cc @@ -436,7 +436,7 @@ void Window::draw_buffer() if (cursor.line == m_cursor->line) draw_crosshair(screen_column, screen_row); if (cursor == *m_cursor) - draw_cursor(screen_column, screen_row); + draw_cursor(screen_column, screen_row, m_buffer->piece_table->in_insert_mode()); uint32_t character = *cursor; if ((character != 0xFFFFFFFFu) && (character != ' ') && @@ -505,15 +505,13 @@ void Window::redraw() SDL_GL_SwapWindow(m_window); } -void Window::draw_cursor(int screen_column, int screen_row) +void Window::draw_cursor(int screen_column, int screen_row, bool insert_mode) { int x, y; colrow_to_xy(screen_column, screen_row, &x, &y); - m_cursor_array->bind(); - m_shaders.flat->use(); - m_shaders.flat->set_color(1.0, 0.2, 1.0, 1.0); - m_shaders.flat->set_position(x, y); - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + int width = insert_mode ? 1 : m_font.get_advance(); + int height = m_font.get_line_height(); + draw_rect(x, y, width, height, 1.0, 0.2, 1.0, 1.0); } void Window::draw_crosshair(int screen_column, int screen_row) diff --git a/src/gui/Window.h b/src/gui/Window.h index 764465f..5455acc 100644 --- a/src/gui/Window.h +++ b/src/gui/Window.h @@ -37,7 +37,7 @@ protected: void resize(); void redraw(); - void draw_cursor(int screen_column, int screen_row); + void draw_cursor(int screen_column, int screen_row, bool insert_mode); void draw_crosshair(int screen_column, int screen_row); void colrow_to_xy(int col, int row, int * x, int * y); void handle_event(SDL_Event & event);