aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2017-06-12 11:49:56 +1000
committerNeil <nyamatongwe@gmail.com>2017-06-12 11:49:56 +1000
commit69b778424b380a32a6c83526b678466712c4a220 (patch)
tree808839f4df4bc62dd0d5faf5cd24620e8cbf8b3a
parentccfd60b0fda24c2daa06ff02b2f909850095a56a (diff)
downloadscintilla-mirror-69b778424b380a32a6c83526b678466712c4a220.tar.gz
Backport: Removed unused functions and methods from Platform.h.
Replaced Platform::Clamp with Sci::clamp. Drop MouseButtonBounce workaround for very early GTK+/Linux. Backported from changeset 6307:7030530a9a0f.
-rw-r--r--cocoa/PlatCocoa.h1
-rw-r--r--cocoa/PlatCocoa.mm146
-rw-r--r--cocoa/ScintillaCocoa.h1
-rw-r--r--cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj4
-rw-r--r--gtk/PlatGTK.cxx100
-rw-r--r--include/Platform.h27
-rw-r--r--qt/ScintillaEdit/ScintillaEdit.pro1
-rw-r--r--qt/ScintillaEditBase/PlatQt.cpp106
-rw-r--r--qt/ScintillaEditBase/PlatQt.h1
-rw-r--r--qt/ScintillaEditBase/ScintillaEditBase.pro2
-rw-r--r--qt/ScintillaEditPy/ScintillaEditPy.pro2
-rw-r--r--scripts/HeaderOrder.txt1
-rw-r--r--src/DBCS.cxx48
-rw-r--r--src/DBCS.h21
-rw-r--r--src/Document.cxx2
-rw-r--r--src/Editor.cxx99
-rw-r--r--src/Position.h8
-rw-r--r--src/ViewStyle.cxx2
-rw-r--r--win32/PlatWin.cxx112
-rw-r--r--win32/ScintillaWin.cxx40
-rw-r--r--win32/makefile1
-rw-r--r--win32/scintilla.mak1
22 files changed, 172 insertions, 554 deletions
diff --git a/cocoa/PlatCocoa.h b/cocoa/PlatCocoa.h
index f8f1bd698..05d2598f4 100644
--- a/cocoa/PlatCocoa.h
+++ b/cocoa/PlatCocoa.h
@@ -107,7 +107,6 @@ public:
XYPOSITION Ascent(Font &font_) override;
XYPOSITION Descent(Font &font_) override;
XYPOSITION InternalLeading(Font &font_) override;
- XYPOSITION ExternalLeading(Font &font_) override;
XYPOSITION Height(Font &font_) override;
XYPOSITION AverageCharWidth(Font &font_) override;
diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm
index 0e311126e..0069106e5 100644
--- a/cocoa/PlatCocoa.mm
+++ b/cocoa/PlatCocoa.mm
@@ -87,19 +87,6 @@ inline PRectangle CGRectToPRectangle(const CGRect& rect)
return rc;
}
-//----------------- Point --------------------------------------------------------------------------
-
-/**
- * Converts a point given as a long into a native Point structure.
- */
-Scintilla::Point Scintilla::Point::FromLong(long lpoint)
-{
- return Scintilla::Point(
- Platform::LowShortFromLong(lpoint),
- Platform::HighShortFromLong(lpoint)
- );
-}
-
//----------------- Font ---------------------------------------------------------------------------
Font::Font(): fid(0)
@@ -982,7 +969,7 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION
} else if (codePage) {
int ui = 0;
for (int i=0;i<len;) {
- size_t lenChar = Platform::IsDBCSLeadByte(codePage, s[i]) ? 2 : 1;
+ size_t lenChar = DBCSIsLeadByte(codePage, s[i]) ? 2 : 1;
CGFloat xPosition = CTLineGetOffsetForStringIndex(mLine, ui+1, NULL);
for (unsigned int bytePos=0; (bytePos<lenChar) && (i<len); bytePos++) {
positions[i++] = static_cast<XYPOSITION>(xPosition);
@@ -1048,15 +1035,6 @@ XYPOSITION SurfaceImpl::InternalLeading(Font &) {
return 0;
}
-XYPOSITION SurfaceImpl::ExternalLeading(Font &font_) {
- if (!font_.GetID())
- return 1;
-
- float leading = static_cast<QuartzTextStyle*>( font_.GetID() )->getLeading();
- return leading + 0.5f;
-
-}
-
XYPOSITION SurfaceImpl::Height(Font &font_) {
return Ascent(font_) + Descent(font_);
@@ -1109,14 +1087,6 @@ Window::~Window()
//--------------------------------------------------------------------------------------------------
-bool Window::HasFocus()
-{
- NSView* container = static_cast<NSView*>(wid);
- return [[container window] firstResponder] == container;
-}
-
-//--------------------------------------------------------------------------------------------------
-
static CGFloat ScreenMax()
{
return NSMaxY([[NSScreen mainScreen] frame]);
@@ -1307,22 +1277,6 @@ void Window::SetCursor(Cursor curs)
//--------------------------------------------------------------------------------------------------
-void Window::SetTitle(const char* s)
-{
- if (wid)
- {
- id idWin = static_cast<id>(wid);
- if ([idWin isKindOfClass: [NSWindow class]])
- {
- NSWindow* win = idWin;
- NSString* sTitle = [NSString stringWithUTF8String:s];
- [win setTitle:sTitle];
- }
- }
-}
-
-//--------------------------------------------------------------------------------------------------
-
PRectangle Window::GetMonitorRect(Point)
{
if (wid)
@@ -2098,93 +2052,6 @@ unsigned int Platform::DoubleClickTime()
//--------------------------------------------------------------------------------------------------
-bool Platform::MouseButtonBounce()
-{
- return false;
-}
-
-//--------------------------------------------------------------------------------------------------
-
-/**
- * Helper method for the backend to reach through to the scintilla window.
- */
-long Platform::SendScintilla(WindowID w, unsigned int msg, unsigned long wParam, long lParam)
-{
- return scintilla_send_message(w, msg, wParam, lParam);
-}
-
-//--------------------------------------------------------------------------------------------------
-
-/**
- * Helper method for the backend to reach through to the scintilla window.
- */
-long Platform::SendScintillaPointer(WindowID w, unsigned int msg, unsigned long wParam, void *lParam)
-{
- return scintilla_send_message(w, msg, wParam, (long) lParam);
-}
-
-//--------------------------------------------------------------------------------------------------
-
-bool Platform::IsDBCSLeadByte(int codePage, char ch)
-{
- // Byte ranges found in Wikipedia articles with relevant search strings in each case
- unsigned char uch = static_cast<unsigned char>(ch);
- switch (codePage)
- {
- case 932:
- // Shift_jis
- return ((uch >= 0x81) && (uch <= 0x9F)) ||
- ((uch >= 0xE0) && (uch <= 0xFC));
- // Lead bytes F0 to FC may be a Microsoft addition.
- case 936:
- // GBK
- return (uch >= 0x81) && (uch <= 0xFE);
- case 949:
- // Korean Wansung KS C-5601-1987
- return (uch >= 0x81) && (uch <= 0xFE);
- case 950:
- // Big5
- return (uch >= 0x81) && (uch <= 0xFE);
- case 1361:
- // Korean Johab KS C-5601-1992
- return
- ((uch >= 0x84) && (uch <= 0xD3)) ||
- ((uch >= 0xD8) && (uch <= 0xDE)) ||
- ((uch >= 0xE0) && (uch <= 0xF9));
- }
- return false;
-}
-
-//--------------------------------------------------------------------------------------------------
-
-int Platform::DBCSCharLength(int /* codePage */, const char* /* s */)
-{
- // DBCS no longer uses this.
- return 1;
-}
-
-//--------------------------------------------------------------------------------------------------
-
-int Platform::DBCSCharMaxLength()
-{
- return 2;
-}
-
-//--------------------------------------------------------------------------------------------------
-
-int Platform::Minimum(int a, int b)
-{
- return (a < b) ? a : b;
-}
-
-//--------------------------------------------------------------------------------------------------
-
-int Platform::Maximum(int a, int b) {
- return (a > b) ? a : b;
-}
-
-//--------------------------------------------------------------------------------------------------
-
//#define TRACE
#ifdef TRACE
@@ -2239,17 +2106,6 @@ void Platform::Assert(const char *c, const char *file, int line)
#endif
}
-//--------------------------------------------------------------------------------------------------
-
-int Platform::Clamp(int val, int minVal, int maxVal)
-{
- if (val > maxVal)
- val = maxVal;
- if (val < minVal)
- val = minVal;
- return val;
-}
-
//----------------- DynamicLibrary -----------------------------------------------------------------
/**
diff --git a/cocoa/ScintillaCocoa.h b/cocoa/ScintillaCocoa.h
index 7b9231012..21eb83b79 100644
--- a/cocoa/ScintillaCocoa.h
+++ b/cocoa/ScintillaCocoa.h
@@ -52,6 +52,7 @@
#include "Document.h"
#include "CaseConvert.h"
#include "UniConversion.h"
+#include "DBCS.h"
#include "Selection.h"
#include "PositionCache.h"
#include "EditModel.h"
diff --git a/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj b/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj
index 0a8ea2723..46dd898ba 100644
--- a/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj
+++ b/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj
@@ -199,6 +199,7 @@
280056FC188DDD2C00F200AE /* StringCopy.h in Headers */ = {isa = PBXBuildFile; fileRef = 280056F9188DDD2C00F200AE /* StringCopy.h */; };
280056FD188DDD2C00F200AE /* SubStyles.h in Headers */ = {isa = PBXBuildFile; fileRef = 280056FA188DDD2C00F200AE /* SubStyles.h */; };
28064A05190F12E100E6E47F /* LexDMIS.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 28064A04190F12E100E6E47F /* LexDMIS.cxx */; };
+ 28804B2C1EEE232E00C0D154 /* DBCS.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 28804B2B1EEE232E00C0D154 /* DBCS.cxx */; };
28A067111A36B42600B4966A /* LexHex.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 28A067101A36B42600B4966A /* LexHex.cxx */; };
28A1DD51196BE0CA006EFCDD /* EditModel.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 28A1DD4E196BE0CA006EFCDD /* EditModel.cxx */; };
28A1DD52196BE0CA006EFCDD /* EditView.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 28A1DD4F196BE0CA006EFCDD /* EditView.cxx */; };
@@ -424,6 +425,7 @@
280056F9188DDD2C00F200AE /* StringCopy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringCopy.h; path = ../../lexlib/StringCopy.h; sourceTree = "<group>"; };
280056FA188DDD2C00F200AE /* SubStyles.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SubStyles.h; path = ../../lexlib/SubStyles.h; sourceTree = "<group>"; };
28064A04190F12E100E6E47F /* LexDMIS.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexDMIS.cxx; path = ../../lexers/LexDMIS.cxx; sourceTree = "<group>"; };
+ 28804B2B1EEE232E00C0D154 /* DBCS.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DBCS.cxx; path = ../../src/DBCS.cxx; sourceTree = "<group>"; };
28A067101A36B42600B4966A /* LexHex.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexHex.cxx; path = ../../lexers/LexHex.cxx; sourceTree = "<group>"; };
28A1DD4E196BE0CA006EFCDD /* EditModel.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EditModel.cxx; path = ../../src/EditModel.cxx; sourceTree = "<group>"; };
28A1DD4F196BE0CA006EFCDD /* EditView.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EditView.cxx; path = ../../src/EditView.cxx; sourceTree = "<group>"; };
@@ -727,6 +729,7 @@
114B6F8F11FA75BE004FB6AB /* CharacterSet.cxx */,
114B6F6411FA7597004FB6AB /* CharClassify.cxx */,
114B6F6511FA7597004FB6AB /* ContractionState.cxx */,
+ 28804B2B1EEE232E00C0D154 /* DBCS.cxx */,
114B6F6611FA7597004FB6AB /* Decoration.cxx */,
114B6F6711FA7597004FB6AB /* Document.cxx */,
28A1DD4E196BE0CA006EFCDD /* EditModel.cxx */,
@@ -1013,6 +1016,7 @@
114B6F3911FA7526004FB6AB /* LexMySQL.cxx in Sources */,
114B6F3A11FA7526004FB6AB /* LexNimrod.cxx in Sources */,
114B6F3B11FA7526004FB6AB /* LexNsis.cxx in Sources */,
+ 28804B2C1EEE232E00C0D154 /* DBCS.cxx in Sources */,
114B6F3C11FA7526004FB6AB /* LexOpal.cxx in Sources */,
114B6F3E11FA7526004FB6AB /* LexPascal.cxx in Sources */,
28B6470D1B54C0720009DC49 /* LexDiff.cxx in Sources */,
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx
index 5252e890c..06926f347 100644
--- a/gtk/PlatGTK.cxx
+++ b/gtk/PlatGTK.cxx
@@ -107,12 +107,6 @@ static GtkWidget *PWidget(WindowID wid) {
return static_cast<GtkWidget *>(wid);
}
-Point Point::FromLong(long lpoint) {
- return Point(
- Platform::LowShortFromLong(lpoint),
- Platform::HighShortFromLong(lpoint));
-}
-
Font::Font() : fid(0) {}
Font::~Font() {}
@@ -184,7 +178,6 @@ public:
XYPOSITION Ascent(Font &font_) override;
XYPOSITION Descent(Font &font_) override;
XYPOSITION InternalLeading(Font &font_) override;
- XYPOSITION ExternalLeading(Font &font_) override;
XYPOSITION Height(Font &font_) override;
XYPOSITION AverageCharWidth(Font &font_) override;
@@ -925,10 +918,6 @@ XYPOSITION SurfaceImpl::InternalLeading(Font &) {
return 0;
}
-XYPOSITION SurfaceImpl::ExternalLeading(Font &) {
- return 0;
-}
-
XYPOSITION SurfaceImpl::Height(Font &font_) {
return Ascent(font_) + Descent(font_);
}
@@ -978,10 +967,6 @@ void Window::Destroy() {
}
}
-bool Window::HasFocus() {
- return gtk_widget_has_focus(GTK_WIDGET(wid));
-}
-
PRectangle Window::GetPosition() {
// Before any size allocated pretend its 1000 wide so not scrolled
PRectangle rc(0, 0, 1000, 1000);
@@ -1125,10 +1110,6 @@ void Window::SetCursor(Cursor curs) {
#endif
}
-void Window::SetTitle(const char *s) {
- gtk_window_set_title(GTK_WINDOW(wid), s);
-}
-
/* Returns rectangle of monitor pt is on, both rect and pt are in Window's
gdk window coordinates */
PRectangle Window::GetMonitorRect(Point pt) {
@@ -2025,83 +2006,10 @@ unsigned int Platform::DoubleClickTime() {
return 500; // Half a second
}
-bool Platform::MouseButtonBounce() {
- return true;
-}
-
void Platform::DebugDisplay(const char *s) {
fprintf(stderr, "%s", s);
}
-bool Platform::IsKeyDown(int) {
- // TODO: discover state of keys in GTK+/X
- return false;
-}
-
-long Platform::SendScintilla(
- WindowID w, unsigned int msg, unsigned long wParam, long lParam) {
- return scintilla_send_message(SCINTILLA(w), msg, wParam, lParam);
-}
-
-long Platform::SendScintillaPointer(
- WindowID w, unsigned int msg, unsigned long wParam, void *lParam) {
- return scintilla_send_message(SCINTILLA(w), msg, wParam,
- reinterpret_cast<sptr_t>(lParam));
-}
-
-bool Platform::IsDBCSLeadByte(int codePage, char ch) {
- // Byte ranges found in Wikipedia articles with relevant search strings in each case
- unsigned char uch = static_cast<unsigned char>(ch);
- switch (codePage) {
- case 932:
- // Shift_jis
- return ((uch >= 0x81) && (uch <= 0x9F)) ||
- ((uch >= 0xE0) && (uch <= 0xFC));
- // Lead bytes F0 to FC may be a Microsoft addition.
- case 936:
- // GBK
- return (uch >= 0x81) && (uch <= 0xFE);
- case 950:
- // Big5
- return (uch >= 0x81) && (uch <= 0xFE);
- // Korean EUC-KR may be code page 949.
- }
- return false;
-}
-
-int Platform::DBCSCharLength(int codePage, const char *s) {
- if (codePage == 932 || codePage == 936 || codePage == 950) {
- return IsDBCSLeadByte(codePage, s[0]) ? 2 : 1;
- } else {
- int bytes = mblen(s, MB_CUR_MAX);
- if (bytes >= 1)
- return bytes;
- else
- return 1;
- }
-}
-
-int Platform::DBCSCharMaxLength() {
- return MB_CUR_MAX;
- //return 2;
-}
-
-// These are utility functions not really tied to a platform
-
-int Platform::Minimum(int a, int b) {
- if (a < b)
- return a;
- else
- return b;
-}
-
-int Platform::Maximum(int a, int b) {
- if (a > b)
- return a;
- else
- return b;
-}
-
//#define TRACE
#ifdef TRACE
@@ -2134,14 +2042,6 @@ void Platform::Assert(const char *c, const char *file, int line) {
abort();
}
-int Platform::Clamp(int val, int minVal, int maxVal) {
- if (val > maxVal)
- val = maxVal;
- if (val < minVal)
- val = minVal;
- return val;
-}
-
void Platform_Initialise() {
}
diff --git a/include/Platform.h b/include/Platform.h
index 3a6818192..a18ef2255 100644
--- a/include/Platform.h
+++ b/include/Platform.h
@@ -109,8 +109,6 @@ public:
}
// Other automatically defined methods (assignment, copy constructor, destructor) are fine
-
- static Point FromLong(long lpoint);
};
/**
@@ -332,7 +330,6 @@ public:
virtual XYPOSITION Ascent(Font &font_)=0;
virtual XYPOSITION Descent(Font &font_)=0;
virtual XYPOSITION InternalLeading(Font &font_)=0;
- virtual XYPOSITION ExternalLeading(Font &font_)=0;
virtual XYPOSITION Height(Font &font_)=0;
virtual XYPOSITION AverageCharWidth(Font &font_)=0;
@@ -376,7 +373,6 @@ public:
WindowID GetID() const { return wid; }
bool Created() const { return wid != 0; }
void Destroy();
- bool HasFocus();
PRectangle GetPosition();
void SetPosition(PRectangle rc);
void SetPositionRelative(PRectangle rc, Window relativeTo);
@@ -387,7 +383,6 @@ public:
virtual void SetFont(Font &font);
enum Cursor { cursorInvalid, cursorText, cursorArrow, cursorUp, cursorWait, cursorHoriz, cursorVert, cursorReverseArrow, cursorHand };
void SetCursor(Cursor curs);
- void SetTitle(const char *s);
PRectangle GetMonitorRect(Point pt);
private:
Cursor cursorLast;
@@ -503,34 +498,14 @@ public:
static const char *DefaultFont();
static int DefaultFontSize();
static unsigned int DoubleClickTime();
- static bool MouseButtonBounce();
static void DebugDisplay(const char *s);
- static bool IsKeyDown(int key);
- static long SendScintilla(
- WindowID w, unsigned int msg, unsigned long wParam=0, long lParam=0);
- static long SendScintillaPointer(
- WindowID w, unsigned int msg, unsigned long wParam=0, void *lParam=0);
- static bool IsDBCSLeadByte(int codePage, char ch);
- static int DBCSCharLength(int codePage, const char *s);
- static int DBCSCharMaxLength();
-
- // These are utility functions not really tied to a platform
- static int Minimum(int a, int b);
- static int Maximum(int a, int b);
- // Next three assume 16 bit shorts and 32 bit longs
static long LongFromTwoShorts(short a,short b) {
return (a) | ((b) << 16);
}
- static short HighShortFromLong(long x) {
- return static_cast<short>(x >> 16);
- }
- static short LowShortFromLong(long x) {
- return static_cast<short>(x & 0xffff);
- }
+
static void DebugPrintf(const char *format, ...);
static bool ShowAssertionPopUps(bool assertionPopUps_);
static void Assert(const char *c, const char *file, int line) CLANG_ANALYZER_NORETURN;
- static int Clamp(int val, int minVal, int maxVal);
};
#ifdef NDEBUG
diff --git a/qt/ScintillaEdit/ScintillaEdit.pro b/qt/ScintillaEdit/ScintillaEdit.pro
index ce0abc39f..2c2ad7303 100644
--- a/qt/ScintillaEdit/ScintillaEdit.pro
+++ b/qt/ScintillaEdit/ScintillaEdit.pro
@@ -48,6 +48,7 @@ SOURCES += \
../../src/EditModel.cxx \
../../src/Document.cxx \
../../src/Decoration.cxx \
+ ../../src/DBCS.cxx \
../../src/ContractionState.cxx \
../../src/CharClassify.cxx \
../../src/CellBuffer.cxx \
diff --git a/qt/ScintillaEditBase/PlatQt.cpp b/qt/ScintillaEditBase/PlatQt.cpp
index 4c7eba127..e288cf5bf 100644
--- a/qt/ScintillaEditBase/PlatQt.cpp
+++ b/qt/ScintillaEditBase/PlatQt.cpp
@@ -10,6 +10,7 @@
#include "PlatQt.h"
#include "Scintilla.h"
+#include "DBCS.h"
#include "FontQuality.h"
#include <QApplication>
@@ -489,7 +490,7 @@ void SurfaceImpl::MeasureWidths(Font &font,
// DBCS
int ui = 0;
for (int i=0; i<len;) {
- size_t lenChar = Platform::IsDBCSLeadByte(codePage, s[i]) ? 2 : 1;
+ size_t lenChar = DBCSIsLeadByte(codePage, s[i]) ? 2 : 1;
qreal xPosition = tl.cursorToX(ui+1);
for (unsigned int bytePos=0; (bytePos<lenChar) && (i<len); bytePos++) {
positions[i++] = xPosition;
@@ -539,12 +540,6 @@ XYPOSITION SurfaceImpl::InternalLeading(Font & /* font */)
return 0;
}
-XYPOSITION SurfaceImpl::ExternalLeading(Font &font)
-{
- QFontMetricsF metrics(*FontPointer(font), device);
- return metrics.leading();
-}
-
XYPOSITION SurfaceImpl::Height(Font &font)
{
QFontMetricsF metrics(*FontPointer(font), device);
@@ -625,11 +620,6 @@ void Window::Destroy()
wid = 0;
}
-bool Window::HasFocus()
-{
- return wid ? window(wid)->hasFocus() : false;
-}
-
PRectangle Window::GetPosition()
{
// Before any size allocated pretend its 1000 wide so not scrolled
@@ -725,12 +715,6 @@ void Window::SetCursor(Cursor curs)
}
}
-void Window::SetTitle(const char *s)
-{
- if (wid)
- window(wid)->setWindowTitle(s);
-}
-
/* Returns rectangle of monitor pt is on, both rect and pt are in Window's
window coordinates */
PRectangle Window::GetMonitorRect(Point pt)
@@ -1201,47 +1185,6 @@ unsigned int Platform::DoubleClickTime()
return QApplication::doubleClickInterval();
}
-bool Platform::MouseButtonBounce()
-{
- return false;
-}
-
-bool Platform::IsKeyDown(int /*key*/)
-{
- return false;
-}
-
-long Platform::SendScintilla(WindowID /*w*/,
- unsigned int /*msg*/,
- unsigned long /*wParam*/,
- long /*lParam*/)
-{
- return 0;
-}
-
-long Platform::SendScintillaPointer(WindowID /*w*/,
- unsigned int /*msg*/,
- unsigned long /*wParam*/,
- void * /*lParam*/)
-{
- return 0;
-}
-
-int Platform::Minimum(int a, int b)
-{
- return qMin(a, b);
-}
-
-int Platform::Maximum(int a, int b)
-{
- return qMax(a, b);
-}
-
-int Platform::Clamp(int val, int minVal, int maxVal)
-{
- return qBound(minVal, val, maxVal);
-}
-
void Platform::DebugDisplay(const char *s)
{
qWarning("Scintilla: %s", s);
@@ -1276,51 +1219,6 @@ void Platform::Assert(const char *c, const char *file, int line)
}
}
-
-bool Platform::IsDBCSLeadByte(int codePage, char ch)
-{
- // Byte ranges found in Wikipedia articles with relevant search strings in each case
- unsigned char uch = static_cast<unsigned char>(ch);
- switch (codePage) {
- case 932:
- // Shift_jis
- return ((uch >= 0x81) && (uch <= 0x9F)) ||
- ((uch >= 0xE0) && (uch <= 0xEF));
- case 936:
- // GBK
- return (uch >= 0x81) && (uch <= 0xFE);
- case 949:
- // Korean Wansung KS C-5601-1987
- return (uch >= 0x81) && (uch <= 0xFE);
- case 950:
- // Big5
- return (uch >= 0x81) && (uch <= 0xFE);
- case 1361:
- // Korean Johab KS C-5601-1992
- return
- ((uch >= 0x84) && (uch <= 0xD3)) ||
- ((uch >= 0xD8) && (uch <= 0xDE)) ||
- ((uch >= 0xE0) && (uch <= 0xF9));
- }
- return false;
-}
-
-int Platform::DBCSCharLength(int codePage, const char *s)
-{
- if (codePage == 932 || codePage == 936 || codePage == 949 ||
- codePage == 950 || codePage == 1361) {
- return IsDBCSLeadByte(codePage, s[0]) ? 2 : 1;
- } else {
- return 1;
- }
-}
-
-int Platform::DBCSCharMaxLength()
-{
- return 2;
-}
-
-
//----------------------------------------------------------------------
static QElapsedTimer timer;
diff --git a/qt/ScintillaEditBase/PlatQt.h b/qt/ScintillaEditBase/PlatQt.h
index 907992d36..bb9da3940 100644
--- a/qt/ScintillaEditBase/PlatQt.h
+++ b/qt/ScintillaEditBase/PlatQt.h
@@ -106,7 +106,6 @@ public:
XYPOSITION Ascent(Font &font) override;
XYPOSITION Descent(Font &font) override;
XYPOSITION InternalLeading(Font &font) override;
- XYPOSITION ExternalLeading(Font &font) override;
XYPOSITION Height(Font &font) override;
XYPOSITION AverageCharWidth(Font &font) override;
diff --git a/qt/ScintillaEditBase/ScintillaEditBase.pro b/qt/ScintillaEditBase/ScintillaEditBase.pro
index e9ec9687c..3ca5a816a 100644
--- a/qt/ScintillaEditBase/ScintillaEditBase.pro
+++ b/qt/ScintillaEditBase/ScintillaEditBase.pro
@@ -10,7 +10,6 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = ScintillaEditBase
TEMPLATE = lib
CONFIG += lib_bundle
-
unix {
# <regex> requires C++11 support
greaterThan(QT_MAJOR_VERSION, 4){
@@ -46,6 +45,7 @@ SOURCES += \
../../src/EditModel.cxx \
../../src/Document.cxx \
../../src/Decoration.cxx \
+ ../../src/DBCS.cxx \
../../src/ContractionState.cxx \
../../src/CharClassify.cxx \
../../src/CellBuffer.cxx \
diff --git a/qt/ScintillaEditPy/ScintillaEditPy.pro b/qt/ScintillaEditPy/ScintillaEditPy.pro
index 49f7fb0f2..270a64b55 100644
--- a/qt/ScintillaEditPy/ScintillaEditPy.pro
+++ b/qt/ScintillaEditPy/ScintillaEditPy.pro
@@ -13,7 +13,7 @@ VERSION = $$SCINTILLA_VERSION
unix {
# <regex> requires C++11 support
- greaterThan(QT_MAJOR_VERSION, 4){
+ greaterThan(QT_MAJOR_VERSION, 4){
CONFIG += c++11
} else {
QMAKE_CXXFLAGS += -std=c++0x -Wno-deprecated-declarations
diff --git a/scripts/HeaderOrder.txt b/scripts/HeaderOrder.txt
index 699963aa9..780f865c4 100644
--- a/scripts/HeaderOrder.txt
+++ b/scripts/HeaderOrder.txt
@@ -130,6 +130,7 @@
#include "CaseConvert.h"
#include "UniConversion.h"
#include "UnicodeFromUTF8.h"
+#include "DBCS.h"
#include "Selection.h"
#include "PositionCache.h"
#include "FontQuality.h"
diff --git a/src/DBCS.cxx b/src/DBCS.cxx
new file mode 100644
index 000000000..46cee8e69
--- /dev/null
+++ b/src/DBCS.cxx
@@ -0,0 +1,48 @@
+// Scintilla source code edit control
+/** @file DBCS.cxx
+ ** Functions to handle DBCS double byte encodings like Shift-JIS.
+ **/
+// Copyright 2017 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include "DBCS.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
+bool DBCSIsLeadByte(int codePage, char ch) {
+ // Byte ranges found in Wikipedia articles with relevant search strings in each case
+ const unsigned char uch = static_cast<unsigned char>(ch);
+ switch (codePage) {
+ case 932:
+ // Shift_jis
+ return ((uch >= 0x81) && (uch <= 0x9F)) ||
+ ((uch >= 0xE0) && (uch <= 0xFC));
+ // Lead bytes F0 to FC may be a Microsoft addition.
+ case 936:
+ // GBK
+ return (uch >= 0x81) && (uch <= 0xFE);
+ case 949:
+ // Korean Wansung KS C-5601-1987
+ return (uch >= 0x81) && (uch <= 0xFE);
+ case 950:
+ // Big5
+ return (uch >= 0x81) && (uch <= 0xFE);
+ case 1361:
+ // Korean Johab KS C-5601-1992
+ return
+ ((uch >= 0x84) && (uch <= 0xD3)) ||
+ ((uch >= 0xD8) && (uch <= 0xDE)) ||
+ ((uch >= 0xE0) && (uch <= 0xF9));
+ }
+ return false;
+}
+
+#ifdef SCI_NAMESPACE
+}
+#endif
diff --git a/src/DBCS.h b/src/DBCS.h
new file mode 100644
index 000000000..875d44c8f
--- /dev/null
+++ b/src/DBCS.h
@@ -0,0 +1,21 @@
+// Scintilla source code edit control
+/** @file DBCS.h
+ ** Functions to handle DBCS double byte encodings like Shift-JIS.
+ **/
+// Copyright 2017 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#ifndef DBCS_H
+#define DBCS_H
+
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
+bool DBCSIsLeadByte(int codePage, char ch);
+
+#ifdef SCI_NAMESPACE
+}
+#endif
+
+#endif
diff --git a/src/Document.cxx b/src/Document.cxx
index 231bc1113..3beba76e9 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -564,7 +564,7 @@ void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, Sc
}
Sci::Position Document::ClampPositionIntoDocument(Sci::Position pos) const {
- return Platform::Clamp(pos, 0, Length());
+ return Sci::clamp(pos, 0, Length());
}
bool Document::IsCrLf(Sci::Position pos) const {
diff --git a/src/Editor.cxx b/src/Editor.cxx
index 1dfb8d9e3..771353654 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -888,10 +888,10 @@ SelectionPosition Editor::MovePositionSoVisible(SelectionPosition pos, int moveD
Sci::Line lineDisplay = cs.DisplayFromDoc(lineDoc);
if (moveDir > 0) {
// lineDisplay is already line before fold as lines in fold use display line of line after fold
- lineDisplay = Platform::Clamp(lineDisplay, 0, cs.LinesDisplayed());
+ lineDisplay = Sci::clamp(lineDisplay, 0, cs.LinesDisplayed());
return SelectionPosition(pdoc->LineStart(cs.DocFromDisplay(lineDisplay)));
} else {
- lineDisplay = Platform::Clamp(lineDisplay - 1, 0, cs.LinesDisplayed());
+ lineDisplay = Sci::clamp(lineDisplay - 1, 0, cs.LinesDisplayed());
return SelectionPosition(pdoc->LineEnd(cs.DocFromDisplay(lineDisplay)));
}
}
@@ -915,7 +915,7 @@ void Editor::SetLastXChosen() {
}
void Editor::ScrollTo(Sci::Line line, bool moveThumb) {
- const Sci::Line topLineNew = Platform::Clamp(line, 0, MaxScrollPos());
+ const Sci::Line topLineNew = Sci::clamp(line, 0, MaxScrollPos());
if (topLineNew != topLine) {
// Try to optimise small scrolls
#ifndef UNDER_CE
@@ -1154,7 +1154,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran
} else {
// yMarginT must equal to caretYSlop, with a minimum of 1 and
// a maximum of slightly less than half the heigth of the text area.
- yMarginT = Platform::Clamp(caretYSlop, 1, halfScreen);
+ yMarginT = Sci::clamp(caretYSlop, 1, halfScreen);
if (bEven) {
yMarginB = yMarginT;
} else {
@@ -1164,7 +1164,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran
yMoveT = yMarginT;
if (bEven) {
if (bJump) {
- yMoveT = Platform::Clamp(caretYSlop * 3, 1, halfScreen);
+ yMoveT = Sci::clamp(caretYSlop * 3, 1, halfScreen);
}
yMoveB = yMoveT;
} else {
@@ -1179,7 +1179,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran
}
} else { // Not strict
yMoveT = bJump ? caretYSlop * 3 : caretYSlop;
- yMoveT = Platform::Clamp(yMoveT, 1, halfScreen);
+ yMoveT = Sci::clamp(yMoveT, 1, halfScreen);
if (bEven) {
yMoveB = yMoveT;
} else {
@@ -1229,7 +1229,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran
newXY.topLine = std::min(newXY.topLine, lineCaret);
}
}
- newXY.topLine = Platform::Clamp(newXY.topLine, 0, MaxScrollPos());
+ newXY.topLine = Sci::clamp(newXY.topLine, 0, MaxScrollPos());
}
// Horizontal positioning
@@ -1251,7 +1251,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran
} else {
// xMargin must equal to caretXSlop, with a minimum of 2 and
// a maximum of slightly less than half the width of the text area.
- xMarginR = Platform::Clamp(caretXSlop, 2, halfScreen);
+ xMarginR = Sci::clamp(caretXSlop, 2, halfScreen);
if (bEven) {
xMarginL = xMarginR;
} else {
@@ -1260,7 +1260,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran
}
if (bJump && bEven) {
// Jump is used only in even mode
- xMoveL = xMoveR = Platform::Clamp(caretXSlop * 3, 1, halfScreen);
+ xMoveL = xMoveR = Sci::clamp(caretXSlop * 3, 1, halfScreen);
} else {
xMoveL = xMoveR = 0; // Not used, avoid a warning
}
@@ -1283,7 +1283,7 @@ Editor::XYScrollPosition Editor::XYScrollToMakeVisible(const SelectionRange &ran
}
} else { // Not strict
xMoveR = bJump ? caretXSlop * 3 : caretXSlop;
- xMoveR = Platform::Clamp(xMoveR, 1, halfScreen);
+ xMoveR = Sci::clamp(xMoveR, 1, halfScreen);
if (bEven) {
xMoveL = xMoveR;
} else {
@@ -1505,7 +1505,7 @@ bool Editor::WrapLines(WrapScope ws) {
const Sci::Line lineDocTop = cs.DocFromDisplay(topLine);
const int subLineTop = topLine - cs.DisplayFromDoc(lineDocTop);
if (ws == WrapScope::wsVisible) {
- lineToWrap = Platform::Clamp(lineDocTop-5, wrapPending.start, pdoc->LinesTotal());
+ lineToWrap = Sci::clamp(lineDocTop-5, wrapPending.start, pdoc->LinesTotal());
// Priority wrap to just after visible area.
// Since wrapping could reduce display lines, treat each
// as taking only one display line.
@@ -1561,7 +1561,7 @@ bool Editor::WrapLines(WrapScope ws) {
if (wrapOccurred) {
SetScrollBars();
- SetTopLine(Platform::Clamp(goodTopLine, 0, MaxScrollPos()));
+ SetTopLine(Sci::clamp(goodTopLine, 0, MaxScrollPos()));
SetVerticalScrollPos();
}
@@ -1816,7 +1816,7 @@ void Editor::SetScrollBars() {
// TODO: ensure always showing as many lines as possible
// May not be, if, for example, window made larger
if (topLine > MaxScrollPos()) {
- SetTopLine(Platform::Clamp(topLine, 0, MaxScrollPos()));
+ SetTopLine(Sci::clamp(topLine, 0, MaxScrollPos()));
SetVerticalScrollPos();
Redraw();
}
@@ -2641,7 +2641,7 @@ void Editor::NotifyModified(Document *, DocModification mh, void *) {
if (mh.linesAdded != 0) {
// Avoid scrolling of display if change before current display
if (mh.position < posTopLine && !CanDeferToLastStep(mh)) {
- Sci::Line newTop = Platform::Clamp(topLine + mh.linesAdded, 0, MaxScrollPos());
+ Sci::Line newTop = Sci::clamp(topLine + mh.linesAdded, 0, MaxScrollPos());
if (newTop != topLine) {
SetTopLine(newTop);
SetVerticalScrollPos();
@@ -2877,7 +2877,7 @@ void Editor::PageMove(int direction, Selection::selTypes selt, bool stuttered) {
} else {
Point pt = LocationFromPosition(sel.MainCaret());
- topLineNew = Platform::Clamp(
+ topLineNew = Sci::clamp(
topLine + direction * LinesToScroll(), 0, MaxScrollPos());
newPos = SPositionFromLocation(
Point::FromInts(lastXChosen - xOffset, static_cast<int>(pt.y) + direction * (vs.lineHeight * LinesToScroll())),
@@ -3209,6 +3209,14 @@ Sci::Position Editor::StartEndDisplayLine(Sci::Position pos, bool start) {
namespace {
+short HighShortFromLong(long x) {
+ return static_cast<short>(x >> 16);
+}
+
+short LowShortFromLong(long x) {
+ return static_cast<short>(x & 0xffff);
+}
+
unsigned int WithExtends(unsigned int iMessage) {
switch (iMessage) {
case SCI_CHARLEFT: return SCI_CHARLEFTEXTEND;
@@ -4470,30 +4478,27 @@ void Editor::ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifie
if (!ctrl || !multipleSelection || (selectionType != selChar && selectionType != selWord))
SetEmptySelection(newPos.Position());
bool doubleClick = false;
- // Stop mouse button bounce changing selection type
- if (!Platform::MouseButtonBounce() || curTime != lastClickTime) {
- if (inSelMargin) {
- // Inside margin selection type should be either selSubLine or selWholeLine.
- if (selectionType == selSubLine) {
- // If it is selSubLine, we're inside a *double* click and word wrap is enabled,
- // so we switch to selWholeLine in order to select whole line.
- selectionType = selWholeLine;
- } else if (selectionType != selSubLine && selectionType != selWholeLine) {
- // If it is neither, reset selection type to line selection.
- selectionType = (Wrapping() && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine;
- }
+ if (inSelMargin) {
+ // Inside margin selection type should be either selSubLine or selWholeLine.
+ if (selectionType == selSubLine) {
+ // If it is selSubLine, we're inside a *double* click and word wrap is enabled,
+ // so we switch to selWholeLine in order to select whole line.
+ selectionType = selWholeLine;
+ } else if (selectionType != selSubLine && selectionType != selWholeLine) {
+ // If it is neither, reset selection type to line selection.
+ selectionType = (Wrapping() && (marginOptions & SC_MARGINOPTION_SUBLINESELECT)) ? selSubLine : selWholeLine;
+ }
+ } else {
+ if (selectionType == selChar) {
+ selectionType = selWord;
+ doubleClick = true;
+ } else if (selectionType == selWord) {
+ // Since we ended up here, we're inside a *triple* click, which should always select
+ // whole line regardless of word wrap being enabled or not.
+ selectionType = selWholeLine;
} else {
- if (selectionType == selChar) {
- selectionType = selWord;
- doubleClick = true;
- } else if (selectionType == selWord) {
- // Since we ended up here, we're inside a *triple* click, which should always select
- // whole line regardless of word wrap being enabled or not.
- selectionType = selWholeLine;
- } else {
- selectionType = selChar;
- originalAnchorPos = sel.MainCaret();
- }
+ selectionType = selChar;
+ originalAnchorPos = sel.MainCaret();
}
}
@@ -5082,7 +5087,7 @@ Sci::Position Editor::PositionAfterMaxStyling(Sci::Position posMax, bool scrolli
// When scrolling, allow less time to ensure responsive
const double secondsAllowed = scrolling ? 0.005 : 0.02;
- const Sci::Line linesToStyle = Platform::Clamp(static_cast<int>(secondsAllowed / pdoc->durationStyleOneLine),
+ const Sci::Line linesToStyle = Sci::clamp(static_cast<int>(secondsAllowed / pdoc->durationStyleOneLine),
10, 0x10000);
const Sci::Line stylingMaxLine = std::min(
static_cast<Sci::Line>(pdoc->LineFromPosition(pdoc->GetEndStyled()) + linesToStyle),
@@ -5426,18 +5431,18 @@ void Editor::EnsureLineVisible(Sci::Line lineDoc, bool enforcePolicy) {
const Sci::Line lineDisplay = cs.DisplayFromDoc(lineDoc);
if (visiblePolicy & VISIBLE_SLOP) {
if ((topLine > lineDisplay) || ((visiblePolicy & VISIBLE_STRICT) && (topLine + visibleSlop > lineDisplay))) {
- SetTopLine(Platform::Clamp(lineDisplay - visibleSlop, 0, MaxScrollPos()));
+ SetTopLine(Sci::clamp(lineDisplay - visibleSlop, 0, MaxScrollPos()));
SetVerticalScrollPos();
Redraw();
} else if ((lineDisplay > topLine + LinesOnScreen() - 1) ||
((visiblePolicy & VISIBLE_STRICT) && (lineDisplay > topLine + LinesOnScreen() - 1 - visibleSlop))) {
- SetTopLine(Platform::Clamp(lineDisplay - LinesOnScreen() + 1 + visibleSlop, 0, MaxScrollPos()));
+ SetTopLine(Sci::clamp(lineDisplay - LinesOnScreen() + 1 + visibleSlop, 0, MaxScrollPos()));
SetVerticalScrollPos();
Redraw();
}
} else {
if ((topLine > lineDisplay) || (lineDisplay > topLine + LinesOnScreen() - 1) || (visiblePolicy & VISIBLE_STRICT)) {
- SetTopLine(Platform::Clamp(lineDisplay - LinesOnScreen() / 2 + 1, 0, MaxScrollPos()));
+ SetTopLine(Sci::clamp(lineDisplay - LinesOnScreen() / 2 + 1, 0, MaxScrollPos()));
SetVerticalScrollPos();
Redraw();
}
@@ -6040,7 +6045,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return pdoc->MovePositionOutsideChar(static_cast<int>(wParam) + 1, 1, true);
case SCI_POSITIONRELATIVE:
- return Platform::Clamp(pdoc->GetRelativePosition(static_cast<int>(wParam), static_cast<int>(lParam)), 0, pdoc->Length());
+ return Sci::clamp(pdoc->GetRelativePosition(static_cast<int>(wParam), static_cast<int>(lParam)), 0, pdoc->Length());
case SCI_LINESCROLL:
ScrollTo(topLine + static_cast<Sci::Line>(lParam));
@@ -7290,13 +7295,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
return vs.caretWidth;
case SCI_ASSIGNCMDKEY:
- kmap.AssignCmdKey(Platform::LowShortFromLong(static_cast<long>(wParam)),
- Platform::HighShortFromLong(static_cast<long>(wParam)), static_cast<unsigned int>(lParam));
+ kmap.AssignCmdKey(LowShortFromLong(static_cast<long>(wParam)),
+ HighShortFromLong(static_cast<long>(wParam)), static_cast<unsigned int>(lParam));
break;
case SCI_CLEARCMDKEY:
- kmap.AssignCmdKey(Platform::LowShortFromLong(static_cast<long>(wParam)),
- Platform::HighShortFromLong(static_cast<long>(wParam)), SCI_NULL);
+ kmap.AssignCmdKey(LowShortFromLong(static_cast<long>(wParam)),
+ HighShortFromLong(static_cast<long>(wParam)), SCI_NULL);
break;
case SCI_CLEARALLCMDKEYS:
diff --git a/src/Position.h b/src/Position.h
index 67365e30f..258eb177f 100644
--- a/src/Position.h
+++ b/src/Position.h
@@ -25,6 +25,14 @@ typedef int Line;
const Position invalidPosition = -1;
+inline int clamp(int val, int minVal, int maxVal) {
+ if (val > maxVal)
+ val = maxVal;
+ if (val < minVal)
+ val = minVal;
+ return val;
+}
+
}
#endif
diff --git a/src/ViewStyle.cxx b/src/ViewStyle.cxx
index 7a0b146f8..771d4a8f4 100644
--- a/src/ViewStyle.cxx
+++ b/src/ViewStyle.cxx
@@ -460,7 +460,7 @@ void ViewStyle::CalcLargestMarkerHeight() {
}
int ViewStyle::GetFrameWidth() const {
- return Platform::Clamp(caretLineFrame, 1, lineHeight / 3);
+ return Sci::clamp(caretLineFrame, 1, lineHeight / 3);
}
bool ViewStyle::IsLineFrameOpaque(bool caretActive, bool lineContainsCaret) const {
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index 72513b071..355a35145 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -46,6 +46,7 @@
#include "StringCopy.h"
#include "XPM.h"
#include "UniConversion.h"
+#include "DBCS.h"
#include "FontQuality.h"
#ifndef SPI_GETFONTSMOOTHINGCONTRAST
@@ -75,10 +76,6 @@ static HCURSOR reverseArrowCursor = NULL;
namespace Scintilla {
#endif
-Point Point::FromLong(long lpoint) {
- return Point(static_cast<short>(LOWORD(lpoint)), static_cast<short>(HIWORD(lpoint)));
-}
-
static RECT RectFromPRectangle(PRectangle prc) {
RECT rc = {static_cast<LONG>(prc.left), static_cast<LONG>(prc.top),
static_cast<LONG>(prc.right), static_cast<LONG>(prc.bottom)};
@@ -558,7 +555,6 @@ public:
XYPOSITION Ascent(Font &font_) override;
XYPOSITION Descent(Font &font_) override;
XYPOSITION InternalLeading(Font &font_) override;
- XYPOSITION ExternalLeading(Font &font_) override;
XYPOSITION Height(Font &font_) override;
XYPOSITION AverageCharWidth(Font &font_) override;
@@ -1010,13 +1006,6 @@ XYPOSITION SurfaceGDI::InternalLeading(Font &font_) {
return static_cast<XYPOSITION>(tm.tmInternalLeading);
}
-XYPOSITION SurfaceGDI::ExternalLeading(Font &font_) {
- SetFont(font_);
- TEXTMETRIC tm;
- ::GetTextMetrics(hdc, &tm);
- return static_cast<XYPOSITION>(tm.tmExternalLeading);
-}
-
XYPOSITION SurfaceGDI::Height(Font &font_) {
SetFont(font_);
TEXTMETRIC tm;
@@ -1121,7 +1110,6 @@ public:
XYPOSITION Ascent(Font &font_) override;
XYPOSITION Descent(Font &font_) override;
XYPOSITION InternalLeading(Font &font_) override;
- XYPOSITION ExternalLeading(Font &font_) override;
XYPOSITION Height(Font &font_) override;
XYPOSITION AverageCharWidth(Font &font_) override;
@@ -1671,7 +1659,7 @@ void SurfaceD2D::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *
int ui = 0;
for (int i=0; i<len && ui<tbuf.tlen;) {
positions[i] = poses.buffer[ui];
- if (Platform::IsDBCSLeadByte(codePageText, s[i])) {
+ if (DBCSIsLeadByte(codePageText, s[i])) {
positions[i+1] = poses.buffer[ui];
i += 2;
} else {
@@ -1716,11 +1704,6 @@ XYPOSITION SurfaceD2D::InternalLeading(Font &font_) {
return floor(yInternalLeading);
}
-XYPOSITION SurfaceD2D::ExternalLeading(Font &) {
- // Not implemented, always return one
- return 1;
-}
-
XYPOSITION SurfaceD2D::Height(Font &font_) {
return Ascent(font_) + Descent(font_);
}
@@ -1786,10 +1769,6 @@ void Window::Destroy() {
wid = 0;
}
-bool Window::HasFocus() {
- return ::GetFocus() == wid;
-}
-
PRectangle Window::GetPosition() {
RECT rc;
::GetWindowRect(static_cast<HWND>(wid), &rc);
@@ -1952,10 +1931,6 @@ void Window::SetCursor(Cursor curs) {
}
}
-void Window::SetTitle(const char *s) {
- ::SetWindowTextA(static_cast<HWND>(wid), s);
-}
-
/* Returns rectangle of monitor pt is on, both rect and pt are in Window's
coordinates */
PRectangle Window::GetMonitorRect(Point pt) {
@@ -3024,85 +2999,10 @@ unsigned int Platform::DoubleClickTime() {
return ::GetDoubleClickTime();
}
-bool Platform::MouseButtonBounce() {
- return false;
-}
-
void Platform::DebugDisplay(const char *s) {
::OutputDebugStringA(s);
}
-bool Platform::IsKeyDown(int key) {
- return (::GetKeyState(key) & 0x80000000) != 0;
-}
-
-long Platform::SendScintilla(WindowID w, unsigned int msg, unsigned long wParam, long lParam) {
- // This should never be called - its here to satisfy an old interface
- return static_cast<long>(::SendMessage(static_cast<HWND>(w), msg, wParam, lParam));
-}
-
-long Platform::SendScintillaPointer(WindowID w, unsigned int msg, unsigned long wParam, void *lParam) {
- // This should never be called - its here to satisfy an old interface
- return static_cast<long>(::SendMessage(static_cast<HWND>(w), msg, wParam,
- reinterpret_cast<LPARAM>(lParam)));
-}
-
-bool Platform::IsDBCSLeadByte(int codePage, char ch) {
- // Byte ranges found in Wikipedia articles with relevant search strings in each case
- const unsigned char uch = static_cast<unsigned char>(ch);
- switch (codePage) {
- case 932:
- // Shift_jis
- return ((uch >= 0x81) && (uch <= 0x9F)) ||
- ((uch >= 0xE0) && (uch <= 0xEF));
- case 936:
- // GBK
- return (uch >= 0x81) && (uch <= 0xFE);
- case 949:
- // Korean Wansung KS C-5601-1987
- return (uch >= 0x81) && (uch <= 0xFE);
- case 950:
- // Big5
- return (uch >= 0x81) && (uch <= 0xFE);
- case 1361:
- // Korean Johab KS C-5601-1992
- return
- ((uch >= 0x84) && (uch <= 0xD3)) ||
- ((uch >= 0xD8) && (uch <= 0xDE)) ||
- ((uch >= 0xE0) && (uch <= 0xF9));
- }
- return false;
-}
-
-int Platform::DBCSCharLength(int codePage, const char *s) {
- if (codePage == 932 || codePage == 936 || codePage == 949 ||
- codePage == 950 || codePage == 1361) {
- return Platform::IsDBCSLeadByte(codePage, s[0]) ? 2 : 1;
- } else {
- return 1;
- }
-}
-
-int Platform::DBCSCharMaxLength() {
- return 2;
-}
-
-// These are utility functions not really tied to a platform
-
-int Platform::Minimum(int a, int b) {
- if (a < b)
- return a;
- else
- return b;
-}
-
-int Platform::Maximum(int a, int b) {
- if (a > b)
- return a;
- else
- return b;
-}
-
//#define TRACE
#ifdef TRACE
@@ -3147,14 +3047,6 @@ void Platform::Assert(const char *c, const char *file, int line) {
}
}
-int Platform::Clamp(int val, int minVal, int maxVal) {
- if (val > maxVal)
- val = maxVal;
- if (val < minVal)
- val = minVal;
- return val;
-}
-
void Platform_Initialise(void *hInstance) {
::InitializeCriticalSection(&crPlatformLock);
hinstPlatformRes = static_cast<HINSTANCE>(hInstance);
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx
index 81f288c72..faf4701c3 100644
--- a/win32/ScintillaWin.cxx
+++ b/win32/ScintillaWin.cxx
@@ -156,6 +156,14 @@ static Point PointFromPOINT(POINT pt) {
return Point::FromInts(pt.x, pt.y);
}
+static Point PointFromLong(long lpoint) {
+ return Point(static_cast<short>(LOWORD(lpoint)), static_cast<short>(HIWORD(lpoint)));
+}
+
+static bool KeyboardIsKeyDown(int key) {
+ return (::GetKeyState(key) & 0x80000000) != 0;
+}
+
class ScintillaWin; // Forward declaration for COM interface subobjects
typedef void VFunction(void);
@@ -1376,19 +1384,19 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
::ImmNotifyIME(imc.hIMC, NI_COMPOSITIONSTR, CPS_COMPLETE, 0);
//
//Platform::DebugPrintf("Buttdown %d %x %x %x %x %x\n",iMessage, wParam, lParam,
- // Platform::IsKeyDown(VK_SHIFT),
- // Platform::IsKeyDown(VK_CONTROL),
- // Platform::IsKeyDown(VK_MENU));
+ // KeyboardIsKeyDown(VK_SHIFT),
+ // KeyboardIsKeyDown(VK_CONTROL),
+ // KeyboardIsKeyDown(VK_MENU));
::SetFocus(MainHWND());
- ButtonDown(Point::FromLong(static_cast<long>(lParam)), ::GetMessageTime(),
+ ButtonDown(PointFromLong(static_cast<long>(lParam)), ::GetMessageTime(),
(wParam & MK_SHIFT) != 0,
(wParam & MK_CONTROL) != 0,
- Platform::IsKeyDown(VK_MENU));
+ KeyboardIsKeyDown(VK_MENU));
}
break;
case WM_MOUSEMOVE: {
- const Point pt = Point::FromLong(static_cast<long>(lParam));
+ const Point pt = PointFromLong(static_cast<long>(lParam));
// Windows might send WM_MOUSEMOVE even though the mouse has not been moved:
// http://blogs.msdn.com/b/oldnewthing/archive/2003/10/01/55108.aspx
@@ -1397,7 +1405,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
ButtonMoveWithModifiers(pt,
((wParam & MK_SHIFT) != 0 ? SCI_SHIFT : 0) |
((wParam & MK_CONTROL) != 0 ? SCI_CTRL : 0) |
- (Platform::IsKeyDown(VK_MENU) ? SCI_ALT : 0));
+ (KeyboardIsKeyDown(VK_MENU) ? SCI_ALT : 0));
}
}
break;
@@ -1408,22 +1416,22 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
case WM_LBUTTONUP:
- ButtonUp(Point::FromLong(static_cast<long>(lParam)),
+ ButtonUp(PointFromLong(static_cast<long>(lParam)),
::GetMessageTime(),
(wParam & MK_CONTROL) != 0);
break;
case WM_RBUTTONDOWN: {
::SetFocus(MainHWND());
- Point pt = Point::FromLong(static_cast<long>(lParam));
+ Point pt = PointFromLong(static_cast<long>(lParam));
if (!PointInSelection(pt)) {
CancelModes();
- SetEmptySelection(PositionFromLocation(Point::FromLong(static_cast<long>(lParam))));
+ SetEmptySelection(PositionFromLocation(PointFromLong(static_cast<long>(lParam))));
}
RightButtonDownWithModifiers(pt, ::GetMessageTime(), ModifierFlags((wParam & MK_SHIFT) != 0,
(wParam & MK_CONTROL) != 0,
- Platform::IsKeyDown(VK_MENU)));
+ KeyboardIsKeyDown(VK_MENU)));
}
break;
@@ -1487,9 +1495,9 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
//Platform::DebugPrintf("S keydown %d %x %x %x %x\n",iMessage, wParam, lParam, ::IsKeyDown(VK_SHIFT), ::IsKeyDown(VK_CONTROL));
lastKeyDownConsumed = false;
const int ret = KeyDown(KeyTranslate(static_cast<int>(wParam)),
- Platform::IsKeyDown(VK_SHIFT),
- Platform::IsKeyDown(VK_CONTROL),
- Platform::IsKeyDown(VK_MENU),
+ KeyboardIsKeyDown(VK_SHIFT),
+ KeyboardIsKeyDown(VK_CONTROL),
+ KeyboardIsKeyDown(VK_MENU),
&lastKeyDownConsumed);
if (!ret && !lastKeyDownConsumed) {
return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam);
@@ -1573,7 +1581,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
}
case WM_CONTEXTMENU: {
- Point pt = Point::FromLong(static_cast<long>(lParam));
+ Point pt = PointFromLong(static_cast<long>(lParam));
POINT rpt = {static_cast<int>(pt.x), static_cast<int>(pt.y)};
::ScreenToClient(MainHWND(), &rpt);
const Point ptClient = PointFromPOINT(rpt);
@@ -3350,7 +3358,7 @@ LRESULT PASCAL ScintillaWin::CTWndProc(
return 0;
} else if (iMessage == WM_LBUTTONDOWN) {
// This does not fire due to the hit test code
- sciThis->ct.MouseClick(Point::FromLong(static_cast<long>(lParam)));
+ sciThis->ct.MouseClick(PointFromLong(static_cast<long>(lParam)));
sciThis->CallTipClick();
return 0;
} else if (iMessage == WM_SETCURSOR) {
diff --git a/win32/makefile b/win32/makefile
index 2801a4234..5ac2b2c30 100644
--- a/win32/makefile
+++ b/win32/makefile
@@ -97,6 +97,7 @@ BASEOBJS = \
CharacterSet.o \
CharClassify.o \
ContractionState.o \
+ DBCS.o \
Decoration.o \
Document.o \
EditModel.o \
diff --git a/win32/scintilla.mak b/win32/scintilla.mak
index aec630604..57f0d1c87 100644
--- a/win32/scintilla.mak
+++ b/win32/scintilla.mak
@@ -75,6 +75,7 @@ SHAREDOBJS=\
$(DIR_O)\CharacterSet.obj \
$(DIR_O)\CharClassify.obj \
$(DIR_O)\ContractionState.obj \
+ $(DIR_O)\DBCS.obj \
$(DIR_O)\Decoration.obj \
$(DIR_O)\Document.obj \
$(DIR_O)\EditModel.obj \