add a cursor position attribute to PieceTable
This commit is contained in:
parent
26f8fb355e
commit
89c0ca0bfa
@ -9,6 +9,8 @@ PieceTable::PieceTable(const uint8_t * file_buffer, unsigned long file_buffer_si
|
|||||||
start_descriptor->next = end_descriptor;
|
start_descriptor->next = end_descriptor;
|
||||||
end_descriptor->prev = start_descriptor;
|
end_descriptor->prev = start_descriptor;
|
||||||
m_piece_descriptor_index = 2u;
|
m_piece_descriptor_index = 2u;
|
||||||
|
m_cursor_position.pd = end_descriptor;
|
||||||
|
m_cursor_position.offset = 0u;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PieceTable::append_initial_line_piece(uint8_t * start, uint32_t length, uint32_t n_chars, bool eol)
|
void PieceTable::append_initial_line_piece(uint8_t * start, uint32_t length, uint32_t n_chars, bool eol)
|
||||||
@ -24,4 +26,6 @@ void PieceTable::append_initial_line_piece(uint8_t * start, uint32_t length, uin
|
|||||||
end_descriptor->prev->next = pd;
|
end_descriptor->prev->next = pd;
|
||||||
end_descriptor->prev = pd;
|
end_descriptor->prev = pd;
|
||||||
m_num_lines++;
|
m_num_lines++;
|
||||||
|
if (m_cursor_position.pd == end_descriptor)
|
||||||
|
m_cursor_position.pd = pd;
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,15 @@ public:
|
|||||||
void toggle_eol() { n_chars ^= PIECE_DESCRIPTOR_N_CHARS_EOL_FLAG_MASK; }
|
void toggle_eol() { n_chars ^= PIECE_DESCRIPTOR_N_CHARS_EOL_FLAG_MASK; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Position
|
||||||
|
{
|
||||||
|
/** The piece. */
|
||||||
|
PieceDescriptor * pd;
|
||||||
|
|
||||||
|
/** Byte offset within the piece. */
|
||||||
|
uint32_t offset;
|
||||||
|
};
|
||||||
|
|
||||||
struct ChangeDescriptor
|
struct ChangeDescriptor
|
||||||
{
|
{
|
||||||
uint32_t piece_descriptor_index;
|
uint32_t piece_descriptor_index;
|
||||||
@ -68,6 +77,8 @@ public:
|
|||||||
PieceDescriptor * start_descriptor;
|
PieceDescriptor * start_descriptor;
|
||||||
PieceDescriptor * end_descriptor;
|
PieceDescriptor * end_descriptor;
|
||||||
|
|
||||||
|
Position m_cursor_position;
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user