Step 186: keyboard shortcut reference

This commit is contained in:
Bill
2026-02-09 22:54:49 -07:00
parent db2c5d9b07
commit 79826f98d4
9 changed files with 92 additions and 1 deletions

View File

@@ -0,0 +1,39 @@
#pragma once
#include "imgui.h"
#include "EditorState.h"
#include <algorithm>
#include <string>
struct ShortcutReferenceState {
char filter[128] = {};
};
static void renderShortcutReference(EditorState& state, ShortcutReferenceState& panel) {
if (!state.ui.showShortcutReference) return;
ImGui::Begin("Keyboard Shortcuts", &state.ui.showShortcutReference);
ImGui::PushFont(state.uiFont);
ImGui::InputText("Filter", panel.filter, sizeof(panel.filter));
std::string filterText = panel.filter;
std::transform(filterText.begin(), filterText.end(), filterText.begin(),
[](unsigned char c) { return (char)std::tolower(c); });
ImGui::Separator();
ImGui::BeginChild("##shortcuts", ImVec2(0, 0), false);
auto actions = state.keys.listActions();
std::sort(actions.begin(), actions.end());
for (const auto& action : actions) {
std::string lower = action;
std::transform(lower.begin(), lower.end(), lower.begin(),
[](unsigned char c) { return (char)std::tolower(c); });
if (!filterText.empty() && lower.find(filterText) == std::string::npos) continue;
KeyCombo combo = state.keys.getBinding(action);
ImGui::Text("%s", action.c_str());
ImGui::SameLine(260.0f);
ImGui::TextDisabled("%s", combo.toString().c_str());
}
ImGui::EndChild();
ImGui::PopFont();
ImGui::End();
}

View File

@@ -17,6 +17,7 @@
#include "ThemeEngine.h"
#include "FirstRunWizard.h"
#include "FeatureHints.h"
#include "ShortcutReference.h"
// --- Panel headers ---
#include "panels/MenuBarPanel.h"
@@ -380,6 +381,8 @@ int main(int, char**) {
renderFirstRunWizard(state, wizard);
state.ui.showFirstRunWizard = wizard.open;
renderFeatureHintBar(state.featureHints, state.workspaceRoot);
static ShortcutReferenceState shortcutPanel;
renderShortcutReference(state, shortcutPanel);
state.notifications.renderHistoryWindow([&](const Notification& note) {
if (note.hasTarget) state.navigateToTarget(note.target);
});

View File

@@ -100,6 +100,7 @@ static void renderMenuBar(EditorState& state) {
ImGui::MenuItem("Emacs Packages", nullptr, &state.emacsState.showEmacsPackagesPanel);
ImGui::MenuItem("Emacs Bridge", nullptr, &state.emacsState.showEmacsBridgePanel);
ImGui::MenuItem("Settings", nullptr, &state.ui.showSettingsPanel);
ImGui::MenuItem("Keyboard Shortcuts", nullptr, &state.ui.showShortcutReference);
ImGui::MenuItem("LSP Servers...", nullptr, &state.ui.showLspSettings);
if (state.active()) {
bool textMode = state.active()->bufferMode == BufferManager::BufferMode::Text;

View File

@@ -10,6 +10,7 @@ struct UIFlags {
bool showLspSettings = false;
bool showSettingsPanel = false;
bool showFirstRunWizard = false;
bool showShortcutReference = false;
int bottomTab = 0; // 0=Output,1=AST,2=Highlighted
LayoutPreset layoutPreset = LayoutPreset::VSCode;
};