From b5ba1cee2188ab879573126c62d6291b346e089c Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 30 Mar 2021 19:34:53 +1100 Subject: Treat SC_MARK_CHARACTER as Unicode for a wider variety of symbols. --- doc/ScintillaDoc.html | 8 ++++---- doc/ScintillaHistory.html | 3 +++ gtk/deps.mak | 3 ++- src/LineMarker.cxx | 10 ++++++---- win32/deps.mak | 3 ++- win32/nmdeps.mak | 3 ++- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 8971f4d93..db04e66c5 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -4477,10 +4477,10 @@ struct Sci_TextToFind { SC_MARK_TCORNER, SC_MARK_TCORNERCURVE, and SC_MARK_VLINE.

- Characters can be used as markers by adding the ASCII value of the character to - SC_MARK_CHARACTER (10000). For example, to use 'A' (ASCII code 65) as marker - number 1 use:
- SCI_MARKERDEFINE(1, SC_MARK_CHARACTER+65).
+ Characters can be used as markers by adding the Unicode code point of the character to + SC_MARK_CHARACTER (10000). For example, to use '▥' SQUARE WITH VERTICAL FILL + (Unicode code point 9637) as marker number 1 use:
+ SCI_MARKERDEFINE(1, SC_MARK_CHARACTER+9637).

The marker numbers SC_MARKNUM_FOLDER and SC_MARKNUM_FOLDEROPEN are used for showing that a fold is present and open or closed. Any symbols may be assigned for diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index d8aea7a2a..2a9a2d498 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -612,6 +612,9 @@ Implement SC_ELEMENT_LIST* to change colours of autocompletion lists.

  • + Support Unicode characters as margin markers with SC_MARK_CHARACTER. +
  • +
  • Change graphics coordinates from float (32-bit) to double (64-bit). Fixes uneven line heights in large documents on Cocoa. Increases memory use. diff --git a/gtk/deps.mak b/gtk/deps.mak index 0ae4b48e5..3bd9b98b1 100644 --- a/gtk/deps.mak +++ b/gtk/deps.mak @@ -311,7 +311,8 @@ LineMarker.o: \ ../include/Scintilla.h \ ../include/Sci_Position.h \ ../src/XPM.h \ - ../src/LineMarker.h + ../src/LineMarker.h \ + ../src/UniConversion.h MarginView.o: \ ../src/MarginView.cxx \ ../src/Debugging.h \ diff --git a/src/LineMarker.cxx b/src/LineMarker.cxx index 02228b6f5..ed9c1ce7a 100644 --- a/src/LineMarker.cxx +++ b/src/LineMarker.cxx @@ -26,6 +26,7 @@ #include "XPM.h" #include "LineMarker.h" +#include "UniConversion.h" using namespace Scintilla; @@ -530,12 +531,13 @@ void LineMarker::Draw(Surface *surface, const PRectangle &rcWhole, const Font *f default: if (markType >= SC_MARK_CHARACTER) { - std::string character(1, static_cast(markType - SC_MARK_CHARACTER)); - const XYPOSITION width = surface->WidthText(fontForCharacter, character); + char character[UTF8MaxBytes + 1]; + UTF8FromUTF32Character(markType - SC_MARK_CHARACTER, character); + const XYPOSITION width = surface->WidthTextUTF8(fontForCharacter, character); PRectangle rcText = rc; rcText.left += (rc.Width() - width) / 2; - rcText.right = rc.left + width; - surface->DrawTextClipped(rcText, fontForCharacter, rcText.bottom - 2, + rcText.right = rcText.left + width; + surface->DrawTextNoClipUTF8(rcText, fontForCharacter, rcText.bottom - 2, character, fore, back); } else { // treat as SC_MARK_FULLRECT diff --git a/win32/deps.mak b/win32/deps.mak index ed31cc100..3fd1b4765 100644 --- a/win32/deps.mak +++ b/win32/deps.mak @@ -280,7 +280,8 @@ LineMarker.o: \ ../include/Scintilla.h \ ../include/Sci_Position.h \ ../src/XPM.h \ - ../src/LineMarker.h + ../src/LineMarker.h \ + ../src/UniConversion.h MarginView.o: \ ../src/MarginView.cxx \ ../src/Debugging.h \ diff --git a/win32/nmdeps.mak b/win32/nmdeps.mak index f3824b54a..b831d6add 100644 --- a/win32/nmdeps.mak +++ b/win32/nmdeps.mak @@ -280,7 +280,8 @@ $(DIR_O)/LineMarker.obj: \ ../include/Scintilla.h \ ../include/Sci_Position.h \ ../src/XPM.h \ - ../src/LineMarker.h + ../src/LineMarker.h \ + ../src/UniConversion.h $(DIR_O)/MarginView.obj: \ ../src/MarginView.cxx \ ../src/Debugging.h \ -- cgit v1.2.3