Skip to content

Commit 880663f

Browse files
committed
Fix: Editor dockable, statusbar attached to editor, scrollbar visible
1 parent c0a1bc3 commit 880663f

3 files changed

Lines changed: 140 additions & 147 deletions

File tree

imgui.ini

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[Window][Editor]
2-
Pos=219,26
3-
Size=1033,774
2+
Pos=0,26
3+
Size=1280,774
44
Collapsed=0
55
DockId=0x00000003,0
66

77
[Window][DockSpace]
88
Pos=0,0
9-
Size=1252,800
9+
Size=1280,800
1010
Collapsed=0
1111

1212
[Window][Debug##Default]
@@ -20,29 +20,26 @@ Size=501,229
2020
Collapsed=0
2121

2222
[Window][Explorer]
23-
Pos=0,26
24-
Size=217,774
23+
Pos=627,650
24+
Size=290,720
2525
Collapsed=0
26-
DockId=0x00000005,0
2726

2827
[Docking][Data]
29-
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,26 Size=1252,774 Split=X Selected=0xDF0EC458
30-
DockNode ID=0x00000011 Parent=0xCCBD8CF7 SizeRef=1306,851 Split=Y
31-
DockNode ID=0x0000000F Parent=0x00000011 SizeRef=1280,480 Split=X
32-
DockNode ID=0x00000005 Parent=0x0000000F SizeRef=217,803 HiddenTabBar=1 Selected=0x00F0E82E
33-
DockNode ID=0x00000006 Parent=0x0000000F SizeRef=1061,803 Split=Y
34-
DockNode ID=0x0000000D Parent=0x00000006 SizeRef=1280,472 Split=Y
35-
DockNode ID=0x0000000B Parent=0x0000000D SizeRef=1280,720 Split=Y
36-
DockNode ID=0x00000009 Parent=0x0000000B SizeRef=1280,686 Split=Y
37-
DockNode ID=0x00000007 Parent=0x00000009 SizeRef=1280,703 Split=Y
38-
DockNode ID=0x00000001 Parent=0x00000007 SizeRef=1280,386 Selected=0x00F0E82E
39-
DockNode ID=0x00000002 Parent=0x00000007 SizeRef=1280,261 Split=X
40-
DockNode ID=0x00000003 Parent=0x00000002 SizeRef=678,778 CentralNode=1 HiddenTabBar=1 Selected=0xDF0EC458
41-
DockNode ID=0x00000004 Parent=0x00000002 SizeRef=600,778 Selected=0xD33228A6
42-
DockNode ID=0x00000008 Parent=0x00000009 SizeRef=1280,64 HiddenTabBar=1 Selected=0x2AB9DED9
43-
DockNode ID=0x0000000A Parent=0x0000000B SizeRef=1280,81 HiddenTabBar=1 Selected=0x2AB9DED9
44-
DockNode ID=0x0000000C Parent=0x0000000D SizeRef=1280,47 HiddenTabBar=1 Selected=0x2AB9DED9
45-
DockNode ID=0x0000000E Parent=0x00000006 SizeRef=1280,300 Selected=0xD33228A6
46-
DockNode ID=0x00000010 Parent=0x00000011 SizeRef=1280,300 Selected=0xD33228A6
47-
DockNode ID=0x00000012 Parent=0xCCBD8CF7 SizeRef=612,851 Selected=0xD33228A6
28+
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,26 Size=1280,774 Split=X Selected=0xDF0EC458
29+
DockNode ID=0x00000011 Parent=0xCCBD8CF7 SizeRef=1306,851 Split=Y
30+
DockNode ID=0x0000000F Parent=0x00000011 SizeRef=1280,480 Split=Y
31+
DockNode ID=0x0000000D Parent=0x0000000F SizeRef=1280,472 Split=Y
32+
DockNode ID=0x0000000B Parent=0x0000000D SizeRef=1280,720 Split=Y
33+
DockNode ID=0x00000009 Parent=0x0000000B SizeRef=1280,686 Split=Y
34+
DockNode ID=0x00000007 Parent=0x00000009 SizeRef=1280,703 Split=Y
35+
DockNode ID=0x00000001 Parent=0x00000007 SizeRef=1280,386 Selected=0x00F0E82E
36+
DockNode ID=0x00000002 Parent=0x00000007 SizeRef=1280,261 Split=X
37+
DockNode ID=0x00000003 Parent=0x00000002 SizeRef=678,778 CentralNode=1 Selected=0xDF0EC458
38+
DockNode ID=0x00000004 Parent=0x00000002 SizeRef=600,778 Selected=0xD33228A6
39+
DockNode ID=0x00000008 Parent=0x00000009 SizeRef=1280,64 HiddenTabBar=1 Selected=0x2AB9DED9
40+
DockNode ID=0x0000000A Parent=0x0000000B SizeRef=1280,81 HiddenTabBar=1 Selected=0x2AB9DED9
41+
DockNode ID=0x0000000C Parent=0x0000000D SizeRef=1280,47 HiddenTabBar=1 Selected=0x2AB9DED9
42+
DockNode ID=0x0000000E Parent=0x0000000F SizeRef=1280,300 Selected=0xD33228A6
43+
DockNode ID=0x00000010 Parent=0x00000011 SizeRef=1280,300 Selected=0xD33228A6
44+
DockNode ID=0x00000012 Parent=0xCCBD8CF7 SizeRef=612,851 Selected=0xD33228A6
4845

pcode-settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
"tab_size": 4,
1313
"font_size": 18,
1414
"font_name": "CascadiaMono",
15-
"last_open_dir": ".\\docs",
16-
"recent_files": [".\\docs\\versioning.md", ".\\docs\\imgui_tutorial.md", ".\\docs\\VIM_MOTIONS_SPEC.md", ".\\src\\editor_app.cpp", "./src/editor_app.h", "./src/main.cpp", "./src/editor_app.cpp", "VERSION", "./CMakeLists.txt"]
15+
"last_open_dir": ".\\src",
16+
"recent_files": [".\\src\\editor_app.cpp", ".\\docs\\versioning.md", ".\\docs\\imgui_tutorial.md", ".\\docs\\VIM_MOTIONS_SPEC.md", "./src/editor_app.h", "./src/main.cpp", "./src/editor_app.cpp", "VERSION", "./CMakeLists.txt"]
1717
}

