From a6ad2ff8b66866aeae17a8bee1eb54edfee331ad Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 5 Jul 2019 11:35:32 +1000 Subject: Backport: Bug [#2118]. Add TabMinimumWidth property to API so applications can display overviews or minimaps with reasonable layout. Backport of changeset 7700:e6efe007d2dc. --- doc/ScintillaDoc.html | 14 +++++++++++++- doc/ScintillaHistory.html | 5 +++++ include/Scintilla.h | 2 ++ include/Scintilla.iface | 6 ++++++ src/Editor.cxx | 7 +++++++ 5 files changed, 33 insertions(+), 1 deletion(-) diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 21b288a21..f05ce6d9a 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -3885,8 +3885,11 @@ struct Sci_TextToFind { inserting a tab at the current character position and backspace unindents the line rather than deleting a character. Scintilla can also display indentation guides (vertical lines) to help you to generate code.

- SCI_SETTABWIDTH(int tabWidth)
+ + SCI_SETTABWIDTH(int tabWidth)
SCI_GETTABWIDTH → int
+ SCI_SETTABMINIMUMWIDTH(int pixels)
+ SCI_GETTABMINIMUMWIDTH → int
SCI_CLEARTABSTOPS(line line)
SCI_ADDTABSTOP(line line, int x)
SCI_GETNEXTTABSTOP(line line, int x) → int
@@ -3909,6 +3912,15 @@ struct Sci_TextToFind { SCI_GETHIGHLIGHTGUIDE → position
+

SCI_SETTABMINIMUMWIDTH(int pixels)
+ SCI_GETTABMINIMUMWIDTH → int
+ SCI_SETTABMINIMUMWIDTH sets the minimum size of a tab in pixels to ensure that the tab + can be seen. The default value is 2. This is particularly useful with proportional fonts with fractional widths where + the character before the tab may end a fraction of a pixel before a tab stop, causing the tab to only be a fraction of + a pixel wide without this setting. + Where displaying a miniaturized version of the document, setting this to 0 may make the miniaturized + version lay out more like the normal size version.

+

SCI_SETTABWIDTH(int tabWidth)
SCI_GETTABWIDTH → int
SCI_SETTABWIDTH sets the size of a tab as a multiple of the size of a space diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index cb05ac396..9c141ee3b 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -553,6 +553,11 @@

  • Released 30 Aug 2019.
  • +
  • + Add SCI_SETTABMINIMUMWIDTH to set the minimum width of tabs. + This allows minimaps or overviews to be layed out to match the full size editing view. + Bug #2118. +
  • Metapost lexer fixes crash with 'interface=none' comment. Bug #2129. diff --git a/include/Scintilla.h b/include/Scintilla.h index 2c9a8ac43..fbbc173d6 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -93,6 +93,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SETBUFFEREDDRAW 2035 #define SCI_SETTABWIDTH 2036 #define SCI_GETTABWIDTH 2121 +#define SCI_SETTABMINIMUMWIDTH 2724 +#define SCI_GETTABMINIMUMWIDTH 2725 #define SCI_CLEARTABSTOPS 2675 #define SCI_ADDTABSTOP 2676 #define SCI_GETNEXTTABSTOP 2677 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 7280f71b8..1dd85982d 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -252,6 +252,12 @@ set void SetTabWidth=2036(int tabWidth,) # Retrieve the visible size of a tab. get int GetTabWidth=2121(,) +# Set the minimum visual width of a tab. +set void SetTabMinimumWidth=2724(int pixels,) + +# Get the minimum visual width of a tab. +get int GetTabMinimumWidth=2725(,) + # Clear explicit tabstops on a line. fun void ClearTabStops=2675(line line,) diff --git a/src/Editor.cxx b/src/Editor.cxx index 4cceb1f5d..cb7269685 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -6528,6 +6528,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETTABWIDTH: return pdoc->tabInChars; + case SCI_SETTABMINIMUMWIDTH: + SetAppearance(view.tabWidthMinimumPixels, static_cast(wParam)); + break; + + case SCI_GETTABMINIMUMWIDTH: + return view.tabWidthMinimumPixels; + case SCI_CLEARTABSTOPS: if (view.ClearTabstops(static_cast(wParam))) { const DocModification mh(SC_MOD_CHANGETABSTOPS, 0, 0, 0, nullptr, static_cast(wParam)); -- cgit v1.2.3