From 2c775e429c14ebd5920e30fa684a69a2ca634451 Mon Sep 17 00:00:00 2001 From: Mirek Fidler Date: Wed, 3 Dec 2025 09:07:47 +0100 Subject: [PATCH] CodeEditor: NoAnnotations option --- uppsrc/CodeEditor/CodeEditor.h | 4 ++++ uppsrc/CodeEditor/EditorBar.cpp | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/uppsrc/CodeEditor/CodeEditor.h b/uppsrc/CodeEditor/CodeEditor.h index 483fa42af..88220950e 100644 --- a/uppsrc/CodeEditor/CodeEditor.h +++ b/uppsrc/CodeEditor/CodeEditor.h @@ -72,6 +72,7 @@ private: bool bingenabled; bool hilite_if_endif; bool line_numbers; + bool no_annotations; int annotations; bool ignored_next_edit; int next_age; @@ -131,6 +132,7 @@ public: void HiliteIfEndif(bool b) { hilite_if_endif = b; Refresh(); } void LineNumbers(bool b); void Annotations(int width); + void NoAnnotations(bool b); bool IsHiliteIfEndif() const { return hilite_if_endif; } @@ -551,6 +553,8 @@ public: void AnimateBar(const Vector& a) { bar.SetAnimate(a); } void BarColor(Color c) { bar.Background(c); } void BarText(const String& text, Color c) { bar.Text(text, c); } + + void NoAnnotations(bool b = true) { bar.NoAnnotations(b); } void Errors(Vector&& errs); diff --git a/uppsrc/CodeEditor/EditorBar.cpp b/uppsrc/CodeEditor/EditorBar.cpp index 06e94bbb0..e46f83590 100644 --- a/uppsrc/CodeEditor/EditorBar.cpp +++ b/uppsrc/CodeEditor/EditorBar.cpp @@ -94,7 +94,7 @@ void EditorBar::Paint(Draw& w) String n = AsString((i + 1) % 1000000); Font fnt = editor->GetFont(); Size tsz = GetTextSize(n, fnt); - w.DrawText(sz.cx - Zx(4 + 12) - tsz.cx, y + (fy - tsz.cy) / 2, n, fnt, SBrown()); + w.DrawText(sz.cx - (no_annotations ? Zx(2) : Zx(4 + 12)) - tsz.cx, y + (fy - tsz.cy) / 2, n, fnt, SBrown()); } if(hi_if) { Vector nextif; @@ -470,7 +470,8 @@ void EditorBar::SyncSize() i++; n /= 10; } - int w = max(DPI(32), (line_numbers && editor ? editor->GetFont()['0'] * i : 0) + Zx(12 + 4) + annotations); + int w = line_numbers && editor ? editor->GetFont()['0'] * i : 0; + w = no_annotations ? w + Zx(2) : max(DPI(32), w + Zx(12 + 4) + annotations); if(w != GetWidth()) Width(w); Refresh(); @@ -488,13 +489,19 @@ void EditorBar::Annotations(int width) SyncSize(); } +void EditorBar::NoAnnotations(bool b) +{ + no_annotations = b; + SyncSize(); +} + EditorBar::EditorBar() { editor = NULL; line_numbers = false; + no_annotations = false; bingenabled = true; hilite_if_endif = true; - line_numbers = false; annotations = 0; ignored_next_edit = false; next_age = 0;