mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-09 03:58:55 +01:00
refactor(editor): the helpers repeated over the editor files are shared
The name of a node or "(no name)" was written out in twenty places and four local functions, a lower-case copy of a text in four files, the test for a number, the file name of a template made comparable and the heading of a direction in three and two, the green main button of a panel in five and the key=value parameters of a self-test command in five. Each of them is one helper now: name_of, tall_button_height and main_button with the panel helpers, numeric with format, normalized with the include helpers, heading_of with the plan geometry and selftest_values with the tools; lower gives way to ToLower.
This commit is contained in:
@@ -52,14 +52,7 @@ editor_mode::selftest_result editor_mode::selftest_sweep(std::string const &comm
|
||||
{
|
||||
if (command == "sweep")
|
||||
{
|
||||
std::map<std::string, std::string> values;
|
||||
std::string pair;
|
||||
while (words >> pair)
|
||||
{
|
||||
auto const equals{pair.find('=')};
|
||||
if (equals != std::string::npos)
|
||||
values[pair.substr(0, equals)] = pair.substr(equals + 1);
|
||||
}
|
||||
auto values{selftest_values(words)};
|
||||
auto &tool{m_sweep};
|
||||
auto const get = [&](char const *Key, std::string const &Default) { auto const found{values.find(Key)}; return found != values.end() ? found->second : Default; };
|
||||
tool.edited = nullptr;
|
||||
@@ -158,14 +151,7 @@ editor_mode::selftest_result editor_mode::selftest_sweep(std::string const &comm
|
||||
}
|
||||
if (command == "bend" || command == "bendset")
|
||||
{
|
||||
std::map<std::string, std::string> values;
|
||||
std::string pair;
|
||||
while (words >> pair)
|
||||
{
|
||||
auto const equals{pair.find('=')};
|
||||
if (equals != std::string::npos)
|
||||
values[pair.substr(0, equals)] = pair.substr(equals + 1);
|
||||
}
|
||||
auto values{selftest_values(words)};
|
||||
auto const vector = [](std::string Text) {
|
||||
std::replace(Text.begin(), Text.end(), ',', ' ');
|
||||
std::istringstream numbers(Text);
|
||||
|
||||
Reference in New Issue
Block a user