diff --git a/src/gui/Window.cc b/src/gui/Window.cc index 4dc6672..118ad71 100644 --- a/src/gui/Window.cc +++ b/src/gui/Window.cc @@ -406,7 +406,7 @@ void Window::draw_text() if ((character != 0xFFFFFFFFu) && (character != ' ') && (character != '\t')) - draw_character(screen_column, screen_row, character); + draw_buffer_character(screen_column, screen_row, character); } if (!cursor.go_right(1)) { @@ -427,11 +427,16 @@ void Window::draw_text() } } -void Window::draw_character(int screen_column, int screen_row, uint32_t character) +void Window::draw_buffer_character(int screen_column, int screen_row, uint32_t character) { int x, y; - m_shaders.text->use(); colrow_to_xy(screen_column, screen_row, &x, &y); + draw_character(x, y, character); +} + +void Window::draw_character(int x, int y, uint32_t character) +{ + m_shaders.text->use(); auto g = m_font.get_glyph(character); m_shaders.text->set_position(x, y + m_font.get_baseline_offset()); g->render(); @@ -506,4 +511,13 @@ void Window::draw_status_bar() { draw_rect(0, m_font.get_line_height(), m_width, 1, 0.5, 0.5, 0.5, 1.0); draw_rect(0, 0, m_width, m_font.get_line_height(), 0.0, 0.0, 0.0, 1.0); + char cursor_position[20]; + sprintf(cursor_position, "%d, %d", m_cursor->line + 1, m_cursor->column + 1u); + int cursor_position_length = strlen(cursor_position); + int x = m_width - m_font.get_advance() * cursor_position_length; + for (int i = 0; i < cursor_position_length; i++) + { + draw_character(x, 0, cursor_position[i]); + x += m_font.get_advance(); + } } diff --git a/src/gui/Window.h b/src/gui/Window.h index 974de0f..e8783bf 100644 --- a/src/gui/Window.h +++ b/src/gui/Window.h @@ -37,7 +37,8 @@ protected: void cursor_move(int which); std::pair calculate_start_position(); void draw_text(); - void draw_character(int screen_column, int screen_row, uint32_t character); + void draw_buffer_character(int screen_column, int screen_row, uint32_t character); + void draw_character(int x, int y, uint32_t character); void update_cursor_row(int cursor_row); void draw_rect(int x, int y, int width, int height, float r, float g, float b, float a); void draw_status_bar();