From fc14d085dd3d97dd7866eba67b5e09120fff90b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Mon, 24 Nov 2008 20:32:32 +0000 Subject: [PATCH] [GB.QT.EXT] * BUG: Fix Editor margin width when showing line numbers. git-svn-id: svn://localhost/gambas/trunk@1715 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- gb.qt/src/ext/gview.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/gb.qt/src/ext/gview.cpp b/gb.qt/src/ext/gview.cpp index eda4a7e33..ed6887966 100644 --- a/gb.qt/src/ext/gview.cpp +++ b/gb.qt/src/ext/gview.cpp @@ -1705,10 +1705,25 @@ bool GEditor::focusNextPrevChild(bool) return false; } +static bool is_power_of_ten(int n) +{ + for(;;) + { + if (n % 10) + return false; + n /= 10; + if (n == 1) + return true; + } +} + void GEditor::lineInserted(int y) { if (largestLine >= y) largestLine++; + + if (getFlag(ShowLineNumbers) && is_power_of_ten(numLines())) + updateMargin(); } void GEditor::lineRemoved(int y) @@ -1717,6 +1732,9 @@ void GEditor::lineRemoved(int y) updateWidth(y); else if (largestLine > y) largestLine--; + + if (getFlag(ShowLineNumbers) && is_power_of_ten(numLines() + 1)) + updateMargin(); } void GEditor::flash()