mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-11 09:18:05 +03:00
6e19ab2bbc
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
43 lines
796 B
C++
43 lines
796 B
C++
/*
|
|
* Copyright (c) 2019-2020, Sergey Bugaev <bugaevc@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include "History.h"
|
|
|
|
void History::push(StringView history_item)
|
|
{
|
|
if (!m_items.is_empty() && m_items[m_current_history_item] == history_item)
|
|
return;
|
|
|
|
m_items.shrink(m_current_history_item + 1);
|
|
m_items.append(history_item);
|
|
m_current_history_item++;
|
|
}
|
|
|
|
DeprecatedString History::current()
|
|
{
|
|
if (m_current_history_item == -1)
|
|
return {};
|
|
return m_items[m_current_history_item];
|
|
}
|
|
|
|
void History::go_back()
|
|
{
|
|
VERIFY(can_go_back());
|
|
m_current_history_item--;
|
|
}
|
|
|
|
void History::go_forward()
|
|
{
|
|
VERIFY(can_go_forward());
|
|
m_current_history_item++;
|
|
}
|
|
|
|
void History::clear()
|
|
{
|
|
m_items = {};
|
|
m_current_history_item = -1;
|
|
}
|