1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:27:45 +00:00

GTextEditor: Start working on editing, starting with inserting newlines.

This commit is contained in:
Andreas Kling 2019-03-07 15:52:11 +01:00
parent b4df33e453
commit 8425ea971a
3 changed files with 36 additions and 11 deletions

View file

@ -159,6 +159,20 @@ public:
m_impl->remove(index);
}
void insert(int index, T&& value)
{
ASSERT(index <= size());
if (index == size())
return append(move(value));
ensure_capacity(size() + 1);
++m_impl->m_size;
for (int i = size() - 1; i > index; --i) {
new (m_impl->slot(i)) T(move(m_impl->at(i - 1)));
m_impl->at(i - 1).~T();
}
new (m_impl->slot(index)) T(move(value));
}
Vector& operator=(const Vector<T>& other)
{
if (this != &other) {