From 02388f3a7a6dfc1c8d22b11a7a22527a50cabcce Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Sun, 18 Feb 2018 12:14:04 -0500 Subject: Backported some previous Scintilla 4.0.0 changes that broke Scinterm. Requires Scinterm r167 (changeset a0a536a4fe7e). --- src/Makefile | 5 +- src/scintilla_backports/6310_7e28cdba6d61.patch | 695 +++++++++++ src/scintilla_backports/6311_7030530a9a0f.patch | 1480 +++++++++++++++++++++++ src/scintilla_backports/6314_af83baede430.patch | 535 ++++++++ src/scintilla_backports/6327_95346e626cf8.patch | 8 +- src/scintilla_backports/6425_73343682cbda.patch | 6 +- 6 files changed, 2721 insertions(+), 8 deletions(-) create mode 100644 src/scintilla_backports/6310_7e28cdba6d61.patch create mode 100644 src/scintilla_backports/6311_7030530a9a0f.patch create mode 100644 src/scintilla_backports/6314_af83baede430.patch (limited to 'src') diff --git a/src/Makefile b/src/Makefile index 4fa2c209..031d7f40 100644 --- a/src/Makefile +++ b/src/Makefile @@ -172,7 +172,8 @@ scintilla-marshal.o: scintilla/gtk/scintilla-marshal.c $(regex_objs): %.o: tre/lib/%.c $(CROSS)$(CC) -c $(CFLAGS) -Itre/lib $< -o $@ ScintillaTerm.o: scintilla/term/ScintillaTerm.cxx - $(CROSS)$(CXX) -c $(CXXFLAGS) $(sci_flags) $(CURSES_CFLAGS) $< -o $@ + $(CROSS)$(CXX) -c $(CXXFLAGS) $(sci_flags) $(CURSES_CFLAGS) -DSCI_COMPAT_4 \ + $< -o $@ $(lexlpeg_objs): LexLPeg.cxx $(CROSS)$(CXX) -c $(CXXFLAGS) $(LUA_CFLAGS) $(sci_flags) $< -o $@ $(textadept_objs): textadept.c @@ -411,7 +412,7 @@ endif scintilla_tgz = scintilla373.tgz tre_zip = cdce45e8dd7a3b36954022b4a4d3570e1ac5a4f8.zip -scinterm_zip = 30bef4e18cae.zip +scinterm_zip = a0a536a4fe7e.zip scintillua_zip = 53fb84d4d0ac.zip lua_tgz = lua-5.3.4.tar.gz lpeg_tgz = lpeg-1.0.0.tar.gz diff --git a/src/scintilla_backports/6310_7e28cdba6d61.patch b/src/scintilla_backports/6310_7e28cdba6d61.patch new file mode 100644 index 00000000..c9de09e8 --- /dev/null +++ b/src/scintilla_backports/6310_7e28cdba6d61.patch @@ -0,0 +1,695 @@ +# HG changeset patch +# User Neil +# Date 1497154123 -36000 +# Node ID 7e28cdba6d61e090ac6f6627c855ffd2603508e4 +# Parent f2f32d58bcd83aae163367781d2dcc65590109bc +Implement SCN_AUTOCSELECTIONCHANGE notification. + +diff -r f2f32d58bcd8 -r 7e28cdba6d61 cocoa/PlatCocoa.mm +--- a/cocoa/PlatCocoa.mm Sat Jun 10 13:22:55 2017 +1000 ++++ b/cocoa/PlatCocoa.mm Sun Jun 11 14:08:43 2017 +1000 +@@ -1274,7 +1274,9 @@ + + namespace { + +-// unnamed namespace hides IListBox interface ++// Unnamed namespace hides local IListBox interface. ++// IListBox is used to cross languages to send events from Objective C++ ++// AutoCompletionDelegate and AutoCompletionDataSource to C++ ListBoxImpl. + + class IListBox { + public: +@@ -1282,18 +1284,43 @@ + virtual NSImage *ImageForRow(NSInteger row) = 0; + virtual NSString *TextForRow(NSInteger row) = 0; + virtual void DoubleClick() = 0; ++ virtual void SelectionChange() = 0; + }; + +-} // unnamed namespace ++} ++ ++//----------------- AutoCompletionDelegate --------------------------------------------------------- ++ ++// AutoCompletionDelegate is an Objective C++ class so it can implement ++// NSTableViewDelegate and receive tableViewSelectionDidChange events. ++ ++@interface AutoCompletionDelegate : NSObject { ++ IListBox *box; ++} ++ ++@property IListBox *box; ++ ++@end ++ ++@implementation AutoCompletionDelegate ++ ++@synthesize box; ++ ++- (void) tableViewSelectionDidChange: (NSNotification *) notification { ++#pragma unused(notification) ++ if (box) { ++ box->SelectionChange(); ++ } ++} ++ ++@end + + //----------------- AutoCompletionDataSource ------------------------------------------------------- + +-@interface AutoCompletionDataSource : +- NSObject +-#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_5 +- +-#endif +-{ ++// AutoCompletionDataSource provides data to display in the list box. ++// It is also the target of the NSTableView so it receives double clicks. ++ ++@interface AutoCompletionDataSource : NSObject { + IListBox *box; + } + +@@ -1400,10 +1427,10 @@ + NSTableColumn *colIcon; + NSTableColumn *colText; + AutoCompletionDataSource *ds; ++ AutoCompletionDelegate *acd; + + LinesData ld; +- CallBackAction doubleClickAction; +- void *doubleClickActionData; ++ IListBoxDelegate *delegate; + + public: + ListBoxImpl() : +@@ -1420,8 +1447,8 @@ + colIcon(nil), + colText(nil), + ds(nil), +- doubleClickAction(nullptr), +- doubleClickActionData(nullptr) { ++ acd(nil), ++ delegate(nullptr) { + images = [[NSMutableDictionary alloc] init]; + } + ~ListBoxImpl() override { +@@ -1445,9 +1472,8 @@ + void RegisterImage(int type, const char *xpm_data) override; + void RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage) override; + void ClearRegisteredImages() override; +- void SetDoubleClickAction(CallBackAction action, void *data) override { +- doubleClickAction = action; +- doubleClickActionData = data; ++ void SetDelegate(IListBoxDelegate *lbDelegate) override { ++ delegate = lbDelegate; + } + void SetList(const char *list, char separator, char typesep) override; + +@@ -1459,6 +1485,7 @@ + NSImage *ImageForRow(NSInteger row) override; + NSString *TextForRow(NSInteger row) override; + void DoubleClick() override; ++ void SelectionChange() override; + }; + + void ListBoxImpl::Create(Window & /*parent*/, int /*ctrlID*/, Scintilla::Point pt, +@@ -1494,6 +1521,9 @@ + ds = [[AutoCompletionDataSource alloc] init]; + ds.box = this; + table.dataSource = ds; // Weak reference ++ acd = [[AutoCompletionDelegate alloc] init]; ++ [acd setBox: this]; ++ table.delegate = acd; + scroller.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; + [winLB.contentView addSubview: scroller]; + +@@ -1568,6 +1598,7 @@ + scroller = nil; + colIcon = nil; + colText = nil; ++ acd = nil; + ds = nil; + } + +@@ -1694,8 +1725,16 @@ + } + + void ListBoxImpl::DoubleClick() { +- if (doubleClickAction) { +- doubleClickAction(doubleClickActionData); ++ if (delegate) { ++ ListBoxEvent event(ListBoxEvent::EventType::doubleClick); ++ delegate->ListNotify(&event); ++ } ++} ++ ++void ListBoxImpl::SelectionChange() { ++ if (delegate) { ++ ListBoxEvent event(ListBoxEvent::EventType::selectionChange); ++ delegate->ListNotify(&event); + } + } + +@@ -1703,6 +1742,8 @@ + + //----------------- ListBox ------------------------------------------------------------------------ + ++// ListBox is implemented by the ListBoxImpl class. ++ + ListBox::ListBox() { + } + +diff -r f2f32d58bcd8 -r 7e28cdba6d61 doc/ScintillaDoc.html +--- a/doc/ScintillaDoc.html Sat Jun 10 13:22:55 2017 +1000 ++++ b/doc/ScintillaDoc.html Sun Jun 11 14:08:43 2017 +1000 +@@ -7011,7 +7011,7 @@ + /* SCN_MARGINRIGHTCLICK, SCN_NEEDSHOWN, SCN_DWELLSTART, SCN_DWELLEND, */ + /* SCN_CALLTIPCLICK, SCN_HOTSPOTCLICK, SCN_HOTSPOTDOUBLECLICK, */ + /* SCN_HOTSPOTRELEASECLICK, SCN_INDICATORCLICK, SCN_INDICATORRELEASE, */ +- /* SCN_USERLISTSELECTION, SCN_AUTOCSELECTION */ ++ /* SCN_USERLISTSELECTION, SCN_AUTOCSELECTION, SCN_AUTOCSELECTIONCHANGE */ + + int ch; + /* SCN_CHARADDED, SCN_KEY, SCN_AUTOCCOMPLETE, SCN_AUTOCSELECTION, */ +@@ -7022,7 +7022,8 @@ + + int modificationType; /* SCN_MODIFIED */ + const char *text; +- /* SCN_MODIFIED, SCN_USERLISTSELECTION, SCN_AUTOCSELECTION, SCN_URIDROPPED */ ++ /* SCN_MODIFIED, SCN_USERLISTSELECTION, SCN_AUTOCSELECTION, SCN_URIDROPPED, */ ++ /* SCN_AUTOCSELECTIONCHANGE */ + + Sci_Position length; /* SCN_MODIFIED */ + Sci_Position linesAdded; /* SCN_MODIFIED */ +@@ -7033,7 +7034,7 @@ + int foldLevelNow; /* SCN_MODIFIED */ + int foldLevelPrev; /* SCN_MODIFIED */ + int margin; /* SCN_MARGINCLICK, SCN_MARGINRIGHTCLICK */ +- int listType; /* SCN_USERLISTSELECTION */ ++ int listType; /* SCN_USERLISTSELECTION, SCN_AUTOCSELECTIONCHANGE */ + int x; /* SCN_DWELLSTART, SCN_DWELLEND */ + int y; /* SCN_DWELLSTART, SCN_DWELLEND */ + int token; /* SCN_MODIFIED with SC_MOD_CONTAINER */ +@@ -7078,6 +7079,7 @@ + SCN_FOCUSOUT
+ SCN_AUTOCCOMPLETED
+ SCN_MARGINRIGHTCLICK
++ SCN_AUTOCSELECTIONCHANGE
+ + +

