[studio] Add Ctrl-W shortcut for closing active tab
All checks were successful
Build / build (push) Successful in 3m36s
All checks were successful
Build / build (push) Successful in 3m36s
This commit is contained in:
parent
cd1f4bdaa3
commit
4461f99fa4
@ -334,6 +334,14 @@ void StudioUI::handleKeyInput() noexcept {
|
|||||||
if (m_activeEditor && m_activeEditor->pasteEnabled()) {
|
if (m_activeEditor && m_activeEditor->pasteEnabled()) {
|
||||||
m_activeEditor->paste();
|
m_activeEditor->paste();
|
||||||
}
|
}
|
||||||
|
} else if (ImGui::IsKeyPressed(ImGuiKey_W)) {
|
||||||
|
if (m_activeEditor) {
|
||||||
|
if (m_activeEditor->unsavedChanges()) {
|
||||||
|
m_closeFileConfirm.open();
|
||||||
|
} else {
|
||||||
|
oxLogError(closeCurrentFile());
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (ImGui::IsKeyPressed(ImGuiKey_X)) {
|
} else if (ImGui::IsKeyPressed(ImGuiKey_X)) {
|
||||||
if (m_activeEditor && m_activeEditor->cutEnabled()) {
|
if (m_activeEditor && m_activeEditor->cutEnabled()) {
|
||||||
m_activeEditor->cut();
|
m_activeEditor->cut();
|
||||||
@ -491,6 +499,12 @@ ox::Error StudioUI::openFileActiveTab(ox::StringViewCR path, bool const makeActi
|
|||||||
|
|
||||||
ox::Error StudioUI::handleCloseFileResponse(ig::PopupResponse const response) noexcept {
|
ox::Error StudioUI::handleCloseFileResponse(ig::PopupResponse const response) noexcept {
|
||||||
if (response == ig::PopupResponse::OK && m_activeEditor) {
|
if (response == ig::PopupResponse::OK && m_activeEditor) {
|
||||||
|
return closeCurrentFile();
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
ox::Error StudioUI::closeCurrentFile() noexcept {
|
||||||
for (size_t i{}; auto &e : m_editors) {
|
for (size_t i{}; auto &e : m_editors) {
|
||||||
if (m_activeEditor == e.get()) {
|
if (m_activeEditor == e.get()) {
|
||||||
oxLogError(closeFile(e->itemPath()));
|
oxLogError(closeFile(e->itemPath()));
|
||||||
@ -499,7 +513,6 @@ ox::Error StudioUI::handleCloseFileResponse(ig::PopupResponse const response) no
|
|||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,6 +118,8 @@ class StudioUI: public ox::SignalHandler {
|
|||||||
|
|
||||||
ox::Error handleCloseFileResponse(ig::PopupResponse response) noexcept;
|
ox::Error handleCloseFileResponse(ig::PopupResponse response) noexcept;
|
||||||
|
|
||||||
|
ox::Error closeCurrentFile() noexcept;
|
||||||
|
|
||||||
ox::Error closeFile(ox::StringViewCR path) noexcept;
|
ox::Error closeFile(ox::StringViewCR path) noexcept;
|
||||||
|
|
||||||
ox::Error queueDirMove(ox::StringParam src, ox::StringParam dst) noexcept;
|
ox::Error queueDirMove(ox::StringParam src, ox::StringParam dst) noexcept;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user