mirror of https://github.com/WerWolv/ImHex.git
sys: Fixed open webpage command, added run command
This commit is contained in:
parent
08ca626b2f
commit
d3a227d0bc
|
@ -37,6 +37,16 @@ namespace hex::plugin::builtin {
|
||||||
hex::openWebpage(input);
|
hex::openWebpage(input);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
hex::ContentRegistry::CommandPaletteCommands::add(
|
||||||
|
hex::ContentRegistry::CommandPaletteCommands::Type::SymbolCommand,
|
||||||
|
"$", "hex.builtin.command.cmd.desc",
|
||||||
|
[](auto input) {
|
||||||
|
return hex::format("hex.builtin.command.cmd.result"_lang, input.data());
|
||||||
|
},
|
||||||
|
[](auto input) {
|
||||||
|
hex::runCommand(input);
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -181,7 +181,8 @@ namespace hex {
|
||||||
std::string toByteString(u64 bytes);
|
std::string toByteString(u64 bytes);
|
||||||
std::string makePrintable(char c);
|
std::string makePrintable(char c);
|
||||||
|
|
||||||
void openWebpage(std::string_view url);
|
void runCommand(const std::string &command);
|
||||||
|
void openWebpage(std::string url);
|
||||||
|
|
||||||
template<typename ... Args>
|
template<typename ... Args>
|
||||||
inline std::string format(std::string_view format, Args ... args) {
|
inline std::string format(std::string_view format, Args ... args) {
|
||||||
|
|
|
@ -175,14 +175,31 @@ namespace hex {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void openWebpage(std::string_view url) {
|
void runCommand(const std::string &command) {
|
||||||
|
|
||||||
#if defined(OS_WINDOWS)
|
#if defined(OS_WINDOWS)
|
||||||
system(hex::format("start {0}", url.data()).c_str());
|
system(hex::format("start {0}", command).c_str());
|
||||||
#elif defined(OS_MACOS)
|
#elif defined(OS_MACOS)
|
||||||
system(hex::format("open {0}", url.data()).c_str());
|
system(hex::format("open {0}", command).c_str());
|
||||||
#elif defined(OS_LINUX)
|
#elif defined(OS_LINUX)
|
||||||
system(hex::format("xdg-open {0}", url.data()).c_str());
|
system(hex::format("xdg-open {0}", command).c_str());
|
||||||
|
#else
|
||||||
|
#warning "Unknown OS, can't open webpages"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void openWebpage(std::string url) {
|
||||||
|
|
||||||
|
if (!url.starts_with("http://") && !url.starts_with("https://"))
|
||||||
|
url = "https://" + url;
|
||||||
|
|
||||||
|
#if defined(OS_WINDOWS)
|
||||||
|
system(hex::format("start {0}", url).c_str());
|
||||||
|
#elif defined(OS_MACOS)
|
||||||
|
system(hex::format("open {0}", url).c_str());
|
||||||
|
#elif defined(OS_LINUX)
|
||||||
|
system(hex::format("xdg-open {0}", url).c_str());
|
||||||
#else
|
#else
|
||||||
#warning "Unknown OS, can't open webpages"
|
#warning "Unknown OS, can't open webpages"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -22,7 +22,7 @@ namespace hex {
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
|
|
||||||
ImGui::PushItemWidth(-1);
|
ImGui::PushItemWidth(-1);
|
||||||
if (ImGui::InputText("##nolabel", this->m_commandBuffer.data(), this->m_commandBuffer.size(), ImGuiInputTextFlags_CallbackEdit | ImGuiInputTextFlags_EnterReturnsTrue,
|
if (ImGui::InputText("##command_input", this->m_commandBuffer.data(), this->m_commandBuffer.size(), ImGuiInputTextFlags_CallbackEdit | ImGuiInputTextFlags_EnterReturnsTrue,
|
||||||
[](ImGuiInputTextCallbackData *callbackData) -> int {
|
[](ImGuiInputTextCallbackData *callbackData) -> int {
|
||||||
auto _this = static_cast<ViewCommandPalette*>(callbackData->UserData);
|
auto _this = static_cast<ViewCommandPalette*>(callbackData->UserData);
|
||||||
_this->m_lastResults = _this->getCommandResults(callbackData->Buf);
|
_this->m_lastResults = _this->getCommandResults(callbackData->Buf);
|
||||||
|
|
Loading…
Reference in New Issue