Skip to content

Commit 467ecba

Browse files
committed
Fix: Statusbar in editor, command line inside editor, proper dockable
1 parent 3169096 commit 467ecba

3 files changed

Lines changed: 58 additions & 62 deletions

File tree

imgui.ini

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[Window][Editor]
2-
Pos=292,25
3-
Size=988,775
2+
Pos=228,24
3+
Size=1052,776
44
Collapsed=0
55
DockId=0x00000003,0
66

@@ -10,7 +10,7 @@ Size=1280,800
1010
Collapsed=0
1111

1212
[Window][Debug##Default]
13-
Pos=0,0
13+
Pos=117,246
1414
Size=1280,800
1515
Collapsed=1
1616
DockId=0x00000013,0
@@ -21,16 +21,16 @@ Size=476,221
2121
Collapsed=0
2222

2323
[Window][Explorer]
24-
Pos=0,25
25-
Size=290,775
24+
Pos=0,24
25+
Size=226,776
2626
Collapsed=0
2727
DockId=0x00000005,0
2828

2929
[Docking][Data]
30-
DockNode ID=0x00000013 Pos=0,0 Size=1280,800
31-
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,25 Size=1280,775 Split=X Selected=0xDF0EC458
32-
DockNode ID=0x00000005 Parent=0xCCBD8CF7 SizeRef=290,774 Selected=0x00F0E82E
33-
DockNode ID=0x00000006 Parent=0xCCBD8CF7 SizeRef=988,774 Split=X
30+
DockNode ID=0x00000013 Pos=117,246 Size=1280,800
31+
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,24 Size=1280,776 Split=X Selected=0xDF0EC458
32+
DockNode ID=0x00000005 Parent=0xCCBD8CF7 SizeRef=226,776 Selected=0x00F0E82E
33+
DockNode ID=0x00000006 Parent=0xCCBD8CF7 SizeRef=1052,776 Split=X
3434
DockNode ID=0x00000011 Parent=0x00000006 SizeRef=1306,851 Split=Y
3535
DockNode ID=0x0000000F Parent=0x00000011 SizeRef=1280,480 Split=Y
3636
DockNode ID=0x0000000D Parent=0x0000000F SizeRef=1280,472 Split=Y

pcode-settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"show_status_bar": true,
66
"word_wrap": true,
77
"show_line_numbers": true,
8-
"show_minimap": false,
8+
"show_minimap": true,
99
"show_spaces": true,
1010
"highlight_line": 2,
1111
"show_tabs": true,

src/editor_app.cpp

Lines changed: 48 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,7 +1820,6 @@ void EditorApp::render() {
18201820

18211821
ImGui::End();
18221822

1823-
render_command_line();
18241823
render_terminal();
18251824
}
18261825

@@ -2030,8 +2029,8 @@ ImGui::EndMenu();
20302029
// Editor Area
20312030
// ============================================================================
20322031
void EditorApp::render_editor_area() {
2033-
// Editor window - can float, dock, and resize
2034-
ImGui::Begin("Editor", nullptr, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize);
2032+
// Editor window - dockable
2033+
ImGui::Begin("Editor", nullptr, ImGuiWindowFlags_NoSavedSettings);
20352034

20362035
if (ImGui::IsWindowFocused(ImGuiFocusedFlags_RootWindow)) {
20372036
editor_focused_ = true;
@@ -2659,22 +2658,53 @@ void EditorApp::render_symbol_outline() {
26592658
void EditorApp::render_status_bar() {
26602659
if (!settings_.show_status_bar) return;
26612660

2662-
float status_height = 24;
2663-
float cmd_height = vim_mode_ == VimMode::Command ? 24 : 0;
2661+
float status_height = 22;
2662+
float cmd_height = vim_mode_ == VimMode::Command ? 22 : 0;
26642663

2665-
// Get editor window dimensions - use current window
2664+
// Get editor window dimensions
26662665
ImVec2 editor_pos = ImGui::GetWindowPos();
26672666
float editor_width = ImGui::GetWindowWidth();
26682667
float editor_height = ImGui::GetWindowHeight();
26692668

2670-
// Position at bottom of current editor window
2671-
ImGui::SetCursorPosY(editor_height - status_height - cmd_height);
2669+
// Command bar - inside editor, one line high, positioned at very bottom of editor
2670+
if (vim_mode_ == VimMode::Command) {
2671+
float cmd_y = editor_height - cmd_height;
2672+
ImGui::SetCursorPosY(cmd_y);
2673+
2674+
ImDrawList* draw_list = ImGui::GetWindowDrawList();
2675+
ImU32 cmd_bg = ImColor(0.1f, 0.1f, 0.2f);
2676+
draw_list->AddRectFilled(
2677+
ImVec2(editor_pos.x, editor_pos.y + cmd_y),
2678+
ImVec2(editor_pos.x + editor_width, editor_pos.y + editor_height),
2679+
cmd_bg);
2680+
2681+
ImGui::SetCursorPosY(cmd_y);
2682+
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4, 2));
2683+
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.9f, 0.9f, 0.9f, 1.0f));
2684+
2685+
ImGui::Text(":");
2686+
ImGui::SameLine();
2687+
ImGui::SetNextItemWidth(editor_width - 30);
2688+
if (ImGui::InputText("##cmd", vim_command_input_, sizeof(vim_command_input_), ImGuiInputTextFlags_EnterReturnsTrue)) {
2689+
execute_vim_command(vim_command_input_);
2690+
vim_command_input_[0] = '\0';
2691+
vim_mode_ = VimMode::Normal;
2692+
}
2693+
2694+
ImGui::PopStyleColor();
2695+
ImGui::PopStyleVar();
2696+
2697+
// Move status bar above command bar
2698+
editor_height -= cmd_height;
2699+
}
2700+
2701+
// Status bar at bottom of editor
2702+
ImGui::SetCursorPosY(editor_height - status_height);
26722703

2673-
// Status bar background - spans full width
26742704
ImDrawList* draw_list = ImGui::GetWindowDrawList();
26752705
ImU32 status_bg = ImColor(0.2f, 0.2f, 0.25f);
26762706
draw_list->AddRectFilled(
2677-
ImVec2(editor_pos.x, editor_pos.y + editor_height - status_height - cmd_height),
2707+
ImVec2(editor_pos.x, editor_pos.y + editor_height - status_height),
26782708
ImVec2(editor_pos.x + editor_width, editor_pos.y + editor_height),
26792709
status_bg);
26802710

@@ -2687,6 +2717,7 @@ void EditorApp::render_status_bar() {
26872717
auto pos = editor ? editor->GetCursorPosition() : TextEditor::Coordinates();
26882718

26892719
const char* mode_str = get_vim_mode_str();
2720+
const char* sep = "|";
26902721

26912722
// Get directory info
26922723
std::string dir_info = ".";
@@ -2702,56 +2733,47 @@ void EditorApp::render_status_bar() {
27022733
}
27032734
}
27042735

2705-
// Status bar sections
2706-
const char* sep = " | ";
2707-
2708-
// Mode: NORMAL/INSERT
2736+
// Exact format: | MODE | filename | * | Ln,Col | Git:branch | encoding | CRLF | Tab:n | v0.2.28 |
27092737
ImGui::Text("%s", mode_str);
27102738
ImGui::SameLine();
27112739
ImGui::Text("%s", sep);
27122740
ImGui::SameLine();
27132741

2714-
// Filename with dirty indicator
27152742
std::string display = tab.display_name + (tab.dirty ? " *" : "");
27162743
ImGui::Text("%s", display.c_str());
27172744
ImGui::SameLine();
27182745
ImGui::Text("%s", sep);
27192746
ImGui::SameLine();
27202747

2721-
// Line and column
27222748
ImGui::Text("Ln %d, Col %d", pos.mLine + 1, pos.mColumn + 1);
27232749
ImGui::SameLine();
27242750
ImGui::Text("%s", sep);
27252751
ImGui::SameLine();
27262752

2727-
// Git branch or directory
27282753
ImGui::Text("Git: %s", dir_info.c_str());
27292754
ImGui::SameLine();
27302755
ImGui::Text("%s", sep);
27312756
ImGui::SameLine();
27322757

2733-
// Encoding (read-only display)
27342758
ImGui::Text("%s", tab.file_encoding.c_str());
27352759
ImGui::SameLine();
27362760
ImGui::Text("%s", sep);
27372761
ImGui::SameLine();
27382762

2739-
// Line ending - clickable popup
2740-
std::string le_id = tab.line_ending;
2741-
if (ImGui::Selectable(le_id.c_str(), false)) {
2763+
// Line ending - clickable
2764+
if (ImGui::Selectable(tab.line_ending.c_str(), false)) {
27422765
ImGui::OpenPopup("LineEndingPopup");
27432766
}
27442767
if (ImGui::BeginPopup("LineEndingPopup")) {
27452768
if (ImGui::MenuItem("LF", nullptr, tab.line_ending == "LF")) { tab.line_ending = "LF"; }
27462769
if (ImGui::MenuItem("CRLF", nullptr, tab.line_ending == "CRLF")) { tab.line_ending = "CRLF"; }
2747-
if (ImGui::MenuItem("CR", nullptr, tab.line_ending == "CR")) { tab.line_ending = "CR"; }
27482770
ImGui::EndPopup();
27492771
}
27502772
ImGui::SameLine();
27512773
ImGui::Text("%s", sep);
27522774
ImGui::SameLine();
27532775

2754-
// Tab size - clickable popup
2776+
// Tab size - clickable
27552777
std::string tab_id = "Tab: " + std::to_string(settings_.tab_size);
27562778
if (ImGui::Selectable(tab_id.c_str(), false)) {
27572779
ImGui::OpenPopup("TabSizePopup");
@@ -2769,11 +2791,11 @@ void EditorApp::render_status_bar() {
27692791
ImGui::Text("%s", sep);
27702792
ImGui::SameLine();
27712793

2772-
// Version
2794+
// Version with git hash
27732795
ImGui::Text("v0.2.28");
27742796
}
27752797

2776-
ImGui::PopStyleColor();
2798+
ImGui::PopStyleColor();
27772799
ImGui::PopStyleVar();
27782800
}
27792801

@@ -2952,33 +2974,7 @@ if (history_index_ > 0) {
29522974
}
29532975

29542976
void EditorApp::render_command_line() {
2955-
if (vim_mode_ != VimMode::Command) return;
2956-
2957-
float cmd_height = 28;
2958-
ImVec2 editor_pos = ImGui::GetWindowPos();
2959-
float editor_width = ImGui::GetWindowWidth();
2960-
float editor_height = ImGui::GetWindowHeight();
2961-
2962-
ImGui::SetCursorPosY(editor_height - 24 - cmd_height);
2963-
2964-
ImDrawList* draw_list = ImGui::GetWindowDrawList();
2965-
ImU32 cmd_bg = ImColor(0.1f, 0.1f, 0.2f);
2966-
draw_list->AddRectFilled(
2967-
ImVec2(editor_pos.x, editor_pos.y + editor_height - cmd_height),
2968-
ImVec2(editor_pos.x + editor_width, editor_pos.y + editor_height),
2969-
cmd_bg);
2970-
2971-
ImGui::SetCursorPosY(editor_height - cmd_height);
2972-
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(4, 4));
2973-
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.9f, 0.9f, 0.9f, 1.0f));
2974-
2975-
ImGui::Text(":");
2976-
ImGui::SameLine();
2977-
ImGui::SetNextItemWidth(editor_width - 40);
2978-
ImGui::InputText("##cmd", vim_command_input_, sizeof(vim_command_input_), ImGuiInputTextFlags_EnterReturnsTrue, nullptr, this);
2979-
2980-
ImGui::PopStyleColor();
2981-
ImGui::PopStyleVar();
2977+
// Command line is now rendered inside render_status_bar
29822978
}
29832979

29842980
#ifdef _WIN32

0 commit comments

Comments
 (0)