1 /***************************************************************************
2 * Copyright (C) 2008-2014 by Andrzej Rybczak *
3 * electricityispower@gmail.com *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
23 #include "macro_utilities.h"
24 #include "utility/string.h"
25 #include "utility/wide_string.h"
29 PushCharacters::PushCharacters(NC::Window
**w
, std::vector
<NC::Key::Type
> &&queue
)
30 : BaseAction(Type::MacroUtility
, "push_characters")
35 std::vector
<std::string
> keys
;
36 for (const auto &key
: queue
)
37 keys
.push_back(ToString(keyToWString(key
)));
39 m_name
+= join
<std::string
>(keys
, ", ");
43 void PushCharacters::run()
45 for (auto it
= m_queue
.begin(); it
!= m_queue
.end(); ++it
)
46 (*m_window
)->pushChar(*it
);
49 RequireRunnable::RequireRunnable(BaseAction
*action
)
50 : BaseAction(Type::MacroUtility
, "require_runnable")
53 assert(m_action
!= nullptr);
55 m_name
+= m_action
->name();
59 bool RequireRunnable::canBeRun()
61 return m_action
->canBeRun();
64 RequireScreen::RequireScreen(ScreenType screen_type
)
65 : BaseAction(Type::MacroUtility
, "require_screen")
66 , m_screen_type(screen_type
)
69 m_name
+= screenTypeToString(m_screen_type
);
73 bool RequireScreen::canBeRun()
75 return Global::myScreen
->type() == m_screen_type
;
78 RunExternalCommand::RunExternalCommand(std::string command
)
79 : BaseAction(Type::MacroUtility
, "run_external_command")
80 , m_command(std::move(command
))
87 void RunExternalCommand::run()
90 res
= std::system(m_command
.c_str());