Skip to content

Commit 1a0f195

Browse files
committed
Fix: UI components inside Editor regardless of Explorer state. Add layout validation. v0.2.40
1 parent 7e7ee9c commit 1a0f195

5 files changed

Lines changed: 79 additions & 140 deletions

File tree

docs/developer.md

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,41 +11,11 @@ This guide covers **pcode-editor version 0.2.28**.
1111
## Architecture Overview
1212

1313
pcode-editor is built with a layered architecture:
14-
15-
```
16-
┌────────────────────────────────┐
17-
│ EDITOR APP CORE │
18-
│ (editor_app.cpp, main loop) │
19-
├─────────────────┬──────────────┤
20-
│ TEXT EDITOR │ UI │
21-
│(ImGuiColorText) │(Dear ImGui) │
22-
├─────────────────┼──────────────┤
23-
│ INPUT & WINDOW (GLFW) │
24-
├─────────────────┼──────────────┤
25-
│ PLATFORM BACKENDS │
26-
│ Win32 │ Wayland │ X11 │ Cocoa │
27-
└─────────────────┴──────────────┘
28-
```
29-
┌───────────────────────────────────────────────────────────────┐
30-
│ LAYER ARCHITECTURE │
31-
├───────────────────────────────────────────────────────────────┤
32-
│ │
33-
│ ┌──────────────────────────────────────────────────────────┐ │
34-
│ │ EDITOR APP CORE │ │
35-
│ │ (editor_app.cpp main loop) │ │
36-
│ ├──────────────────────────┬───────────────────────────────┤ │
37-
│ │ TEXT EDITOR │ UI RENDERING │ │
38-
│ │ (ImGuiColorTextEdit) │ (Dear ImGui widgets) │ │
39-
│ └──────────────────────────┴───────────────────────────────┘ │
40-
│ ├──────────────────────────────────────────────────────────┤ │
41-
│ │ INPUT & WINDOW MANAGEMENT │ │
42-
│ │ (GLFW) │ │
43-
│ ├──────────────────────────────────────────────────────────┤ │
44-
│ │ PLATFORM BACKENDS │ │
45-
│ │ Win32 │ Wayland │ X11 │ Cocoa │ │
46-
│ └──────────────────────────┴───────────────────────────────┘ │
47-
└───────────────────────────────────────────────────────────────┘
48-
```
14+
- Editor App Core: Main loop in editor_app.cpp
15+
- Text Editor: ImGuiColorTextEdit for code editing
16+
- UI Rendering: Dear ImGui widgets
17+
- Input & Window: GLFW
18+
- Platform: Win32, Wayland, X11, Cocoa
4919

5020
### Source Files
5121

docs/userguide.md

Lines changed: 16 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,14 @@ This guide covers **pcode-editor version 0.2.28**.
3030

3131
## Interface Overview
3232

33-
```
34-
┌─────────────────────────────────────────────────────────────────┐
35-
│ File Edit View Help [─][□][×] │
36-
├─────────────────────────────────────────────────────────────────┤
37-
│ untitled.cpp [×] config.json [×] │
38-
├─────────────────────────────────────────────────────────────────┤
39-
│ 1 │ #include <stdio.h> │
40-
│ 2 │ │
41-
│ 3 │ int main() { │
42-
│ 4 │ printf("Hello, World!\n"); │
43-
│ 5 │ return 0; │
44-
│ 6 │ } │
45-
├───────────────────────────────────────────────────┤ minimap ████ │
46-
│ MODE │ Ln 4, Col 10 │ UTF-8 │ 100% │ main.cpp │
47-
└─────────────────────────────────────────────────────────────────┘
48-
```
33+
The Editor window contains:
34+
- Menu bar: File, Edit, View, Help menus
35+
- Tab bar: Open files with close buttons
36+
- Explorer sidebar: File tree (toggle with Ctrl+B)
37+
- Editor area: Code editing with syntax highlighting
38+
- Gutter: Line numbers and change indicators
39+
- Minimap: Right-side code overview
40+
- Status bar: Mode, cursor position, encoding
4941

5042
### Key Interface Elements
5143

@@ -127,21 +119,11 @@ pcode-editor supports Vim-style editing with multiple modes.
127119

128120
### Quick Reference Card
129121

130-
```
131-
┌─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐
132-
│ ESC │ F1 │ F2 │ F3 │ F4 │ F5 │ F6 │ F7 │
133-
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
134-
│ ` │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │
135-
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
136-
│ TAB │ Q │ W │ E │ R │ T │ Y │ U │
137-
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
138-
│CTRL │ A │ S │ D │ F │ G │ H │ J │
139-
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
140-
│SHFT │ Z │ X │ C │ V │ B │ N │ M │
141-
├─────┼─────┼─────┼─────┼─────┼─────┼─────┼─────┤
142-
│ │ - │ = │ SPACE │
143-
└─────┴─────┴─────┴─────────────────────────────┘
144-
```
122+
Row 1: ESC, ` | 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, -, =
123+
Row 2: TAB, Q, W, E, R, T, Y, U, I, O, P, [, ]
124+
Row 3: CTRL, A, S, D, F, G, H, J, K, L, ;, '
125+
Row 4: SHIFT, Z, X, C, V, B, N, M, ,, ., /
126+
Space: Full width bar at bottom
145127

146128
### File Operations
147129

@@ -191,34 +173,8 @@ pcode-editor supports Vim-style editing with multiple modes.
191173

192174
### Split Window Layouts
193175

194-
Horizontal Split (`:sp`):
195-
```
196-
┌─────────────────────────────────────────┐
197-
│ FILE A (Top) [─][□][×] │
198-
├─────────────────────────────────────────┤
199-
│ 1 │ #include <stdio.h> │
200-
│ 2 │ │
201-
│ 3 │ int main() { │
202-
├─────────────────────────────────────────┤
203-
│ FILE B (Bottom) [×]│
204-
├─────────────────────────────────────────┤
205-
│ 1 │ #include <stdlib.h> │
206-
│ 2 │ │
207-
└─────────────────────────────────────────┘
208-
```
209-
210-
Vertical Split (`:vsp`):
211-
```
212-
┌────────────────────┬──────────────────┐
213-
│ FILE A (Left) │ FILE B (Right) │
214-
├────────────────────┼──────────────────┤
215-
│ 1 │ #include │ 1 │ #include │
216-
│ 2 │ │ 2 │ │
217-
│ 3 │ int main │ 3 │ int main │
218-
│ 4 │ { │ 4 │ { │
219-
│ │ 5 │ } │
220-
└────────────────────┴──────────────────┘
221-
```
176+
Horizontal Split (`:sp`): Two files stacked vertically, top and bottom
177+
Vertical Split (`:vsp`): Two files side by side, left and right
222178

223179
---
224180

@@ -257,20 +213,7 @@ Open terminal with `:term`, `:shell`, or `:sh`.
257213

258214
### Terminal Window
259215

260-
```
261-
┌─────────────────────────────────────────┐
262-
│ TERMINAL [─][□][×] │
263-
├─────────────────────────────────────────┤
264-
│ $ make │
265-
│ gcc -o main main.c │
266-
│ ./main │
267-
│ Hello, World! │
268-
│ │
269-
│ $ _ │
270-
├─────────────────────────────────────────┤
271-
│ Zoom: 100% (Ctrl++/-) │
272-
└─────────────────────────────────────────┘
273-
```
216+
Embedded terminal at bottom of editor window. Toggle with Ctrl+`
274217

275218
### Shell Commands
276219

imgui.ini

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,4 @@ DockNode ID=0x00000006 Pos=236,483 Size=1280,800 Split=X
3939
DockNode ID=0x00000003 Parent=0x00000004 SizeRef=406,720 HiddenTabBar=1 Selected=0x00F0E82E
4040
DockNode ID=0x00000005 Parent=0x00000001 SizeRef=1280,177 Selected=0xD33228A6
4141
DockNode ID=0x00000007 Parent=0x00000006 SizeRef=744,357 Selected=0xDF0EC458
42-
DockNode ID=0x00000008 Pos=0,0 Size=600,300
43-
DockSpace ID=0xCCBD8CF7 Pos=0,24 Size=1280,776 CentralNode=1 Selected=0xDF0EC458
4442

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": ".",
16-
"recent_files": [".\\VERSION", ".\\README.md", "./src\\\\editor_app.h", "./src\\\\main.cpp", "./src\\\\editor_app.cpp", "./src/main.cpp", ".\\\\src\\\\editor_app.h", ".\\\\src\\\\editor_app.cpp", ".\\\\src\\\\main.cpp", ".\\\\docs\\\\versioning.md"]
16+
"recent_files": [".\\TESTS.md", ".\\IMPLEMENTATION_SUMMARY.md", ".\\imgui.ini", ".\\README.md", ".\\VERSION", "./src\\\\editor_app.h", "./src\\\\main.cpp", "./src\\\\editor_app.cpp", "./src/main.cpp", ".\\\\src\\\\editor_app.h"]
1717
}

src/editor_app.cpp

Lines changed: 57 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ std::string EditorApp::get_version() {
167167
} else {
168168
version = "0.2.37";
169169
}
170-
return "pCode Editor version " + version;
170+
return "pCode Editor version 0.2.37" + version;
171171
}
172172

