diff options
author | XhmikosR <xhmikosr@gmail.com> | 2015-05-24 10:30:56 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2015-05-26 07:48:38 +0300 |
commit | aaced3ee7e32b63bc8460abcd2ee9817a052fbf3 (patch) | |
tree | f6d90ed1eed29e991e086e0f9b8bd4d553fc7851 | |
parent | 3194c494fc903bada6217bbea92147690e56adbb (diff) | |
download | notepad2-mod-aaced3ee7e32b63bc8460abcd2ee9817a052fbf3.zip notepad2-mod-aaced3ee7e32b63bc8460abcd2ee9817a052fbf3.tar.gz notepad2-mod-aaced3ee7e32b63bc8460abcd2ee9817a052fbf3.tar.bz2 |
Update Scintilla to v3.5.6.4.2.25.954
-rw-r--r-- | scintilla/doc/ScintillaDoc.html | 4 | ||||
-rw-r--r-- | scintilla/doc/ScintillaDownload.html | 10 | ||||
-rw-r--r-- | scintilla/doc/ScintillaHistory.html | 70 | ||||
-rw-r--r-- | scintilla/doc/index.html | 7 | ||||
-rw-r--r-- | scintilla/lexers/LexCPP.cxx | 6 | ||||
-rw-r--r-- | scintilla/lexers/LexFortran.cxx | 1 | ||||
-rw-r--r-- | scintilla/lexers/LexVHDL.cxx | 7 | ||||
-rw-r--r-- | scintilla/lexers/LexVerilog.cxx | 4 | ||||
-rw-r--r-- | scintilla/src/Document.cxx | 2 | ||||
-rw-r--r-- | scintilla/src/EditModel.h | 2 | ||||
-rw-r--r-- | scintilla/src/Editor.h | 2 | ||||
-rw-r--r-- | scintilla/src/ScintillaBase.h | 2 | ||||
-rw-r--r-- | scintilla/version.txt | 2 | ||||
-rw-r--r-- | scintilla/win32/HanjaDic.cxx | 5 | ||||
-rw-r--r-- | scintilla/win32/PlatWin.cxx | 9 | ||||
-rw-r--r-- | scintilla/win32/ScintillaWin.cxx | 132 |
16 files changed, 197 insertions, 68 deletions
diff --git a/scintilla/doc/ScintillaDoc.html b/scintilla/doc/ScintillaDoc.html index da63297..3a51cfb 100644 --- a/scintilla/doc/ScintillaDoc.html +++ b/scintilla/doc/ScintillaDoc.html @@ -587,14 +587,14 @@ struct Sci_TextRange { }; </pre> - <h3 id="EncodedAccess">Specific to GTK+ and Cocoa only: Access to encoded text</h3> + <h3 id="EncodedAccess">Specific to GTK+, Cocoa and Windows only: Access to encoded text</h3> <p><b id="SCI_TARGETASUTF8">SCI_TARGETASUTF8(<unused>, char *s)</b><br /> This method retrieves the value of the target encoded as UTF-8 which is the default encoding of GTK+ so is useful for retrieving text for use in other parts of the user interface, such as find and replace dialogs. The length of the encoded text in bytes is returned. Cocoa uses UTF-16 which is easily converted from UTF-8 so this method can be used to perform the - more complex work of transcoding from the various of encodings supported. + more complex work of transcoding from the various encodings supported. </p> <p><b id="SCI_ENCODEDFROMUTF8">SCI_ENCODEDFROMUTF8(const char *utf8, char *encoded)</b><br /> diff --git a/scintilla/doc/ScintillaDownload.html b/scintilla/doc/ScintillaDownload.html index cca92c8..48b88dc 100644 --- a/scintilla/doc/ScintillaDownload.html +++ b/scintilla/doc/ScintillaDownload.html @@ -25,9 +25,9 @@ <table bgcolor="#CCCCCC" width="100%" cellspacing="0" cellpadding="8" border="0">
<tr>
<td>
- <font size="4"> <a href="http://prdownloads.sourceforge.net/scintilla/scintilla355.zip?download">
+ <font size="4"> <a href="http://prdownloads.sourceforge.net/scintilla/scintilla356.zip?download">
Windows</a>
- <a href="http://prdownloads.sourceforge.net/scintilla/scintilla355.tgz?download">
+ <a href="http://prdownloads.sourceforge.net/scintilla/scintilla356.tgz?download">
GTK+/Linux</a>
</font>
</td>
@@ -41,7 +41,7 @@ containing very few restrictions.
</p>
<h3>
- Release 3.5.5
+ Release 3.5.6
</h3>
<h4>
Source Code
@@ -49,8 +49,8 @@ The source code package contains all of the source code for Scintilla but no binary
executable code and is available in
<ul>
- <li><a href="http://prdownloads.sourceforge.net/scintilla/scintilla355.zip?download">zip format</a> (1450K) commonly used on Windows</li>
- <li><a href="http://prdownloads.sourceforge.net/scintilla/scintilla355.tgz?download">tgz format</a> (1300K) commonly used on Linux and compatible operating systems</li>
+ <li><a href="http://prdownloads.sourceforge.net/scintilla/scintilla356.zip?download">zip format</a> (1450K) commonly used on Windows</li>
+ <li><a href="http://prdownloads.sourceforge.net/scintilla/scintilla356.tgz?download">tgz format</a> (1300K) commonly used on Linux and compatible operating systems</li>
</ul>
Instructions for building on both Windows and Linux are included in the readme file.
<h4>
diff --git a/scintilla/doc/ScintillaHistory.html b/scintilla/doc/ScintillaHistory.html index 413a23a..87bf61d 100644 --- a/scintilla/doc/ScintillaHistory.html +++ b/scintilla/doc/ScintillaHistory.html @@ -469,6 +469,9 @@ <td>Mika Attila</td>
<td>JoMazM</td>
<td>Markus Moser</td>
+ <td>Stefan Küng</td>
+ </tr><tr>
+ <td>Jiří Techet</td>
</tr>
</table>
<p>
@@ -481,6 +484,73 @@ </li>
</ul>
<h3>
+ <a href="http://prdownloads.sourceforge.net/scintilla/scite356.zip?download">Release 3.5.6</a>
+ </h3>
+ <ul>
+ <li>
+ Released 26 May 2015.
+ </li>
+ <li>
+ On Qt, use fractional positioning calls and avoid rounding to ensure consistency.
+ </li>
+ <li>
+ SCI_TARGETASUTF8 and SCI_ENCODEDFROMUTF8 implemented on
+ Win32 as well as GTK+ and Cocoa.
+ </li>
+ <li>
+ C++ lexer fixes empty backquoted string.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1711/">Bug #1711</a>.
+ </li>
+ <li>
+ C++ lexer fixes #undef directive.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1719/">Bug #1719</a>.
+ </li>
+ <li>
+ Fortran folder fixes handling of "selecttype" and "selectcase".
+ <a href="http://sourceforge.net/p/scintilla/bugs/1724/">Bug #1724</a>.
+ </li>
+ <li>
+ Verilog folder folds interface definitions.
+ </li>
+ <li>
+ VHDL folder folds units declarations and fixes a case insensitivity bug with not treating "IS" the same as "is".
+ </li>
+ <li>
+ Fix bug when drawing text margins in buffered mode which would use default
+ encoding instead of chosen encoding.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1703/">Bug #1703</a>.
+ </li>
+ <li>
+ Fix bug with Korean Hanja conversions in DBCS encoding on Windows.
+ </li>
+ <li>
+ Fix for reading a UTF-16 file in SciTE where a non-BMP character is split over a read buffer boundary.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1710/">Bug #1710</a>.
+ </li>
+ <li>
+ Fix bug on GTK+ 2.x for Windows where there was an ABI difference between
+ compiler version.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1726/">Bug #1726</a>.
+ </li>
+ <li>
+ Fix undo bug on Cocoa that could lose data..
+ </li>
+ <li>
+ Fix link error on Windows when SCI_NAMESPACE used.
+ </li>
+ <li>
+ Fix exporting from SciTE when using Scintillua for lexing.
+ </li>
+ <li>
+ SciTE does not report twice that a search string can not be found when "Replace" pressed.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1716/">Bug #1716</a>.
+ </li>
+ <li>
+ SciTE on GTK+ 3.x disables arrow in search combo when no entries.
+ <a href="http://sourceforge.net/p/scintilla/bugs/1717/">Bug #1717</a>.
+ </li>
+ </ul>
+ <h3>
<a href="http://prdownloads.sourceforge.net/scintilla/scite355.zip?download">Release 3.5.5</a>
</h3>
<ul>
diff --git a/scintilla/doc/index.html b/scintilla/doc/index.html index 23b652b..45a1e3c 100644 --- a/scintilla/doc/index.html +++ b/scintilla/doc/index.html @@ -9,7 +9,7 @@ <meta name="keywords" content="Scintilla, SciTE, Editing Component, Text Editor" />
<meta name="Description"
content="www.scintilla.org is the home of the Scintilla editing component and SciTE text editor application." />
- <meta name="Date.Modified" content="20150417" />
+ <meta name="Date.Modified" content="20150526" />
<style type="text/css">
#versionlist {
margin: 0;
@@ -55,8 +55,8 @@ GTK+, and OS X</font>
</td>
<td width="40%" align="right">
- <font color="#FFCC99" size="3"> Release version 3.5.5<br />
- Site last modified April 17 2015</font>
+ <font color="#FFCC99" size="3"> Release version 3.5.6<br />
+ Site last modified May 26 2015</font>
</td>
<td width="20%">
@@ -71,6 +71,7 @@ </tr>
</table>
<ul id="versionlist">
+ <li>Version 3.5.6 fixes a bug with undo on Cocoa that could lose data.</li>
<li>Version 3.5.5 improves IME on Qt and fixes minor bugs.</li>
<li>Version 3.5.4 improves indicators to be able to change appearance on mouse-over and to use a wide variety of colours together.</li>
<li>Version 3.5.3 removes support for Windows 95, 98, and ME.</li>
diff --git a/scintilla/lexers/LexCPP.cxx b/scintilla/lexers/LexCPP.cxx index ab982bb..1d9e40d 100644 --- a/scintilla/lexers/LexCPP.cxx +++ b/scintilla/lexers/LexCPP.cxx @@ -1092,7 +1092,6 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, } else if (options.backQuotedStrings && sc.Match('`')) { sc.SetState(SCE_C_STRINGRAW|activitySet); rawStringTerminator = "`"; - sc.Forward(); } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { if (lastWordWasUUID) { sc.SetState(SCE_C_UUID|activitySet); @@ -1246,11 +1245,10 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, } } else if (sc.Match("undef")) { if (options.updatePreprocessor && !preproc.IsInactive()) { - std::string restOfLine = GetRestOfLine(styler, sc.currentPos + 5, true); + const std::string restOfLine = GetRestOfLine(styler, sc.currentPos + 5, false); std::vector<std::string> tokens = Tokenize(restOfLine); - std::string key; if (tokens.size() >= 1) { - key = tokens[0]; + const std::string key = tokens[0]; preprocessorDefinitions.erase(key); ppDefineHistory.push_back(PPDefinition(lineCurrent, key, "", true)); definitionsChanged = true; diff --git a/scintilla/lexers/LexFortran.cxx b/scintilla/lexers/LexFortran.cxx index 70234f3..3b76f77 100644 --- a/scintilla/lexers/LexFortran.cxx +++ b/scintilla/lexers/LexFortran.cxx @@ -260,6 +260,7 @@ static int classifyFoldPointFortran(const char* s, const char* prevWord, const c lev = 0;
} else if (strcmp(s, "associate") == 0 || strcmp(s, "block") == 0
|| strcmp(s, "blockdata") == 0 || strcmp(s, "select") == 0
+ || strcmp(s, "selecttype") == 0 || strcmp(s, "selectcase") == 0
|| strcmp(s, "do") == 0 || strcmp(s, "enum") ==0
|| strcmp(s, "function") == 0 || strcmp(s, "interface") == 0
|| strcmp(s, "module") == 0 || strcmp(s, "program") == 0
diff --git a/scintilla/lexers/LexVHDL.cxx b/scintilla/lexers/LexVHDL.cxx index 95404bd..53e8377 100644 --- a/scintilla/lexers/LexVHDL.cxx +++ b/scintilla/lexers/LexVHDL.cxx @@ -216,7 +216,7 @@ static void FoldNoBoxVHDLDoc( // don't check if the style for the keywords that I use to adjust the levels.
char words[] =
"architecture begin block case component else elsif end entity generate loop package process record then "
- "procedure function when";
+ "procedure function when units";
WordList keywords;
keywords.Set(words);
@@ -382,7 +382,8 @@ static void FoldNoBoxVHDLDoc( strcmp(s, "package") ==0 ||
strcmp(s, "process") == 0 ||
strcmp(s, "record") == 0 ||
- strcmp(s, "then") == 0)
+ strcmp(s, "then") == 0 ||
+ strcmp(s, "units") == 0)
{
if (strcmp(prevWord, "end") != 0)
{
@@ -437,7 +438,7 @@ static void FoldNoBoxVHDLDoc( (!IsCommentStyle(styleAtPos)) &&
(styleAtPos != SCE_VHDL_STRING) &&
!iswordchar(styler.SafeGetCharAt(pos-1)) &&
- styler.Match(pos, "is") &&
+ (chAtPos|' ')=='i' && (styler.SafeGetCharAt(pos+1)|' ')=='s' &&
!iswordchar(styler.SafeGetCharAt(pos+2)))
{
if (levelMinCurrentElse > levelNext) {
diff --git a/scintilla/lexers/LexVerilog.cxx b/scintilla/lexers/LexVerilog.cxx index 2108210..96109d0 100644 --- a/scintilla/lexers/LexVerilog.cxx +++ b/scintilla/lexers/LexVerilog.cxx @@ -928,9 +928,10 @@ void SCI_METHOD LexerVerilog::Fold(unsigned int startPos, int length, int initSt if (styler.Match(j, "case") ||
styler.Match(j, "casex") ||
styler.Match(j, "casez") ||
+ styler.Match(j, "covergroup") ||
styler.Match(j, "function") ||
styler.Match(j, "generate") ||
- styler.Match(j, "covergroup") ||
+ styler.Match(j, "interface") ||
styler.Match(j, "package") ||
styler.Match(j, "primitive") ||
styler.Match(j, "program") ||
@@ -962,6 +963,7 @@ void SCI_METHOD LexerVerilog::Fold(unsigned int startPos, int length, int initSt styler.Match(j, "endfunction") ||
styler.Match(j, "endgenerate") ||
styler.Match(j, "endgroup") ||
+ styler.Match(j, "endinterface") ||
styler.Match(j, "endpackage") ||
styler.Match(j, "endprimitive") ||
styler.Match(j, "endprogram") ||
diff --git a/scintilla/src/Document.cxx b/scintilla/src/Document.cxx index 47c2302..fbb305b 100644 --- a/scintilla/src/Document.cxx +++ b/scintilla/src/Document.cxx @@ -216,6 +216,8 @@ void Document::SetSavePoint() { }
void Document::TentativeUndo() {
+ if (!TentativeActive())
+ return;
CheckReadOnly();
if (enteredModification == 0) {
enteredModification++;
diff --git a/scintilla/src/EditModel.h b/scintilla/src/EditModel.h index fce26bd..33c1ac0 100644 --- a/scintilla/src/EditModel.h +++ b/scintilla/src/EditModel.h @@ -25,7 +25,7 @@ public: class EditModel { // Private so EditModel objects can not be copied - EditModel(const EditModel &); + explicit EditModel(const EditModel &); EditModel &operator=(const EditModel &); public: diff --git a/scintilla/src/Editor.h b/scintilla/src/Editor.h index 82640fb..15adde8 100644 --- a/scintilla/src/Editor.h +++ b/scintilla/src/Editor.h @@ -153,7 +153,7 @@ struct WrapPending { */
class Editor : public EditModel, public DocWatcher {
// Private so Editor objects can not be copied
- Editor(const Editor &);
+ explicit Editor(const Editor &);
Editor &operator=(const Editor &);
protected: // ScintillaBase subclass needs access to much of Editor
diff --git a/scintilla/src/ScintillaBase.h b/scintilla/src/ScintillaBase.h index 28155ff..9cffce5 100644 --- a/scintilla/src/ScintillaBase.h +++ b/scintilla/src/ScintillaBase.h @@ -20,7 +20,7 @@ class LexState; */
class ScintillaBase : public Editor {
// Private so ScintillaBase objects can not be copied
- ScintillaBase(const ScintillaBase &);
+ explicit ScintillaBase(const ScintillaBase &);
ScintillaBase &operator=(const ScintillaBase &);
protected:
diff --git a/scintilla/version.txt b/scintilla/version.txt index d60f25f..bd32c15 100644 --- a/scintilla/version.txt +++ b/scintilla/version.txt @@ -1 +1 @@ -355
+356
diff --git a/scintilla/win32/HanjaDic.cxx b/scintilla/win32/HanjaDic.cxx index 3a86ad3..dbb755f 100644 --- a/scintilla/win32/HanjaDic.cxx +++ b/scintilla/win32/HanjaDic.cxx @@ -12,7 +12,7 @@ #include "HanjaDic.h" #ifdef SCI_NAMESPACE -using namespace Scintilla; +namespace Scintilla { #endif namespace HanjaDict { @@ -124,3 +124,6 @@ int GetHangulOfHanja(wchar_t *inout) { } } +#ifdef SCI_NAMESPACE +} +#endif diff --git a/scintilla/win32/PlatWin.cxx b/scintilla/win32/PlatWin.cxx index 384f56e..4752204 100644 --- a/scintilla/win32/PlatWin.cxx +++ b/scintilla/win32/PlatWin.cxx @@ -634,11 +634,14 @@ void SurfaceGDI::Init(SurfaceID sid, WindowID) { void SurfaceGDI::InitPixMap(int width, int height, Surface *surface_, WindowID) {
Release();
- hdc = ::CreateCompatibleDC(static_cast<SurfaceGDI *>(surface_)->hdc);
+ SurfaceGDI *psurfOther = static_cast<SurfaceGDI *>(surface_);
+ hdc = ::CreateCompatibleDC(psurfOther->hdc);
hdcOwned = true;
- bitmap = ::CreateCompatibleBitmap(static_cast<SurfaceGDI *>(surface_)->hdc, width, height);
+ bitmap = ::CreateCompatibleBitmap(psurfOther->hdc, width, height);
bitmapOld = static_cast<HBITMAP>(::SelectObject(hdc, bitmap));
::SetTextAlign(reinterpret_cast<HDC>(hdc), TA_BASELINE);
+ SetUnicodeMode(psurfOther->unicodeMode);
+ SetDBCSMode(psurfOther->codePage);
}
void SurfaceGDI::PenColour(ColourDesired fore) {
@@ -1287,6 +1290,8 @@ void SurfaceD2D::InitPixMap(int width, int height, Surface *surface_, WindowID) pRenderTarget->BeginDraw();
ownRenderTarget = true;
}
+ SetUnicodeMode(psurfOther->unicodeMode);
+ SetDBCSMode(psurfOther->codePage);
}
void SurfaceD2D::PenColour(ColourDesired fore) {
diff --git a/scintilla/win32/ScintillaWin.cxx b/scintilla/win32/ScintillaWin.cxx index 4f02a0c..b9cd0b2 100644 --- a/scintilla/win32/ScintillaWin.cxx +++ b/scintilla/win32/ScintillaWin.cxx @@ -12,6 +12,7 @@ #include <ctype.h>
#include <limits.h>
+#include <cmath>
#include <stdexcept>
#include <new>
#include <string>
@@ -115,7 +116,6 @@ typedef UINT_PTR (WINAPI *SetCoalescableTimerSig)(HWND hwnd, UINT_PTR nIDEvent, // GCC has trouble with the standard COM ABI so do it the old C way with explicit vtables.
-const TCHAR scintillaClassName[] = TEXT("Scintilla");
const TCHAR callClassName[] = TEXT("CallTip");
#ifdef SCI_NAMESPACE
@@ -244,6 +244,8 @@ class ScintillaWin : virtual bool DragThreshold(Point ptStart, Point ptNow);
virtual void StartDrag();
+ int TargetAsUTF8(char *text);
+ int EncodedFromUTF8(char *utf8, char *encoded) const;
sptr_t WndPaint(uptr_t wParam);
sptr_t HandleCompositionWindowed(uptr_t wParam, sptr_t lParam);
@@ -252,13 +254,11 @@ class ScintillaWin : void MoveImeCarets(int offset);
void DrawImeIndicator(int indicator, int len);
void SetCandidateWindowPos();
- void BytesToUniChar(const char *bytes, const int bytesLen, wchar_t *character, int &charsLen);
- void UniCharToBytes(const wchar_t *character, const int charsLen, char *bytes, int &bytesLen);
void SelectionToHangul();
void EscapeHanja();
void ToggleHanja();
- UINT CodePageOfDocument();
+ UINT CodePageOfDocument() const;
virtual bool ValidCodePage(int codePage) const;
virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
virtual bool SetIdle(bool on);
@@ -548,8 +548,8 @@ HWND ScintillaWin::MainHWND() { }
bool ScintillaWin::DragThreshold(Point ptStart, Point ptNow) {
- int xMove = static_cast<int>(abs(ptStart.x - ptNow.x));
- int yMove = static_cast<int>(abs(ptStart.y - ptNow.y));
+ int xMove = static_cast<int>(std::abs(ptStart.x - ptNow.x));
+ int yMove = static_cast<int>(std::abs(ptStart.y - ptNow.y));
return (xMove > ::GetSystemMetrics(SM_CXDRAG)) ||
(yMove > ::GetSystemMetrics(SM_CYDRAG));
}
@@ -654,6 +654,56 @@ static bool BoundsContains(PRectangle rcBounds, HRGN hRgnBounds, PRectangle rcCh return contains;
}
+// Returns the target converted to UTF8.
+// Return the length in bytes.
+int ScintillaWin::TargetAsUTF8(char *text) {
+ int targetLength = targetEnd - targetStart;
+ if (IsUnicodeMode()) {
+ if (text) {
+ pdoc->GetCharRange(text, targetStart, targetLength);
+ }
+ } else {
+ // Need to convert
+ std::string s = RangeText(targetStart, targetEnd);
+ int charsLen = ::MultiByteToWideChar(CodePageOfDocument(), 0, &s[0], targetLength, NULL, 0);
+ std::wstring characters(charsLen, '\0');
+ ::MultiByteToWideChar(CodePageOfDocument(), 0, &s[0], targetLength, &characters[0], charsLen);
+
+ int utf8Len = ::WideCharToMultiByte(CP_UTF8, 0, &characters[0], charsLen, NULL, 0, 0, 0);
+ if (text) {
+ ::WideCharToMultiByte(CP_UTF8, 0, &characters[0], charsLen, text, utf8Len, 0, 0);
+ text[utf8Len] = '\0';
+ }
+ return utf8Len;
+ }
+ return targetLength;
+}
+
+// Translates a nul terminated UTF8 string into the document encoding.
+// Return the length of the result in bytes.
+int ScintillaWin::EncodedFromUTF8(char *utf8, char *encoded) const {
+ int inputLength = (lengthForEncode >= 0) ? lengthForEncode : static_cast<int>(strlen(utf8));
+ if (IsUnicodeMode()) {
+ if (encoded) {
+ memcpy(encoded, utf8, inputLength);
+ }
+ return inputLength;
+ } else {
+ // Need to convert
+ int charsLen = ::MultiByteToWideChar(CP_UTF8, 0, utf8, inputLength, NULL, 0);
+ std::wstring characters(charsLen, '\0');
+ ::MultiByteToWideChar(CP_UTF8, 0, utf8, inputLength, &characters[0], charsLen);
+
+ int encodedLen = ::WideCharToMultiByte(CodePageOfDocument(),
+ 0, &characters[0], charsLen, NULL, 0, 0, 0);
+ if (encoded) {
+ ::WideCharToMultiByte(CodePageOfDocument(), 0, &characters[0], charsLen, encoded, encodedLen, 0, 0);
+ encoded[encodedLen] = '\0';
+ }
+ return encodedLen;
+ }
+}
+
LRESULT ScintillaWin::WndPaint(uptr_t wParam) {
//ElapsedTime et;
@@ -803,27 +853,25 @@ void ScintillaWin::SetCandidateWindowPos() { }
}
-void ScintillaWin::BytesToUniChar(const char *bytes, const int bytesLen, wchar_t *characters, int &charsLen) {
- // Return results over characters and charsLen.
- if (IsUnicodeMode()) {
- charsLen = ::MultiByteToWideChar(SC_CP_UTF8, 0, bytes, bytesLen, NULL, 0);
- ::MultiByteToWideChar(SC_CP_UTF8, 0, bytes, bytesLen, characters, charsLen);
+static std::string StringEncode(std::wstring s, int codePage) {
+ if (s.length()) {
+ int cchMulti = ::WideCharToMultiByte(codePage, 0, s.c_str(), static_cast<int>(s.length()), NULL, 0, NULL, NULL);
+ std::string sMulti(cchMulti, 0);
+ ::WideCharToMultiByte(codePage, 0, s.c_str(), static_cast<int>(s.size()), &sMulti[0], cchMulti, NULL, NULL);
+ return sMulti;
} else {
- charsLen = ::MultiByteToWideChar(CodePageOfDocument(), 0, bytes, bytesLen, NULL, 0);
- ::MultiByteToWideChar(CodePageOfDocument(), 0, bytes, bytesLen, characters, charsLen);
+ return std::string();
}
}
-void ScintillaWin::UniCharToBytes(const wchar_t *characters, const int charsLen, char *bytes, int &bytesLen) {
- // Return results over bytes and bytesLen.
- if (IsUnicodeMode()) {
- bytesLen = UTF8Length(characters, charsLen);
- UTF8FromUTF16(characters, charsLen, bytes, bytesLen);
- bytes[bytesLen] = '\0';
+static std::wstring StringDecode(std::string s, int codePage) {
+ if (s.length()) {
+ int cchWide = ::MultiByteToWideChar(codePage, 0, s.c_str(), static_cast<int>(s.length()), NULL, 0);
+ std::wstring sWide(cchWide, 0);
+ ::MultiByteToWideChar(codePage, 0, s.c_str(), static_cast<int>(s.length()), &sWide[0], cchWide);
+ return sWide;
} else {
- bytesLen = ::WideCharToMultiByte(CodePageOfDocument(), 0,
- characters, charsLen, bytes, bytesLen, 0, 0);
- bytes[bytesLen] = '\0';
+ return std::wstring();
}
}
@@ -835,21 +883,17 @@ void ScintillaWin::SelectionToHangul() { const int utf16Len = pdoc->CountUTF16(selStart, selEnd);
if (utf16Len > 0) {
- std::vector<wchar_t> uniStr(utf16Len+1, '\0');
- std::vector<char> documentStr(documentStrLen+1, '\0');
-
+ std::string documentStr(documentStrLen, '\0');
pdoc->GetCharRange(&documentStr[0], selStart, documentStrLen);
- int countedUniLen = 0;
- int countedDocLen = 0;
- BytesToUniChar(&documentStr[0], documentStrLen, &uniStr[0], countedUniLen);
+ std::wstring uniStr = StringDecode(documentStr, CodePageOfDocument());
int converted = HanjaDict::GetHangulOfHanja(&uniStr[0]);
- UniCharToBytes(&uniStr[0], countedUniLen, &documentStr[0], countedDocLen);
+ documentStr = StringEncode(uniStr, CodePageOfDocument());
if (converted > 0) {
pdoc->BeginUndoAction();
ClearSelection();
- InsertPaste(&documentStr[0], countedDocLen);
+ InsertPaste(&documentStr[0], static_cast<int>(documentStr.size()));
pdoc->EndUndoAction();
}
}
@@ -872,22 +916,17 @@ void ScintillaWin::EscapeHanja() { // ImmEscapeW() may overwrite uniChar[] with a null terminated string.
// So enlarge it enough to Maximum 4 as in UTF-8.
unsigned int const safeLength = UTF8MaxBytes+1;
- wchar_t uniChar[safeLength] = {0};
- int uniCharLen = 1;
- char oneChar[safeLength] = "\0\0\0\0";
-
- pdoc->GetCharRange(oneChar, currentPos, oneCharLen);
-
- BytesToUniChar(oneChar, oneCharLen, uniChar, uniCharLen);
+ std::string oneChar(safeLength, '\0');
+ pdoc->GetCharRange(&oneChar[0], currentPos, oneCharLen);
- // Set the candidate box position since IME may show it.
- SetCandidateWindowPos();
+ std::wstring uniChar = StringDecode(oneChar, CodePageOfDocument());
- // IME_ESC_HANJA_MODE appears to receive the first character only.
HIMC hIMC=ImmGetContext(MainHWND());
if (hIMC) {
- if (ImmEscapeW(GetKeyboardLayout(0), hIMC, IME_ESC_HANJA_MODE, &uniChar)) {
- SetCandidateWindowPos(); // Force it again for sure.
+ // Set the candidate box position since IME may show it.
+ SetCandidateWindowPos();
+ // IME_ESC_HANJA_MODE appears to receive the first character only.
+ if (ImmEscapeW(GetKeyboardLayout(0), hIMC, IME_ESC_HANJA_MODE, &uniChar[0])) {
SetSelection (currentPos, currentPos + oneCharLen);
}
::ImmReleaseContext(MainHWND(), hIMC);
@@ -1093,7 +1132,7 @@ UINT CodePageFromCharSet(DWORD characterSet, UINT documentCodePage) { return documentCodePage;
}
-UINT ScintillaWin::CodePageOfDocument() {
+UINT ScintillaWin::CodePageOfDocument() const {
return CodePageFromCharSet(vs.styles[STYLE_DEFAULT].characterSet, pdoc->dbcsCodePage);
}
@@ -1647,6 +1686,13 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam break;
#endif
+ case SCI_TARGETASUTF8:
+ return TargetAsUTF8(reinterpret_cast<char*>(lParam));
+
+ case SCI_ENCODEDFROMUTF8:
+ return EncodedFromUTF8(reinterpret_cast<char*>(wParam),
+ reinterpret_cast<char*>(lParam));
+
default:
return ScintillaBase::WndProc(iMessage, wParam, lParam);
}
|