add PieceTable::get_start_of_line()

This commit is contained in:
josh committed 2016-07-29 21:19:01 -04:00
1 parent d043137099
commit b61513b97e
2 files changed
+14

No files matched your search

+12
View File
@@ -29,3 +29,15 @@ void PieceTable::append_initial_line_piece(uint8_t * start, uint32_t length, uin
if (cursor_position.pd == end_descriptor) if (cursor_position.pd == end_descriptor)
cursor_position.pd = pd; cursor_position.pd = pd;
} }
PieceTable::PieceDescriptor * PieceTable::get_start_of_line(PieceTable::PieceDescriptor * start) const
{
PieceDescriptor * pd = start;
while (pd->prev != start_descriptor && !pd->prev->eol())
{
pd = pd->prev;
}
return pd;
}
+2
View File
@@ -81,6 +81,8 @@ public:
void append_initial_line_piece(uint8_t * start, uint32_t length, uint32_t n_chars, bool eol); void append_initial_line_piece(uint8_t * start, uint32_t length, uint32_t n_chars, bool eol);
PieceDescriptor * get_start_of_line(PieceDescriptor * start) const;
protected: protected:
const uint8_t * m_file_buffer; const uint8_t * m_file_buffer;
unsigned long m_file_buffer_size; unsigned long m_file_buffer_size;