Skip to content

Commit 23f6772

Browse files
committed
Add HSplit/VSplit to Explorer right-click, Split menu options
1 parent 814478e commit 23f6772

4 files changed

Lines changed: 46 additions & 2 deletions

File tree

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.2.74 (d6226fa)
1+
0.2.75 (814478e)

pcode-settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
"font_size": 17,
1414
"font_name": "CascadiaMono",
1515
"last_open_dir": "C:\\Users\\casse\\github\\pcode-editor\\src",
16-
"recent_files": ["C:\\Users\\casse\\github\\pcode-editor\\src\\editor_app.h", "C:\\Users\\casse\\github\\pcode-editor\\src\\main.cpp", "C:\\Users\\casse\\github\\pcode-editor\\src\\editor_app.cpp", "C:\\Users\\casse\\github\\pcode-editor\\CMakeLists.txt", "C:\\Users\\casse\\github\\pcode-editor\\TESTS.md", "C:\\Users\\casse\\github\\pcode-editor\\IMPLEMENTATION_SUMMARY.md", "C:\\Users\\casse\\github\\pcode-editor\\BUILD_SYSTEM.md", ".\\BUILD_SYSTEM.md"]
16+
"recent_files": ["C:\\Users\\casse\\github\\pcode-editor\\src\\editor_app.cpp", "C:\\Users\\casse\\github\\pcode-editor\\src\\main.cpp", "C:\\Users\\casse\\github\\pcode-editor\\src\\editor_app.h", "C:\\Users\\casse\\github\\pcode-editor\\CMakeLists.txt", "C:\\Users\\casse\\github\\pcode-editor\\TESTS.md", "C:\\Users\\casse\\github\\pcode-editor\\IMPLEMENTATION_SUMMARY.md", "C:\\Users\\casse\\github\\pcode-editor\\BUILD_SYSTEM.md", ".\\BUILD_SYSTEM.md"]
1717
}

src/editor_app.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,6 +2224,9 @@ void EditorApp::render_menu_split() {
22242224
if (ImGui::MenuItem("Split Tab Horizontally", "Ctrl+Shift+H")) split_horizontal();
22252225
if (ImGui::MenuItem("Split Tab Vertically", "Ctrl+Shift+V")) split_vertical();
22262226
ImGui::Separator();
2227+
if (ImGui::MenuItem("Split and Open Horizontally")) open_file_split("");
2228+
if (ImGui::MenuItem("Split and Open Vertically")) open_file_split_vertical("");
2229+
ImGui::Separator();
22272230
if (ImGui::MenuItem("Focus Next", "Ctrl+K")) next_split();
22282231
if (ImGui::MenuItem("Focus Previous", "Ctrl+J")) prev_split();
22292232
ImGui::Separator();
@@ -2788,6 +2791,24 @@ void EditorApp::render_dir_tree(const std::string& dir_path, std::unordered_map<
27882791
open_file(e.path);
27892792
}
27902793
}
2794+
if (ImGui::BeginPopupContextItem(e.path.c_str())) {
2795+
if (ImGui::MenuItem("Open")) {
2796+
bool already_open = false;
2797+
for (size_t i = 0; i < tabs_.size(); i++) {
2798+
if (tabs_[i].file_path == e.path) { already_open = true; break; }
2799+
}
2800+
if (!already_open) open_file(e.path);
2801+
}
2802+
if (ImGui::MenuItem("Open in HSplit")) {
2803+
split_horizontal();
2804+
open_file(e.path);
2805+
}
2806+
if (ImGui::MenuItem("Open in VSplit")) {
2807+
split_vertical();
2808+
open_file(e.path);
2809+
}
2810+
ImGui::EndPopup();
2811+
}
27912812
ImGui::PopID();
27922813
}
27932814
}
@@ -3942,6 +3963,28 @@ void EditorApp::open_file_split(const std::string& path) {
39423963
}
39433964
}
39443965

3966+
void EditorApp::open_file_split_vertical(const std::string& path) {
3967+
if (active_tab_ < 0 || active_tab_ >= (int)tabs_.size()) return;
3968+
3969+
std::string selected_path = path;
3970+
if (path.empty()) {
3971+
nfdchar_t* out_path = nullptr;
3972+
nfdresult_t result = NFD_OpenDialog(&out_path, nullptr, 0, nullptr);
3973+
if (result == NFD_OKAY && out_path) {
3974+
selected_path = out_path;
3975+
settings_.last_open_dir = std::filesystem::path(out_path).parent_path().string();
3976+
NFD_FreePath(out_path);
3977+
} else if (result == NFD_CANCEL) {
3978+
return;
3979+
}
3980+
}
3981+
3982+
if (!selected_path.empty()) {
3983+
split_vertical();
3984+
open_file(selected_path);
3985+
}
3986+
}
3987+
39453988
void EditorApp::rotate_splits() {
39463989
if (active_tab_ < 0 || active_tab_ >= (int)tabs_.size()) return;
39473990
auto& tab = tabs_[active_tab_];

src/editor_app.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ EditorApp(int argc = 0, char* argv[] = nullptr);
344344
void next_split();
345345
void prev_split();
346346
void open_file_split(const std::string& path);
347+
void open_file_split_vertical(const std::string& path);
347348
void rotate_splits();
348349
void equalize_splits();
349350
void render_splits(int tab_idx);

0 commit comments

Comments
 (0)