Step 241: text-first defaults and trim headers

This commit is contained in:
Bill
2026-02-10 11:22:44 -07:00
parent f074f51e7f
commit 686de5a4ef
27 changed files with 3821 additions and 3274 deletions

View File

@@ -204,7 +204,7 @@ static void renderBottomPanel(EditorState& state) {
? p.string()
: (std::filesystem::path(state.workspaceRoot) / p).string();
if (state.buffers.hasBuffer(path)) state.switchToBuffer(path);
else state.doOpen(path);
else state.doOpen(path, state.defaultBufferMode());
if (state.active()) {
state.jumpTo(state.active(),
std::max(0, err.line - 1),
@@ -286,7 +286,7 @@ static void renderBottomPanel(EditorState& state) {
if (ImGui::Selectable(d.message.c_str(), false, ImGuiSelectableFlags_SpanAllColumns)) {
if (!d.file.empty() && d.line >= 0) {
if (state.buffers.hasBuffer(d.file)) state.switchToBuffer(d.file);
else state.doOpen(d.file);
else state.doOpen(d.file, state.defaultBufferMode());
state.jumpTo(state.active(), d.line, d.col);
}
}

View File

@@ -528,7 +528,7 @@ static void renderCommandPalette(EditorState& state) {
}
if (accept && !fileMatches.empty()) {
state.doOpen(fileMatches[state.commandSelected].path);
state.doOpen(fileMatches[state.commandSelected].path, state.defaultBufferMode());
state.showCommandPalette = false;
}
}

View File

@@ -10,14 +10,14 @@ static void renderMenuBar(EditorState& state) {
if (ImGui::MenuItem("New", state.keys.getBinding("file.new").toString().c_str()))
{
std::string lang = state.active() ? state.active()->language : "python";
state.createBuffer(state.makeUntitledName(), "", lang);
state.createBuffer(state.makeUntitledName(), "", lang, state.defaultBufferMode());
}
if (ImGui::MenuItem("Open...", state.keys.getBinding("file.open").toString().c_str()))
{
auto path = FileDialog::openFile({"Open File", {"*.py","*.cpp","*.h","*.el","*.js","*.ts","*.java","*.rs","*.go","*.org"}, state.lastDialogPath});
if (!path.empty()) {
state.lastDialogPath = path;
state.doOpen(path);
state.doOpen(path, state.defaultBufferMode());
}
}
if (ImGui::MenuItem("Open Project...")) {

View File

@@ -214,7 +214,7 @@ static void renderProjectSearchPanel(EditorState& state) {
std::to_string(match.col + 1) + " " + match.lineText;
if (ImGui::Selectable(lineLabel.c_str())) {
if (state.buffers.hasBuffer(fileRes.path)) state.switchToBuffer(fileRes.path);
else state.doOpen(fileRes.path);
else state.doOpen(fileRes.path, state.defaultBufferMode());
state.jumpTo(state.active(), match.line, match.col);
}
}

View File

@@ -344,6 +344,13 @@ static void renderSettingsPanel(EditorState& state) {
state.ui.showLineNumbers = showLineNumbers;
settingsChanged = true;
}
std::string defaultMode = state.settings.getDefaultBufferMode();
int modeIndex = (defaultMode == "structured") ? 1 : 0;
const char* modeLabels[] = {"Text (Recommended)", "Structured"};
if (ImGui::Combo("Default Buffer Mode", &modeIndex, modeLabels, 2)) {
state.settings.setDefaultBufferMode(modeIndex == 1 ? "structured" : "text");
settingsChanged = true;
}
bool reduceMotionSetting = state.settings.getReduceMotion();
if (ImGui::Checkbox("Reduce Motion", &reduceMotionSetting)) {
state.settings.setReduceMotion(reduceMotionSetting);