The following SCI_* messages are associated with these notifications:

+@@ -7946,10 +7948,6 @@ + The user deleted a character while autocompletion list was active. + There is no other information in SCNotification.

+ +-

SCN_FOCUSIN
+- SCN_FOCUSOUT
+- SCN_FOCUSIN (2028) is fired when Scintilla receives focus and +- SCN_FOCUSOUT (2029) when it loses focus.

+ +

SCN_AUTOCCOMPLETED
+
This notification is generated after an autocompletion has inserted its +@@ -7958,6 +7956,48 @@ + SCN_AUTOCSELECTION + notification.

+ ++

SCN_AUTOCSELECTIONCHANGE
++
This notification is sent when items are highlighted in an autocompletion or user list. ++ The ++ SCNotification fields used are:

++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
FieldUsage
listTypeThis is set to the listType parameter from the SCI_USERLISTSHOW message ++ or 0 for an autocompletion.
textThe text of the selection.
positionThe position the list was displayed at.
++ ++

SCN_FOCUSIN
++ SCN_FOCUSOUT
++ SCN_FOCUSIN (2028) is fired when Scintilla receives focus and ++ SCN_FOCUSOUT (2029) when it loses focus.

++ +

Images

+ +

Two formats are supported for images used in margin markers and autocompletion lists, RGBA and XPM.

