display column as 0 on empty lines in command mode
This commit is contained in:
parent
2339380dd3
commit
8542de4ee1
@ -371,6 +371,23 @@ void BufferPane::handle_key(uint32_t keyval)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t BufferPane::display_column() const
|
||||||
|
{
|
||||||
|
if (!m_iterator->valid())
|
||||||
|
{
|
||||||
|
return 0u;
|
||||||
|
}
|
||||||
|
if ((**m_iterator == '\n') && (!m_buffer->insert_mode()))
|
||||||
|
{
|
||||||
|
Buffer::Iterator i = *m_iterator;
|
||||||
|
if (!i.go_left_in_line())
|
||||||
|
{
|
||||||
|
return 0u;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return m_cursor_virtual_column + 1u;
|
||||||
|
}
|
||||||
|
|
||||||
void BufferPane::cursor_move(CursorMovement which)
|
void BufferPane::cursor_move(CursorMovement which)
|
||||||
{
|
{
|
||||||
bool moved = false;
|
bool moved = false;
|
||||||
|
@ -15,8 +15,8 @@ public:
|
|||||||
void resize(int width, int height) override;
|
void resize(int width, int height) override;
|
||||||
void draw();
|
void draw();
|
||||||
void handle_key(uint32_t keyval);
|
void handle_key(uint32_t keyval);
|
||||||
size_t line() const { return m_iterator->line(); }
|
size_t display_line() const { return m_iterator->line() + 1u; }
|
||||||
size_t column() const { return m_cursor_virtual_column; }
|
size_t display_column() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
enum class CursorMovement : uint8_t
|
enum class CursorMovement : uint8_t
|
||||||
|
@ -5,7 +5,7 @@ void BufferStatusPane::draw()
|
|||||||
m_gl->draw_rect(win_x(0), win_y(m_font->get_line_height()), m_width, 1, 0.5, 0.5, 0.5, 1.0);
|
m_gl->draw_rect(win_x(0), win_y(m_font->get_line_height()), m_width, 1, 0.5, 0.5, 0.5, 1.0);
|
||||||
m_gl->draw_rect(win_x(0), win_y(0), m_width, m_font->get_line_height(), 0.0, 0.0, 0.0, 1.0);
|
m_gl->draw_rect(win_x(0), win_y(0), m_width, m_font->get_line_height(), 0.0, 0.0, 0.0, 1.0);
|
||||||
char cursor_position[20];
|
char cursor_position[20];
|
||||||
sprintf(cursor_position, "%zu, %zu", m_buffer_pane->line() + 1, m_buffer_pane->column() + 1u);
|
sprintf(cursor_position, "%zu, %zu", m_buffer_pane->display_line(), m_buffer_pane->display_column());
|
||||||
int cursor_position_length = strlen(cursor_position);
|
int cursor_position_length = strlen(cursor_position);
|
||||||
int x = m_width - m_font->get_advance() * cursor_position_length;
|
int x = m_width - m_font->get_advance() * cursor_position_length;
|
||||||
for (int i = 0; i < cursor_position_length; i++)
|
for (int i = 0; i < cursor_position_length; i++)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user