From 15b9b273247099ba0eac75a5769592bf7bcb89dc Mon Sep 17 00:00:00 2001 From: hachem Date: Wed, 1 Apr 2026 19:52:33 +0200 Subject: feat: ui refactor of doom and despair --- src/ui/source_view.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src/ui/source_view.cpp') diff --git a/src/ui/source_view.cpp b/src/ui/source_view.cpp index a98594c..f9a3f85 100644 --- a/src/ui/source_view.cpp +++ b/src/ui/source_view.cpp @@ -259,8 +259,7 @@ namespace Hsdbg while (at < size && is_word(line[at])) ++at; - const std::string_view word = - std::string_view(line).substr(start, at - start); + const std::string_view word = std::string_view(line).substr(start, at - start); SyntaxKind kind = classify_word(word, language); if (kind == SyntaxKind::Default && language == Language::Cpp && @@ -479,25 +478,31 @@ namespace Hsdbg if (m_lines.empty()) { - ImGui::TextDisabled("no source file open"); + ImGui::TextDisabled("No source file open"); return; } + if (m_mono_font != nullptr) + ImGui::PushFont(m_mono_font, 0.0f); + draw_lines(debugger); + + if (m_mono_font != nullptr) + ImGui::PopFont(); } auto SourceView::draw_open_bar() -> void { - ImGui::SetNextItemWidth(-ImGui::CalcTextSize("open").x - ImGui::GetStyle().FramePadding.x * 4.0f); + ImGui::SetNextItemWidth(-ImGui::CalcTextSize("Open").x - ImGui::GetStyle().FramePadding.x * 4.0f); const bool submitted = ImGui::InputTextWithHint("##source_path", - "path to a source file", + "Path to a source file", &m_path_input, ImGuiInputTextFlags_EnterReturnsTrue); ImGui::SameLine(); - if (ImGui::Button("open") || submitted) + if (ImGui::Button("Open") || submitted) { if (const auto result = open(m_path_input); !result) { @@ -530,9 +535,9 @@ namespace Hsdbg m_scroll_to_highlight = false; } - const std::span locals = - (debugger.is_stopped() && m_highlighted_line != 0) ? debugger.locals() - : std::span{}; + const std::span locals = debugger.is_stopped() && m_highlighted_line != 0 + ? debugger.locals() + : std::span{}; ImGuiListClipper clipper; clipper.Begin(static_cast(m_lines.size()), text_height); @@ -743,7 +748,7 @@ namespace Hsdbg const size_t steps = expansion.levels.size() - 1; if (steps == 0) - ImGui::TextDisabled("no expansion"); + ImGui::TextDisabled("No expansion"); else if (!expansion.fully_expanded()) ImGui::TextDisabled("%zu+ levels — click to step through", steps); else -- cgit v1.3