Add realization open editor

This commit is contained in:
Timofey 2022-08-10 22:02:39 +03:00
parent 82cc4d0f6f
commit 7487bab9ae

View file

@ -1,9 +1,22 @@
#include <utils/editor.hpp> #include <utils/editor.hpp>
#define SIGPIPE_ALWAYS_IGNORE
#include <cppshell/shell.hpp>
#undef SIGPIPE_ALWAYS_IGNORE
#include <iostream> #include <iostream>
namespace utils { namespace utils {
void OpenEditor(const std::string& file) { void OpenEditor(const std::string& file) {
std::cout << "Open file " << file << " TODO" << std::endl; std::string editors[] = {"nvim", "vim", "vi"};
cppshell::Shell shell;
for (auto& editor : editors) {
shell.Execute(editor + " " + file);
if (shell.GetExitCodeLastCommand() == 0) {
break;
} }
} }
}
} // namespace utils