add Buffer functions to enter/exit/query insert mode
This commit is contained in:
parent
1a34b8d7f7
commit
099ea267d6
@ -146,3 +146,18 @@ bool Buffer::write_to_file(const char * filename)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Buffer::enter_insert_mode(const Buffer::Iterator & position)
|
||||
{
|
||||
m_insert_position = position.offset();
|
||||
if (m_insert_position > m_gap_buffer->size())
|
||||
{
|
||||
m_insert_position = 0;
|
||||
}
|
||||
m_insert_mode = true;
|
||||
}
|
||||
|
||||
void Buffer::exit_insert_mode()
|
||||
{
|
||||
m_insert_mode = false;
|
||||
}
|
||||
|
@ -78,6 +78,7 @@ public:
|
||||
return m_offset >= other.m_offset;
|
||||
}
|
||||
size_t line() const { return m_line; }
|
||||
size_t offset() const { return m_offset; }
|
||||
|
||||
protected:
|
||||
Buffer * m_buffer;
|
||||
@ -99,6 +100,9 @@ public:
|
||||
uint8_t * address(size_t offset) const { return m_gap_buffer->address(offset); }
|
||||
Encoding::Type encoding() const { return m_encoding; }
|
||||
uint8_t tabstop() const { return m_tabstop; }
|
||||
void enter_insert_mode(const Buffer::Iterator & position);
|
||||
void exit_insert_mode();
|
||||
bool insert_mode() const { return m_insert_mode; }
|
||||
|
||||
protected:
|
||||
bool m_eol_at_eof;
|
||||
@ -106,6 +110,8 @@ protected:
|
||||
std::shared_ptr<GapBuffer> m_gap_buffer;
|
||||
Encoding::Type m_encoding;
|
||||
uint8_t m_tabstop;
|
||||
bool m_insert_mode;
|
||||
size_t m_insert_position;
|
||||
|
||||
void common_initialization();
|
||||
bool load_from_file(const char * filename);
|
||||
|
Loading…
x
Reference in New Issue
Block a user