src/editor_app.cpp

Lines changed: 116 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,8 +1821,6 @@ void EditorApp::render() {
18211821

18221822
ImGui::End();
18231823

1824-
// Render status bar AFTER DockSpace ends to avoid nesting issues
1825-
if (settings_.show_status_bar) render_status_bar();
18261824
render_command_line();
18271825
render_terminal();
18281826
}
@@ -2033,7 +2031,8 @@ ImGui::EndMenu();
20332031
// Editor Area
20342032
// ============================================================================
20352033
void EditorApp::render_editor_area() {
2036-
ImGui::Begin("Editor", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse);
2034+
// Editor window - dockable and can float
2035+
ImGui::Begin("Editor", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove);
20372036

20382037
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_RootWindow)) {
20392038
editor_focused_ = true;
@@ -2107,6 +2106,60 @@ void EditorApp::render_editor_area() {
21072106
render_editor_with_margins();
21082107
}
21092108
}
2109+
2110+
// Render status bar at bottom of editor window (docked to editor)
2111+
if (settings_.show_status_bar) {
2112+
float status_height = 24;
2113+
ImVec2 editor_pos = ImGui::GetWindowPos();
2114+
float editor_width = ImGui::GetWindowWidth();
2115+
float editor_height = ImGui::GetWindowHeight();
2116+
2117+
// Status bar background
2118+
ImDrawList* draw_list = ImGui::GetWindowDrawList();
2119+
ImU32 status_bg = ImColor(0.2f, 0.2f, 0.25f);
2120+
draw_list->AddRectFilled(
2121+
ImVec2(editor_pos.x, editor_pos.y + editor_height - status_height),
2122+
ImVec2(editor_pos.x + editor_width, editor_pos.y + editor_height),
2123+
status_bg);
2124+
2125+
// Position cursor at bottom
2126+
ImGui::SetCursorPosY(editor_height - status_height);
2127+
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4, 2));
2128+
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.8f, 0.8f, 0.8f, 1.0f));
2129+
2130+
if (active_tab_ >= 0 && active_tab_ < (int)tabs_.size()) {
2131+
auto& tab = tabs_[active_tab_];
2132+
TextEditor* ed = get_active_editor();
2133+
auto pos = ed ? ed->GetCursorPosition() : TextEditor::Coordinates();
2134+
2135+
ImGui::Text("%s", get_vim_mode_str());
2136+
ImGui::SameLine();
2137+
ImGui::Text(" | ");
2138+
ImGui::SameLine();
2139+
ImGui::Text("Ln %d, Col %d", pos.mLine + 1, pos.mColumn + 1);
2140+
ImGui::SameLine();
2141+
ImGui::Text(" | ");
2142+
ImGui::SameLine();
2143+
ImGui::Text("%s", tab.file_encoding.c_str());
2144+
ImGui::SameLine();
2145+
ImGui::Text(" | ");
2146+
ImGui::SameLine();
2147+
ImGui::Text("%s", tab.line_ending.c_str());
2148+
ImGui::SameLine();
2149+
ImGui::Text(" | ");
2150+
ImGui::SameLine();
2151+
ImGui::Text("%d%%", tabs_[active_tab_].zoom_pct);
2152+
ImGui::SameLine();
2153+
ImGui::Text(" | ");
2154+
ImGui::SameLine();
2155+
ImGui::Text("%s", tab.display_name.c_str());
2156+
ImGui::SameLine();
2157+
ImGui::Text(" | v0.2.28");
2158+
}
2159+
2160+
ImGui::PopStyleColor();
2161+
ImGui::PopStyleVar();
2162+
}
21102163