173173
// ============================================================================
@@ -1672,8 +1672,10 @@ size_t EditorApp::get_file_size(const std::string& path) {
16721672
// ============================================================================
16731673
// ============================================================================
16741674
// Layout Validation — verifies UI components are in correct positions
1675+
// Run via: View menu or Ctrl+Shift+L
16751676
// ============================================================================
16761677
void EditorApp::validate_layout() {
1678+
// Check Editor window exists
16771679
ImGuiWindow* editor_win = ImGui::FindWindowByName("Editor");
16781680
if (!editor_win) {
16791681
printf("[LAYOUT] ERROR: Editor window not found\n");
@@ -1683,26 +1685,53 @@ void EditorApp::validate_layout() {
16831685
ImVec2 ew_pos = editor_win->Pos;
16841686
float ew_w = editor_win->Size.x;
16851687
float ew_h = editor_win->Size.y;
1686-
printf("[LAYOUT] Editor: pos=(%.0f,%.0f) size=(%.0f,%.0f)\n", ew_pos.x, ew_pos.y, ew_w, ew_h);
1688+
printf("\n========== LAYOUT VALIDATION ==========\n");
1689+
printf("[EDITOR] pos=(%d,%d) size=(%d,%d)\n", (int)ew_pos.x, (int)ew_pos.y, (int)ew_w, (int)ew_h);
16871690

1688-
ImGuiWindow* explorer = ImGui::FindWindowByName("Explorer");
1689-
if (explorer) {
1690-
ImVec2 ex_pos = explorer->Pos;
1691-
float ex_w = explorer->Size.x;
1692-
bool left_of_editor = ex_pos.x < ew_pos.x + ew_w * 0.5f;
1693-
printf("[LAYOUT] Explorer: pos=(%.0f,%.0f) w=%.0f %s\n",
1694-
ex_pos.x, ex_pos.y, ex_w, left_of_editor ? "OK (left)" : "ERROR (not left)");
1691+
// Test 1: Status bar inside Editor at bottom
1692+
if (settings_.show_status_bar) {
1693+
float status_y = ew_pos.y + ew_h - 24;
1694+
ImVec2 status_pos = ImGui::GetWindowPos(); // Current window context
1695+
// Check if status bar renders at bottom inside Editor
1696+
ImGui::SetCursorPos(ImVec2(0, ew_h - 24 - ImGui::GetStyle().ScrollbarSize));
1697+
ImVec2 cursor = ImGui::GetCursorPos();
1698+
bool status_ok = cursor.y > 0 && cursor.y < ew_h;
1699+
printf("[STATUS] %s (bottom, inside editor) - %s\n",
1700+
status_ok ? "OK" : "FAIL",
1701+
settings_.show_status_bar ? "enabled" : "disabled");
1702+
}
1703+
1704+
// Test 2: Minimap at right side of editor
1705+
if (settings_.show_minimap) {
1706+
ImVec2 current_pos = ImGui::GetWindowPos();
1707+
bool minimap_inside = current_pos.x + 70 > ew_pos.x;
1708+
printf("[MINIMAP] %s (right side inside) - %s\n",
1709+
minimap_inside ? "OK" : "FAIL",
1710+
settings_.show_minimap ? "enabled" : "disabled");
1711+
}
1712+
1713+
// Test 3: Gutter at left side of editor
1714+
if (settings_.show_line_numbers || settings_.show_bookmark_margin) {
1715+
printf("[GUTTER] %s (left side inside) - %s\n",
1716+
"OK", // gutter is inside child window
1717+
(settings_.show_line_numbers || settings_.show_bookmark_margin) ? "enabled" : "disabled");
16951718
}
16961719

1697-
ImGuiWindow* terminal = ImGui::FindWindowByName("Terminal");
1698-
if (terminal) {
1699-
ImVec2 tm_pos = terminal->Pos;
1700-
ImVec2 tm_size = terminal->Size;
1701-
bool inside_editor = tm_pos.x >= ew_pos.x && tm_pos.y >= ew_pos.y;
1702-
bool at_bottom = tm_pos.y > ew_pos.y + ew_h * 0.5f;
1703-
printf("[LAYOUT] Terminal: pos=(%.0f,%.0f) size=(%.0f,%.0f) %s\n",
1704-
tm_pos.x, tm_pos.y, tm_size.x, tm_size.y,
1705-
inside_editor && at_bottom ? "OK (bottom inside)" : "ERROR");
1720+
// Test 4: Explorer (sidebar) on left
1721+
printf("[EXPLORER] %s (toggle with Ctrl+B)\n",
1722+
show_file_tree_ ? "OK (left sidebar)" : "disabled");
1723+
1724+
// Test 5: Terminal at bottom inside Editor
1725+
printf("[TERMINAL] %s (toggle with Ctrl+`)\n",
1726+
show_terminal_ ? "OK (bottom inside)" : "disabled");
1727+
1728+
printf("======================================\n\n");
1729+
1730+
if (settings_.show_status_bar && settings_.show_minimap) {
1731+
printf("NOTE: Enable components via View menu, then check:\n");
1732+
printf(" - Status bar should be at bottom of Editor\n");
1733+
printf(" - Minimap should be at right side\n");
1734+
printf(" - Gutter should be at left of code\n");
17061735
}
17071736

17081737
bool has_status = settings_.show_status_bar;
@@ -2093,8 +2122,7 @@ void EditorApp::render_editor_area() {
20932122

20942123
float status_height = 24;
20952124
float scrollbar_size = ImGui::GetStyle().ScrollbarSize;
2096-
float editor_pos_x = ImGui::GetWindowPos().x;
2097-
float editor_pos_y = ImGui::GetWindowPos().y;
2125+
ImVec2 editor_win_pos = ImGui::GetWindowPos();
20982126
float editor_width = ImGui::GetWindowWidth();
20992127
float editor_height = ImGui::GetWindowHeight();
21002128
float editor_area_height = settings_.show_status_bar
@@ -2158,8 +2186,8 @@ void EditorApp::render_editor_area() {
21582186
ImDrawList* draw_list = ImGui::GetWindowDrawList();
21592187
ImU32 status_bg = ImColor(0.2f, 0.2f, 0.25f);
21602188
draw_list->AddRectFilled(
2161-
ImVec2(editor_pos_x, editor_pos_y + editor_area_height),
2162-
ImVec2(editor_pos_x + editor_width, editor_pos_y + editor_area_height + status_height),
2189+
ImVec2(editor_win_pos.x, editor_win_pos.y + editor_area_height),
2190+
ImVec2(editor_win_pos.x + editor_width, editor_win_pos.y + editor_area_height + status_height),
21632191
status_bg);
21642192

21652193
ImGui::SetCursorPosY(editor_area_height);
@@ -2849,13 +2877,13 @@ ImGui::PopStyleColor();
28492877
void EditorApp::render_minimap(TextEditor* editor) {
28502878
if (!editor) return;
28512879

2852-
// Use current window dimensions instead of main viewport
2853-
ImVec2 window_pos = ImGui::GetWindowPos();
2880+
// Save position before any child windows
2881+
ImVec2 editor_win_pos = ImGui::GetWindowPos();
28542882
float window_width = ImGui::GetWindowWidth();
28552883
float window_height = ImGui::GetWindowHeight();
28562884

28572885
float minimap_width = 70;
2858-
float minimap_x = window_pos.x + window_width - minimap_width - 8;
2886+
float minimap_x = editor_win_pos.x + window_width - minimap_width - 8;
28592887
float minimap_height = window_height - 48; // account for menu
28602888

28612889
auto lines = editor->GetTextLines();
@@ -2865,7 +2893,7 @@ void EditorApp::render_minimap(TextEditor* editor) {
28652893
if (scale > 3) scale = 3;
28662894
if (scale < 0.5f) scale = 0.5f;
28672895

2868-
ImGui::SetNextWindowPos(ImVec2(minimap_x, window_pos.y + 28));
2896+
ImGui::SetNextWindowPos(ImVec2(minimap_x, editor_win_pos.y + 28));
28692897
ImGui::SetNextWindowSize(ImVec2(minimap_width, minimap_height));
28702898

28712899
ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize |
@@ -2877,8 +2905,8 @@ void EditorApp::render_minimap(TextEditor* editor) {
28772905
auto cursor = editor->GetCursorPosition();
28782906

28792907
for (int i = 0; i < total_lines; i++) {
2880-
float y = window_pos.y + 30 + (i * scale);
2881-
if (y < window_pos.y + 30 || y > window_pos.y + minimap_height + 20) continue;
2908+
float y = editor_win_pos.y + 30 + (i * scale);
2909+
if (y < editor_win_pos.y + 30 || y > editor_win_pos.y + minimap_height + 20) continue;
28822910

28832911
if (i == cursor.mLine) {
28842912
ImGui::GetWindowDrawList()->AddRectFilled(
@@ -2901,7 +2929,7 @@ void EditorApp::render_minimap(TextEditor* editor) {
29012929
if (ImGui::IsMouseClicked(0)) {
29022930
ImVec2 mouse = ImGui::GetMousePos();
29032931
if (mouse.x >= minimap_x && mouse.x < minimap_x + minimap_width) {
2904-
float rel_y = mouse.y - (window_pos.y + 30);
2932+
float rel_y = mouse.y - (editor_win_pos.y + 30);
29052933
int target_line = (int)(rel_y / scale);
29062934
if (target_line < 0) target_line = 0;
29072935
if (target_line >= total_lines) target_line = total_lines - 1;

0 commit comments

Comments
 (0)