@@ -134,13 +134,13 @@ NC::Key::Type stringToKey(const std::string &s)
134134}
135135
136136template <typename F>
137- Actions::BaseAction * parseActionLine (const std::string &line, F error)
137+ std::shared_ptr< Actions::BaseAction> parseActionLine (const std::string &line, F error)
138138{
139- Actions::BaseAction * result = 0 ;
139+ std::shared_ptr< Actions::BaseAction> result;
140140 size_t i = 0 ;
141141 for (; i < line.size () && !isspace (line[i]); ++i) { }
142142 if (i == line.size ()) // only action name
143- result = Actions::get (line);
143+ result = Actions::get_ (line);
144144 else // there is something else
145145 {
146146 std::string action_name = line.substr (0 , i);
@@ -149,9 +149,11 @@ Actions::BaseAction *parseActionLine(const std::string &line, F error)
149149 // push single character into input queue
150150 std::string arg = getEnclosedString (line, ' "' , ' "' , 0 );
151151 NC ::Key::Type k = stringToSpecialKey (arg);
152- auto queue = std::vector<NC ::Key::Type>{ k };
153152 if (k != NC ::Key::None)
154- result = new Actions::PushCharacters (&Global::wFooter, std::move (queue));
153+ result = std::static_pointer_cast<Actions::BaseAction>(
154+ std::make_shared<Actions::PushCharacters>(
155+ &Global::wFooter,
156+ std::vector<NC ::Key::Type>{k}));
155157 else
156158 error () << " invalid character passed to push_character: '" << arg << " '\n " ;
157159 }
@@ -161,11 +163,13 @@ Actions::BaseAction *parseActionLine(const std::string &line, F error)
161163 std::string arg = getEnclosedString (line, ' "' , ' "' , 0 );
162164 if (!arg.empty ())
163165 {
164- std::vector<NC ::Key::Type> queue (arg.begin (), arg.end ());
165166 // if char is signed, erase 1s from char -> int conversion
166167 for (auto it = arg.begin (); it != arg.end (); ++it)
167168 *it &= 0xff ;
168- result = new Actions::PushCharacters (&Global::wFooter, std::move (queue));
169+ result = std::static_pointer_cast<Actions::BaseAction>(
170+ std::make_shared<Actions::PushCharacters>(
171+ &Global::wFooter,
172+ std::vector<NC ::Key::Type>{arg.begin (), arg.end ()}));
169173 }
170174 else
171175 error () << " empty argument passed to push_characters\n " ;
@@ -176,25 +180,28 @@ Actions::BaseAction *parseActionLine(const std::string &line, F error)
176180 std::string arg = getEnclosedString (line, ' "' , ' "' , 0 );
177181 ScreenType screen_type = stringToScreenType (arg);
178182 if (screen_type != ScreenType::Unknown)
179- result = new Actions::RequireScreen (screen_type);
183+ result = std::static_pointer_cast<Actions::BaseAction>(
184+ std::make_shared<Actions::RequireScreen>(screen_type));
180185 else
181186 error () << " unknown screen passed to require_screen: '" << arg << " '\n " ;
182187 }
183188 else if (action_name == " require_runnable" )
184189 {
185190 // require that given action is runnable
186191 std::string arg = getEnclosedString (line, ' "' , ' "' , 0 );
187- auto action = Actions::get (arg);
192+ auto action = Actions::get_ (arg);
188193 if (action)
189- result = new Actions::RequireRunnable (action);
194+ result = std::static_pointer_cast<Actions::BaseAction>(
195+ std::make_shared<Actions::RequireRunnable>(action));
190196 else
191197 error () << " unknown action passed to require_runnable: '" << arg << " '\n " ;
192198 }
193199 else if (action_name == " run_external_command" )
194200 {
195201 std::string command = getEnclosedString (line, ' "' , ' "' , 0 );
196202 if (!command.empty ())
197- result = new Actions::RunExternalCommand (std::move (command));
203+ result = std::static_pointer_cast<Actions::BaseAction>(
204+ std::make_shared<Actions::RunExternalCommand>(std::move (command)));
198205 else
199206 error () << " empty command passed to run_external_command\n " ;
200207 }
@@ -472,11 +479,11 @@ void BindingsConfiguration::generateDefaults()
472479 if (notBound (k = stringToKey (" up" )))
473480 bind (k, Actions::Type::ScrollUp);
474481 if (notBound (k = stringToKey (" shift-up" )))
475- bind (k, Binding::ActionChain ({ & Actions::get (Actions::Type::SelectItem), & Actions::get (Actions::Type::ScrollUp) }));
482+ bind (k, Binding::ActionChain ({Actions::get_ (Actions::Type::SelectItem), Actions::get_ (Actions::Type::ScrollUp)}));
476483 if (notBound (k = stringToKey (" down" )))
477484 bind (k, Actions::Type::ScrollDown);
478485 if (notBound (k = stringToKey (" shift-down" )))
479- bind (k, Binding::ActionChain ({ & Actions::get (Actions::Type::SelectItem), & Actions::get (Actions::Type::ScrollDown) }));
486+ bind (k, Binding::ActionChain ({Actions::get_ (Actions::Type::SelectItem), Actions::get_ (Actions::Type::ScrollDown)}));
480487 if (notBound (k = stringToKey (" [" )))
481488 bind (k, Actions::Type::ScrollUpAlbum);
482489 if (notBound (k = stringToKey (" ]" )))
0 commit comments