From 01c48f98e5557089fc7501394f905a5b15fde9c0 Mon Sep 17 00:00:00 2001
From: Neil
Date: Tue, 19 Dec 2017 15:00:40 +1100
Subject: Start of bidirectional code - implement SCI_SETBIDIRECTIONAL.
---
doc/ScintillaDoc.html | 29 ++++++++++++++++++++++++++---
include/Scintilla.h | 7 +++++++
include/Scintilla.iface | 13 +++++++++++--
src/EditModel.cxx | 1 +
src/EditModel.h | 2 ++
src/Editor.cxx | 7 +++++++
win32/ScintillaWin.cxx | 11 +++++++++++
7 files changed, 65 insertions(+), 5 deletions(-)
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html
index 90c5745e2..1e71bafbd 100644
--- a/doc/ScintillaDoc.html
+++ b/doc/ScintillaDoc.html
@@ -119,7 +119,7 @@
Scintilla Documentation
- Last edited 11 August 2017 NH
+ Last edited 10 January 2018 NH
There is an overview of the internal design of
Scintilla.
@@ -3594,6 +3594,10 @@ struct Sci_TextToFind {
SCI_GETCODEPAGE → int
SCI_SETIMEINTERACTION(int imeInteraction)
SCI_GETIMEINTERACTION → int
+
SCI_GRABFOCUS
SCI_SETFOCUS(bool focus)
SCI_GETFOCUS → bool
@@ -3718,6 +3722,27 @@ struct Sci_TextToFind {
and the inline behaviour with SCI_SETIMEINTERACTION(SC_IME_INLINE).
Scintilla may ignore this call in some cases. For example, the inline behaviour might only be supported for some languages.
+
+
These bidirectional features are not yet implemented and the API is provisional
+
SCI_SETBIDIRECTIONAL(int bidirectional)
+ SCI_GETBIDIRECTIONAL → int
+ Some languages, like Arabic and Hebrew, are written from right to left instead of from left to right as English is.
+ Documents that use multiple languages may contain both directions and this is termed "bidirectional".
+ The default text direction may be right to left or left to right.
+ Scintilla only correctly displays bidirectional text on some platforms and there can be additional processing and storage
+ costs to this.
+ Currently, bidirectional text only works on Win32 using DirectWrite.
+ As some applications may not want to pay the costs, bidirectional support must be explicitly enabled by calling
+ SCI_SETBIDIRECTIONAL(SC_BIDIRECTIONAL_L2R) (1) which chooses left to right as the default direction or
+ SCI_SETBIDIRECTIONAL(SC_BIDIRECTIONAL_R2L) (2) for default right to left.
+ This should be done after setting the technology to SC_TECHNOLOGY_DIRECTWRITE,
+ SC_TECHNOLOGY_DIRECTWRITERETAIN, or
+ SC_TECHNOLOGY_DIRECTWRITEDC.
+
If the call succeeded SCI_GETBIDIRECTIONAL will return the same value otherwise
+ SC_BIDIRECTIONAL_DISABLED (0) is returned.
+
+
+
SCI_GRABFOCUS
SCI_SETFOCUS(bool focus)
SCI_GETFOCUS → bool
@@ -8073,8 +8098,6 @@ for line = lineStart to lineEnd do SCI_ENSUREVISIBLE(line) next
Provisional features are displayed in this document with a distinctive background colour.
- There are currently no provisional messages or values.
-
Some developers may want to only use features that are stable and have graduated from
provisional status. To avoid using provisional messages compile with the symbol
SCI_DISABLE_PROVISIONAL defined.
diff --git a/include/Scintilla.h b/include/Scintilla.h
index 25649302e..74ec5b91a 100644
--- a/include/Scintilla.h
+++ b/include/Scintilla.h
@@ -1103,6 +1103,13 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
#define SCN_AUTOCCOMPLETED 2030
#define SCN_MARGINRIGHTCLICK 2031
#define SCN_AUTOCSELECTIONCHANGE 2032
+#ifndef SCI_DISABLE_PROVISIONAL
+#define SC_BIDIRECTIONAL_DISABLED 0
+#define SC_BIDIRECTIONAL_L2R 1
+#define SC_BIDIRECTIONAL_R2L 2
+#define SCI_GETBIDIRECTIONAL 2708
+#define SCI_SETBIDIRECTIONAL 2709
+#endif
/* --Autogenerated -- end of section automatically generated from Scintilla.iface */
/* These structures are defined to be exactly the same shape as the Win32
diff --git a/include/Scintilla.iface b/include/Scintilla.iface
index 04de613a5..bb00ed634 100644
--- a/include/Scintilla.iface
+++ b/include/Scintilla.iface
@@ -4861,10 +4861,19 @@ evt void AutoCCompleted=2030(string text, int position, int ch, CompletionMethod
evt void MarginRightClick=2031(int modifiers, int position, int margin)
evt void AutoCSelectionChange=2032(int listType, string text, int position)
-# There are no provisional APIs currently.
-
cat Provisional
+enu Bidirectional=SC_BIDIRECTIONAL_
+val SC_BIDIRECTIONAL_DISABLED=0
+val SC_BIDIRECTIONAL_L2R=1
+val SC_BIDIRECTIONAL_R2L=2
+
+# Retrieve bidirectional text display state.
+get int GetBidirectional=2708(,)
+
+# Set bidirectional text display state.
+set void SetBidirectional=2709(int bidirectional,)
+
cat Deprecated
# Divide each styling byte into lexical class bits (default: 5) and indicator
diff --git a/src/EditModel.cxx b/src/EditModel.cxx
index 7dfd90e37..0e00bcfe0 100644
--- a/src/EditModel.cxx
+++ b/src/EditModel.cxx
@@ -63,6 +63,7 @@ EditModel::EditModel() {
highlightGuideColumn = 0;
primarySelection = true;
imeInteraction = imeWindowed;
+ bidirectional = Bidirectional::bidiDisabled;
foldFlags = 0;
foldDisplayTextStyle = SC_FOLDDISPLAYTEXT_HIDDEN;
hotspot = Range(Sci::invalidPosition);
diff --git a/src/EditModel.h b/src/EditModel.h
index 773309d45..6e4919bd5 100644
--- a/src/EditModel.h
+++ b/src/EditModel.h
@@ -38,6 +38,8 @@ public:
enum IMEInteraction { imeWindowed, imeInline } imeInteraction;
+ enum class Bidirectional { bidiDisabled, bidiL2R, bidiR2L } bidirectional;
+
int foldFlags;
int foldDisplayTextStyle;
ContractionState cs;
diff --git a/src/Editor.cxx b/src/Editor.cxx
index d45a8684c..36af34685 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -6736,6 +6736,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
case SCI_GETIMEINTERACTION:
return imeInteraction;
+ case SCI_SETBIDIRECTIONAL:
+ // SCI_SETBIDIRECTIONAL is implemented on platform subclasses if they support bidirectional text.
+ break;
+
+ case SCI_GETBIDIRECTIONAL:
+ return static_cast(bidirectional);
+
// Marker definition and setting
case SCI_MARKERDEFINE:
if (wParam <= MARKER_MAX) {
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index 2d2fc266c..45b091546 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -1744,6 +1744,17 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
}
break;
+ case SCI_SETBIDIRECTIONAL:
+ if (technology == SC_TECHNOLOGY_DEFAULT) {
+ bidirectional = EditModel::Bidirectional::bidiDisabled;
+ } else if ((wParam >= SC_BIDIRECTIONAL_DISABLED) && (wParam <= SC_BIDIRECTIONAL_R2L)) {
+ bidirectional = static_cast(wParam);
+ }
+ // Invalidate all cached information including layout.
+ DropGraphics(true);
+ InvalidateStyleRedraw();
+ break;
+
#ifdef SCI_LEXER
case SCI_LOADLEXERLIBRARY:
LexerManager::GetInstance()->Load(reinterpret_cast(lParam));
--
cgit v1.2.3