diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-03-09 21:39:40 +0100 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-03-09 21:39:40 +0100 |
| commit | 8df6671acae6d301b645ffd6abcedc819d3f5365 (patch) | |
| tree | ff73cb3f71ba319c6cf73f36d7daddbc9497e617 | |
| parent | 92b2ad31658ffad3d6401c7aa278eace89480bc7 (diff) | |
show indentation with arrow
| -rw-r--r-- | imgui/imgui_spectrum.cpp | 14 | ||||
| -rw-r--r-- | src/main.cpp | 18 |
2 files changed, 30 insertions, 2 deletions
diff --git a/imgui/imgui_spectrum.cpp b/imgui/imgui_spectrum.cpp index 92667e0..30ff713 100644 --- a/imgui/imgui_spectrum.cpp +++ b/imgui/imgui_spectrum.cpp @@ -10,11 +10,23 @@ namespace ImGui { ImGuiIO& io = ImGui::GetIO(); ImFontConfig config; config.MergeMode = true; + + static const ImWchar rr[] = + { + 0x2192, 0x2193, // Basic Latin + Latin Supplement + 0, + }; + + ImFontGlyphRangesBuilder builder; + ImVector<ImWchar> ranges; + builder.AddRanges(io.Fonts->GetGlyphRangesDefault()); + builder.AddRanges(rr); + builder.BuildRanges(&ranges); ImFont* font = io.Fonts->AddFontFromMemoryCompressedTTF( SourceSansProRegular_compressed_data, SourceSansProRegular_compressed_size, - size, nullptr, nullptr); + size, nullptr, ranges.Data); IM_ASSERT(font != nullptr); io.FontDefault = font; diff --git a/src/main.cpp b/src/main.cpp index abdc170..345657f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -261,7 +261,23 @@ void _ts_create_text_match_rows() { ImGui::Text("#%d", item+1); ImGui::TableNextColumn(); - ImGui::Text("%.*s", (int)file->word_match_offset, file->line_info); + + utf8_int32_t iter_ch = 0; + utf8_int8_t* iter = file->line_info; + size_t whitespace_size = 0; + while ((iter = utf8codepoint(iter, &iter_ch)) && iter_ch) + { + if (iter_ch == ' ') { + ImGui::TextColored({0,0,0,0.2f}, "%s", "→"); + ImGui::SameLine(0.0f, 5.0f); + whitespace_size++; + } + else { + break; + } + } + + ImGui::Text("%.*s", (int)(file->word_match_offset - whitespace_size), file->line_info + whitespace_size); ImGui::SameLine(0.0f, 0.0f); ImGui::TextColored({255,0,0,255}, "%.*s", (int)file->word_match_length, file->line_info + file->word_match_offset); ImGui::SameLine(0.0f, 0.0f); |