+diff -r f2f32d58bcd8 -r 7e28cdba6d61 doc/ScintillaHistory.html +--- a/doc/ScintillaHistory.html Sat Jun 10 13:22:55 2017 +1000 ++++ b/doc/ScintillaHistory.html Sun Jun 11 14:08:43 2017 +1000 +@@ -536,6 +536,9 @@ + Support dropped for GTK+ versions before 2.24. + +
  • ++ An SCN_AUTOCSELECTIONCHANGE notification is sent when items are highlighted in an autocompletion or user list. ++
  • ++
  • + SciTE allows user.shortcuts to be defined with symbolic Scintilla messages like + 'Ctrl+L|SCI_LINEDELETE|'. +
  • +diff -r f2f32d58bcd8 -r 7e28cdba6d61 gtk/PlatGTK.cxx +--- a/gtk/PlatGTK.cxx Sat Jun 10 13:22:55 2017 +1000 ++++ b/gtk/PlatGTK.cxx Sun Jun 11 14:08:43 2017 +1000 +@@ -1196,8 +1196,7 @@ + GtkCssProvider *cssProvider; + #endif + public: +- CallBackAction doubleClickAction; +- void *doubleClickActionData; ++ IListBoxDelegate *delegate; + + ListBoxX() : widCached(0), frame(0), list(0), scroller(0), pixhash(NULL), pixbuf_renderer(0), + renderer(0), +@@ -1206,7 +1205,7 @@ + #if GTK_CHECK_VERSION(3,0,0) + cssProvider(NULL), + #endif +- doubleClickAction(NULL), doubleClickActionData(NULL) { ++ delegate(nullptr) { + } + ~ListBoxX() override { + if (pixhash) { +@@ -1243,10 +1242,7 @@ + virtual void RegisterImage(int type, const char *xpm_data); + virtual void RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage); + virtual void ClearRegisteredImages(); +- virtual void SetDoubleClickAction(CallBackAction action, void *data) { +- doubleClickAction = action; +- doubleClickActionData = data; +- } ++ virtual void SetDelegate(IListBoxDelegate *lbDelegate); + virtual void SetList(const char *listText, char separator, char typesep); + }; + +@@ -1337,8 +1333,9 @@ + static gboolean ButtonPress(GtkWidget *, GdkEventButton* ev, gpointer p) { + try { + ListBoxX* lb = static_cast(p); +- if (ev->type == GDK_2BUTTON_PRESS && lb->doubleClickAction != NULL) { +- lb->doubleClickAction(lb->doubleClickActionData); ++ if (ev->type == GDK_2BUTTON_PRESS && lb->delegate) { ++ ListBoxEvent event(ListBoxEvent::EventType::doubleClick); ++ lb->delegate->ListNotify(&event); + return TRUE; + } + +@@ -1348,6 +1345,20 @@ + return FALSE; + } + ++static gboolean ButtonRelease(GtkWidget *, GdkEventButton* ev, gpointer p) { ++ try { ++ ListBoxX* lb = static_cast(p); ++ if (ev->type != GDK_2BUTTON_PRESS && lb->delegate) { ++ ListBoxEvent event(ListBoxEvent::EventType::selectionChange); ++ lb->delegate->ListNotify(&event); ++ return TRUE; ++ } ++ } catch (...) { ++ // No pointer back to Scintilla to save status ++ } ++ return FALSE; ++} ++ + /* Change the active color to the selected color so the listbox uses the color + scheme that it would use if it had the focus. */ + static void StyleSet(GtkWidget *w, GtkStyle*, void*) { +@@ -1472,6 +1483,8 @@ + gtk_widget_show(widget); + g_signal_connect(G_OBJECT(widget), "button_press_event", + G_CALLBACK(ButtonPress), this); ++ g_signal_connect(G_OBJECT(widget), "button_release_event", ++ G_CALLBACK(ButtonRelease), this); + + GtkWidget *top = gtk_widget_get_toplevel(static_cast(parent.GetID())); + gtk_window_set_transient_for(GTK_WINDOW(static_cast(wid)), +@@ -1747,6 +1760,11 @@ + } else { + gtk_tree_selection_unselect_all(selection); + } ++ ++ if (delegate) { ++ ListBoxEvent event(ListBoxEvent::EventType::selectionChange); ++ delegate->ListNotify(&event); ++ } + } + + int ListBoxX::GetSelection() { +@@ -1843,6 +1861,10 @@ + images.Clear(); + } + ++void ListBoxX::SetDelegate(IListBoxDelegate *lbDelegate) { ++ delegate = lbDelegate; ++} ++ + void ListBoxX::SetList(const char *listText, char separator, char typesep) { + Clear(); + int count = strlen(listText) + 1; +diff -r f2f32d58bcd8 -r 7e28cdba6d61 include/Platform.h +--- a/include/Platform.h Sat Jun 10 13:22:55 2017 +1000 ++++ b/include/Platform.h Sun Jun 11 14:08:43 2017 +1000 +@@ -397,6 +397,19 @@ + * Listbox management. + */ + ++// ScintillaBase implements IListBoxDelegate to receive ListBoxEvents from a ListBox ++ ++struct ListBoxEvent { ++ enum class EventType { selectionChange, doubleClick } event; ++ ListBoxEvent(EventType event_) : event(event_) { ++ } ++}; ++ ++class IListBoxDelegate { ++public: ++ virtual void ListNotify(ListBoxEvent *plbe)=0; ++}; ++ + class ListBox : public Window { + public: + ListBox(); +@@ -420,7 +433,7 @@ + virtual void RegisterImage(int type, const char *xpm_data)=0; + virtual void RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage) = 0; + virtual void ClearRegisteredImages()=0; +- virtual void SetDoubleClickAction(CallBackAction, void *)=0; ++ virtual void SetDelegate(IListBoxDelegate *lbDelegate)=0; + virtual void SetList(const char* list, char separator, char typesep)=0; + }; + +diff -r f2f32d58bcd8 -r 7e28cdba6d61 include/Scintilla.h +--- a/include/Scintilla.h Sat Jun 10 13:22:55 2017 +1000 ++++ b/include/Scintilla.h Sun Jun 11 14:08:43 2017 +1000 +@@ -1102,6 +1102,7 @@ + #define SCN_FOCUSOUT 2029 + #define SCN_AUTOCCOMPLETED 2030 + #define SCN_MARGINRIGHTCLICK 2031 ++#define SCN_AUTOCSELECTIONCHANGE 2032 + /* --Autogenerated -- end of section automatically generated from Scintilla.iface */ + + /* These structures are defined to be exactly the same shape as the Win32 +diff -r f2f32d58bcd8 -r 7e28cdba6d61 include/Scintilla.iface +--- a/include/Scintilla.iface Sat Jun 10 13:22:55 2017 +1000 ++++ b/include/Scintilla.iface Sun Jun 11 14:08:43 2017 +1000 +@@ -4855,6 +4855,7 @@ + evt void FocusOut=2029(void) + evt void AutoCCompleted=2030(string text, int position, int ch, CompletionMethods listCompletionMethod) + 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, but some arguments to SCI_SETTECHNOLOGY are provisional. + +diff -r f2f32d58bcd8 -r 7e28cdba6d61 qt/ScintillaEditBase/PlatQt.cpp +--- a/qt/ScintillaEditBase/PlatQt.cpp Sat Jun 10 13:22:55 2017 +1000 ++++ b/qt/ScintillaEditBase/PlatQt.cpp Sun Jun 11 14:08:43 2017 +1000 +@@ -772,7 +772,7 @@ + const unsigned char *pixelsImage) override; + virtual void RegisterQPixmapImage(int type, const QPixmap& pm); + void ClearRegisteredImages() override; +- void SetDoubleClickAction(CallBackAction action, void *data) override; ++ void SetDelegate(IListBoxDelegate *lbDelegate) override; + void SetList(const char *list, char separator, char typesep) override; + private: + bool unicodeMode; +@@ -785,15 +785,16 @@ + explicit ListWidget(QWidget *parent); + virtual ~ListWidget(); + +- void setDoubleClickAction(CallBackAction action, void *data); ++ void setDelegate(IListBoxDelegate *lbDelegate); ++ void selectionChanged(); + + protected: ++ void mouseReleaseEvent(QMouseEvent * event) override; + void mouseDoubleClickEvent(QMouseEvent *event) override; + QStyleOptionViewItem viewOptions() const override; + + private: +- CallBackAction doubleClickAction; +- void *doubleClickActionData; ++ IListBoxDelegate *delegate; + }; + + +@@ -946,6 +947,7 @@ + } + } + list->setCurrentRow(n); ++ list->selectionChanged(); + } + + int ListBoxImpl::GetSelection() +@@ -1014,10 +1016,10 @@ + list->setIconSize(QSize(0, 0)); + } + +-void ListBoxImpl::SetDoubleClickAction(CallBackAction action, void *data) ++void ListBoxImpl::SetDelegate(IListBoxDelegate *lbDelegate) + { + ListWidget *list = static_cast(wid); +- list->setDoubleClickAction(action, data); ++ list->setDelegate(lbDelegate); + } + + void ListBoxImpl::SetList(const char *list, char separator, char typesep) +@@ -1059,24 +1061,36 @@ + } + + ListWidget::ListWidget(QWidget *parent) +-: QListWidget(parent), doubleClickAction(0), doubleClickActionData(0) ++: QListWidget(parent), delegate(0) + {} + + ListWidget::~ListWidget() {} + +-void ListWidget::setDoubleClickAction(CallBackAction action, void *data) ++void ListWidget::setDelegate(IListBoxDelegate *lbDelegate) + { +- doubleClickAction = action; +- doubleClickActionData = data; ++ delegate = lbDelegate; ++} ++ ++void ListWidget::selectionChanged() { ++ if (delegate) { ++ ListBoxEvent event(ListBoxEvent::EventType::selectionChange); ++ delegate->ListNotify(&event); ++ } + } + + void ListWidget::mouseDoubleClickEvent(QMouseEvent * /* event */) + { +- if (doubleClickAction != 0) { +- doubleClickAction(doubleClickActionData); ++ if (delegate) { ++ ListBoxEvent event(ListBoxEvent::EventType::doubleClick); ++ delegate->ListNotify(&event); + } + } + ++void ListWidget::mouseReleaseEvent(QMouseEvent * /* event */) ++{ ++ selectionChanged(); ++} ++ + QStyleOptionViewItem ListWidget::viewOptions() const + { + QStyleOptionViewItem result = QListWidget::viewOptions(); +diff -r f2f32d58bcd8 -r 7e28cdba6d61 src/ScintillaBase.cxx +--- a/src/ScintillaBase.cxx Sat Jun 10 13:22:55 2017 +1000 ++++ b/src/ScintillaBase.cxx Sun Jun 11 14:08:43 2017 +1000 +@@ -202,9 +202,15 @@ + return Editor::KeyCommand(iMessage); + } + +-void ScintillaBase::AutoCompleteDoubleClick(void *p) { +- ScintillaBase *sci = static_cast(p); +- sci->AutoCompleteCompleted(0, SC_AC_DOUBLECLICK); ++void ScintillaBase::ListNotify(ListBoxEvent *plbe) { ++ switch (plbe->event) { ++ case ListBoxEvent::EventType::selectionChange: ++ AutoCompleteSelection(); ++ break; ++ case ListBoxEvent::EventType::doubleClick: ++ AutoCompleteCompleted(0, SC_AC_DOUBLECLICK); ++ break; ++ } + } + + void ScintillaBase::AutoCompleteInsert(Sci::Position startPos, int removeLen, const char *text, int textLen) { +@@ -293,7 +299,7 @@ + ac.lb->SetFont(vs.styles[STYLE_DEFAULT].font); + unsigned int aveCharWidth = static_cast(vs.styles[STYLE_DEFAULT].aveCharWidth); + ac.lb->SetAverageCharWidth(aveCharWidth); +- ac.lb->SetDoubleClickAction(AutoCompleteDoubleClick, this); ++ ac.lb->SetDelegate(this); + + ac.SetList(list ? list : ""); + +@@ -340,6 +346,25 @@ + ac.Select(wordCurrent.c_str()); + } + ++void ScintillaBase::AutoCompleteSelection() { ++ int item = ac.GetSelection(); ++ std::string selected; ++ if (item != -1) { ++ selected = ac.GetValue(item); ++ } ++ ++ SCNotification scn = {}; ++ scn.nmhdr.code = SCN_AUTOCSELECTIONCHANGE; ++ scn.message = 0; ++ scn.wParam = listType; ++ scn.listType = listType; ++ Sci::Position firstPos = ac.posStart - ac.startLen; ++ scn.position = firstPos; ++ scn.lParam = firstPos; ++ scn.text = selected.c_str(); ++ NotifyParent(scn); ++} ++ + void ScintillaBase::AutoCompleteCharacterAdded(char ch) { + if (ac.IsFillUpChar(ch)) { + AutoCompleteCompleted(ch, SC_AC_FILLUP); +diff -r f2f32d58bcd8 -r 7e28cdba6d61 src/ScintillaBase.h +--- a/src/ScintillaBase.h Sat Jun 10 13:22:55 2017 +1000 ++++ b/src/ScintillaBase.h Sun Jun 11 14:08:43 2017 +1000 +@@ -18,7 +18,7 @@ + + /** + */ +-class ScintillaBase : public Editor { ++class ScintillaBase : public Editor, IListBoxDelegate { + // Private so ScintillaBase objects can not be copied + explicit ScintillaBase(const ScintillaBase &); + ScintillaBase &operator=(const ScintillaBase &); +@@ -76,7 +76,8 @@ + void AutoCompleteCharacterDeleted(); + void AutoCompleteCompleted(char ch, unsigned int completionMethod); + void AutoCompleteMoveToCurrentWord(); +- static void AutoCompleteDoubleClick(void *p); ++ void AutoCompleteSelection(); ++ virtual void ListNotify(ListBoxEvent *plbe); + + void CallTipClick(); + void CallTipShow(Point pt, const char *defn); +diff -r f2f32d58bcd8 -r 7e28cdba6d61 win32/PlatWin.cxx +--- a/win32/PlatWin.cxx Sat Jun 10 13:22:55 2017 +1000 ++++ b/win32/PlatWin.cxx Sun Jun 11 14:08:43 2017 +1000 +@@ -2042,8 +2042,7 @@ + unsigned int aveCharWidth; + Window *parent; + int ctrlID; +- CallBackAction doubleClickAction; +- void *doubleClickActionData; ++ IListBoxDelegate *delegate; + const char *widestItem; + unsigned int maxCharWidth; + int resizeHit; +@@ -2063,6 +2062,7 @@ + POINT MaxTrackSize() const; + void SetRedraw(bool on); + void OnDoubleClick(); ++ void OnSelChange(); + void ResizeToCursor(); + void StartResize(WPARAM); + LRESULT NcHitTest(WPARAM, LPARAM) const; +@@ -2077,7 +2077,8 @@ + public: + ListBoxX() : lineHeight(10), fontCopy(0), technology(0), lb(0), unicodeMode(false), + desiredVisibleRows(9), maxItemCharacters(0), aveCharWidth(8), +- parent(NULL), ctrlID(0), doubleClickAction(NULL), doubleClickActionData(NULL), ++ parent(NULL), ctrlID(0), ++ delegate(nullptr), + widestItem(NULL), maxCharWidth(1), resizeHit(0), wheelDelta(0) { + } + ~ListBoxX() override { +@@ -2103,10 +2104,7 @@ + void RegisterImage(int type, const char *xpm_data) override; + void RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage) override; + void ClearRegisteredImages() override; +- void SetDoubleClickAction(CallBackAction action, void *data) override { +- doubleClickAction = action; +- doubleClickActionData = data; +- } ++ virtual void SetDelegate(IListBoxDelegate *lbDelegate) override; + void SetList(const char *list, char separator, char typesep) override; + void Draw(DRAWITEMSTRUCT *pDrawItem); + LRESULT WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam); +@@ -2247,6 +2245,7 @@ + SetRedraw(false); + CentreItem(n); + ::SendMessage(lb, LB_SETCURSEL, n, 0); ++ OnSelChange(); + SetRedraw(true); + } + +@@ -2377,6 +2376,10 @@ + } + } + ++void ListBoxX::SetDelegate(IListBoxDelegate *lbDelegate) { ++ delegate = lbDelegate; ++} ++ + void ListBoxX::SetList(const char *list, char separator, char typesep) { + // Turn off redraw while populating the list - this has a significant effect, even if + // the listbox is not visible. +@@ -2606,9 +2609,16 @@ + } + + void ListBoxX::OnDoubleClick() { +- +- if (doubleClickAction != NULL) { +- doubleClickAction(doubleClickActionData); ++ if (delegate) { ++ ListBoxEvent event(ListBoxEvent::EventType::doubleClick); ++ delegate->ListNotify(&event); ++ } ++} ++ ++void ListBoxX::OnSelChange() { ++ if (delegate) { ++ ListBoxEvent event(ListBoxEvent::EventType::selectionChange); ++ delegate->ListNotify(&event); + } + } + +@@ -2683,6 +2693,10 @@ + int item = LOWORD(lResult); + if (HIWORD(lResult) == 0 && item >= 0) { + ::SendMessage(hWnd, LB_SETCURSEL, item, 0); ++ ListBoxX *lbx = static_cast(PointerFromWindow(::GetParent(hWnd))); ++ if (lbx) { ++ lbx->OnSelChange(); ++ } + } + } + return 0; diff --git a/src/scintilla_backports/6311_7030530a9a0f.patch b/src/scintilla_backports/6311_7030530a9a0f.patch new file mode 100644 index 00000000..dc85a84d --- /dev/null +++ b/src/scintilla_backports/6311_7030530a9a0f.patch @@ -0,0 +1,1480 @@ +# HG changeset patch +# User Neil +# Date 1497232196 -36000 +# Node ID 7030530a9a0f4fc1203a04378e83d82f0c35e7a0 +# Parent 7e28cdba6d61e090ac6f6627c855ffd2603508e4 +Removed unused functions and methods from Platform.h. +Replaced Platform::Clamp with Sci::clamp but will later change this to +std::clamp once on full C++17 compilers. +Drop MouseButtonBounce workaround for very early GTK+/Linux. + +diff -r 7e28cdba6d61 -r 7030530a9a0f cocoa/PlatCocoa.mm +--- a/cocoa/PlatCocoa.mm Sun Jun 11 14:08:43 2017 +1000 ++++ b/cocoa/PlatCocoa.mm Mon Jun 12 11:49:56 2017 +1000 +@@ -83,18 +83,6 @@ + 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) { +@@ -921,7 +909,7 @@ + } else if (codePage) { + int ui = 0; + for (int i=0; i(xPosition); +@@ -984,15 +972,6 @@ + return 0; + } + +-XYPOSITION SurfaceImpl::ExternalLeading(Font &font_) { +- if (!font_.GetID()) +- return 1; +- +- float leading = static_cast(font_.GetID())->getLeading(); +- return leading + 0.5f; +- +-} +- + XYPOSITION SurfaceImpl::Height(Font &font_) { + + return Ascent(font_) + Descent(font_); +@@ -1043,13 +1022,6 @@ + + //-------------------------------------------------------------------------------------------------- + +-bool Window::HasFocus() { +- NSView *container = (__bridge NSView *)(wid); +- return container.window.firstResponder == container; +-} +- +-//-------------------------------------------------------------------------------------------------- +- + static CGFloat ScreenMax() { + return NSMaxY([NSScreen mainScreen].frame); + } +@@ -1205,19 +1177,6 @@ + + //-------------------------------------------------------------------------------------------------- + +-void Window::SetTitle(const char *s) { +- if (wid) { +- id idWin = (__bridge id)(wid); +- if ([idWin isKindOfClass: [NSWindow class]]) { +- NSWindow *win = idWin; +- NSString *sTitle = @(s); +- win.title = sTitle; +- } +- } +-} +- +-//-------------------------------------------------------------------------------------------------- +- + PRectangle Window::GetMonitorRect(Point) { + if (wid) { + id idWin = (__bridge id)(wid); +@@ -1897,85 +1856,6 @@ + + //-------------------------------------------------------------------------------------------------- + +-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(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 + +@@ -2026,16 +1906,6 @@ + #endif + } + +-//-------------------------------------------------------------------------------------------------- +- +-int Platform::Clamp(int val, int minVal, int maxVal) { +- if (val > maxVal) +- val = maxVal; +- if (val < minVal) +- val = minVal; +- return val; +-} +- + //----------------- DynamicLibrary ----------------------------------------------------------------- + + /** +diff -r 7e28cdba6d61 -r 7030530a9a0f cocoa/ScintillaCocoa.h +--- a/cocoa/ScintillaCocoa.h Sun Jun 11 14:08:43 2017 +1000 ++++ b/cocoa/ScintillaCocoa.h Mon Jun 12 11:49:56 2017 +1000 +@@ -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 -r 7e28cdba6d61 -r 7030530a9a0f cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj +--- a/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj Sun Jun 11 14:08:43 2017 +1000 ++++ b/cocoa/ScintillaFramework/ScintillaFramework.xcodeproj/project.pbxproj Mon Jun 12 11:49:56 2017 +1000 +@@ -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 */; }; +@@ -423,6 +424,7 @@ + 280056FA188DDD2C00F200AE /* SubStyles.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SubStyles.h; path = ../../lexlib/SubStyles.h; sourceTree = ""; }; + 28064A04190F12E100E6E47F /* LexDMIS.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexDMIS.cxx; path = ../../lexers/LexDMIS.cxx; sourceTree = ""; }; + 282E41F3B9E2BFEDD6A05BE7 /* LexIndent.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexIndent.cxx; path = ../../lexers/LexIndent.cxx; sourceTree = SOURCE_ROOT; }; ++ 28804B2B1EEE232E00C0D154 /* DBCS.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DBCS.cxx; path = ../../src/DBCS.cxx; sourceTree = ""; }; + 28A067101A36B42600B4966A /* LexHex.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LexHex.cxx; path = ../../lexers/LexHex.cxx; sourceTree = ""; }; + 28A1DD4E196BE0CA006EFCDD /* EditModel.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EditModel.cxx; path = ../../src/EditModel.cxx; sourceTree = ""; }; + 28A1DD4F196BE0CA006EFCDD /* EditView.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EditView.cxx; path = ../../src/EditView.cxx; sourceTree = ""; }; +@@ -724,6 +726,7 @@ + 114B6F8F11FA75BE004FB6AB /* CharacterSet.cxx */, + 114B6F6411FA7597004FB6AB /* CharClassify.cxx */, + 114B6F6511FA7597004FB6AB /* ContractionState.cxx */, ++ 28804B2B1EEE232E00C0D154 /* DBCS.cxx */, + 114B6F6611FA7597004FB6AB /* Decoration.cxx */, + 114B6F6711FA7597004FB6AB /* Document.cxx */, + 28A1DD4E196BE0CA006EFCDD /* EditModel.cxx */, +@@ -1010,6 +1013,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 -r 7e28cdba6d61 -r 7030530a9a0f gtk/PlatGTK.cxx +--- a/gtk/PlatGTK.cxx Sun Jun 11 14:08:43 2017 +1000 ++++ b/gtk/PlatGTK.cxx Mon Jun 12 11:49:56 2017 +1000 +@@ -107,12 +107,6 @@ + return static_cast(wid); + } + +-Point Point::FromLong(long lpoint) { +- return Point( +- Platform::LowShortFromLong(lpoint), +- Platform::HighShortFromLong(lpoint)); +-} +- + Font::Font() : fid(0) {} + + Font::~Font() {} +@@ -184,7 +178,6 @@ + XYPOSITION Ascent(Font &font_); + XYPOSITION Descent(Font &font_); + XYPOSITION InternalLeading(Font &font_); +- XYPOSITION ExternalLeading(Font &font_); + XYPOSITION Height(Font &font_); + XYPOSITION AverageCharWidth(Font &font_); + +@@ -925,10 +918,6 @@ + return 0; + } + +-XYPOSITION SurfaceImpl::ExternalLeading(Font &) { +- return 0; +-} +- + XYPOSITION SurfaceImpl::Height(Font &font_) { + return Ascent(font_) + Descent(font_); + } +@@ -978,10 +967,6 @@ + } + } + +-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 @@ + #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 @@ + 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(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(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 @@ + 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 -r 7e28cdba6d61 -r 7030530a9a0f gtk/makefile +--- a/gtk/makefile Sun Jun 11 14:08:43 2017 +1000 ++++ b/gtk/makefile Mon Jun 12 11:49:56 2017 +1000 +@@ -78,7 +78,7 @@ + CTFLAGS=-DNDEBUG -Os $(CXXBASEFLAGS) $(THREADFLAGS) + endif + +-CXXTFLAGS:=--std=gnu++0x $(CTFLAGS) $(REFLAGS) ++CXXTFLAGS:=--std=gnu++17 $(CTFLAGS) $(REFLAGS) + + CONFIGFLAGS:=$(shell pkg-config --cflags $(GTKVERSION)) + MARSHALLER=scintilla-marshal.o +diff -r 7e28cdba6d61 -r 7030530a9a0f include/Platform.h +--- a/include/Platform.h Sun Jun 11 14:08:43 2017 +1000 ++++ b/include/Platform.h Mon Jun 12 11:49:56 2017 +1000 +@@ -109,8 +109,6 @@ + } + + // Other automatically defined methods (assignment, copy constructor, destructor) are fine +- +- static Point FromLong(long lpoint); + }; + + /** +@@ -332,7 +330,6 @@ + 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 @@ + 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 @@ + 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 @@ + 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(x >> 16); +- } +- static short LowShortFromLong(long x) { +- return static_cast(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 -r 7e28cdba6d61 -r 7030530a9a0f qt/ScintillaEdit/ScintillaEdit.pro +--- a/qt/ScintillaEdit/ScintillaEdit.pro Sun Jun 11 14:08:43 2017 +1000 ++++ b/qt/ScintillaEdit/ScintillaEdit.pro Mon Jun 12 11:49:56 2017 +1000 +@@ -10,18 +10,14 @@ + TARGET = ScintillaEdit + TEMPLATE = lib + CONFIG += lib_bundle +- +-unix { +- # requires C++11 support +- greaterThan(QT_MAJOR_VERSION, 4){ +- CONFIG += c++11 +- } else { +- QMAKE_CXXFLAGS += -std=c++0x +- } +-} ++CONFIG += c++14 + + VERSION = 3.7.5 + ++win32 { ++ QMAKE_CXXFLAGS += -std:c++latest ++} ++ + SOURCES += \ + ScintillaEdit.cpp \ + ScintillaDocument.cpp \ +@@ -48,6 +44,7 @@ + ../../src/EditModel.cxx \ + ../../src/Document.cxx \ + ../../src/Decoration.cxx \ ++ ../../src/DBCS.cxx \ + ../../src/ContractionState.cxx \ + ../../src/CharClassify.cxx \ + ../../src/CellBuffer.cxx \ +diff -r 7e28cdba6d61 -r 7030530a9a0f qt/ScintillaEditBase/PlatQt.cpp +--- a/qt/ScintillaEditBase/PlatQt.cpp Sun Jun 11 14:08:43 2017 +1000 ++++ b/qt/ScintillaEditBase/PlatQt.cpp Mon Jun 12 11:49:56 2017 +1000 +@@ -10,6 +10,7 @@ + + #include "PlatQt.h" + #include "Scintilla.h" ++#include "DBCS.h" + #include "FontQuality.h" + + #include +@@ -489,7 +490,7 @@ + // DBCS + int ui = 0; + for (int i=0; ihasFocus() : false; +-} +- + PRectangle Window::GetPosition() + { + // Before any size allocated pretend its 1000 wide so not scrolled +@@ -725,12 +715,6 @@ + } + } + +-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 @@ + 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 @@ + } + } + +- +-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(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 -r 7e28cdba6d61 -r 7030530a9a0f qt/ScintillaEditBase/PlatQt.h +--- a/qt/ScintillaEditBase/PlatQt.h Sun Jun 11 14:08:43 2017 +1000 ++++ b/qt/ScintillaEditBase/PlatQt.h Mon Jun 12 11:49:56 2017 +1000 +@@ -106,7 +106,6 @@ + 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 -r 7e28cdba6d61 -r 7030530a9a0f qt/ScintillaEditBase/ScintillaEditBase.pro +--- a/qt/ScintillaEditBase/ScintillaEditBase.pro Sun Jun 11 14:08:43 2017 +1000 ++++ b/qt/ScintillaEditBase/ScintillaEditBase.pro Mon Jun 12 11:49:56 2017 +1000 +@@ -10,18 +10,14 @@ + TARGET = ScintillaEditBase + TEMPLATE = lib + CONFIG += lib_bundle +- +-unix { +- # requires C++11 support +- greaterThan(QT_MAJOR_VERSION, 4){ +- CONFIG += c++11 +- } else { +- QMAKE_CXXFLAGS += -std=c++0x +- } +-} ++CONFIG += c++14 + + VERSION = 3.7.5 + ++win32 { ++ QMAKE_CXXFLAGS += -std:c++latest ++} ++ + SOURCES += \ + PlatQt.cpp \ + ScintillaQt.cpp \ +@@ -46,6 +42,7 @@ + ../../src/EditModel.cxx \ + ../../src/Document.cxx \ + ../../src/Decoration.cxx \ ++ ../../src/DBCS.cxx \ + ../../src/ContractionState.cxx \ + ../../src/CharClassify.cxx \ + ../../src/CellBuffer.cxx \ +diff -r 7e28cdba6d61 -r 7030530a9a0f qt/ScintillaEditPy/ScintillaEditPy.pro +--- a/qt/ScintillaEditPy/ScintillaEditPy.pro Sun Jun 11 14:08:43 2017 +1000 ++++ b/qt/ScintillaEditPy/ScintillaEditPy.pro Mon Jun 12 11:49:56 2017 +1000 +@@ -6,21 +6,14 @@ + + # Clear debug & release so that sepbuild.pri can set one or the other + CONFIG -= debug release ++CONFIG += c++14 + + include(sepbuild.pri) + + VERSION = $$SCINTILLA_VERSION + +-unix { +- # requires C++11 support +- greaterThan(QT_MAJOR_VERSION, 4){ +- CONFIG += c++11 +- } else { +- QMAKE_CXXFLAGS += -std=c++0x -Wno-deprecated-declarations +- } +-} +- + win32 { ++ QMAKE_CXXFLAGS += -std:c++latest + DebugBuild { + TARGET_EXT = _d.pyd + } +diff -r 7e28cdba6d61 -r 7030530a9a0f scripts/HeaderOrder.txt +--- a/scripts/HeaderOrder.txt Sun Jun 11 14:08:43 2017 +1000 ++++ b/scripts/HeaderOrder.txt Mon Jun 12 11:49:56 2017 +1000 +@@ -129,6 +129,7 @@ + #include "CaseConvert.h" + #include "UniConversion.h" + #include "UnicodeFromUTF8.h" ++#include "DBCS.h" + #include "Selection.h" + #include "PositionCache.h" + #include "FontQuality.h" +diff -r 7e28cdba6d61 -r 7030530a9a0f src/DBCS.cxx +--- /dev/null Thu Jan 01 00:00:00 1970 +0000 ++++ b/src/DBCS.cxx Mon Jun 12 11:49:56 2017 +1000 +@@ -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 ++// 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(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 -r 7e28cdba6d61 -r 7030530a9a0f src/DBCS.h +--- /dev/null Thu Jan 01 00:00:00 1970 +0000 ++++ b/src/DBCS.h Mon Jun 12 11:49:56 2017 +1000 +@@ -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 ++// 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 -r 7e28cdba6d61 -r 7030530a9a0f src/Document.cxx +--- a/src/Document.cxx Sun Jun 11 14:08:43 2017 +1000 ++++ b/src/Document.cxx Mon Jun 12 11:49:56 2017 +1000 +@@ -564,7 +564,7 @@ + } + + 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 -r 7e28cdba6d61 -r 7030530a9a0f src/Editor.cxx +--- a/src/Editor.cxx Sun Jun 11 14:08:43 2017 +1000 ++++ b/src/Editor.cxx Mon Jun 12 11:49:56 2017 +1000 +@@ -888,10 +888,10 @@ + 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::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 @@ + } 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 @@ + 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 @@ + } + } 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 @@ + 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 @@ + } 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 @@ + } + 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 @@ + } + } 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 @@ + const Sci::Line lineDocTop = cs.DocFromDisplay(topLine); + const int subLineTop = topLine - cs.DisplayFromDoc(lineDocTop); + if (ws == 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 @@ + + if (wrapOccurred) { + SetScrollBars(); +- SetTopLine(Platform::Clamp(goodTopLine, 0, MaxScrollPos())); ++ SetTopLine(Sci::clamp(goodTopLine, 0, MaxScrollPos())); + SetVerticalScrollPos(); + } + +@@ -1816,7 +1816,7 @@ + // 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 @@ + 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 @@ + } 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(pt.y) + direction * (vs.lineHeight * LinesToScroll())), +@@ -3209,6 +3209,14 @@ + + namespace { + ++short HighShortFromLong(long x) { ++ return static_cast(x >> 16); ++} ++ ++short LowShortFromLong(long x) { ++ return static_cast(x & 0xffff); ++} ++ + unsigned int WithExtends(unsigned int iMessage) { + switch (iMessage) { + case SCI_CHARLEFT: return SCI_CHARLEFTEXTEND; +@@ -4470,30 +4478,27 @@ + 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 @@ + // When scrolling, allow less time to ensure responsive + const double secondsAllowed = scrolling ? 0.005 : 0.02; + +- const Sci::Line linesToStyle = Platform::Clamp(static_cast(secondsAllowed / pdoc->durationStyleOneLine), ++ const Sci::Line linesToStyle = Sci::clamp(static_cast(secondsAllowed / pdoc->durationStyleOneLine), + 10, 0x10000); + const Sci::Line stylingMaxLine = std::min( + static_cast(pdoc->LineFromPosition(pdoc->GetEndStyled()) + linesToStyle), +@@ -5426,18 +5431,18 @@ + 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 @@ + return pdoc->MovePositionOutsideChar(static_cast(wParam) + 1, 1, true); + + case SCI_POSITIONRELATIVE: +- return Platform::Clamp(pdoc->GetRelativePosition(static_cast(wParam), static_cast(lParam)), 0, pdoc->Length()); ++ return Sci::clamp(pdoc->GetRelativePosition(static_cast(wParam), static_cast(lParam)), 0, pdoc->Length()); + + case SCI_LINESCROLL: + ScrollTo(topLine + static_cast(lParam)); +@@ -7290,13 +7295,13 @@ + return vs.caretWidth; + + case SCI_ASSIGNCMDKEY: +- kmap.AssignCmdKey(Platform::LowShortFromLong(static_cast(wParam)), +- Platform::HighShortFromLong(static_cast(wParam)), static_cast(lParam)); ++ kmap.AssignCmdKey(LowShortFromLong(static_cast(wParam)), ++ HighShortFromLong(static_cast(wParam)), static_cast(lParam)); + break; + + case SCI_CLEARCMDKEY: +- kmap.AssignCmdKey(Platform::LowShortFromLong(static_cast(wParam)), +- Platform::HighShortFromLong(static_cast(wParam)), SCI_NULL); ++ kmap.AssignCmdKey(LowShortFromLong(static_cast(wParam)), ++ HighShortFromLong(static_cast(wParam)), SCI_NULL); + break; + + case SCI_CLEARALLCMDKEYS: +diff -r 7e28cdba6d61 -r 7030530a9a0f src/Position.h +--- a/src/Position.h Sun Jun 11 14:08:43 2017 +1000 ++++ b/src/Position.h Mon Jun 12 11:49:56 2017 +1000 +@@ -25,6 +25,14 @@ + + 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 -r 7e28cdba6d61 -r 7030530a9a0f src/ViewStyle.cxx +--- a/src/ViewStyle.cxx Sun Jun 11 14:08:43 2017 +1000 ++++ b/src/ViewStyle.cxx Mon Jun 12 11:49:56 2017 +1000 +@@ -460,7 +460,7 @@ + } + + 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 -r 7e28cdba6d61 -r 7030530a9a0f win32/PlatWin.cxx +--- a/win32/PlatWin.cxx Sun Jun 11 14:08:43 2017 +1000 ++++ b/win32/PlatWin.cxx Mon Jun 12 11:49:56 2017 +1000 +@@ -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 @@ + namespace Scintilla { + #endif + +-Point Point::FromLong(long lpoint) { +- return Point(static_cast(LOWORD(lpoint)), static_cast(HIWORD(lpoint))); +-} +- + static RECT RectFromPRectangle(PRectangle prc) { + RECT rc = {static_cast(prc.left), static_cast(prc.top), + static_cast(prc.right), static_cast(prc.bottom)}; +@@ -558,7 +555,6 @@ + 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 @@ + return static_cast(tm.tmInternalLeading); + } + +-XYPOSITION SurfaceGDI::ExternalLeading(Font &font_) { +- SetFont(font_); +- TEXTMETRIC tm; +- ::GetTextMetrics(hdc, &tm); +- return static_cast(tm.tmExternalLeading); +-} +- + XYPOSITION SurfaceGDI::Height(Font &font_) { + SetFont(font_); + TEXTMETRIC tm; +@@ -1121,7 +1110,6 @@ + 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 @@ + int ui = 0; + for (int i=0; i(wid), &rc); +@@ -1952,10 +1931,6 @@ + } + } + +-void Window::SetTitle(const char *s) { +- ::SetWindowTextA(static_cast(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 @@ + 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(::SendMessage(static_cast(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(::SendMessage(static_cast(w), msg, wParam, +- reinterpret_cast(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(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 @@ + } + } + +-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); +diff -r 7e28cdba6d61 -r 7030530a9a0f win32/ScintillaWin.cxx +--- a/win32/ScintillaWin.cxx Sun Jun 11 14:08:43 2017 +1000 ++++ b/win32/ScintillaWin.cxx Mon Jun 12 11:49:56 2017 +1000 +@@ -156,6 +156,14 @@ + return Point::FromInts(pt.x, pt.y); + } + ++static Point PointFromLong(long lpoint) { ++ return Point(static_cast(LOWORD(lpoint)), static_cast(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 @@ + ::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(lParam)), ::GetMessageTime(), ++ ButtonDown(PointFromLong(static_cast(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(lParam)); ++ const Point pt = PointFromLong(static_cast(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 @@ + 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 @@ + return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam); + + case WM_LBUTTONUP: +- ButtonUp(Point::FromLong(static_cast(lParam)), ++ ButtonUp(PointFromLong(static_cast(lParam)), + ::GetMessageTime(), + (wParam & MK_CONTROL) != 0); + break; + + case WM_RBUTTONDOWN: { + ::SetFocus(MainHWND()); +- Point pt = Point::FromLong(static_cast(lParam)); ++ Point pt = PointFromLong(static_cast(lParam)); + if (!PointInSelection(pt)) { + CancelModes(); +- SetEmptySelection(PositionFromLocation(Point::FromLong(static_cast(lParam)))); ++ SetEmptySelection(PositionFromLocation(PointFromLong(static_cast(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 @@ + //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(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 @@ + } + + case WM_CONTEXTMENU: { +- Point pt = Point::FromLong(static_cast(lParam)); ++ Point pt = PointFromLong(static_cast(lParam)); + POINT rpt = {static_cast(pt.x), static_cast(pt.y)}; + ::ScreenToClient(MainHWND(), &rpt); + const Point ptClient = PointFromPOINT(rpt); +@@ -3350,7 +3358,7 @@ + return 0; + } else if (iMessage == WM_LBUTTONDOWN) { + // This does not fire due to the hit test code +- sciThis->ct.MouseClick(Point::FromLong(static_cast(lParam))); ++ sciThis->ct.MouseClick(PointFromLong(static_cast(lParam))); + sciThis->CallTipClick(); + return 0; + } else if (iMessage == WM_SETCURSOR) { +diff -r 7e28cdba6d61 -r 7030530a9a0f win32/makefile +--- a/win32/makefile Sun Jun 11 14:08:43 2017 +1000 ++++ b/win32/makefile Mon Jun 12 11:49:56 2017 +1000 +@@ -13,7 +13,7 @@ + LDMINGW = -Wl,--enable-runtime-pseudo-reloc-v2 -Wl,--add-stdcall-alias + LIBSMINGW = -lstdc++ + STRIPOPTION = -s +-CXXSTD = gnu++0x ++CXXSTD = gnu++17 + endif + + .SUFFIXES: .cxx +@@ -83,6 +83,7 @@ + CharacterSet.o \ + CharClassify.o \ + ContractionState.o \ ++ DBCS.o \ + Decoration.o \ + Document.o \ + EditModel.o \ +diff -r 7e28cdba6d61 -r 7030530a9a0f win32/scintilla.mak +--- a/win32/scintilla.mak Sun Jun 11 14:08:43 2017 +1000 ++++ b/win32/scintilla.mak Mon Jun 12 11:49:56 2017 +1000 +@@ -25,7 +25,7 @@ + !ENDIF + + CRTFLAGS=-D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1 -D_CRT_SECURE_NO_DEPRECATE=1 -D_SCL_SECURE_NO_WARNINGS=1 $(XP_DEFINE) +-CXXFLAGS=-Zi -TP -MP -W4 -EHsc $(CRTFLAGS) ++CXXFLAGS=-Zi -TP -MP -W4 -EHsc -std:c++latest $(CRTFLAGS) + CXXDEBUG=-Od -MTd -DDEBUG + CXXNDEBUG=-O1 -MT -DNDEBUG -GL + NAME=-Fo +@@ -75,6 +75,7 @@ + $(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 \ diff --git a/src/scintilla_backports/6314_af83baede430.patch b/src/scintilla_backports/6314_af83baede430.patch new file mode 100644 index 00000000..ef028826 --- /dev/null +++ b/src/scintilla_backports/6314_af83baede430.patch @@ -0,0 +1,535 @@ +# HG changeset patch +# User Neil +# Date 1497239386 -36000 +# Node ID af83baede4309993b2ef0aa4f30968148855bc11 +# Parent 2d4cb83e92975d4b8d578f29807031fcf532605a +Simplify mouse and keyboard handling by only retaining the 'WithModifiers" form. +All events include a set of keyboard modifier flags. +Older calls that passed individual parameters for each key were removed. + +diff -r 2d4cb83e9297 -r af83baede430 cocoa/ScintillaCocoa.mm +--- a/cocoa/ScintillaCocoa.mm Mon Jun 12 12:49:30 2017 +1000 ++++ b/cocoa/ScintillaCocoa.mm Mon Jun 12 13:49:46 2017 +1000 +@@ -2262,7 +2262,9 @@ + + // Mouse location is given in screen coordinates and might also be outside of our bounds. + Point location = ConvertPoint(event.locationInWindow); +- ButtonMove(location); ++ ButtonMoveWithModifiers(location, ++ (int)(event.timestamp * 1000), ++ TranslateModifierFlags(event.modifierFlags)); + } + } + +@@ -2276,22 +2278,16 @@ + + void ScintillaCocoa::MouseDown(NSEvent *event) { + Point location = ConvertPoint(event.locationInWindow); +- NSTimeInterval time = event.timestamp; +- bool command = (event.modifierFlags & NSCommandKeyMask) != 0; +- bool shift = (event.modifierFlags & NSShiftKeyMask) != 0; +- bool alt = (event.modifierFlags & NSAlternateKeyMask) != 0; +- +- ButtonDown(Point(location.x, location.y), (int)(time * 1000), shift, command, alt); ++ ButtonDownWithModifiers(location, ++ (int)(event.timestamp * 1000), ++ TranslateModifierFlags(event.modifierFlags)); + } + + void ScintillaCocoa::RightMouseDown(NSEvent *event) { + Point location = ConvertPoint(event.locationInWindow); +- NSTimeInterval time = event.timestamp; +- bool command = (event.modifierFlags & NSCommandKeyMask) != 0; +- bool shift = (event.modifierFlags & NSShiftKeyMask) != 0; +- bool alt = (event.modifierFlags & NSAlternateKeyMask) != 0; +- +- RightButtonDownWithModifiers(Point(location.x, location.y), (int)(time * 1000), ModifierFlags(shift, command, alt)); ++ RightButtonDownWithModifiers(location, ++ (int)(event.timestamp * 1000), ++ TranslateModifierFlags(event.modifierFlags)); + } + + //-------------------------------------------------------------------------------------------------- +@@ -2299,16 +2295,17 @@ + void ScintillaCocoa::MouseMove(NSEvent *event) { + lastMouseEvent = event; + +- ButtonMoveWithModifiers(ConvertPoint(event.locationInWindow), TranslateModifierFlags(event.modifierFlags)); ++ ButtonMoveWithModifiers(ConvertPoint(event.locationInWindow), ++ (int)(event.timestamp * 1000), ++ TranslateModifierFlags(event.modifierFlags)); + } + + //-------------------------------------------------------------------------------------------------- + + void ScintillaCocoa::MouseUp(NSEvent *event) { +- NSTimeInterval time = event.timestamp; +- bool control = (event.modifierFlags & NSControlKeyMask) != 0; +- +- ButtonUp(ConvertPoint(event.locationInWindow), (int)(time * 1000), control); ++ ButtonUpWithModifiers(ConvertPoint(event.locationInWindow), ++ (int)(event.timestamp * 1000), ++ TranslateModifierFlags(event.modifierFlags)); + } + + //-------------------------------------------------------------------------------------------------- +@@ -2344,7 +2341,7 @@ + } + + void ScintillaCocoa::DeleteBackward() { +- KeyDown(SCK_BACK, false, false, false, nil); ++ KeyDownWithModifiers(SCK_BACK, 0, nil); + } + + void ScintillaCocoa::Cut() { +diff -r 2d4cb83e9297 -r af83baede430 gtk/ScintillaGTK.cxx +--- a/gtk/ScintillaGTK.cxx Mon Jun 12 12:49:30 2017 +1000 ++++ b/gtk/ScintillaGTK.cxx Mon Jun 12 13:49:46 2017 +1000 +@@ -1775,7 +1775,11 @@ + // If mouse released on scroll bar then the position is relative to the + // scrollbar, not the drawing window so just repeat the most recent point. + pt = sciThis->ptMouseLast; +- sciThis->ButtonUp(pt, event->time, (event->state & GDK_CONTROL_MASK) != 0); ++ const int modifiers = ModifierFlags( ++ (event->state & GDK_SHIFT_MASK) != 0, ++ (event->state & GDK_CONTROL_MASK) != 0, ++ (event->state & modifierTranslated(sciThis->rectangularSelectionModifier)) != 0); ++ sciThis->ButtonUpWithModifiers(pt, event->time, modifiers); + } + } catch (...) { + sciThis->errorStatus = SC_STATUS_FAILURE; +@@ -1912,10 +1916,11 @@ + //Platform::DebugPrintf("Move %x %x %d %c %d %d\n", + // sciThis,event->window,event->time,event->is_hint? 'h' :'.', x, y); + Point pt(x, y); +- int modifiers = ((event->state & GDK_SHIFT_MASK) != 0 ? SCI_SHIFT : 0) | +- ((event->state & GDK_CONTROL_MASK) != 0 ? SCI_CTRL : 0) | +- ((event->state & modifierTranslated(sciThis->rectangularSelectionModifier)) != 0 ? SCI_ALT : 0); +- sciThis->ButtonMoveWithModifiers(pt, modifiers); ++ const int modifiers = ModifierFlags( ++ (event->state & GDK_SHIFT_MASK) != 0, ++ (event->state & GDK_CONTROL_MASK) != 0, ++ (event->state & modifierTranslated(sciThis->rectangularSelectionModifier)) != 0); ++ sciThis->ButtonMoveWithModifiers(pt, event->time, modifiers); + } catch (...) { + sciThis->errorStatus = SC_STATUS_FAILURE; + } +diff -r 2d4cb83e9297 -r af83baede430 qt/ScintillaEditBase/ScintillaEditBase.cpp +--- a/qt/ScintillaEditBase/ScintillaEditBase.cpp Mon Jun 12 12:49:30 2017 +1000 ++++ b/qt/ScintillaEditBase/ScintillaEditBase.cpp Mon Jun 12 13:49:46 2017 +1000 +@@ -241,7 +241,9 @@ + bool alt = QApplication::keyboardModifiers() & Qt::AltModifier; + + bool consumed = false; +- bool added = sqt->KeyDown(key, shift, ctrl, alt, &consumed) != 0; ++ bool added = sqt->KeyDownWithModifiers(key, ++ ScintillaQt::ModifierFlags(shift, ctrl, alt), ++ &consumed) != 0; + if (!consumed) + consumed = added; + +@@ -314,24 +316,19 @@ + bool alt = QApplication::keyboardModifiers() & Qt::AltModifier; + #endif + +- sqt->ButtonDown(pos, time.elapsed(), shift, ctrl, alt); ++ sqt->ButtonDownWithModifiers(pos, time.elapsed(), ScintillaQt::ModifierFlags(shift, ctrl, alt)); + } + + if (event->button() == Qt::RightButton) { +- bool shift = QApplication::keyboardModifiers() & Qt::ShiftModifier; +- bool ctrl = QApplication::keyboardModifiers() & Qt::ControlModifier; +- bool alt = QApplication::keyboardModifiers() & Qt::AltModifier; +- +- sqt->RightButtonDownWithModifiers(pos, time.elapsed(), ScintillaQt::ModifierFlags(shift, ctrl, alt)); ++ sqt->RightButtonDownWithModifiers(pos, time.elapsed(), ModifiersOfKeyboard()); + } + } + + void ScintillaEditBase::mouseReleaseEvent(QMouseEvent *event) + { + Point point = PointFromQPoint(event->pos()); +- bool ctrl = QApplication::keyboardModifiers() & Qt::ControlModifier; + if (event->button() == Qt::LeftButton) +- sqt->ButtonUp(point, time.elapsed(), ctrl); ++ sqt->ButtonUpWithModifiers(point, time.elapsed(), ModifiersOfKeyboard()); + + int pos = send(SCI_POSITIONFROMPOINT, point.x, point.y); + int line = send(SCI_LINEFROMPOSITION, pos); +@@ -361,9 +358,9 @@ + bool alt = QApplication::keyboardModifiers() & Qt::AltModifier; + #endif + +- int modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | (alt ? SCI_ALT : 0); ++ const int modifiers = ScintillaQt::ModifierFlags(shift, ctrl, alt); + +- sqt->ButtonMoveWithModifiers(pos, modifiers); ++ sqt->ButtonMoveWithModifiers(pos, time.elapsed(), modifiers); + } + + void ScintillaEditBase::contextMenuEvent(QContextMenuEvent *event) +@@ -794,3 +791,12 @@ + { + emit command(wParam, lParam); + } ++ ++int ScintillaEditBase::ModifiersOfKeyboard() const ++{ ++ const bool shift = QApplication::keyboardModifiers() & Qt::ShiftModifier; ++ const bool ctrl = QApplication::keyboardModifiers() & Qt::ControlModifier; ++ const bool alt = QApplication::keyboardModifiers() & Qt::AltModifier; ++ ++ return ScintillaQt::ModifierFlags(shift, ctrl, alt); ++} +diff -r 2d4cb83e9297 -r af83baede430 qt/ScintillaEditBase/ScintillaEditBase.h +--- a/qt/ScintillaEditBase/ScintillaEditBase.h Mon Jun 12 12:49:30 2017 +1000 ++++ b/qt/ScintillaEditBase/ScintillaEditBase.h Mon Jun 12 13:49:46 2017 +1000 +@@ -147,6 +147,7 @@ + static bool IsHangul(const QChar qchar); + void MoveImeCarets(int offset); + void DrawImeIndicator(int indicator, int len); ++ int ModifiersOfKeyboard() const; + }; + + #ifdef SCI_NAMESPACE +diff -r 2d4cb83e9297 -r af83baede430 src/Editor.cxx +--- a/src/Editor.cxx Mon Jun 12 12:49:30 2017 +1000 ++++ b/src/Editor.cxx Mon Jun 12 13:49:46 2017 +1000 +@@ -2340,10 +2340,6 @@ + NotifyParent(scn); + } + +-void Editor::NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt) { +- NotifyDoubleClick(pt, ModifierFlags(shift, ctrl, alt)); +-} +- + void Editor::NotifyHotSpotDoubleClicked(Sci::Position position, int modifiers) { + SCNotification scn = {}; + scn.nmhdr.code = SCN_HOTSPOTDOUBLECLICK; +@@ -2352,10 +2348,6 @@ + NotifyParent(scn); + } + +-void Editor::NotifyHotSpotDoubleClicked(Sci::Position position, bool shift, bool ctrl, bool alt) { +- NotifyHotSpotDoubleClicked(position, ModifierFlags(shift, ctrl, alt)); +-} +- + void Editor::NotifyHotSpotClicked(Sci::Position position, int modifiers) { + SCNotification scn = {}; + scn.nmhdr.code = SCN_HOTSPOTCLICK; +@@ -2364,10 +2356,6 @@ + NotifyParent(scn); + } + +-void Editor::NotifyHotSpotClicked(Sci::Position position, bool shift, bool ctrl, bool alt) { +- NotifyHotSpotClicked(position, ModifierFlags(shift, ctrl, alt)); +-} +- + void Editor::NotifyHotSpotReleaseClick(Sci::Position position, int modifiers) { + SCNotification scn = {}; + scn.nmhdr.code = SCN_HOTSPOTRELEASECLICK; +@@ -2376,10 +2364,6 @@ + NotifyParent(scn); + } + +-void Editor::NotifyHotSpotReleaseClick(Sci::Position position, bool shift, bool ctrl, bool alt) { +- NotifyHotSpotReleaseClick(position, ModifierFlags(shift, ctrl, alt)); +-} +- + bool Editor::NotifyUpdateUI() { + if (needUpdateUI) { + SCNotification scn = {}; +@@ -2410,10 +2394,6 @@ + } + } + +-void Editor::NotifyIndicatorClick(bool click, Sci::Position position, bool shift, bool ctrl, bool alt) { +- NotifyIndicatorClick(click, position, ModifierFlags(shift, ctrl, alt)); +-} +- + bool Editor::NotifyMarginClick(Point pt, int modifiers) { + const int marginClicked = vs.MarginFromLocation(pt); + if ((marginClicked >= 0) && vs.ms[marginClicked].sensitive) { +@@ -2452,10 +2432,6 @@ + } + } + +-bool Editor::NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt) { +- return NotifyMarginClick(pt, ModifierFlags(shift, ctrl, alt)); +-} +- + bool Editor::NotifyMarginRightClick(Point pt, int modifiers) { + int marginRightClicked = vs.MarginFromLocation(pt); + if ((marginRightClicked >= 0) && vs.ms[marginRightClicked].sensitive) { +@@ -3882,10 +3858,6 @@ + } + } + +-int Editor::KeyDown(int key, bool shift, bool ctrl, bool alt, bool *consumed) { +- return KeyDownWithModifiers(key, ModifierFlags(shift, ctrl, alt), consumed); +-} +- + void Editor::Indent(bool forwards) { + UndoGroup ug(pdoc); + for (size_t r=0; rStyleIndexAt(position)].hotspot; + } +@@ -4703,7 +4671,7 @@ + return hotspot; + } + +-void Editor::ButtonMoveWithModifiers(Point pt, int modifiers) { ++void Editor::ButtonMoveWithModifiers(Point pt, unsigned int, int modifiers) { + if ((ptMouseLast.x != pt.x) || (ptMouseLast.y != pt.y)) { + DwellEnd(true); + } +@@ -4830,11 +4798,7 @@ + } + } + +-void Editor::ButtonMove(Point pt) { +- ButtonMoveWithModifiers(pt, 0); +-} +- +-void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) { ++void Editor::ButtonUpWithModifiers(Point pt, unsigned int curTime, int modifiers) { + //Platform::DebugPrintf("ButtonUp %d %d\n", HaveMouseCapture(), inDragDrop); + SelectionPosition newPos = SPositionFromLocation(pt, false, false, + AllowVirtualSpace(virtualSpaceOptions, sel.IsRectangular())); +@@ -4851,7 +4815,7 @@ + hotSpotClickPos = INVALID_POSITION; + SelectionPosition newCharPos = SPositionFromLocation(pt, false, true, false); + newCharPos = MovePositionOutsideChar(newCharPos, -1); +- NotifyHotSpotReleaseClick(newCharPos.Position(), ctrl ? SCI_CTRL : 0); ++ NotifyHotSpotReleaseClick(newCharPos.Position(), modifiers & SCI_CTRL); + } + if (HaveMouseCapture()) { + if (PointInSelMargin(pt)) { +@@ -4872,7 +4836,7 @@ + if (selStart < selEnd) { + if (drag.Length()) { + const int length = static_cast(drag.Length()); +- if (ctrl) { ++ if (modifiers & SCI_CTRL) { + const Sci::Position lengthInserted = pdoc->InsertString( + newPos.Position(), drag.Data(), length); + if (lengthInserted > 0) { +@@ -4929,7 +4893,7 @@ + void Editor::Tick() { + if (HaveMouseCapture()) { + // Auto scroll +- ButtonMove(ptMouseLast); ++ ButtonMoveWithModifiers(ptMouseLast, 0, 0); + } + if (caret.period > 0) { + timer.ticksToWait -= timer.tickSize; +@@ -4996,7 +4960,7 @@ + break; + case tickScroll: + // Auto scroll +- ButtonMove(ptMouseLast); ++ ButtonMoveWithModifiers(ptMouseLast, 0, 0); + break; + case tickWiden: + SetScrollBars(); +diff -r 2d4cb83e9297 -r af83baede430 src/Editor.h +--- a/src/Editor.h Mon Jun 12 12:49:30 2017 +1000 ++++ b/src/Editor.h Mon Jun 12 13:49:46 2017 +1000 +@@ -425,19 +425,13 @@ + void NotifySavePoint(bool isSavePoint); + void NotifyModifyAttempt(); + virtual void NotifyDoubleClick(Point pt, int modifiers); +- virtual void NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt); + void NotifyHotSpotClicked(Sci::Position position, int modifiers); +- void NotifyHotSpotClicked(Sci::Position position, bool shift, bool ctrl, bool alt); + void NotifyHotSpotDoubleClicked(Sci::Position position, int modifiers); +- void NotifyHotSpotDoubleClicked(Sci::Position position, bool shift, bool ctrl, bool alt); + void NotifyHotSpotReleaseClick(Sci::Position position, int modifiers); +- void NotifyHotSpotReleaseClick(Sci::Position position, bool shift, bool ctrl, bool alt); + bool NotifyUpdateUI(); + void NotifyPainted(); + void NotifyIndicatorClick(bool click, Sci::Position position, int modifiers); +- void NotifyIndicatorClick(bool click, Sci::Position position, bool shift, bool ctrl, bool alt); + bool NotifyMarginClick(Point pt, int modifiers); +- bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt); + bool NotifyMarginRightClick(Point pt, int modifiers); + void NotifyNeedShown(Sci::Position pos, Sci::Position len); + void NotifyDwelling(Point pt, bool state); +@@ -476,7 +470,6 @@ + virtual int KeyCommand(unsigned int iMessage); + virtual int KeyDefault(int /* key */, int /*modifiers*/); + int KeyDownWithModifiers(int key, int modifiers, bool *consumed); +- int KeyDown(int key, bool shift, bool ctrl, bool alt, bool *consumed=0); + + void Indent(bool forwards); + +@@ -510,10 +503,8 @@ + void MouseLeave(); + virtual void ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers); + virtual void RightButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers); +- virtual void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt); +- void ButtonMoveWithModifiers(Point pt, int modifiers); +- void ButtonMove(Point pt); +- void ButtonUp(Point pt, unsigned int curTime, bool ctrl); ++ void ButtonMoveWithModifiers(Point pt, unsigned int curTime, int modifiers); ++ void ButtonUpWithModifiers(Point pt, unsigned int curTime, int modifiers); + + void Tick(); + bool Idle(); +diff -r 2d4cb83e9297 -r af83baede430 src/ScintillaBase.cxx +--- a/src/ScintillaBase.cxx Mon Jun 12 12:49:30 2017 +1000 ++++ b/src/ScintillaBase.cxx Mon Jun 12 13:49:46 2017 +1000 +@@ -537,10 +537,6 @@ + Editor::ButtonDownWithModifiers(pt, curTime, modifiers); + } + +-void ScintillaBase::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) { +- ButtonDownWithModifiers(pt, curTime, ModifierFlags(shift, ctrl, alt)); +-} +- + void ScintillaBase::RightButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers) { + CancelModes(); + Editor::RightButtonDownWithModifiers(pt, curTime, modifiers); +diff -r 2d4cb83e9297 -r af83baede430 src/ScintillaBase.h +--- a/src/ScintillaBase.h Mon Jun 12 12:49:30 2017 +1000 ++++ b/src/ScintillaBase.h Mon Jun 12 13:49:46 2017 +1000 +@@ -88,7 +88,6 @@ + void ContextMenu(Point pt); + + void ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers); +- void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt); + void RightButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers); + + void NotifyStyleToNeeded(Sci::Position endStyleNeeded); +diff -r 2d4cb83e9297 -r af83baede430 win32/ScintillaWin.cxx +--- a/win32/ScintillaWin.cxx Mon Jun 12 12:49:30 2017 +1000 ++++ b/win32/ScintillaWin.cxx Mon Jun 12 13:49:46 2017 +1000 +@@ -156,7 +156,7 @@ + return Point::FromInts(pt.x, pt.y); + } + +-static Point PointFromLong(long lpoint) { ++static Point PointFromLParam(sptr_t lpoint) { + return Point(static_cast(LOWORD(lpoint)), static_cast(HIWORD(lpoint))); + } + +@@ -305,6 +305,8 @@ + + bool DragThreshold(Point ptStart, Point ptNow) override; + void StartDrag() override; ++ static int MouseModifiers(uptr_t wParam); ++ + Sci::Position TargetAsUTF8(char *text); + void AddCharUTF16(wchar_t const *wcs, unsigned int wclen); + Sci::Position EncodedFromUTF8(char *utf8, char *encoded) const; +@@ -632,6 +634,12 @@ + SetDragPosition(SelectionPosition(Sci::invalidPosition)); + } + ++int ScintillaWin::MouseModifiers(uptr_t wParam) { ++ return ModifierFlags((wParam & MK_SHIFT) != 0, ++ (wParam & MK_CONTROL) != 0, ++ KeyboardIsKeyDown(VK_MENU)); ++} ++ + // Avoid warnings everywhere for old style casts by concentrating them here + static WORD LoWord(uptr_t l) { + return LOWORD(l); +@@ -1388,24 +1396,19 @@ + // KeyboardIsKeyDown(VK_CONTROL), + // KeyboardIsKeyDown(VK_MENU)); + ::SetFocus(MainHWND()); +- ButtonDown(PointFromLong(static_cast(lParam)), ::GetMessageTime(), +- (wParam & MK_SHIFT) != 0, +- (wParam & MK_CONTROL) != 0, +- KeyboardIsKeyDown(VK_MENU)); ++ ButtonDownWithModifiers(PointFromLParam(lParam), ::GetMessageTime(), ++ MouseModifiers(wParam)); + } + break; + + case WM_MOUSEMOVE: { +- const Point pt = PointFromLong(static_cast(lParam)); ++ const Point pt = PointFromLParam(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 + if (ptMouseLast.x != pt.x || ptMouseLast.y != pt.y) { + SetTrackMouseLeaveEvent(true); +- ButtonMoveWithModifiers(pt, +- ((wParam & MK_SHIFT) != 0 ? SCI_SHIFT : 0) | +- ((wParam & MK_CONTROL) != 0 ? SCI_CTRL : 0) | +- (KeyboardIsKeyDown(VK_MENU) ? SCI_ALT : 0)); ++ ButtonMoveWithModifiers(pt, ::GetMessageTime(), MouseModifiers(wParam)); + } + } + break; +@@ -1416,22 +1419,19 @@ + return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam); + + case WM_LBUTTONUP: +- ButtonUp(PointFromLong(static_cast(lParam)), +- ::GetMessageTime(), +- (wParam & MK_CONTROL) != 0); ++ ButtonUpWithModifiers(PointFromLParam(lParam), ++ ::GetMessageTime(), MouseModifiers(wParam)); + break; + + case WM_RBUTTONDOWN: { + ::SetFocus(MainHWND()); +- Point pt = PointFromLong(static_cast(lParam)); ++ Point pt = PointFromLParam(lParam); + if (!PointInSelection(pt)) { + CancelModes(); +- SetEmptySelection(PositionFromLocation(PointFromLong(static_cast(lParam)))); ++ SetEmptySelection(PositionFromLocation(PointFromLParam(lParam))); + } + +- RightButtonDownWithModifiers(pt, ::GetMessageTime(), ModifierFlags((wParam & MK_SHIFT) != 0, +- (wParam & MK_CONTROL) != 0, +- KeyboardIsKeyDown(VK_MENU))); ++ RightButtonDownWithModifiers(pt, ::GetMessageTime(), MouseModifiers(wParam)); + } + break; + +@@ -1494,10 +1494,10 @@ + case WM_KEYDOWN: { + //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(wParam)), +- KeyboardIsKeyDown(VK_SHIFT), ++ const int ret = KeyDownWithModifiers(KeyTranslate(static_cast(wParam)), ++ ModifierFlags(KeyboardIsKeyDown(VK_SHIFT), + KeyboardIsKeyDown(VK_CONTROL), +- KeyboardIsKeyDown(VK_MENU), ++ KeyboardIsKeyDown(VK_MENU)), + &lastKeyDownConsumed); + if (!ret && !lastKeyDownConsumed) { + return ::DefWindowProc(MainHWND(), iMessage, wParam, lParam); +@@ -1581,7 +1581,7 @@ + } + + case WM_CONTEXTMENU: { +- Point pt = PointFromLong(static_cast(lParam)); ++ Point pt = PointFromLParam(lParam); + POINT rpt = {static_cast(pt.x), static_cast(pt.y)}; + ::ScreenToClient(MainHWND(), &rpt); + const Point ptClient = PointFromPOINT(rpt); +@@ -3358,7 +3358,7 @@ + return 0; + } else if (iMessage == WM_LBUTTONDOWN) { + // This does not fire due to the hit test code +- sciThis->ct.MouseClick(PointFromLong(static_cast(lParam))); ++ sciThis->ct.MouseClick(PointFromLParam(lParam)); + sciThis->CallTipClick(); + return 0; + } else if (iMessage == WM_SETCURSOR) { diff --git a/src/scintilla_backports/6327_95346e626cf8.patch b/src/scintilla_backports/6327_95346e626cf8.patch index 608b9b80..2bbd03e4 100644 --- a/src/scintilla_backports/6327_95346e626cf8.patch +++ b/src/scintilla_backports/6327_95346e626cf8.patch @@ -989,12 +989,12 @@ diff -r c15f84c11e17 -r 95346e626cf8 src/Editor.cxx @@ -892,10 +902,12 @@ 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))); + return SelectionPosition(static_cast( + 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))); + return SelectionPosition(static_cast( + pdoc->LineEnd(cs.DocFromDisplay(lineDisplay)))); @@ -1684,8 +1684,8 @@ diff -r c15f84c11e17 -r 95346e626cf8 src/Editor.cxx return pdoc->MovePositionOutsideChar(static_cast(wParam) + 1, 1, true); case SCI_POSITIONRELATIVE: -- return Platform::Clamp(pdoc->GetRelativePosition(static_cast(wParam), static_cast(lParam)), 0, pdoc->Length()); -+ return Platform::Clamp(static_cast(pdoc->GetRelativePosition(static_cast(wParam), static_cast(lParam))), +- return Sci::Clamp(pdoc->GetRelativePosition(static_cast(wParam), static_cast(lParam)), 0, pdoc->Length()); ++ return Sci::Clamp(static_cast(pdoc->GetRelativePosition(static_cast(wParam), static_cast(lParam))), + 0, static_cast(pdoc->Length())); case SCI_LINESCROLL: diff --git a/src/scintilla_backports/6425_73343682cbda.patch b/src/scintilla_backports/6425_73343682cbda.patch index 80225666..36445a10 100644 --- a/src/scintilla_backports/6425_73343682cbda.patch +++ b/src/scintilla_backports/6425_73343682cbda.patch @@ -68,9 +68,10 @@ diff -r 5246ca55cf24 -r 73343682cbda doc/ScintillaDoc.html diff -r 5246ca55cf24 -r 73343682cbda include/Scintilla.h --- a/include/Scintilla.h Wed Jan 10 10:04:03 2018 +1100 +++ b/include/Scintilla.h Tue Dec 19 15:00:40 2017 +1100 -@@ -1103,5 +1103,12 @@ +@@ -1103,6 +1103,13 @@ #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 @@ -84,8 +85,9 @@ diff -r 5246ca55cf24 -r 73343682cbda include/Scintilla.h diff -r 5246ca55cf24 -r 73343682cbda include/Scintilla.iface --- a/include/Scintilla.iface Wed Jan 10 10:04:03 2018 +1100 +++ b/include/Scintilla.iface Tue Dec 19 15:00:40 2017 +1100 -@@ -4861,9 +4861,18 @@ +@@ -4861,10 +4861,19 @@ 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, but some arguments to SCI_SETTECHNOLOGY are provisional. - -- cgit v1.2.3