[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()) {
|
||||
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)) {
|
||||
if (m_activeEditor && m_activeEditor->cutEnabled()) {
|
||||
m_activeEditor->cut();
|
||||
@ -491,14 +499,19 @@ ox::Error StudioUI::openFileActiveTab(ox::StringViewCR path, bool const makeActi
|
||||
|
||||
ox::Error StudioUI::handleCloseFileResponse(ig::PopupResponse const response) noexcept {
|
||||
if (response == ig::PopupResponse::OK && m_activeEditor) {
|
||||
for (size_t i{}; auto &e : m_editors) {
|
||||
if (m_activeEditor == e.get()) {
|
||||
oxLogError(closeFile(e->itemPath()));
|
||||
oxLogError(m_editors.erase(i).error);
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
return closeCurrentFile();
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
ox::Error StudioUI::closeCurrentFile() noexcept {
|
||||
for (size_t i{}; auto &e : m_editors) {
|
||||
if (m_activeEditor == e.get()) {
|
||||
oxLogError(closeFile(e->itemPath()));
|
||||
oxLogError(m_editors.erase(i).error);
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
@ -118,6 +118,8 @@ class StudioUI: public ox::SignalHandler {
|
||||
|
||||
ox::Error handleCloseFileResponse(ig::PopupResponse response) noexcept;
|
||||
|
||||
ox::Error closeCurrentFile() noexcept;
|
||||
|
||||
ox::Error closeFile(ox::StringViewCR path) noexcept;
|
||||
|
||||
ox::Error queueDirMove(ox::StringParam src, ox::StringParam dst) noexcept;
|
||||
|
Loading…
x
Reference in New Issue
Block a user