ladybird/Userland/Libraries/LibGUI/Command.h
Andreas Kling ff912946ae LibGUI: Support merging of adjacent commands on the UndoStack
When pushing a new command on an undo stack, we will now attempt to
merge it into the stack's current command.

Merging is implemented by overriding the "merge_with(Command const&)"
virtual on GUI::Command. :^)
2021-05-08 22:17:50 +02:00

32 lines
541 B
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/String.h>
namespace GUI {
class Command {
public:
virtual ~Command();
virtual void undo() { }
virtual void redo() { }
String action_text() const { return m_action_text; }
virtual bool merge_with(Command const&) { return false; }
protected:
Command() { }
void set_action_text(const String& text) { m_action_text = text; }
private:
String m_action_text;
};
}