place cursor after currently-inserting piece

cursor currently is not updating while inserting
This commit is contained in:
Josh Holtrop 2016-10-29 12:06:58 -04:00
parent 239da4962e
commit 35ff48c38f
2 changed files with 11 additions and 2 deletions

View File

@ -333,6 +333,13 @@ void PieceTable::Cursor::warp_to_inserted_piece(Piece * piece)
calculate_column();
}
void PieceTable::Cursor::warp_to_beginning_of_piece(Piece * piece)
{
iterator.piece = piece;
iterator.offset = 0u;
calculate_column();
}
bool PieceTable::Cursor::is_start_of_line()
{
if (!iterator.valid() || (iterator.offset > 0u))
@ -418,7 +425,7 @@ void PieceTable::Cursor::forward_to_column(uint32_t c)
}
}
void PieceTable::begin_insert(const Cursor & cursor, bool before)
void PieceTable::begin_insert(Cursor & cursor, bool before)
{
Piece * piece = cursor.iterator.piece;
uint32_t offset = cursor.iterator.offset;
@ -479,6 +486,7 @@ void PieceTable::begin_insert(const Cursor & cursor, bool before)
change->chains[1][1] = nullptr;
apply_change(change, 1u);
cursor.warp_to_beginning_of_piece(change->after);
}
void PieceTable::insert_code_point(uint32_t code_point)

View File

@ -134,6 +134,7 @@ public:
return !(*this == c);
}
void warp_to_inserted_piece(Piece * piece);
void warp_to_beginning_of_piece(Piece * piece);
protected:
bool is_start_of_line();
@ -165,7 +166,7 @@ public:
std::shared_ptr<Cursor> add_cursor();
void begin_insert(const Cursor & cursor, bool before);
void begin_insert(Cursor & cursor, bool before);
void insert_code_point(uint32_t code_point);
void end_insert();
void insertion_test(Cursor & c);