mirror of
https://github.com/RGBCube/serenity
synced 2025-05-25 18:35:09 +00:00

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 :^)
36 lines
851 B
C++
36 lines
851 B
C++
/*
|
|
* Copyright (c) 2021, Ryan Wilson <ryan@rdwilson.xyz>
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include "Pattern.h"
|
|
#include <AK/DeprecatedString.h>
|
|
#include <AK/StringBuilder.h>
|
|
#include <AK/Vector.h>
|
|
#include <LibGUI/Action.h>
|
|
#include <stdio.h>
|
|
|
|
Pattern::Pattern(Vector<DeprecatedString> pattern)
|
|
{
|
|
m_pattern = move(pattern);
|
|
}
|
|
|
|
void Pattern::set_action(GUI::Action* action)
|
|
{
|
|
m_action = action;
|
|
}
|
|
|
|
void Pattern::rotate_clockwise()
|
|
{
|
|
Vector<DeprecatedString> rotated;
|
|
for (size_t i = 0; i < m_pattern.first().length(); i++) {
|
|
StringBuilder builder;
|
|
for (int j = m_pattern.size() - 1; j >= 0; j--) {
|
|
builder.append(m_pattern.at(j).substring(i, 1));
|
|
}
|
|
rotated.append(builder.to_string());
|
|
}
|
|
m_pattern = move(rotated);
|
|
}
|