21112164
ImGui::End();
21122165
}
@@ -2607,134 +2660,77 @@ void EditorApp::render_symbol_outline() {
26072660
void EditorApp::render_status_bar() {
26082661
if (!settings_.show_status_bar) return;
26092662

2610-
ImGuiViewport* viewport = ImGui::GetMainViewport();
2611-
float line_height = 28;
2612-
float status_height = line_height;
2613-
float cmd_height = vim_mode_ == VimMode::Command ? line_height : 0;
2663+
float status_height = 24;
2664+
float cmd_height = vim_mode_ == VimMode::Command ? 24 : 0;
26142665

2615-
// Calculate editor area bounds
2616-
float sidebar_width = show_file_tree_ ? 220.0f : 0.0f;
2617-
float editor_x = viewport->Pos.x + sidebar_width;
2618-
float editor_width = viewport->Size.x - sidebar_width;
2619-
float editor_bottom = viewport->Pos.y + viewport->Size.y - status_height - cmd_height;
2666+
// Get editor window dimensions - use current window
2667+
ImVec2 editor_pos = ImGui::GetWindowPos();
2668+
float editor_width = ImGui::GetWindowWidth();
2669+
float editor_height = ImGui::GetWindowHeight();
26202670

2621-
// Position at bottom of editor window only, not full viewport
2622-
ImGui::SetNextWindowPos(ImVec2(editor_x, editor_bottom));
2623-
ImGui::SetNextWindowSize(ImVec2(editor_width, status_height + cmd_height));
2624-
ImGui::SetNextWindowViewport(viewport->ID);
2671+
// Position at bottom of current editor window
2672+
ImGui::SetCursorPosY(editor_height - status_height - cmd_height);
2673+
2674+
// Status bar background - spans full width
2675+
ImDrawList* draw_list = ImGui::GetWindowDrawList();
2676+
ImU32 status_bg = ImColor(0.2f, 0.2f, 0.25f);
2677+
draw_list->AddRectFilled(
2678+
ImVec2(editor_pos.x, editor_pos.y + editor_height - status_height - cmd_height),
2679+
ImVec2(editor_pos.x + editor_width, editor_pos.y + editor_height),
2680+
status_bg);
26252681

2626-
// Fixed to bottom of editor - no moving or resizing
2627-
ImGuiWindowFlags flags = ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove;
2628-
2629-
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0);
2630-
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8, 4));
26312682
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4, 2));
2683+
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.8f, 0.8f, 0.8f, 1.0f));
2684+
2685+
if (active_tab_ >= 0 && active_tab_ < (int)tabs_.size()) {
2686+
auto& tab = tabs_[active_tab_];
2687+
TextEditor* editor = get_active_editor();
2688+
auto pos = editor ? editor->GetCursorPosition() : TextEditor::Coordinates();
26322689

2633-
if (ImGui::Begin("StatusBar", nullptr, flags)) {
2634-
if (active_tab_ >= 0 && active_tab_ < (int)tabs_.size()) {
2635-
auto& tab = tabs_[active_tab_];
2636-
TextEditor* editor = get_active_editor();
2637-
auto pos = editor ? editor->GetCursorPosition() : TextEditor::Coordinates();
2638-
2639-
const char* mode_str = get_vim_mode_str();
2640-
const char* dirty_indicator = tab.dirty ? "*" : "";
2641-
const char* sep = "|";
2642-
2643-
// Get directory info - show git branch if in git repo
2644-
std::string dir_info = ".";
2645-
if (!tab.file_path.empty()) {
2646-
std::filesystem::path p(tab.file_path);
2647-
if (p.has_parent_path()) {
2648-
std::string dir = p.parent_path().string();
2649-
if (std::filesystem::exists(dir + "/.git")) {
2650-
dir_info = git_branch_;
2651-
} else {
2652-
dir_info = p.parent_path().filename().string();
2653-
}
2690+
const char* mode_str = get_vim_mode_str();
2691+
const char* sep = " | ";
2692+
2693+
// Get directory info
2694+
std::string dir_info = ".";
2695+
if (!tab.file_path.empty()) {
2696+
std::filesystem::path p(tab.file_path);
2697+
if (p.has_parent_path()) {
2698+
std::string dir = p.parent_path().string();
2699+
if (std::filesystem::exists(dir + "/.git")) {
2700+
dir_info = git_branch_;
2701+
} else {
2702+
dir_info = p.parent_path().filename().string();
26542703
}
26552704
}
2656-
2657-
// Each section with separator
2658-
ImGui::Text("%s", mode_str);
2659-
ImGui::SameLine();
2660-
ImGui::Text(" %s ", sep);
2661-
ImGui::SameLine();
2662-
ImGui::Text("%s%s", tab.display_name.c_str(), dirty_indicator);
2663-
ImGui::SameLine();
2664-
ImGui::Text(" %s ", sep);
2665-
ImGui::SameLine();
2666-
ImGui::Text("%s", dir_info.c_str());
2667-
ImGui::SameLine();
2668-
ImGui::Text(" %s ", sep);
2669-
ImGui::SameLine();
2670-
ImGui::Text("Ln %d, Col %d", pos.mLine + 1, pos.mColumn + 1);
2671-
ImGui::SameLine();
2672-
ImGui::Text(" %s ", sep);
2673-
ImGui::SameLine();
2674-
2675-
// Calculate scroll percentage: 0% = beginning, 100% = end
2676-
auto lines = editor->GetTextLines();
2677-
int total_lines = (int)lines.size();
2678-
int pct = 0;
2679-
if (total_lines > 1) {
2680-
pct = (int)((pos.mLine * 100) / (total_lines - 1));
2681-
}
2682-
ImGui::Text("%d%%", pct);
2683-
ImGui::SameLine();
2684-
ImGui::Text(" %s ", sep);
2685-
ImGui::SameLine();
2686-
ImGui::Text("%s", tab.file_encoding.c_str());
2687-
ImGui::SameLine();
2688-
ImGui::Text(" %s ", sep);
2689-
ImGui::SameLine();
2690-
2691-
// Line ending popup - separate clickable
2692-
std::string le_id = "LE:" + tab.line_ending;
2693-
if (ImGui::Selectable(le_id.c_str(), false, ImGuiSelectableFlags_None)) {
2694-
ImGui::OpenPopup("LineEndingPopup");
2695-
}
2696-
if (ImGui::BeginPopup("LineEndingPopup")) {
2697-
ImGui::TextDisabled("Line Ending");
2698-
ImGui::Separator();
2699-
if (ImGui::MenuItem("LF", nullptr, tab.line_ending == "LF")) { tab.line_ending = "LF"; }
2700-
if (ImGui::MenuItem("CRLF", nullptr, tab.line_ending == "CRLF")) { tab.line_ending = "CRLF"; }
2701-
if (ImGui::MenuItem("CR", nullptr, tab.line_ending == "CR")) { tab.line_ending = "CR"; }
2702-
ImGui::EndPopup();
2703-
}
2704-
ImGui::SameLine();
2705-
ImGui::Text(" %s ", sep);
2706-
ImGui::SameLine();
2707-
2708-
// Tab size popup - separate clickable
2709-
std::string tab_id = "Tab: " + std::to_string(settings_.tab_size);
2710-
if (ImGui::Selectable(tab_id.c_str(), false, ImGuiSelectableFlags_None)) {
2711-
ImGui::OpenPopup("TabSizePopup");
2712-
}
2713-
if (ImGui::BeginPopup("TabSizePopup")) {
2714-
ImGui::TextDisabled("Tab Size");
2715-
ImGui::Separator();
2716-
if (ImGui::MenuItem("Tab: 1", nullptr, settings_.tab_size == 1)) { settings_.tab_size = 1; for (auto& t : tabs_) t.editor->SetTabSize(1); }
2717-
if (ImGui::MenuItem("Tab: 2", nullptr, settings_.tab_size == 2)) { settings_.tab_size = 2; for (auto& t : tabs_) t.editor->SetTabSize(2); }
2718-
if (ImGui::MenuItem("Tab: 3", nullptr, settings_.tab_size == 3)) { settings_.tab_size = 3; for (auto& t : tabs_) t.editor->SetTabSize(3); }
2719-
if (ImGui::MenuItem("Tab: 4", nullptr, settings_.tab_size == 4)) { settings_.tab_size = 4; for (auto& t : tabs_) t.editor->SetTabSize(4); }
2720-
if (ImGui::MenuItem("Tab: 5", nullptr, settings_.tab_size == 5)) { settings_.tab_size = 5; for (auto& t : tabs_) t.editor->SetTabSize(5); }
2721-
if (ImGui::MenuItem("Tab: 6", nullptr, settings_.tab_size == 6)) { settings_.tab_size = 6; for (auto& t : tabs_) t.editor->SetTabSize(6); }
2722-
if (ImGui::MenuItem("Tab: 7", nullptr, settings_.tab_size == 7)) { settings_.tab_size = 7; for (auto& t : tabs_) t.editor->SetTabSize(7); }
2723-
if (ImGui::MenuItem("Tab: 8", nullptr, settings_.tab_size == 8)) { settings_.tab_size = 8; for (auto& t : tabs_) t.editor->SetTabSize(8); }
2724-
if (ImGui::MenuItem("Tab: 9", nullptr, settings_.tab_size == 9)) { settings_.tab_size = 9; for (auto& t : tabs_) t.editor->SetTabSize(9); }
2725-
if (ImGui::MenuItem("Tab: 10", nullptr, settings_.tab_size == 10)) { settings_.tab_size = 10; for (auto& t : tabs_) t.editor->SetTabSize(10); }
2726-
ImGui::EndPopup();
2727-
}
27282705
}
27292706

2730-
ImGui::End();
2707+
ImGui::Text("%s", mode_str);
2708+
ImGui::SameLine();
2709+
ImGui::Text("%s", sep);
2710+
ImGui::SameLine();
2711+
ImGui::Text("Ln %d, Col %d", pos.mLine + 1, pos.mColumn + 1);
2712+
ImGui::SameLine();
2713+
ImGui::Text("%s", sep);
2714+
ImGui::SameLine();
2715+
ImGui::Text("%s", tab.file_encoding.c_str());
2716+
ImGui::SameLine();
2717+
ImGui::Text("%s", sep);
2718+
ImGui::SameLine();
2719+
ImGui::Text("%s", tab.line_ending.c_str());
2720+
ImGui::SameLine();
2721+
ImGui::Text("%s", sep);
2722+
ImGui::SameLine();
2723+
ImGui::Text("%d%%", tabs_[active_tab_].zoom_pct);
2724+
ImGui::SameLine();
2725+
ImGui::Text("%s", sep);
2726+
ImGui::SameLine();
2727+
ImGui::Text("%s", tab.display_name.c_str());
2728+
ImGui::SameLine();
2729+
ImGui::Text(" | v0.2.28");
27312730
}
2732-
ImGui::PopStyleVar(3);
27332731

2734-
// Render floating command window at bottom of editor
2735-
if (vim_mode_ == VimMode::Command) {
2736-
render_floating_command();
2737-
}
2732+
ImGui::PopStyleColor();
2733+
ImGui::PopStyleVar();
27382734
}
27392735

27402736
void EditorApp::render_minimap(TextEditor* editor) {

0 commit comments

Comments
 (0)