add Buffer::apply_change_{operation,unit}() for undo/redo
This commit is contained in:
parent
fca838fcbf
commit
e0615011a3
@ -364,3 +364,25 @@ void Buffer::save_current_operation()
|
|||||||
m_current_change_operation_index = new_change_operation_index;
|
m_current_change_operation_index = new_change_operation_index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Buffer::apply_change_operation(const ChangeOperation & change_operation, bool forward)
|
||||||
|
{
|
||||||
|
for (auto change_unit : change_operation.changes)
|
||||||
|
{
|
||||||
|
apply_change_unit(change_unit, forward);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Buffer::apply_change_unit(const ChangeUnit & change_unit, bool forward)
|
||||||
|
{
|
||||||
|
if (forward == change_unit.insert)
|
||||||
|
{
|
||||||
|
insert_data(change_unit.buffer_position,
|
||||||
|
m_change_buffer->address(change_unit.change_buffer_offset),
|
||||||
|
change_unit.length);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
erase_data(change_unit.buffer_position, change_unit.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -165,6 +165,8 @@ protected:
|
|||||||
void erase_data(size_t offset, size_t length);
|
void erase_data(size_t offset, size_t length);
|
||||||
size_t lines_in_data(size_t offset, size_t length);
|
size_t lines_in_data(size_t offset, size_t length);
|
||||||
void post_warp_cursors();
|
void post_warp_cursors();
|
||||||
|
void apply_change_operation(const ChangeOperation & change_operation, bool forward);
|
||||||
|
void apply_change_unit(const ChangeUnit & change_unit, bool forward);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user