2020-01-18 11:38:21 +03:00
|
|
|
/*
|
2020-01-24 16:45:29 +03:00
|
|
|
* Copyright (c) 2019-2020, Sergey Bugaev <bugaevc@serenityos.org>
|
2020-01-18 11:38:21 +03:00
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 11:38:21 +03:00
|
|
|
*/
|
|
|
|
|
2019-10-02 22:44:05 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/String.h>
|
|
|
|
#include <AK/Vector.h>
|
|
|
|
|
|
|
|
class History final {
|
|
|
|
public:
|
2021-11-11 02:55:02 +03:00
|
|
|
void push(StringView history_item);
|
2019-10-02 22:44:05 +03:00
|
|
|
String current();
|
|
|
|
|
|
|
|
void go_back();
|
|
|
|
void go_forward();
|
|
|
|
|
|
|
|
bool can_go_back() { return m_current_history_item > 0; }
|
2020-02-25 16:49:47 +03:00
|
|
|
bool can_go_forward() { return m_current_history_item + 1 < static_cast<int>(m_items.size()); }
|
2019-10-02 22:44:05 +03:00
|
|
|
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
private:
|
|
|
|
Vector<String> m_items;
|
|
|
|
int m_current_history_item { -1 };
|
|
|
|
};
|