From d744f3aedb7b09625f45ef659ed4c787bf45c42f Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 12 Sep 2014 11:22:39 +1000 Subject: Allow choice between windowed and inline IME. --- cocoa/ScintillaCocoa.mm | 5 +++++ doc/ScintillaDoc.html | 17 ++++++++++++++++- doc/ScintillaHistory.html | 3 +++ include/Scintilla.h | 4 ++++ include/Scintilla.iface | 10 ++++++++++ qt/ScintillaEditBase/ScintillaQt.cpp | 6 ++++++ src/EditModel.cxx | 1 + src/EditModel.h | 2 ++ src/Editor.cxx | 7 +++++++ 9 files changed, 54 insertions(+), 1 deletion(-) diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index f8c53932c..5f5d68b73 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -395,6 +395,7 @@ ScintillaCocoa::ScintillaCocoa(SCIContentView* view, SCIMarginView* viewMargin) idleTimer = NULL; observer = NULL; layerFindIndicator = NULL; + imeInteraction = imeInline; for (TickReason tr=tickCaret; tr<=tickPlatform; tr = static_cast(tr+1)) { timers[tr] = nil; @@ -826,6 +827,10 @@ sptr_t ScintillaCocoa::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPar case SCI_GETDIRECTPOINTER: return reinterpret_cast(this); + case SCI_SETIMEINTERACTION: + // Only inline IME supported on Cocoa + break; + case SCI_GRABFOCUS: [[ContentView() window] makeFirstResponder:ContentView()]; break; diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 0d1f33bcb..e71b39a4d 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -82,7 +82,7 @@

Scintilla Documentation

-

Last edited 4 September 2014 NH

+

Last edited 12 September 2014 NH

There is an overview of the internal design of Scintilla.
@@ -3171,6 +3171,8 @@ struct Sci_TextToFind { SCI_GETFONTQUALITY
SCI_SETCODEPAGE(int codePage)
SCI_GETCODEPAGE
+ SCI_SETIMEINTERACTION(int imeInteraction)
+ SCI_GETIMEINTERACTION
SCI_SETKEYSUNICODE(bool keysUnicode)
SCI_GETKEYSUNICODE
SCI_SETWORDCHARS(<unused>, const char *characters)
@@ -3281,6 +3283,19 @@ struct Sci_TextToFind { 949 (Korean Unified Hangul Code), 950 (Traditional Chinese Big5), or 1361 (Korean Johab) although these may require installation of language specific support.

+

SCI_SETIMEINTERACTION(int imeInteraction)
+ SCI_GETIMEINTERACTION
+ When entering text in Chinese, Japanese, or Korean an Input Method Editor (IME) may be displayed. + The IME may be an extra window appearing above Scintilla or may be displayed by Scintilla itself + as text. On some platforms there is a choice between the two techniques. + A windowed IME SC_IME_WINDOWED (0) may be more similar in appearance and + behaviour to the IME in other applications. + An inline IME SC_IME_INLINE (1) may work better with some Scintilla features such as + rectangular and multiple selection.

+

The windowed behaviour can be chosen with SCI_SETIMEINTERACTION(SC_IME_WINDOWED) + 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.

+

SCI_SETKEYSUNICODE(bool keysUnicode)
SCI_GETKEYSUNICODE
On Windows, character keys are normally handled differently depending on whether Scintilla is a wide diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index b2fa52fb2..daf06d14e 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -497,6 +497,9 @@ Bug #1652.

  • + Allow choice between windowed and inline IME on some platforms. +
  • +
  • On GTK+ cache autocomplete window to avoid platform bug where windows were sometimes lost. Bug #1649. diff --git a/include/Scintilla.h b/include/Scintilla.h index 184bcacb7..74b0cefd5 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -97,6 +97,10 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETNEXTTABSTOP 2677 #define SC_CP_UTF8 65001 #define SCI_SETCODEPAGE 2037 +#define SC_IME_WINDOWED 0 +#define SC_IME_INLINE 1 +#define SCI_GETIMEINTERACTION 2678 +#define SCI_SETIMEINTERACTION 2679 #define MARKER_MAX 31 #define SC_MARK_CIRCLE 0 #define SC_MARK_ROUNDRECT 1 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 134078786..bf3fa0811 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -243,6 +243,16 @@ val SC_CP_UTF8=65001 # The SC_CP_UTF8 value can be used to enter Unicode mode. set void SetCodePage=2037(int codePage,) +enu IMEInteraction=SC_IME_ +val SC_IME_WINDOWED=0 +val SC_IME_INLINE=1 + +# Is the IME displayed in a winow or inline? +get int GetIMEInteraction=2678(,) + +# Choose to display the the IME in a winow or inline. +set void SetIMEInteraction=2679(int imeInteraction,) + enu MarkerSymbol=SC_MARK_ val MARKER_MAX=31 val SC_MARK_CIRCLE=0 diff --git a/qt/ScintillaEditBase/ScintillaQt.cpp b/qt/ScintillaEditBase/ScintillaQt.cpp index c2b250a3e..1c34a5b0b 100644 --- a/qt/ScintillaEditBase/ScintillaQt.cpp +++ b/qt/ScintillaEditBase/ScintillaQt.cpp @@ -38,6 +38,8 @@ ScintillaQt::ScintillaQt(QAbstractScrollArea *parent) wMain = scrollArea->viewport(); + imeInteraction = imeInline; + // On OS X drawing text into a pixmap moves it around 1 pixel to // the right compared to drawing it directly onto a window. // Buffered drawing turned off by default to avoid this. @@ -651,6 +653,10 @@ sptr_t ScintillaQt::WndProc(unsigned int message, uptr_t wParam, sptr_t lParam) try { switch (message) { + case SCI_SETIMEINTERACTION: + // Only inline IME supported on Qt + break; + case SCI_GRABFOCUS: scrollArea->setFocus(Qt::OtherFocusReason); break; diff --git a/src/EditModel.cxx b/src/EditModel.cxx index 815d22781..8f66da463 100644 --- a/src/EditModel.cxx +++ b/src/EditModel.cxx @@ -61,6 +61,7 @@ EditModel::EditModel() { bracesMatchStyle = STYLE_BRACEBAD; highlightGuideColumn = 0; primarySelection = true; + imeInteraction = imeWindowed; foldFlags = 0; hotspot = Range(invalidPosition); wrapWidth = LineLayout::wrapWidthInfinite; diff --git a/src/EditModel.h b/src/EditModel.h index f7ca7497a..d8def3294 100644 --- a/src/EditModel.h +++ b/src/EditModel.h @@ -42,6 +42,8 @@ public: Selection sel; bool primarySelection; + enum IMEInteraction { imeWindowed, imeInline } imeInteraction; + int foldFlags; ContractionState cs; // Hotspot support diff --git a/src/Editor.cxx b/src/Editor.cxx index 8f0f43b08..af9d92cdc 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -6251,6 +6251,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETCODEPAGE: return pdoc->dbcsCodePage; + case SCI_SETIMEINTERACTION: + imeInteraction = static_cast(wParam); + break; + + case SCI_GETIMEINTERACTION: + return imeInteraction; + #ifdef INCLUDE_DEPRECATED_FEATURES case SCI_SETUSEPALETTE: InvalidateStyleRedraw(); -- cgit v1.2.3