Add cursor movements to move to SOL and EOL.
This commit is contained in:
1 parent
c2166b4bd1
commit
f876b68bd0
4 files changed
+39
-4
No files matched your search
+13
-2
@@ -122,28 +122,39 @@ PieceTable::Cursor::Cursor(PieceTable * pt) : iterator(pt)
|
||||
init_column();
|
||||
}
|
||||
|
||||
void PieceTable::Cursor::go_start_of_line()
|
||||
bool PieceTable::Cursor::go_start_of_line()
|
||||
{
|
||||
bool rv = false;
|
||||
while (iterator.valid() &&
|
||||
(!iterator.piece->prev->eol()) &&
|
||||
(iterator.piece->prev != iterator.piece_table->start_piece))
|
||||
{
|
||||
iterator.go_prev_piece();
|
||||
rv = true;
|
||||
}
|
||||
if (iterator.offset != 0u)
|
||||
rv = true;
|
||||
iterator.offset = 0u;
|
||||
init_column();
|
||||
return rv;
|
||||
}
|
||||
|
||||
void PieceTable::Cursor::go_end_of_line()
|
||||
bool PieceTable::Cursor::go_end_of_line()
|
||||
{
|
||||
bool rv = false;
|
||||
while (iterator.valid() &&
|
||||
(!iterator.piece->eol()) &&
|
||||
(iterator.piece->next != iterator.piece_table->end_piece))
|
||||
{
|
||||
iterator.go_next_piece();
|
||||
rv = true;
|
||||
}
|
||||
uint32_t current_column = column;
|
||||
iterator.go_end_of_piece();
|
||||
calculate_column();
|
||||
if (column != current_column)
|
||||
rv = true;
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool PieceTable::Cursor::go_up(int n, uint32_t desired_column)
|
||||
|
||||
@@ -110,8 +110,8 @@ public:
|
||||
|
||||
Cursor(PieceTable * pt);
|
||||
|
||||
void go_start_of_line();
|
||||
void go_end_of_line();
|
||||
bool go_start_of_line();
|
||||
bool go_end_of_line();
|
||||
bool go_up(int n, uint32_t desired_column);
|
||||
bool go_down(int n, uint32_t desired_column);
|
||||
bool go_left(int n);
|
||||
|
||||
Reference in new issue
Block a user