Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Wed, 01 Aug 2018 12:51:52 UTC Commit: 3fa7576e13e129900a6e0acbd5460237f9a1b614 https://github.com/geany/geany/commit/3fa7576e13e129900a6e0acbd5460237f9a1b6...
Log Message: ----------- Update Scintilla to version 3.10.0
Scintilla 3.7.6/4.0.0 deprecated `SCE_*STYLEBITS*` and moved it to deprecated features that require a build-time flag to be available.
Thus, drop use of those (as they are now no-ops anyway) and bump the ABI (so plugins depending on those don't build mistakenly load) and API (so a developer can guard use of those if wanted) version accordingly.
Modified Paths: -------------- plugins/export.c scintilla/License.txt scintilla/Makefile.am scintilla/gtk/Converter.h scintilla/gtk/PlatGTK.cxx scintilla/gtk/ScintillaGTK.cxx scintilla/gtk/ScintillaGTK.h scintilla/gtk/ScintillaGTKAccessible.cxx scintilla/gtk/ScintillaGTKAccessible.h scintilla/gtk/scintilla-marshal.c scintilla/gtk/scintilla-marshal.h scintilla/gtk/scintilla-marshal.list scintilla/include/ILexer.h scintilla/include/ILoader.h scintilla/include/Platform.h scintilla/include/SciLexer.h scintilla/include/Sci_Position.h scintilla/include/Scintilla.h scintilla/include/Scintilla.iface scintilla/lexers/LexAbaqus.cxx scintilla/lexers/LexAda.cxx scintilla/lexers/LexAsm.cxx scintilla/lexers/LexBash.cxx scintilla/lexers/LexBasic.cxx scintilla/lexers/LexBatch.cxx scintilla/lexers/LexCOBOL.cxx scintilla/lexers/LexCPP.cxx scintilla/lexers/LexCSS.cxx scintilla/lexers/LexCaml.cxx scintilla/lexers/LexCmake.cxx scintilla/lexers/LexCoffeeScript.cxx scintilla/lexers/LexD.cxx scintilla/lexers/LexDiff.cxx scintilla/lexers/LexErlang.cxx scintilla/lexers/LexForth.cxx scintilla/lexers/LexFortran.cxx scintilla/lexers/LexHTML.cxx scintilla/lexers/LexHaskell.cxx scintilla/lexers/LexLaTeX.cxx scintilla/lexers/LexLisp.cxx scintilla/lexers/LexLua.cxx scintilla/lexers/LexMake.cxx scintilla/lexers/LexMarkdown.cxx scintilla/lexers/LexMatlab.cxx scintilla/lexers/LexNsis.cxx scintilla/lexers/LexNull.cxx scintilla/lexers/LexPO.cxx scintilla/lexers/LexPascal.cxx scintilla/lexers/LexPerl.cxx scintilla/lexers/LexPowerShell.cxx scintilla/lexers/LexProps.cxx scintilla/lexers/LexPython.cxx scintilla/lexers/LexR.cxx scintilla/lexers/LexRuby.cxx scintilla/lexers/LexRust.cxx scintilla/lexers/LexSQL.cxx scintilla/lexers/LexTCL.cxx scintilla/lexers/LexTxt2tags.cxx scintilla/lexers/LexVHDL.cxx scintilla/lexers/LexVerilog.cxx scintilla/lexers/LexYAML.cxx scintilla/lexlib/Accessor.cxx scintilla/lexlib/Accessor.h scintilla/lexlib/CharacterCategory.cxx scintilla/lexlib/CharacterCategory.h scintilla/lexlib/CharacterSet.cxx scintilla/lexlib/CharacterSet.h scintilla/lexlib/DefaultLexer.cxx scintilla/lexlib/DefaultLexer.h scintilla/lexlib/LexAccessor.h scintilla/lexlib/LexerBase.cxx scintilla/lexlib/LexerBase.h scintilla/lexlib/LexerModule.cxx scintilla/lexlib/LexerModule.h scintilla/lexlib/LexerNoExceptions.cxx scintilla/lexlib/LexerNoExceptions.h scintilla/lexlib/LexerSimple.cxx scintilla/lexlib/LexerSimple.h scintilla/lexlib/OptionSet.h scintilla/lexlib/PropSetSimple.cxx scintilla/lexlib/PropSetSimple.h scintilla/lexlib/SparseState.h scintilla/lexlib/StringCopy.h scintilla/lexlib/StyleContext.cxx scintilla/lexlib/StyleContext.h scintilla/lexlib/SubStyles.h scintilla/lexlib/WordList.cxx scintilla/lexlib/WordList.h scintilla/scintilla_changes.patch scintilla/src/AutoComplete.cxx scintilla/src/AutoComplete.h scintilla/src/CallTip.cxx scintilla/src/CallTip.h scintilla/src/CaseConvert.cxx scintilla/src/CaseConvert.h scintilla/src/CaseFolder.cxx scintilla/src/CaseFolder.h scintilla/src/Catalogue.cxx scintilla/src/Catalogue.h scintilla/src/CellBuffer.cxx scintilla/src/CellBuffer.h scintilla/src/CharClassify.cxx scintilla/src/CharClassify.h scintilla/src/ContractionState.cxx scintilla/src/ContractionState.h scintilla/src/DBCS.cxx scintilla/src/DBCS.h scintilla/src/Decoration.cxx scintilla/src/Decoration.h scintilla/src/Document.cxx scintilla/src/Document.h scintilla/src/EditModel.cxx scintilla/src/EditModel.h scintilla/src/EditView.cxx scintilla/src/EditView.h scintilla/src/Editor.cxx scintilla/src/Editor.h scintilla/src/ElapsedPeriod.h scintilla/src/ExternalLexer.cxx scintilla/src/ExternalLexer.h scintilla/src/FontQuality.h scintilla/src/Indicator.cxx scintilla/src/Indicator.h scintilla/src/IntegerRectangle.h scintilla/src/KeyMap.cxx scintilla/src/KeyMap.h scintilla/src/LineMarker.cxx scintilla/src/LineMarker.h scintilla/src/MarginView.cxx scintilla/src/MarginView.h scintilla/src/Partitioning.h scintilla/src/PerLine.cxx scintilla/src/PerLine.h scintilla/src/Position.h scintilla/src/PositionCache.cxx scintilla/src/PositionCache.h scintilla/src/RESearch.cxx scintilla/src/RESearch.h scintilla/src/RunStyles.cxx scintilla/src/RunStyles.h scintilla/src/ScintillaBase.cxx scintilla/src/ScintillaBase.h scintilla/src/Selection.cxx scintilla/src/Selection.h scintilla/src/SparseVector.h scintilla/src/SplitVector.h scintilla/src/Style.cxx scintilla/src/Style.h scintilla/src/UniConversion.cxx scintilla/src/UniConversion.h scintilla/src/UniqueString.h scintilla/src/ViewStyle.cxx scintilla/src/ViewStyle.h scintilla/src/XPM.cxx scintilla/src/XPM.h scintilla/version.txt src/highlighting.c src/plugindata.h
Modified: plugins/export.c 10 lines changed, 4 insertions(+), 6 deletions(-) =================================================================== @@ -374,10 +374,9 @@ static void write_latex_file(GeanyDocument *doc, const gchar *filename, GString *body; GString *cmds; GString *latex; - gint style_max = pow(2, scintilla_send_message(sci, SCI_GETSTYLEBITS, 0, 0));
/* first read all styles from Scintilla */ - for (i = 0; i < style_max; i++) + for (i = 0; i < STYLE_MAX; i++) { styles[i][FORE] = scintilla_send_message(sci, SCI_STYLEGETFORE, i, 0); styles[i][BACK] = scintilla_send_message(sci, SCI_STYLEGETBACK, i, 0); @@ -517,7 +516,7 @@ static void write_latex_file(GeanyDocument *doc, const gchar *filename,
/* write used styles in the header */ cmds = g_string_new(""); - for (i = 0; i < style_max; i++) + for (i = 0; i < STYLE_MAX; i++) { if (styles[i][USED]) { @@ -578,10 +577,9 @@ static void write_html_file(GeanyDocument *doc, const gchar *filename, GString *body; GString *css; GString *html; - gint style_max = pow(2, scintilla_send_message(sci, SCI_GETSTYLEBITS, 0, 0));
/* first read all styles from Scintilla */ - for (i = 0; i < style_max; i++) + for (i = 0; i < STYLE_MAX; i++) { styles[i][FORE] = ROTATE_RGB(scintilla_send_message(sci, SCI_STYLEGETFORE, i, 0)); styles[i][BACK] = ROTATE_RGB(scintilla_send_message(sci, SCI_STYLEGETBACK, i, 0)); @@ -707,7 +705,7 @@ static void write_html_file(GeanyDocument *doc, const gchar *filename, "\tbody\n\t{\n\t\tfont-family: %s, monospace;\n\t\tfont-size: %dpt;\n\t}\n", font_name, font_size);
- for (i = 0; i < style_max; i++) + for (i = 0; i < STYLE_MAX; i++) { if (styles[i][USED]) {
Modified: scintilla/License.txt 28 lines changed, 14 insertions(+), 14 deletions(-) =================================================================== @@ -2,19 +2,19 @@ License for Scintilla and SciTE
Copyright 1998-2003 by Neil Hodgson neilh@scintilla.org
-All Rights Reserved +All Rights Reserved
-Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation. +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation.
-NEIL HODGSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS, IN NO EVENT SHALL NEIL HODGSON BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE -OR PERFORMANCE OF THIS SOFTWARE. \ No newline at end of file +NEIL HODGSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS +SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS, IN NO EVENT SHALL NEIL HODGSON BE LIABLE FOR ANY +SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE +OR PERFORMANCE OF THIS SOFTWARE. \ No newline at end of file
Modified: scintilla/Makefile.am 6 lines changed, 6 insertions(+), 0 deletions(-) =================================================================== @@ -64,6 +64,8 @@ lexlib/CharacterCategory.cxx \ lexlib/CharacterCategory.h \ lexlib/CharacterSet.cxx \ lexlib/CharacterSet.h \ +lexlib/DefaultLexer.cxx \ +lexlib/DefaultLexer.h \ lexlib/LexAccessor.h \ lexlib/LexerBase.cxx \ lexlib/LexerBase.h \ @@ -99,6 +101,8 @@ src/CharClassify.cxx \ src/CharClassify.h \ src/ContractionState.cxx \ src/ContractionState.h \ +src/DBCS.cxx \ +src/DBCS.h \ src/Decoration.cxx \ src/Decoration.h \ src/Document.cxx \ @@ -109,11 +113,13 @@ src/EditModel.cxx \ src/EditModel.h \ src/EditView.cxx \ src/EditView.h \ +src/ElapsedPeriod.h \ src/ExternalLexer.cxx \ src/ExternalLexer.h \ src/FontQuality.h \ src/Indicator.cxx \ src/Indicator.h \ +src/IntegerRectangle.h \ src/KeyMap.cxx \ src/KeyMap.h \ src/LineMarker.cxx \
Modified: scintilla/gtk/Converter.h 4 lines changed, 0 insertions(+), 4 deletions(-) =================================================================== @@ -6,9 +6,7 @@ #ifndef CONVERTER_H #define CONVERTER_H
-#ifdef SCI_NAMESPACE namespace Scintilla { -#endif
const GIConv iconvhBad = (GIConv)(-1); const gsize sizeFailure = static_cast<gsize>(-1); @@ -67,8 +65,6 @@ class Converter { } };
-#ifdef SCI_NAMESPACE } -#endif
#endif
Modified: scintilla/gtk/PlatGTK.cxx 280 lines changed, 78 insertions(+), 202 deletions(-) =================================================================== @@ -45,21 +45,7 @@ static double doubleFromPangoUnits(int pu) { }
static cairo_surface_t *CreateSimilarSurface(GdkWindow *window, cairo_content_t content, int width, int height) { -#if GTK_CHECK_VERSION(2,22,0) return gdk_window_create_similar_surface(window, content, width, height); -#else - cairo_surface_t *window_surface, *surface; - - g_return_val_if_fail(GDK_IS_WINDOW(window), NULL); - - window_surface = GDK_DRAWABLE_GET_CLASS(window)->ref_cairo_surface(window); - - surface = cairo_surface_create_similar(window_surface, content, width, height); - - cairo_surface_destroy(window_surface); - - return surface; -#endif }
static GdkWindow *WindowFromWidget(GtkWidget *w) { @@ -71,9 +57,7 @@ static GdkWindow *WindowFromWidget(GtkWidget *w) { #pragma warning(disable: 4505) #endif
-#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif
enum encodingType { singleByte, UTF8, dbcs};
@@ -121,13 +105,7 @@ static GtkWidget *PWidget(WindowID wid) { return static_cast<GtkWidget *>(wid); }
-Point Point::FromLong(long lpoint) { - return Point( - Platform::LowShortFromLong(lpoint), - Platform::HighShortFromLong(lpoint)); -} - -Font::Font() : fid(0) {} +Font::Font() noexcept : fid(0) {}
Font::~Font() {}
@@ -143,9 +121,7 @@ void Font::Release() { }
// Required on OS X -#ifdef SCI_NAMESPACE namespace Scintilla { -#endif
// SurfaceID is a cairo_t* class SurfaceImpl : public Surface { @@ -177,13 +153,14 @@ class SurfaceImpl : public Surface { int DeviceHeightFont(int points) override; void MoveTo(int x_, int y_) override; void LineTo(int x_, int y_) override; - void Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired back) override; + void Polygon(Point *pts, size_t npts, ColourDesired fore, ColourDesired back) override; void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) override; void FillRectangle(PRectangle rc, ColourDesired back) override; void FillRectangle(PRectangle rc, Surface &surfacePattern) override; void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back) override; void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill, ColourDesired outline, int alphaOutline, int flags) override; + void GradientRectangle(PRectangle rc, const std::vector<ColourStop> &stops, GradientOptions options) override; void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) override; void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) override; void Copy(PRectangle rc, Point from, Surface &surfaceSource) override; @@ -194,11 +171,9 @@ class SurfaceImpl : public Surface { void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore) override; void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions) override; XYPOSITION WidthText(Font &font_, const char *s, int len) override; - XYPOSITION WidthChar(Font &font_, char ch) override; 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;
@@ -208,9 +183,7 @@ class SurfaceImpl : public Surface { void SetUnicodeMode(bool unicodeMode_) override; void SetDBCSMode(int codePage) override; }; -#ifdef SCI_NAMESPACE } -#endif
const char *CharacterSetID(int characterSet) { switch (characterSet) { @@ -310,7 +283,6 @@ void SurfaceImpl::Release() { }
bool SurfaceImpl::Initialised() { -#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 8, 0) if (inited && context) { if (cairo_status(context) == CAIRO_STATUS_SUCCESS) { // Even when status is success, the target surface may have been @@ -327,7 +299,6 @@ bool SurfaceImpl::Initialised() { } return cairo_status(context) == CAIRO_STATUS_SUCCESS; } -#endif return inited; }
@@ -390,7 +361,7 @@ void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_, WindowID
void SurfaceImpl::PenColour(ColourDesired fore) { if (context) { - ColourDesired cdFore(fore.AsLong()); + ColourDesired cdFore(fore.AsInteger()); cairo_set_source_rgb(context, cdFore.GetRed() / 255.0, cdFore.GetGreen() / 255.0, @@ -432,10 +403,10 @@ void SurfaceImpl::LineTo(int x_, int y_) { if ((xDiff == 0) || (yDiff == 0)) { // Horizontal or vertical lines can be more precisely drawn as a filled rectangle int xEnd = x_ - xDelta; - int left = Platform::Minimum(x, xEnd); + int left = std::min(x, xEnd); int width = abs(x - xEnd) + 1; int yEnd = y_ - yDelta; - int top = Platform::Minimum(y, yEnd); + int top = std::min(y, yEnd); int height = abs(y - yEnd) + 1; cairo_rectangle(context, left, top, width, height); cairo_fill(context); @@ -454,12 +425,12 @@ void SurfaceImpl::LineTo(int x_, int y_) { y = y_; }
-void SurfaceImpl::Polygon(Point *pts, int npts, ColourDesired fore, +void SurfaceImpl::Polygon(Point *pts, size_t npts, ColourDesired fore, ColourDesired back) { PLATFORM_ASSERT(context); PenColour(back); cairo_move_to(context, pts[0].x + 0.5, pts[0].y + 0.5); - for (int i = 1; i < npts; i++) { + for (size_t i = 1; i < npts; i++) { cairo_line_to(context, pts[i].x + 0.5, pts[i].y + 0.5); } cairo_close_path(context); @@ -537,12 +508,7 @@ void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesi static void PathRoundRectangle(cairo_t *context, double left, double top, double width, double height, int radius) { double degrees = kPi / 180.0;
-#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0) cairo_new_sub_path(context); -#else - // First arc is in the top-right corner and starts from a point on the top line - cairo_move_to(context, left + width - radius, top); -#endif cairo_arc(context, left + width - radius, top + radius, radius, -90 * degrees, 0 * degrees); cairo_arc(context, left + width - radius, top + height - radius, radius, 0 * degrees, 90 * degrees); cairo_arc(context, left + radius, top + height - radius, radius, 90 * degrees, 180 * degrees); @@ -553,7 +519,7 @@ static void PathRoundRectangle(cairo_t *context, double left, double top, double void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill, ColourDesired outline, int alphaOutline, int /*flags*/) { if (context && rc.Width() > 0) { - ColourDesired cdFill(fill.AsLong()); + ColourDesired cdFill(fill.AsInteger()); cairo_set_source_rgba(context, cdFill.GetRed() / 255.0, cdFill.GetGreen() / 255.0, @@ -565,7 +531,7 @@ void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fi cairo_rectangle(context, rc.left + 1.0, rc.top + 1.0, rc.right - rc.left - 2.0, rc.bottom - rc.top - 2.0); cairo_fill(context);
- ColourDesired cdOutline(outline.AsLong()); + ColourDesired cdOutline(outline.AsInteger()); cairo_set_source_rgba(context, cdOutline.GetRed() / 255.0, cdOutline.GetGreen() / 255.0, @@ -579,6 +545,32 @@ void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fi } }
+void SurfaceImpl::GradientRectangle(PRectangle rc, const std::vector<ColourStop> &stops, GradientOptions options) { + if (context) { + cairo_pattern_t *pattern; + switch (options) { + case GradientOptions::leftToRight: + pattern = cairo_pattern_create_linear(rc.left, rc.top, rc.right, rc.top); + break; + case GradientOptions::topToBottom: + default: + pattern = cairo_pattern_create_linear(rc.left, rc.top, rc.left, rc.bottom); + break; + } + for (const ColourStop &stop : stops) { + cairo_pattern_add_color_stop_rgba(pattern, stop.position, + stop.colour.GetRedComponent(), + stop.colour.GetGreenComponent(), + stop.colour.GetBlueComponent(), + stop.colour.GetAlphaComponent()); + } + cairo_rectangle(context, rc.left, rc.top, rc.Width(), rc.Height()); + cairo_set_source(context, pattern); + cairo_fill(context); + cairo_pattern_destroy(pattern); + } +} + void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) { PLATFORM_ASSERT(context); if (rc.Width() > width) @@ -588,11 +580,7 @@ void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsi rc.top += (rc.Height() - height) / 2; rc.bottom = rc.top + height;
-#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1,6,0) int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width); -#else - int stride = width * 4; -#endif int ucs = stride * height; std::vector<unsigned char> image(ucs); for (int iy=0; iy<height; iy++) { @@ -618,7 +606,7 @@ void SurfaceImpl::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) PLATFORM_ASSERT(context); PenColour(back); cairo_arc(context, (rc.left + rc.right) / 2, (rc.top + rc.bottom) / 2, - Platform::Minimum(rc.Width(), rc.Height()) / 2, 0, 2*kPi); + std::min(rc.Width(), rc.Height()) / 2, 0, 2*kPi); cairo_fill_preserve(context); PenColour(fore); cairo_stroke(context); @@ -706,11 +694,7 @@ void SurfaceImpl::DrawTextBase(PRectangle rc, Font &font_, XYPOSITION ybase, con } pango_layout_set_font_description(layout, PFont(font_)->pfd); pango_cairo_update_layout(context, layout); -#ifdef PANGO_VERSION PangoLayoutLine *pll = pango_layout_get_line_readonly(layout,0); -#else - PangoLayoutLine *pll = pango_layout_get_line(layout,0); -#endif cairo_move_to(context, xText, ybase); pango_cairo_show_layout_line(context, pll); } @@ -823,7 +807,7 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION positions[i++] = iti.position - (places - place) * iti.distance / places; positionsCalculated++; } - clusterStart += UTF8CharLength(static_cast<unsigned char>(utfForm.c_str()[clusterStart])); + clusterStart += UTF8BytesOfLead[static_cast<unsigned char>(utfForm.c_str()[clusterStart])]; place++; } } @@ -897,11 +881,7 @@ XYPOSITION SurfaceImpl::WidthText(Font &font_, const char *s, int len) { } pango_layout_set_text(layout, utfForm.c_str(), utfForm.length()); } -#ifdef PANGO_VERSION PangoLayoutLine *pangoLine = pango_layout_get_line_readonly(layout,0); -#else - PangoLayoutLine *pangoLine = pango_layout_get_line(layout,0); -#endif pango_layout_line_get_extents(pangoLine, NULL, &pos); return doubleFromPangoUnits(pos.width); } @@ -911,17 +891,6 @@ XYPOSITION SurfaceImpl::WidthText(Font &font_, const char *s, int len) { } }
-XYPOSITION SurfaceImpl::WidthChar(Font &font_, char ch) { - if (font_.GetID()) { - if (PFont(font_)->pfd) { - return WidthText(font_, &ch, 1); - } - return 1; - } else { - return 1; - } -} - // Ascent and descent determined by Pango font metrics.
XYPOSITION SurfaceImpl::Ascent(Font &font_) { @@ -958,16 +927,12 @@ XYPOSITION SurfaceImpl::InternalLeading(Font &) { return 0; }
-XYPOSITION SurfaceImpl::ExternalLeading(Font &) { - return 0; -} - XYPOSITION SurfaceImpl::Height(Font &font_) { return Ascent(font_) + Descent(font_); }
XYPOSITION SurfaceImpl::AverageCharWidth(Font &font_) { - return WidthChar(font_, 'n'); + return WidthText(font_, "n", 1); }
void SurfaceImpl::SetClip(PRectangle rc) { @@ -1011,11 +976,7 @@ void Window::Destroy() { } }
-bool Window::HasFocus() { - return gtk_widget_has_focus(GTK_WIDGET(wid)); -} - -PRectangle Window::GetPosition() { +PRectangle Window::GetPosition() const { // Before any size allocated pretend its 1000 wide so not scrolled PRectangle rc(0, 0, 1000, 1000); if (wid) { @@ -1059,15 +1020,15 @@ GdkRectangle MonitorRectangleForWidget(GtkWidget *wid) {
}
-void Window::SetPositionRelative(PRectangle rc, Window relativeTo) { +void Window::SetPositionRelative(PRectangle rc, const Window *relativeTo) { int ox = 0; int oy = 0; - GdkWindow *wndRelativeTo = WindowFromWidget(PWidget(relativeTo.wid)); + GdkWindow *wndRelativeTo = WindowFromWidget(PWidget(relativeTo->wid)); gdk_window_get_origin(wndRelativeTo, &ox, &oy); ox += rc.left; oy += rc.top;
- GdkRectangle rcMonitor = MonitorRectangleForWidget(PWidget(relativeTo.wid)); + GdkRectangle rcMonitor = MonitorRectangleForWidget(PWidget(relativeTo->wid));
/* do some corrections to fit into screen */ int sizex = rc.right - rc.left; @@ -1086,7 +1047,7 @@ void Window::SetPositionRelative(PRectangle rc, Window relativeTo) { gtk_window_resize(GTK_WINDOW(wid), sizex, sizey); }
-PRectangle Window::GetClientPosition() { +PRectangle Window::GetClientPosition() const { // On GTK+, the client position is the window position return GetPosition(); } @@ -1158,10 +1119,6 @@ void Window::SetCursor(Cursor curs) { #endif }
-void Window::SetTitle(const char *s) { - gtk_window_set_title(GTK_WINDOW(wid), s); -} - /* Returns rectangle of monitor pt is on, both rect and pt are in Window's gdk window coordinates */ PRectangle Window::GetMonitorRect(Point pt) { @@ -1201,7 +1158,7 @@ static void list_image_free(gpointer, gpointer value, gpointer) { g_free(list_image); }
-ListBox::ListBox() { +ListBox::ListBox() noexcept { }
ListBox::~ListBox() { @@ -1229,8 +1186,7 @@ class ListBoxX : public ListBox { 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), @@ -1239,7 +1195,7 @@ class ListBoxX : public ListBox { #if GTK_CHECK_VERSION(3,0,0) cssProvider(NULL), #endif - doubleClickAction(NULL), doubleClickActionData(NULL) { + delegate(nullptr) { } ~ListBoxX() override { if (pixhash) { @@ -1276,10 +1232,7 @@ class ListBoxX : public ListBox { 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; void SetList(const char *listText, char separator, char typesep) override; };
@@ -1307,7 +1260,7 @@ static int treeViewGetRowHeight(GtkTreeView *view) { "vertical-separator", &vertical_separator, "expander-size", &expander_size, NULL); row_height += vertical_separator; - row_height = Platform::Maximum(row_height, expander_size); + row_height = std::max(row_height, expander_size); return row_height; #endif } @@ -1370,8 +1323,9 @@ static void small_scroller_init(SmallScroller *){} static gboolean ButtonPress(GtkWidget *, GdkEventButton* ev, gpointer p) { try { ListBoxX* lb = static_cast<ListBoxX*>(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; }
@@ -1381,6 +1335,20 @@ static gboolean ButtonPress(GtkWidget *, GdkEventButton* ev, gpointer p) { return FALSE; }
+static gboolean ButtonRelease(GtkWidget *, GdkEventButton* ev, gpointer p) { + try { + ListBoxX* lb = static_cast<ListBoxX*>(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*) { @@ -1505,6 +1473,8 @@ void ListBoxX::Create(Window &parent, int, Point, int, bool, int) { 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<GtkWidget *>(parent.GetID())); gtk_window_set_transient_for(GTK_WINDOW(static_cast<GtkWidget *>(wid)), @@ -1780,6 +1750,11 @@ void ListBoxX::Select(int n) { } else { gtk_tree_selection_unselect_all(selection); } + + if (delegate) { + ListBoxEvent event(ListBoxEvent::EventType::selectionChange); + delegate->ListNotify(&event); + } }
int ListBoxX::GetSelection() { @@ -1876,6 +1851,10 @@ void ListBoxX::ClearRegisteredImages() { 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; @@ -1902,7 +1881,7 @@ void ListBoxX::SetList(const char *listText, char separator, char typesep) { } }
-Menu::Menu() : mid(0) {} +Menu::Menu() noexcept : mid(0) {}
void Menu::CreatePopUp() { Destroy(); @@ -1950,13 +1929,6 @@ void Menu::Show(Point pt, Window &w) { #endif }
-ElapsedTime::ElapsedTime() { - GTimeVal curTime; - g_get_current_time(&curTime); - bigBit = curTime.tv_sec; - littleBit = curTime.tv_usec; -} - class DynamicLibraryImpl : public DynamicLibrary { protected: GModule* m; @@ -1993,21 +1965,6 @@ DynamicLibrary *DynamicLibrary::Load(const char *modulePath) { return static_cast<DynamicLibrary *>( new DynamicLibraryImpl(modulePath) ); }
-double ElapsedTime::Duration(bool reset) { - GTimeVal curTime; - g_get_current_time(&curTime); - long endBigBit = curTime.tv_sec; - long endLittleBit = curTime.tv_usec; - double result = 1000000.0 * (endBigBit - bigBit); - result += endLittleBit - littleBit; - result /= 1000000.0; - if (reset) { - bigBit = endBigBit; - littleBit = endLittleBit; - } - return result; -} - ColourDesired Platform::Chrome() { return ColourDesired(0xe0, 0xe0, 0xe0); } @@ -2036,83 +1993,10 @@ unsigned int Platform::DoubleClickTime() { return 500; // Half a second }
-bool Platform::MouseButtonBounce() { - return true; -} - void Platform::DebugDisplay(const char *s) { fprintf(stderr, "%s", s); }
-bool Platform::IsKeyDown(int) { - // TODO: discover state of keys in GTK+/X - return false; -} - -long Platform::SendScintilla( - WindowID w, unsigned int msg, unsigned long wParam, long lParam) { - return scintilla_send_message(SCINTILLA(w), msg, wParam, lParam); -} - -long Platform::SendScintillaPointer( - WindowID w, unsigned int msg, unsigned long wParam, void *lParam) { - return scintilla_send_message(SCINTILLA(w), msg, wParam, - reinterpret_cast<sptr_t>(lParam)); -} - -bool Platform::IsDBCSLeadByte(int codePage, char ch) { - // Byte ranges found in Wikipedia articles with relevant search strings in each case - unsigned char uch = static_cast<unsigned char>(ch); - switch (codePage) { - case 932: - // Shift_jis - return ((uch >= 0x81) && (uch <= 0x9F)) || - ((uch >= 0xE0) && (uch <= 0xFC)); - // Lead bytes F0 to FC may be a Microsoft addition. - case 936: - // GBK - return (uch >= 0x81) && (uch <= 0xFE); - case 950: - // Big5 - return (uch >= 0x81) && (uch <= 0xFE); - // Korean EUC-KR may be code page 949. - } - return false; -} - -int Platform::DBCSCharLength(int codePage, const char *s) { - if (codePage == 932 || codePage == 936 || codePage == 950) { - return IsDBCSLeadByte(codePage, s[0]) ? 2 : 1; - } else { - int bytes = mblen(s, MB_CUR_MAX); - if (bytes >= 1) - return bytes; - else - return 1; - } -} - -int Platform::DBCSCharMaxLength() { - return MB_CUR_MAX; - //return 2; -} - -// These are utility functions not really tied to a platform - -int Platform::Minimum(int a, int b) { - if (a < b) - return a; - else - return b; -} - -int Platform::Maximum(int a, int b) { - if (a > b) - return a; - else - return b; -} - //#define TRACE
#ifdef TRACE @@ -2145,14 +2029,6 @@ void Platform::Assert(const char *c, const char *file, int line) { abort(); }
-int Platform::Clamp(int val, int minVal, int maxVal) { - if (val > maxVal) - val = maxVal; - if (val < minVal) - val = minVal; - return val; -} - void Platform_Initialise() { }
Modified: scintilla/gtk/ScintillaGTK.cxx 183 lines changed, 83 insertions(+), 100 deletions(-) =================================================================== @@ -35,6 +35,7 @@
#include "Platform.h"
+#include "ILoader.h" #include "ILexer.h" #include "Scintilla.h" #include "ScintillaWidget.h" @@ -55,7 +56,6 @@ #include "CallTip.h" #include "KeyMap.h" #include "Indicator.h" -#include "XPM.h" #include "LineMarker.h" #include "Style.h" #include "ViewStyle.h" @@ -65,7 +65,6 @@ #include "Document.h" #include "CaseConvert.h" #include "UniConversion.h" -#include "UnicodeFromUTF8.h" #include "Selection.h" #include "PositionCache.h" #include "EditModel.h" @@ -85,13 +84,8 @@
#include "Converter.h"
-#if GTK_CHECK_VERSION(2,20,0) #define IS_WIDGET_REALIZED(w) (gtk_widget_get_realized(GTK_WIDGET(w))) #define IS_WIDGET_MAPPED(w) (gtk_widget_get_mapped(GTK_WIDGET(w))) -#else -#define IS_WIDGET_REALIZED(w) (GTK_WIDGET_REALIZED(w)) -#define IS_WIDGET_MAPPED(w) (GTK_WIDGET_MAPPED(w)) -#endif
#define SC_INDICATOR_INPUT INDIC_IME #define SC_INDICATOR_TARGET INDIC_IME+1 @@ -109,9 +103,7 @@ static GdkWindow *WindowFromWidget(GtkWidget *w) { #pragma warning(disable: 4505) #endif
-#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif
static GdkWindow *PWindow(const Window &w) { GtkWidget *widget = static_cast<GtkWidget *>(w.GetID()); @@ -155,6 +147,8 @@ static const GtkTargetEntry clipboardPasteTargets[] = { }; static const gint nClipboardPasteTargets = ELEMENTS(clipboardPasteTargets);
+static const GdkDragAction actionCopyOrMove = static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE); + static GtkWidget *PWidget(Window &w) { return static_cast<GtkWidget *>(w.GetID()); } @@ -167,7 +161,7 @@ ScintillaGTK *ScintillaGTK::FromWidget(GtkWidget *widget) { ScintillaGTK::ScintillaGTK(_ScintillaObject *sci_) : adjustmentv(0), adjustmenth(0), verticalScrollBarWidth(30), horizontalScrollBarHeight(30), - evbtn(0), capturedMouse(false), dragWasDropped(false), + evbtn(nullptr), capturedMouse(false), dragWasDropped(false), lastKey(0), rectangularSelectionModifier(SCMOD_CTRL), parentClass(0), im_context(NULL), lastNonCommonScript(PANGO_SCRIPT_INVALID_CODE), lastWheelMouseDirection(0), @@ -182,11 +176,7 @@ ScintillaGTK::ScintillaGTK(_ScintillaObject *sci_) : sci = sci_; wMain = GTK_WIDGET(sci);
-#if PLAT_GTK_WIN32 rectangularSelectionModifier = SCMOD_ALT; -#else - rectangularSelectionModifier = SCMOD_CTRL; -#endif
#if PLAT_GTK_WIN32 // There does not seem to be a real standard for indicating that the clipboard @@ -215,8 +205,8 @@ ScintillaGTK::~ScintillaGTK() { styleIdleID = 0; } if (evbtn) { - gdk_event_free(reinterpret_cast<GdkEvent *>(evbtn)); - evbtn = 0; + gdk_event_free(evbtn); + evbtn = nullptr; } wPreedit.Destroy(); } @@ -231,11 +221,7 @@ static void UnRefCursor(GdkCursor *cursor) {
void ScintillaGTK::RealizeThis(GtkWidget *widget) { //Platform::DebugPrintf("ScintillaGTK::realize this\n"); -#if GTK_CHECK_VERSION(2,20,0) gtk_widget_set_realized(widget, TRUE); -#else - GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED); -#endif GdkWindowAttr attrs; attrs.window_type = GDK_WINDOW_CHILD; GtkAllocation allocation; @@ -306,7 +292,10 @@ void ScintillaGTK::RealizeThis(GtkWidget *widget) { gdk_window_set_cursor(PWindow(scrollbarh), cursor); UnRefCursor(cursor);
- gtk_selection_add_targets(widget, GDK_SELECTION_PRIMARY, + wSelection = gtk_invisible_new(); + g_signal_connect(PWidget(wSelection), "selection_get", G_CALLBACK(PrimarySelection), (gpointer) this); + g_signal_connect(PWidget(wSelection), "selection_clear_event", G_CALLBACK(PrimaryClear), (gpointer) this); + gtk_selection_add_targets(PWidget(wSelection), GDK_SELECTION_PRIMARY, clipboardCopyTargets, nClipboardCopyTargets); }
@@ -317,16 +306,13 @@ void ScintillaGTK::Realize(GtkWidget *widget) {
void ScintillaGTK::UnRealizeThis(GtkWidget *widget) { try { - gtk_selection_clear_targets(widget, GDK_SELECTION_PRIMARY); + gtk_selection_clear_targets(PWidget(wSelection), GDK_SELECTION_PRIMARY); + wSelection.Destroy();
if (IS_WIDGET_MAPPED(widget)) { gtk_widget_unmap(widget); } -#if GTK_CHECK_VERSION(2,20,0) gtk_widget_set_realized(widget, FALSE); -#else - GTK_WIDGET_UNSET_FLAGS(widget, GTK_REALIZED); -#endif gtk_widget_unrealize(PWidget(wText)); if (PWidget(scrollbarv)) gtk_widget_unrealize(PWidget(scrollbarv)); @@ -361,11 +347,7 @@ static void MapWidget(GtkWidget *widget) { void ScintillaGTK::MapThis() { try { //Platform::DebugPrintf("ScintillaGTK::map this\n"); -#if GTK_CHECK_VERSION(2,20,0) gtk_widget_set_mapped(PWidget(wMain), TRUE); -#else - GTK_WIDGET_SET_FLAGS(PWidget(wMain), GTK_MAPPED); -#endif MapWidget(PWidget(wText)); MapWidget(PWidget(scrollbarh)); MapWidget(PWidget(scrollbarv)); @@ -387,11 +369,7 @@ void ScintillaGTK::Map(GtkWidget *widget) { void ScintillaGTK::UnMapThis() { try { //Platform::DebugPrintf("ScintillaGTK::unmap this\n"); -#if GTK_CHECK_VERSION(2,20,0) gtk_widget_set_mapped(PWidget(wMain), FALSE); -#else - GTK_WIDGET_UNSET_FLAGS(PWidget(wMain), GTK_MAPPED); -#endif DropGraphics(false); gdk_window_hide(PWindow(wMain)); gtk_widget_unmap(PWidget(wText)); @@ -631,7 +609,7 @@ void ScintillaGTK::Init() {
gtk_drag_dest_set(GTK_WIDGET(PWidget(wMain)), GTK_DEST_DEFAULT_ALL, clipboardPasteTargets, nClipboardPasteTargets, - static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE)); + actionCopyOrMove);
/* create pre-edit window */ wPreedit = gtk_window_new(GTK_WINDOW_POPUP); @@ -708,29 +686,27 @@ bool ScintillaGTK::DragThreshold(Point ptStart, Point ptNow) { }
void ScintillaGTK::StartDrag() { - PLATFORM_ASSERT(evbtn != 0); + PLATFORM_ASSERT(evbtn); dragWasDropped = false; inDragDrop = ddDragging; GtkTargetList *tl = gtk_target_list_new(clipboardCopyTargets, nClipboardCopyTargets); #if GTK_CHECK_VERSION(3,10,0) gtk_drag_begin_with_coordinates(GTK_WIDGET(PWidget(wMain)), tl, - static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE), - evbtn->button, - reinterpret_cast<GdkEvent *>(evbtn), + actionCopyOrMove, + buttonMouse, + evbtn, -1, -1); #else gtk_drag_begin(GTK_WIDGET(PWidget(wMain)), tl, - static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE), - evbtn->button, - reinterpret_cast<GdkEvent *>(evbtn)); + actionCopyOrMove, + buttonMouse, + evbtn); #endif }
-#ifdef SCI_NAMESPACE namespace Scintilla { -#endif std::string ConvertText(const char *s, size_t len, const char *charSetDest, const char *charSetSource, bool transliterations, bool silent) { // s is not const because of different versions of iconv disagreeing about const @@ -763,14 +739,12 @@ std::string ConvertText(const char *s, size_t len, const char *charSetDest, } return destForm; } -#ifdef SCI_NAMESPACE } -#endif
// Returns the target converted to UTF8. // Return the length in bytes. -int ScintillaGTK::TargetAsUTF8(char *text) { - int targetLength = targetEnd - targetStart; +Sci::Position ScintillaGTK::TargetAsUTF8(char *text) const { + Sci::Position targetLength = targetEnd - targetStart; if (IsUnicodeMode()) { if (text) { pdoc->GetCharRange(text, targetStart, targetLength); @@ -796,8 +770,8 @@ int ScintillaGTK::TargetAsUTF8(char *text) {
// Translates a nul terminated UTF8 string into the document encoding. // Return the length of the result in bytes. -int ScintillaGTK::EncodedFromUTF8(char *utf8, char *encoded) const { - int inputLength = (lengthForEncode >= 0) ? lengthForEncode : strlen(utf8); +Sci::Position ScintillaGTK::EncodedFromUTF8(const char *utf8, char *encoded) const { + Sci::Position inputLength = (lengthForEncode >= 0) ? lengthForEncode : strlen(utf8); if (IsUnicodeMode()) { if (encoded) { memcpy(encoded, utf8, inputLength); @@ -849,15 +823,15 @@ sptr_t ScintillaGTK::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
#ifdef SCI_LEXER case SCI_LOADLEXERLIBRARY: - LexerManager::GetInstance()->Load(reinterpret_cast<const char*>(lParam)); + LexerManager::GetInstance()->Load(ConstCharPtrFromSPtr(lParam)); break; #endif case SCI_TARGETASUTF8: - return TargetAsUTF8(reinterpret_cast<char*>(lParam)); + return TargetAsUTF8(CharPtrFromSPtr(lParam));
case SCI_ENCODEDFROMUTF8: - return EncodedFromUTF8(reinterpret_cast<char*>(wParam), - reinterpret_cast<char*>(lParam)); + return EncodedFromUTF8(ConstCharPtrFromUPtr(wParam), + CharPtrFromSPtr(lParam));
case SCI_SETRECTANGULARSELECTIONMODIFIER: rectangularSelectionModifier = wParam; @@ -898,20 +872,13 @@ sptr_t ScintillaGTK::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam } catch (...) { errorStatus = SC_STATUS_FAILURE; } - return 0l; + return 0; }
sptr_t ScintillaGTK::DefWndProc(unsigned int, uptr_t, sptr_t) { return 0; }
-/** -* Report that this Editor subclass has a working implementation of FineTickerStart. -*/ -bool ScintillaGTK::FineTickerAvailable() { - return true; -} - bool ScintillaGTK::FineTickerRunning(TickReason reason) { return timers[reason].timer != 0; } @@ -933,7 +900,7 @@ bool ScintillaGTK::SetIdle(bool on) { // Start idler, if it's not running. if (!idler.state) { idler.state = true; - idler.idlerID = reinterpret_cast<IdlerID>( + idler.idlerID = GUINT_TO_POINTER( gdk_threads_add_idle_full(G_PRIORITY_DEFAULT_IDLE, IdleCallback, this, NULL)); } } else { @@ -1012,8 +979,7 @@ void ScintillaGTK::FullPaint() { }
PRectangle ScintillaGTK::GetClientRectangle() const { - Window win = wMain; - PRectangle rc = win.GetClientPosition(); + PRectangle rc = wMain.GetClientPosition(); if (verticalScrollBarVisible) rc.right -= verticalScrollBarWidth; if (horizontalScrollBarVisible && !Wrapping()) @@ -1332,7 +1298,7 @@ void ScintillaGTK::CreateCallTipWindow(PRectangle rc) { G_CALLBACK(ScintillaGTK::ExposeCT), &ct); #endif g_signal_connect(G_OBJECT(widcdrw), "button_press_event", - G_CALLBACK(ScintillaGTK::PressCT), static_cast<void *>(this)); + G_CALLBACK(ScintillaGTK::PressCT), this); gtk_widget_set_events(widcdrw, GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK); GtkWidget *top = gtk_widget_get_toplevel(static_cast<GtkWidget *>(wMain.GetID())); @@ -1363,17 +1329,17 @@ void ScintillaGTK::AddToPopUp(const char *label, int cmd, bool enabled) { }
bool ScintillaGTK::OwnPrimarySelection() { - return ((gdk_selection_owner_get(GDK_SELECTION_PRIMARY) - == PWindow(wMain)) && - (PWindow(wMain) != NULL)); + return (wSelection.Created() && + (gdk_selection_owner_get(GDK_SELECTION_PRIMARY) == PWindow(wSelection)) && + (PWindow(wSelection) != NULL)); }
void ScintillaGTK::ClaimSelection() { // X Windows has a 'primary selection' as well as the clipboard. // Whenever the user selects some text, we become the primary selection - if (!sel.Empty() && IS_WIDGET_REALIZED(GTK_WIDGET(PWidget(wMain)))) { + if (!sel.Empty() && wSelection.Created() && IS_WIDGET_REALIZED(GTK_WIDGET(PWidget(wSelection)))) { primarySelection = true; - gtk_selection_owner_set(GTK_WIDGET(PWidget(wMain)), + gtk_selection_owner_set(GTK_WIDGET(PWidget(wSelection)), GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME); primary.Clear(); } else if (OwnPrimarySelection()) { @@ -1541,7 +1507,7 @@ void ScintillaGTK::GetSelection(GtkSelectionData *selection_data, guint info, Se } else { gtk_selection_data_set(selection_data, static_cast<GdkAtom>(GDK_SELECTION_TYPE_STRING), - 8, reinterpret_cast<const unsigned char *>(textData), len); + 8, reinterpret_cast<const guchar *>(textData), len); } }
@@ -1582,6 +1548,27 @@ void ScintillaGTK::UnclaimSelection(GdkEventSelection *selection_event) { } }
+void ScintillaGTK::PrimarySelection(GtkWidget *, GtkSelectionData *selection_data, guint info, guint, ScintillaGTK *sciThis) { + try { + if (SelectionOfGSD(selection_data) == GDK_SELECTION_PRIMARY) { + if (sciThis->primary.Empty()) { + sciThis->CopySelectionRange(&sciThis->primary); + } + sciThis->GetSelection(selection_data, info, &sciThis->primary); + } + } catch (...) { + sciThis->errorStatus = SC_STATUS_FAILURE; + } +} + +gboolean ScintillaGTK::PrimaryClear(GtkWidget *widget, GdkEventSelection *event, ScintillaGTK *sciThis) { + sciThis->UnclaimSelection(event); + if (GTK_WIDGET_CLASS(sciThis->parentClass)->selection_clear_event) { + return GTK_WIDGET_CLASS(sciThis->parentClass)->selection_clear_event(widget, event); + } + return TRUE; +} + void ScintillaGTK::Resize(int width, int height) { //Platform::DebugPrintf("Resize %d %d\n", width, height); //printf("Resize %d %d\n", width, height); @@ -1614,7 +1601,7 @@ void ScintillaGTK::Resize(int width, int height) { gtk_widget_show(GTK_WIDGET(PWidget(scrollbarh))); alloc.x = 0; alloc.y = height - horizontalScrollBarHeight; - alloc.width = Platform::Maximum(minHScrollBarWidth, width - verticalScrollBarWidth); + alloc.width = std::max(minHScrollBarWidth, width - verticalScrollBarWidth); alloc.height = horizontalScrollBarHeight; gtk_widget_size_allocate(GTK_WIDGET(PWidget(scrollbarh)), &alloc); } else { @@ -1627,7 +1614,7 @@ void ScintillaGTK::Resize(int width, int height) { alloc.x = width - verticalScrollBarWidth; alloc.y = 0; alloc.width = verticalScrollBarWidth; - alloc.height = Platform::Maximum(minVScrollBarHeight, height - horizontalScrollBarHeight); + alloc.height = std::max(minVScrollBarHeight, height - horizontalScrollBarHeight); gtk_widget_size_allocate(GTK_WIDGET(PWidget(scrollbarv)), &alloc); } else { gtk_widget_hide(GTK_WIDGET(PWidget(scrollbarv))); @@ -1648,8 +1635,8 @@ void ScintillaGTK::Resize(int width, int height) { alloc.width = requisition.width; alloc.height = requisition.height; #endif - alloc.width = Platform::Maximum(alloc.width, width - verticalScrollBarWidth); - alloc.height = Platform::Maximum(alloc.height, height - horizontalScrollBarHeight); + alloc.width = std::max(alloc.width, width - verticalScrollBarWidth); + alloc.height = std::max(alloc.height, height - horizontalScrollBarHeight); gtk_widget_size_allocate(GTK_WIDGET(PWidget(wText)), &alloc); }
@@ -1688,13 +1675,13 @@ gint ScintillaGTK::PressThis(GdkEventButton *event) { return FALSE;
if (evbtn) { - gdk_event_free(reinterpret_cast<GdkEvent *>(evbtn)); - evbtn = 0; + gdk_event_free(evbtn); } - evbtn = reinterpret_cast<GdkEventButton *>(gdk_event_copy(reinterpret_cast<GdkEvent *>(event))); + evbtn = gdk_event_copy(reinterpret_cast<GdkEvent *>(event)); + buttonMouse = event->button; Point pt; - pt.x = int(event->x); - pt.y = int(event->y); + pt.x = floor(event->x); + pt.y = floor(event->y); PRectangle rcClient = GetClientRectangle(); //Platform::DebugPrintf("Press %0d,%0d in %0d,%0d %0d,%0d\n", // pt.x, pt.y, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom); @@ -1796,7 +1783,11 @@ gint ScintillaGTK::MouseRelease(GtkWidget *widget, GdkEventButton *event) { // 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; @@ -1933,10 +1924,11 @@ gint ScintillaGTK::Motion(GtkWidget *widget, GdkEventMotion *event) { //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; } @@ -2465,8 +2457,8 @@ static GObjectClass *scintilla_class_parent_class;
void ScintillaGTK::Dispose(GObject *object) { try { - ScintillaObject *scio = reinterpret_cast<ScintillaObject *>(object); - ScintillaGTK *sciThis = reinterpret_cast<ScintillaGTK *>(scio->pscin); + ScintillaObject *scio = SCINTILLA(object); + ScintillaGTK *sciThis = static_cast<ScintillaGTK *>(scio->pscin);
if (PWidget(sciThis->scrollbarv)) { gtk_widget_unparent(PWidget(sciThis->scrollbarv)); @@ -2622,11 +2614,12 @@ gboolean ScintillaGTK::ExposeTextThis(GtkWidget * /*widget*/, GdkEventExpose *os Paint(surfaceWindow.get(), rcPaint); surfaceWindow->Release(); cairo_destroy(cr); - if (paintState == paintAbandoned) { + if ((paintState == paintAbandoned) || repaintFullWindow) { // Painting area was insufficient to cover new styling or brace highlight positions FullPaint(); } paintState = notPainting; + repaintFullWindow = false;
if (rgnUpdate) { gdk_region_destroy(rgnUpdate); @@ -2723,20 +2716,14 @@ gboolean ScintillaGTK::DragMotionThis(GdkDragContext *context, try { Point npt(x, y); SetDragPosition(SPositionFromLocation(npt, false, false, UserVirtualSpace())); -#if GTK_CHECK_VERSION(2,22,0) GdkDragAction preferredAction = gdk_drag_context_get_suggested_action(context); GdkDragAction actions = gdk_drag_context_get_actions(context); -#else - GdkDragAction preferredAction = context->suggested_action; - GdkDragAction actions = context->actions; -#endif SelectionPosition pos = SPositionFromLocation(npt); if ((inDragDrop == ddDragging) && (PositionInSelection(pos.Position()))) { // Avoid dragging selection onto itself as that produces a move // with no real effect but which creates undo actions. preferredAction = static_cast<GdkDragAction>(0); - } else if (actions == static_cast<GdkDragAction> - (GDK_ACTION_COPY | GDK_ACTION_MOVE)) { + } else if (actions == actionCopyOrMove) { preferredAction = GDK_ACTION_MOVE; } gdk_drag_status(context, preferredAction, dragtime); @@ -2807,11 +2794,7 @@ void ScintillaGTK::DragDataGet(GtkWidget *widget, GdkDragContext *context, if (!sciThis->sel.Empty()) { sciThis->GetSelection(selection_data, info, &sciThis->drag); } -#if GTK_CHECK_VERSION(2,22,0) GdkDragAction action = gdk_drag_context_get_selected_action(context); -#else - GdkDragAction action = context->action; -#endif if (action == GDK_ACTION_MOVE) { for (size_t r=0; r<sciThis->sel.Count(); r++) { if (sciThis->posDrop >= sciThis->sel.Range(r).Start()) {
Modified: scintilla/gtk/ScintillaGTK.h 17 lines changed, 9 insertions(+), 8 deletions(-) =================================================================== @@ -6,9 +6,7 @@ #ifndef SCINTILLAGTK_H #define SCINTILLAGTK_H
-#ifdef SCI_NAMESPACE namespace Scintilla { -#endif
class ScintillaGTKAccessible;
@@ -23,12 +21,14 @@ class ScintillaGTK : public ScintillaBase { Window scrollbarh; GtkAdjustment *adjustmentv; GtkAdjustment *adjustmenth; + Window wSelection; int verticalScrollBarWidth; int horizontalScrollBarHeight;
SelectionText primary;
- GdkEventButton *evbtn; + GdkEvent *evbtn; + guint buttonMouse; bool capturedMouse; bool dragWasDropped; int lastKey; @@ -75,7 +75,9 @@ class ScintillaGTK : public ScintillaBase { explicit ScintillaGTK(_ScintillaObject *sci_); // Deleted so ScintillaGTK objects can not be copied. ScintillaGTK(const ScintillaGTK &) = delete; + ScintillaGTK(ScintillaGTK &&) = delete; ScintillaGTK &operator=(const ScintillaGTK &) = delete; + ScintillaGTK &operator=(ScintillaGTK &&) = delete; virtual ~ScintillaGTK(); static ScintillaGTK *FromWidget(GtkWidget *widget); static void ClassInit(OBJECT_CLASS* object_class, GtkWidgetClass *widget_class, GtkContainerClass *container_class); @@ -86,8 +88,8 @@ class ScintillaGTK : public ScintillaBase { void DisplayCursor(Window::Cursor c) override; bool DragThreshold(Point ptStart, Point ptNow) override; void StartDrag() override; - int TargetAsUTF8(char *text); - int EncodedFromUTF8(char *utf8, char *encoded) const; + Sci::Position TargetAsUTF8(char *text) const; + Sci::Position EncodedFromUTF8(const char *utf8, char *encoded) const; bool ValidCodePage(int codePage) const override; public: // Public for scintilla_send_message sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override; @@ -100,7 +102,6 @@ class ScintillaGTK : public ScintillaBase { TimeThunk() : reason(tickCaret), scintilla(NULL), timer(0) {} }; TimeThunk timers[tickDwell+1]; - bool FineTickerAvailable() override; bool FineTickerRunning(TickReason reason) override; void FineTickerStart(TickReason reason, int millis, int tolerance) override; void FineTickerCancel(TickReason reason) override; @@ -140,6 +141,8 @@ class ScintillaGTK : public ScintillaBase { static void ClipboardClearSelection(GtkClipboard* clip, void *data);
void UnclaimSelection(GdkEventSelection *selection_event); + static void PrimarySelection(GtkWidget *widget, GtkSelectionData *selection_data, guint info, guint time_stamp, ScintillaGTK *sciThis); + static gboolean PrimaryClear(GtkWidget *widget, GdkEventSelection *event, ScintillaGTK *sciThis); void Resize(int width, int height);
// Callback functions @@ -282,8 +285,6 @@ class GObjectWatcher { std::string ConvertText(const char *s, size_t len, const char *charSetDest, const char *charSetSource, bool transliterations, bool silent=false);
-#ifdef SCI_NAMESPACE } -#endif
#endif
Modified: scintilla/gtk/ScintillaGTKAccessible.cxx 7 lines changed, 2 insertions(+), 5 deletions(-) =================================================================== @@ -84,6 +84,7 @@ // ScintillaGTK.h and stuff it needs #include "Platform.h"
+#include "ILoader.h" #include "ILexer.h" #include "Scintilla.h" #include "ScintillaWidget.h" @@ -104,7 +105,6 @@ #include "CallTip.h" #include "KeyMap.h" #include "Indicator.h" -#include "XPM.h" #include "LineMarker.h" #include "Style.h" #include "ViewStyle.h" @@ -114,7 +114,6 @@ #include "Document.h" #include "CaseConvert.h" #include "UniConversion.h" -#include "UnicodeFromUTF8.h" #include "Selection.h" #include "PositionCache.h" #include "EditModel.h" @@ -127,9 +126,7 @@ #include "ScintillaGTK.h" #include "ScintillaGTKAccessible.h"
-#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif
struct ScintillaObjectAccessiblePrivate { ScintillaGTKAccessible *pscin; @@ -764,7 +761,7 @@ void ScintillaGTKAccessible::PasteText(int charPosition) { }
static void TextReceivedCallback(GtkClipboard *clipboard, const gchar *text, gpointer data) { - Helper *helper = reinterpret_cast<Helper*>(data); + Helper *helper = static_cast<Helper*>(data); try { if (helper->scia != 0) { helper->TextReceived(clipboard, text);
Modified: scintilla/gtk/ScintillaGTKAccessible.h 6 lines changed, 1 insertions(+), 5 deletions(-) =================================================================== @@ -6,9 +6,7 @@ #ifndef SCINTILLAGTKACCESSIBLE_H #define SCINTILLAGTKACCESSIBLE_H
-#ifdef SCI_NAMESPACE namespace Scintilla { -#endif
#ifndef ATK_CHECK_VERSION # define ATK_CHECK_VERSION(x, y, z) 0 @@ -34,7 +32,7 @@ class ScintillaGTKAccessible { void Notify(GtkWidget *widget, gint code, SCNotification *nt); static void SciNotify(GtkWidget *widget, gint code, SCNotification *nt, gpointer data) { try { - reinterpret_cast<ScintillaGTKAccessible*>(data)->Notify(widget, code, nt); + static_cast<ScintillaGTKAccessible*>(data)->Notify(widget, code, nt); } catch (...) {} }
@@ -188,9 +186,7 @@ class ScintillaGTKAccessible { }; };
-#ifdef SCI_NAMESPACE } -#endif
#endif /* SCINTILLAGTKACCESSIBLE_H */
Modified: scintilla/gtk/scintilla-marshal.c 33 lines changed, 15 insertions(+), 18 deletions(-) =================================================================== @@ -1,6 +1,4 @@ - -#include <glib-object.h> - +#include <glib-object.h>
#ifdef G_ENABLE_DEBUG #define g_marshal_value_peek_boolean(v) g_value_get_boolean (v) @@ -48,8 +46,7 @@ #define g_marshal_value_peek_variant(v) (v)->data[0].v_pointer #endif /* !G_ENABLE_DEBUG */
- -/* NONE:INT,OBJECT (scintilla-marshal.list:1) */ +/* VOID:INT,OBJECT (scintilla-marshal.list:1) */ void scintilla_marshal_VOID__INT_OBJECT (GClosure *closure, GValue *return_value G_GNUC_UNUSED, @@ -58,13 +55,13 @@ scintilla_marshal_VOID__INT_OBJECT (GClosure *closure, gpointer invocation_hint G_GNUC_UNUSED, gpointer marshal_data) { - typedef void (*GMarshalFunc_VOID__INT_OBJECT) (gpointer data1, - gint arg_1, - gpointer arg_2, - gpointer data2); - GMarshalFunc_VOID__INT_OBJECT callback; - GCClosure *cc = (GCClosure*) closure; + typedef void (*GMarshalFunc_VOID__INT_OBJECT) (gpointer data1, + gint arg1, + gpointer arg2, + gpointer data2); + GCClosure *cc = (GCClosure *) closure; gpointer data1, data2; + GMarshalFunc_VOID__INT_OBJECT callback;
g_return_if_fail (n_param_values == 3);
@@ -86,7 +83,7 @@ scintilla_marshal_VOID__INT_OBJECT (GClosure *closure, data2); }
-/* NONE:INT,BOXED (scintilla-marshal.list:2) */ +/* VOID:INT,BOXED (scintilla-marshal.list:2) */ void scintilla_marshal_VOID__INT_BOXED (GClosure *closure, GValue *return_value G_GNUC_UNUSED, @@ -95,13 +92,13 @@ scintilla_marshal_VOID__INT_BOXED (GClosure *closure, gpointer invocation_hint G_GNUC_UNUSED, gpointer marshal_data) { - typedef void (*GMarshalFunc_VOID__INT_BOXED) (gpointer data1, - gint arg_1, - gpointer arg_2, - gpointer data2); - GMarshalFunc_VOID__INT_BOXED callback; - GCClosure *cc = (GCClosure*) closure; + typedef void (*GMarshalFunc_VOID__INT_BOXED) (gpointer data1, + gint arg1, + gpointer arg2, + gpointer data2); + GCClosure *cc = (GCClosure *) closure; gpointer data1, data2; + GMarshalFunc_VOID__INT_BOXED callback;
g_return_if_fail (n_param_values == 3);
Modified: scintilla/gtk/scintilla-marshal.h 44 lines changed, 22 insertions(+), 22 deletions(-) =================================================================== @@ -1,30 +1,30 @@ +/* This file is generated, all changes will be lost */ +#ifndef __SCINTILLA_MARSHAL_MARSHAL_H__ +#define __SCINTILLA_MARSHAL_MARSHAL_H__
-#ifndef __scintilla_marshal_MARSHAL_H__ -#define __scintilla_marshal_MARSHAL_H__ - -#include <glib-object.h> +#include <glib-object.h>
G_BEGIN_DECLS
-/* NONE:INT,OBJECT (scintilla-marshal.list:1) */ -extern void scintilla_marshal_VOID__INT_OBJECT (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -#define scintilla_marshal_NONE__INT_OBJECT scintilla_marshal_VOID__INT_OBJECT +/* VOID:INT,OBJECT (scintilla-marshal.list:1) */ +extern +void scintilla_marshal_VOID__INT_OBJECT (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data); + +/* VOID:INT,BOXED (scintilla-marshal.list:2) */ +extern +void scintilla_marshal_VOID__INT_BOXED (GClosure *closure, + GValue *return_value, + guint n_param_values, + const GValue *param_values, + gpointer invocation_hint, + gpointer marshal_data);
-/* NONE:INT,BOXED (scintilla-marshal.list:2) */ -extern void scintilla_marshal_VOID__INT_BOXED (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); -#define scintilla_marshal_NONE__INT_BOXED scintilla_marshal_VOID__INT_BOXED
G_END_DECLS
-#endif /* __scintilla_marshal_MARSHAL_H__ */ - +#endif /* __SCINTILLA_MARSHAL_MARSHAL_H__ */
Modified: scintilla/gtk/scintilla-marshal.list 4 lines changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -1,2 +1,2 @@ -NONE:INT,OBJECT -NONE:INT,BOXED +VOID:INT,OBJECT +VOID:INT,BOXED
Modified: scintilla/include/ILexer.h 22 lines changed, 6 insertions(+), 16 deletions(-) =================================================================== @@ -10,15 +10,7 @@
#include "Sci_Position.h"
-#ifdef SCI_NAMESPACE namespace Scintilla { -#endif - -#ifdef _WIN32 - #define SCI_METHOD __stdcall -#else - #define SCI_METHOD -#endif
enum { dvOriginal=0, dvLineEnd=1 };
@@ -54,7 +46,7 @@ class IDocumentWithLineEnd : public IDocument { virtual int SCI_METHOD GetCharacterAndWidth(Sci_Position position, Sci_Position *pWidth) const = 0; };
-enum { lvOriginal=0, lvSubStyles=1 }; +enum { lvOriginal=0, lvSubStyles=1, lvMetaData=2 };
class ILexer { public: @@ -85,16 +77,14 @@ class ILexerWithSubStyles : public ILexer { virtual const char * SCI_METHOD GetSubStyleBases() = 0; };
-class ILoader { +class ILexerWithMetaData : public ILexerWithSubStyles { public: - virtual int SCI_METHOD Release() = 0; - // Returns a status code from SC_STATUS_* - virtual int SCI_METHOD AddData(char *data, Sci_Position length) = 0; - virtual void * SCI_METHOD ConvertToDocument() = 0; + virtual int SCI_METHOD NamedStyles() = 0; + virtual const char * SCI_METHOD NameOfStyle(int style) = 0; + virtual const char * SCI_METHOD TagsOfStyle(int style) = 0; + virtual const char * SCI_METHOD DescriptionOfStyle(int style) = 0; };
-#ifdef SCI_NAMESPACE } -#endif
#endif
Modified: scintilla/include/ILoader.h 21 lines changed, 21 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,21 @@ +// Scintilla source code edit control +/** @file ILoader.h + ** Interface for loading into a Scintilla document from a background thread. + **/ +// Copyright 1998-2017 by Neil Hodgson neilh@scintilla.org +// The License.txt file describes the conditions under which this software may be distributed. + +#ifndef ILOADER_H +#define ILOADER_H + +#include "Sci_Position.h" + +class ILoader { +public: + virtual int SCI_METHOD Release() = 0; + // Returns a status code from SC_STATUS_* + virtual int SCI_METHOD AddData(const char *data, Sci_Position length) = 0; + virtual void * SCI_METHOD ConvertToDocument() = 0; +}; + +#endif
Modified: scintilla/include/Platform.h 287 lines changed, 141 insertions(+), 146 deletions(-) =================================================================== @@ -71,15 +71,10 @@
#endif
-#ifdef SCI_NAMESPACE namespace Scintilla { -#endif
typedef float XYPOSITION; typedef double XYACCUMULATOR; -inline int RoundXYPosition(XYPOSITION xyPos) { - return static_cast<int>(xyPos + 0.5); -}
// Underlying the implementation of the platform classes are platform specific types. // Sometimes these need to be passed around by client code so they are defined here @@ -101,21 +96,19 @@ class Point { XYPOSITION x; XYPOSITION y;
- explicit Point(XYPOSITION x_=0, XYPOSITION y_=0) : x(x_), y(y_) { + constexpr explicit Point(XYPOSITION x_=0, XYPOSITION y_=0) noexcept : x(x_), y(y_) { }
- static Point FromInts(int x_, int y_) { + static Point FromInts(int x_, int y_) noexcept { return Point(static_cast<XYPOSITION>(x_), static_cast<XYPOSITION>(y_)); }
// Other automatically defined methods (assignment, copy constructor, destructor) are fine - - static Point FromLong(long lpoint); };
/** * A geometric rectangle class. - * PRectangle is similar to the Win32 RECT. + * PRectangle is similar to Win32 RECT. * PRectangles contain their top and left sides, but not their right and bottom sides. */ class PRectangle { @@ -125,112 +118,146 @@ class PRectangle { XYPOSITION right; XYPOSITION bottom;
- explicit PRectangle(XYPOSITION left_=0, XYPOSITION top_=0, XYPOSITION right_=0, XYPOSITION bottom_ = 0) : + constexpr explicit PRectangle(XYPOSITION left_=0, XYPOSITION top_=0, XYPOSITION right_=0, XYPOSITION bottom_ = 0) noexcept : left(left_), top(top_), right(right_), bottom(bottom_) { }
- static PRectangle FromInts(int left_, int top_, int right_, int bottom_) { + static PRectangle FromInts(int left_, int top_, int right_, int bottom_) noexcept { return PRectangle(static_cast<XYPOSITION>(left_), static_cast<XYPOSITION>(top_), static_cast<XYPOSITION>(right_), static_cast<XYPOSITION>(bottom_)); }
// Other automatically defined methods (assignment, copy constructor, destructor) are fine
- bool operator==(const PRectangle &rc) const { + bool operator==(const PRectangle &rc) const noexcept { return (rc.left == left) && (rc.right == right) && (rc.top == top) && (rc.bottom == bottom); } - bool Contains(Point pt) const { + bool Contains(Point pt) const noexcept { return (pt.x >= left) && (pt.x <= right) && (pt.y >= top) && (pt.y <= bottom); } - bool ContainsWholePixel(Point pt) const { + bool ContainsWholePixel(Point pt) const noexcept { // Does the rectangle contain all of the pixel to left/below the point return (pt.x >= left) && ((pt.x+1) <= right) && (pt.y >= top) && ((pt.y+1) <= bottom); } - bool Contains(PRectangle rc) const { + bool Contains(PRectangle rc) const noexcept { return (rc.left >= left) && (rc.right <= right) && (rc.top >= top) && (rc.bottom <= bottom); } - bool Intersects(PRectangle other) const { + bool Intersects(PRectangle other) const noexcept { return (right > other.left) && (left < other.right) && (bottom > other.top) && (top < other.bottom); } - void Move(XYPOSITION xDelta, XYPOSITION yDelta) { + void Move(XYPOSITION xDelta, XYPOSITION yDelta) noexcept { left += xDelta; top += yDelta; right += xDelta; bottom += yDelta; } - XYPOSITION Width() const { return right - left; } - XYPOSITION Height() const { return bottom - top; } - bool Empty() const { + XYPOSITION Width() const noexcept { return right - left; } + XYPOSITION Height() const noexcept { return bottom - top; } + bool Empty() const noexcept { return (Height() <= 0) || (Width() <= 0); } };
/** - * Holds a desired RGB colour. + * Holds an RGB colour with 8 bits for each component. */ +constexpr const float componentMaximum = 255.0f; class ColourDesired { - long co; + int co; public: - ColourDesired(long lcol=0) { - co = lcol; + explicit ColourDesired(int co_=0) noexcept : co(co_) { }
- ColourDesired(unsigned int red, unsigned int green, unsigned int blue) { - Set(red, green, blue); + ColourDesired(unsigned int red, unsigned int green, unsigned int blue) noexcept : + co(red | (green << 8) | (blue << 16)) { }
- bool operator==(const ColourDesired &other) const { + bool operator==(const ColourDesired &other) const noexcept { return co == other.co; }
- void Set(long lcol) { - co = lcol; + int AsInteger() const noexcept { + return co; }
- void Set(unsigned int red, unsigned int green, unsigned int blue) { - co = red | (green << 8) | (blue << 16); + // Red, green and blue values as bytes 0..255 + unsigned char GetRed() const noexcept { + return co & 0xff; + } + unsigned char GetGreen() const noexcept { + return (co >> 8) & 0xff; + } + unsigned char GetBlue() const noexcept { + return (co >> 16) & 0xff; }
- static inline unsigned int ValueOfHex(const char ch) { - if (ch >= '0' && ch <= '9') - return ch - '0'; - else if (ch >= 'A' && ch <= 'F') - return ch - 'A' + 10; - else if (ch >= 'a' && ch <= 'f') - return ch - 'a' + 10; - else - return 0; + // Red, green and blue values as float 0..1.0 + float GetRedComponent() const noexcept { + return GetRed() / componentMaximum; + } + float GetGreenComponent() const noexcept { + return GetGreen() / componentMaximum; + } + float GetBlueComponent() const noexcept { + return GetBlue() / componentMaximum; } +};
- void Set(const char *val) { - if (*val == '#') { - val++; - } - unsigned int r = ValueOfHex(val[0]) * 16 + ValueOfHex(val[1]); - unsigned int g = ValueOfHex(val[2]) * 16 + ValueOfHex(val[3]); - unsigned int b = ValueOfHex(val[4]) * 16 + ValueOfHex(val[5]); - Set(r, g, b); +/** +* Holds an RGBA colour. +*/ +class ColourAlpha : public ColourDesired { +public: + explicit ColourAlpha(int co_ = 0) noexcept : ColourDesired(co_) { }
- long AsLong() const { - return co; + ColourAlpha(unsigned int red, unsigned int green, unsigned int blue) noexcept : + ColourDesired(red | (green << 8) | (blue << 16)) { }
- unsigned int GetRed() const { - return co & 0xff; + ColourAlpha(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) noexcept : + ColourDesired(red | (green << 8) | (blue << 16) | (alpha << 24)) { }
- unsigned int GetGreen() const { - return (co >> 8) & 0xff; + ColourAlpha(ColourDesired cd, unsigned int alpha) noexcept : + ColourDesired(cd.AsInteger() | (alpha << 24)) { }
- unsigned int GetBlue() const { - return (co >> 16) & 0xff; + ColourDesired GetColour() const noexcept { + return ColourDesired(AsInteger() & 0xffffff); + } + + unsigned char GetAlpha() const noexcept { + return (AsInteger() >> 24) & 0xff; + } + + float GetAlphaComponent() const noexcept { + return GetAlpha() / componentMaximum; + } + + ColourAlpha MixedWith(ColourAlpha other) const noexcept { + const unsigned int red = (GetRed() + other.GetRed()) / 2; + const unsigned int green = (GetGreen() + other.GetGreen()) / 2; + const unsigned int blue = (GetBlue() + other.GetBlue()) / 2; + const unsigned int alpha = (GetAlpha() + other.GetAlpha()) / 2; + return ColourAlpha(red, green, blue, alpha); + } +}; + +/** +* Holds an element of a gradient with an RGBA colour and a relative position. +*/ +class ColourStop { +public: + float position; + ColourAlpha colour; + ColourStop(float position_, ColourAlpha colour_) noexcept : + position(position_), colour(colour_) { } };
@@ -254,7 +281,7 @@ struct FontParameters { bool italic_=false, int extraFontFlag_=0, int technology_=0, - int characterSet_=0) : + int characterSet_=0) noexcept :
faceName(faceName_), size(size_), @@ -271,19 +298,21 @@ struct FontParameters { class Font { protected: FontID fid; - // Private so Font objects can not be copied - Font(const Font &); - Font &operator=(const Font &); public: - Font(); + Font() noexcept; + // Deleted so Font objects can not be copied + Font(const Font &) = delete; + Font(Font &&) = delete; + Font &operator=(const Font &) = delete; + Font &operator=(Font &&) = delete; virtual ~Font();
virtual void Create(const FontParameters &fp); virtual void Release();
- FontID GetID() { return fid; } + FontID GetID() const noexcept { return fid; } // Alias another font - caller guarantees not to Release - void SetID(FontID fid_) { fid = fid_; } + void SetID(FontID fid_) noexcept { fid = fid_; } friend class Surface; friend class SurfaceImpl; }; @@ -292,12 +321,12 @@ class Font { * A surface abstracts a place to draw. */ class Surface { -private: - // Private so Surface objects can not be copied - Surface(const Surface &) {} - Surface &operator=(const Surface &) { return *this; } public: - Surface() {} + Surface() noexcept = default; + Surface(const Surface &) = delete; + Surface(Surface &&) = delete; + Surface &operator=(const Surface &) = delete; + Surface &operator=(Surface &&) = delete; virtual ~Surface() {} static Surface *Allocate(int technology);
@@ -312,13 +341,15 @@ class Surface { virtual int DeviceHeightFont(int points)=0; virtual void MoveTo(int x_, int y_)=0; virtual void LineTo(int x_, int y_)=0; - virtual void Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired back)=0; + virtual void Polygon(Point *pts, size_t npts, ColourDesired fore, ColourDesired back)=0; virtual void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back)=0; virtual void FillRectangle(PRectangle rc, ColourDesired back)=0; virtual void FillRectangle(PRectangle rc, Surface &surfacePattern)=0; virtual void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back)=0; virtual void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill, ColourDesired outline, int alphaOutline, int flags)=0; + enum class GradientOptions { leftToRight, topToBottom }; + virtual void GradientRectangle(PRectangle rc, const std::vector<ColourStop> &stops, GradientOptions options)=0; virtual void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) = 0; virtual void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back)=0; virtual void Copy(PRectangle rc, Point from, Surface &surfaceSource)=0; @@ -328,11 +359,9 @@ class Surface { virtual void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore)=0; virtual void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions)=0; virtual XYPOSITION WidthText(Font &font_, const char *s, int len)=0; - virtual XYPOSITION WidthChar(Font &font_, char ch)=0; 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;
@@ -343,11 +372,6 @@ class Surface { virtual void SetDBCSMode(int codePage)=0; };
-/** - * A simple callback action passing one piece of untyped user data. - */ -typedef void (*CallBackAction)(void*); - /** * Class to hide the details of window manipulation. * Does not own the window which will normally have a longer life than this object. @@ -356,38 +380,31 @@ class Window { protected: WindowID wid; public: - Window() : wid(0), cursorLast(cursorInvalid) { - } - Window(const Window &source) : wid(source.wid), cursorLast(cursorInvalid) { + Window() noexcept : wid(nullptr), cursorLast(cursorInvalid) { } - virtual ~Window(); - Window &operator=(WindowID wid_) { + Window(const Window &source) = delete; + Window(Window &&) = delete; + Window &operator=(WindowID wid_) noexcept { wid = wid_; cursorLast = cursorInvalid; return *this; } - Window &operator=(const Window &other) { - if (this != &other) { - wid = other.wid; - cursorLast = other.cursorLast; - } - return *this; - } - WindowID GetID() const { return wid; } - bool Created() const { return wid != 0; } + Window &operator=(const Window &) = delete; + Window &operator=(Window &&) = delete; + virtual ~Window(); + WindowID GetID() const noexcept { return wid; } + bool Created() const noexcept { return wid != nullptr; } void Destroy(); - bool HasFocus(); - PRectangle GetPosition(); + PRectangle GetPosition() const; void SetPosition(PRectangle rc); - void SetPositionRelative(PRectangle rc, Window relativeTo); - PRectangle GetClientPosition(); + void SetPositionRelative(PRectangle rc, const Window *relativeTo); + PRectangle GetClientPosition() const; void Show(bool show=true); void InvalidateAll(); void InvalidateRectangle(PRectangle rc); 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; @@ -397,13 +414,26 @@ class Window { * Listbox management. */
+// ScintillaBase implements IListBoxDelegate to receive ListBoxEvents from a ListBox + +struct ListBoxEvent { + enum class EventType { selectionChange, doubleClick } event; + ListBoxEvent(EventType event_) noexcept : event(event_) { + } +}; + +class IListBoxDelegate { +public: + virtual void ListNotify(ListBoxEvent *plbe)=0; +}; + class ListBox : public Window { public: - ListBox(); - virtual ~ListBox(); + ListBox() noexcept; + ~ListBox() override; static ListBox *Allocate();
- virtual void SetFont(Font &font)=0; + void SetFont(Font &font) override =0; virtual void Create(Window &parent, int ctrlID, Point location, int lineHeight_, bool unicodeMode_, int technology_)=0; virtual void SetAverageCharWidth(int width)=0; virtual void SetVisibleRows(int rows)=0; @@ -420,7 +450,7 @@ class ListBox : public Window { 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; };
@@ -430,27 +460,19 @@ class ListBox : public Window { class Menu { MenuID mid; public: - Menu(); - MenuID GetID() { return mid; } + Menu() noexcept; + MenuID GetID() const noexcept { return mid; } void CreatePopUp(); void Destroy(); void Show(Point pt, Window &w); };
-class ElapsedTime { - long bigBit; - long littleBit; -public: - ElapsedTime(); - double Duration(bool reset=false); -}; - /** * Dynamic Library (DLL/SO/...) loading */ class DynamicLibrary { public: - virtual ~DynamicLibrary() {} + virtual ~DynamicLibrary() = default;
/// @return Pointer to function "name", or NULL on failure. virtual Function FindFunction(const char *name) = 0; @@ -477,61 +499,34 @@ class DynamicLibrary { * and chrome colour. Not a creatable object, more of a module with several functions. */ class Platform { - // Private so Platform objects can not be copied - Platform(const Platform &) {} - Platform &operator=(const Platform &) { return *this; } public: - // Should be private because no new Platforms are ever created - // but gcc warns about this - Platform() {} - ~Platform() {} + Platform() = default; + Platform(const Platform &) = delete; + Platform(Platform &&) = delete; + Platform &operator=(const Platform &) = delete; + Platform &operator=(Platform &&) = delete; + ~Platform() = default; static ColourDesired Chrome(); static ColourDesired ChromeHighlight(); 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) { + static constexpr long LongFromTwoShorts(short a,short b) noexcept { return (a) | ((b) << 16); } - static short HighShortFromLong(long x) { - return static_cast<short>(x >> 16); - } - static short LowShortFromLong(long x) { - return static_cast<short>(x & 0xffff); - } + static void DebugPrintf(const char *format, ...); static bool ShowAssertionPopUps(bool assertionPopUps_); static void Assert(const char *c, const char *file, int line) CLANG_ANALYZER_NORETURN; - static int Clamp(int val, int minVal, int maxVal); };
#ifdef NDEBUG #define PLATFORM_ASSERT(c) ((void)0) #else -#ifdef SCI_NAMESPACE #define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Scintilla::Platform::Assert(#c, __FILE__, __LINE__)) -#else -#define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Platform::Assert(#c, __FILE__, __LINE__)) -#endif #endif
-#ifdef SCI_NAMESPACE } -#endif
#endif
Modified: scintilla/include/SciLexer.h 14 lines changed, 14 insertions(+), 0 deletions(-) =================================================================== @@ -135,6 +135,8 @@ #define SCLEX_JSON 120 #define SCLEX_EDIFACT 121 #define SCLEX_INDENT 122 +#define SCLEX_MAXIMA 123 +#define SCLEX_LPEG 999 #define SCLEX_AUTOMATIC 1000 #define SCE_P_DEFAULT 0 #define SCE_P_COMMENTLINE 1 @@ -557,6 +559,10 @@ #define SCE_DIFF_DELETED 5 #define SCE_DIFF_ADDED 6 #define SCE_DIFF_CHANGED 7 +#define SCE_DIFF_PATCH_ADD 8 +#define SCE_DIFF_PATCH_DELETE 9 +#define SCE_DIFF_REMOVED_PATCH_ADD 10 +#define SCE_DIFF_REMOVED_PATCH_DELETE 11 #define SCE_CONF_DEFAULT 0 #define SCE_CONF_COMMENT 1 #define SCE_CONF_NUMBER 2 @@ -672,6 +678,14 @@ #define SCE_MATLAB_OPERATOR 6 #define SCE_MATLAB_IDENTIFIER 7 #define SCE_MATLAB_DOUBLEQUOTESTRING 8 +#define SCE_MAXIMA_OPERATOR 0 +#define SCE_MAXIMA_COMMANDENDING 1 +#define SCE_MAXIMA_COMMENT 2 +#define SCE_MAXIMA_NUMBER 3 +#define SCE_MAXIMA_STRING 4 +#define SCE_MAXIMA_COMMAND 5 +#define SCE_MAXIMA_VARIABLE 6 +#define SCE_MAXIMA_UNKNOWN 7 #define SCE_SCRIPTOL_DEFAULT 0 #define SCE_SCRIPTOL_WHITE 1 #define SCE_SCRIPTOL_COMMENTLINE 2
Modified: scintilla/include/Sci_Position.h 12 lines changed, 10 insertions(+), 2 deletions(-) =================================================================== @@ -9,13 +9,21 @@ #ifndef SCI_POSITION_H #define SCI_POSITION_H
+#include <stddef.h> + // Basic signed type used throughout interface -typedef int Sci_Position; +typedef ptrdiff_t Sci_Position;
// Unsigned variant used for ILexer::Lex and ILexer::Fold -typedef unsigned int Sci_PositionU; +typedef size_t Sci_PositionU;
// For Sci_CharacterRange which is defined as long to be compatible with Win32 CHARRANGE typedef long Sci_PositionCR;
+#ifdef _WIN32 + #define SCI_METHOD __stdcall +#else + #define SCI_METHOD +#endif + #endif
Modified: scintilla/include/Scintilla.h 26 lines changed, 18 insertions(+), 8 deletions(-) =================================================================== @@ -27,12 +27,7 @@ int Scintilla_LinkLexers(void); #endif
// Include header that defines basic numeric types. -#if defined(_MSC_VER) -// Older releases of MSVC did not have stdint.h. -#include <stddef.h> -#else #include <stdint.h> -#endif
// Define uptr_t, an unsigned integer type large enough to hold a pointer. typedef uintptr_t uptr_t; @@ -293,6 +288,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define INDIC_TEXTFORE 17 #define INDIC_POINT 18 #define INDIC_POINTCHARACTER 19 +#define INDIC_GRADIENT 20 +#define INDIC_GRADIENTCENTRE 21 #define INDIC_IME 32 #define INDIC_IME_MAX 35 #define INDIC_MAX 35 @@ -320,8 +317,6 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SETWHITESPACEBACK 2085 #define SCI_SETWHITESPACESIZE 2086 #define SCI_GETWHITESPACESIZE 2087 -#define SCI_SETSTYLEBITS 2090 -#define SCI_GETSTYLEBITS 2091 #define SCI_SETLINESTATE 2092 #define SCI_GETLINESTATE 2093 #define SCI_GETMAXLINESTATE 2094 @@ -397,6 +392,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_PRINT_BLACKONWHITE 2 #define SC_PRINT_COLOURONWHITE 3 #define SC_PRINT_COLOURONWHITEDEFAULTBG 4 +#define SC_PRINT_SCREENCOLOURS 5 #define SCI_SETPRINTCOLOURMODE 2148 #define SCI_GETPRINTCOLOURMODE 2149 #define SCFIND_WHOLEWORD 0x2 @@ -552,6 +548,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_WRAPINDENT_FIXED 0 #define SC_WRAPINDENT_SAME 1 #define SC_WRAPINDENT_INDENT 2 +#define SC_WRAPINDENT_DEEPINDENT 3 #define SCI_SETWRAPINDENTMODE 2472 #define SCI_GETWRAPINDENTMODE 2473 #define SC_CACHE_NONE 0 @@ -693,9 +690,13 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SELECTIONISRECTANGLE 2372 #define SCI_SETZOOM 2373 #define SCI_GETZOOM 2374 +#define SC_DOCUMENTOPTION_DEFAULT 0 +#define SC_DOCUMENTOPTION_STYLES_NONE 0x1 +#define SC_DOCUMENTOPTION_TEXT_LARGE 0x100 #define SCI_CREATEDOCUMENT 2375 #define SCI_ADDREFDOCUMENT 2376 #define SCI_RELEASEDOCUMENT 2377 +#define SCI_GETDOCUMENTOPTIONS 2379 #define SCI_GETMODEVENTMASK 2378 #define SCI_SETFOCUS 2380 #define SCI_GETFOCUS 2381 @@ -762,6 +763,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_SEL_THIN 3 #define SCI_SETSELECTIONMODE 2422 #define SCI_GETSELECTIONMODE 2423 +#define SCI_GETMOVEEXTENDSSELECTION 2706 #define SCI_GETLINESELSTARTPOSITION 2424 #define SCI_GETLINESELENDPOSITION 2425 #define SCI_LINEDOWNRECTEXTEND 2426 @@ -990,7 +992,6 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETPROPERTY 4008 #define SCI_GETPROPERTYEXPANDED 4009 #define SCI_GETPROPERTYINT 4010 -#define SCI_GETSTYLEBITSNEEDED 4011 #define SCI_GETLEXERLANGUAGE 4012 #define SCI_PRIVATELEXERCALL 4013 #define SCI_PROPERTYNAMES 4014 @@ -1010,6 +1011,10 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SETIDENTIFIERS 4024 #define SCI_DISTANCETOSECONDARYSTYLES 4025 #define SCI_GETSUBSTYLEBASES 4026 +#define SCI_GETNAMEDSTYLES 4029 +#define SCI_NAMEOFSTYLE 4030 +#define SCI_TAGSOFSTYLE 4031 +#define SCI_DESCRIPTIONOFSTYLE 4032 #define SC_MOD_INSERTTEXT 0x1 #define SC_MOD_DELETETEXT 0x2 #define SC_MOD_CHANGESTYLE 0x4 @@ -1102,6 +1107,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #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 @@ -1210,6 +1216,10 @@ struct SCNotification { #define RangeToFormat Sci_RangeToFormat #define NotifyHeader Sci_NotifyHeader
+#define SCI_SETSTYLEBITS 2090 +#define SCI_GETSTYLEBITS 2091 +#define SCI_GETSTYLEBITSNEEDED 4011 + #endif
#endif
Modified: scintilla/include/Scintilla.iface 85 lines changed, 69 insertions(+), 16 deletions(-) =================================================================== @@ -639,6 +639,8 @@ val INDIC_FULLBOX=16 val INDIC_TEXTFORE=17 val INDIC_POINT=18 val INDIC_POINTCHARACTER=19 +val INDIC_GRADIENT=20 +val INDIC_GRADIENTCENTRE=21 val INDIC_IME=32 val INDIC_IME_MAX=35 val INDIC_MAX=35 @@ -702,14 +704,6 @@ set void SetWhitespaceSize=2086(int size,) # Get the size of the dots used to mark space characters. get int GetWhitespaceSize=2087(,)
-# Divide each styling byte into lexical class bits (default: 5) and indicator -# bits (default: 3). If a lexer requires more than 32 lexical states, then this -# is used to expand the possible states. -set void SetStyleBits=2090(int bits,) - -# Retrieve number of bits in style bytes used to hold the lexical state. -get int GetStyleBits=2091(,) - # Used to hold extra styling information for each line. set void SetLineState=2092(int line, int state)
@@ -930,6 +924,7 @@ get int GetPrintMagnification=2147(,)
enu PrintOption=SC_PRINT_ # PrintColourMode - use same colours as screen. +# with the exception of line number margins, which use a white background val SC_PRINT_NORMAL=0 # PrintColourMode - invert the light value of each style for printing. val SC_PRINT_INVERTLIGHT=1 @@ -939,6 +934,8 @@ val SC_PRINT_BLACKONWHITE=2 val SC_PRINT_COLOURONWHITE=3 # PrintColourMode - only the default-background is forced to be white for printing. val SC_PRINT_COLOURONWHITEDEFAULTBG=4 +# PrintColourMode - use same colours as screen, including line number margins. +val SC_PRINT_SCREENCOLOURS=5
# Modify colours when printing for clearer printed text. set void SetPrintColourMode=2148(int mode,) @@ -997,7 +994,7 @@ fun int GetSelText=2161(, stringresult text) # Return the length of the text. fun int GetTextRange=2162(, textrange tr)
-# Draw the selection in normal style or with selection highlighted. +# Draw the selection either highlighted or in normal (non-highlighted) style. fun void HideSelection=2163(bool hide,)
# Retrieve the x value of the point in the window where a position is displayed. @@ -1362,6 +1359,7 @@ enu WrapIndentMode=SC_WRAPINDENT_ val SC_WRAPINDENT_FIXED=0 val SC_WRAPINDENT_SAME=1 val SC_WRAPINDENT_INDENT=2 +val SC_WRAPINDENT_DEEPINDENT=3
# Sets how wrapped sublines are placed. Default is fixed. set void SetWrapIndentMode=2472(int wrapIndentMode,) @@ -1786,14 +1784,22 @@ set void SetZoom=2373(int zoomInPoints,) # Retrieve the zoom level. get int GetZoom=2374(,)
+enu DocumentOption=SC_DOCUMENTOPTION_ +val SC_DOCUMENTOPTION_DEFAULT=0 +val SC_DOCUMENTOPTION_STYLES_NONE=0x1 +val SC_DOCUMENTOPTION_TEXT_LARGE=0x100 + # Create a new document object. # Starts with reference count of 1 and not selected into editor. -fun int CreateDocument=2375(,) +fun int CreateDocument=2375(int bytes, int documentOptions) # Extend life of document. fun void AddRefDocument=2376(, int doc) # Release a reference to the document, deleting document if it fades to black. fun void ReleaseDocument=2377(, int doc)
+# Get which document options are set. +get int GetDocumentOptions=2379(,) + # Get which document modification events are sent to the container. get int GetModEventMask=2378(,)
@@ -1979,6 +1985,9 @@ set void SetSelectionMode=2422(int selectionMode,) # Get the mode of the current selection. get int GetSelectionMode=2423(,)
+# Get whether or not regular caret moves will extend or reduce the selection. +get bool GetMoveExtendsSelection=2706(,) + # Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line). fun position GetLineSelStartPosition=2424(int line,)
@@ -2552,7 +2561,7 @@ set void SetTechnology=2630(int technology,) get int GetTechnology=2631(,)
# Create an ILoader*. -fun int CreateLoader=2632(int bytes,) +fun int CreateLoader=2632(int bytes, int documentOptions)
# On OS X, show a find indicator. fun void FindIndicatorShow=2640(position start, position end) @@ -2645,9 +2654,6 @@ get int GetPropertyExpanded=4009(string key, stringresult value) # interpreted as an int AFTER any "$()" variable replacement. get int GetPropertyInt=4010(string key, int defaultValue)
-# Retrieve the number of bits the current lexer needs for styling. -get int GetStyleBitsNeeded=4011(,) - # Retrieve the name of the lexer. # Return the length of the text. # Result is NUL-terminated. @@ -2709,6 +2715,21 @@ get int DistanceToSecondaryStyles=4025(,) # Result is NUL-terminated. get int GetSubStyleBases=4026(, stringresult styles)
+# Retrieve the number of named styles for the lexer. +get int GetNamedStyles=4029(,) + +# Retrieve the name of a style. +# Result is NUL-terminated. +fun int NameOfStyle=4030(int style, stringresult name) + +# Retrieve a ' ' separated list of style tags like "literal quoted string". +# Result is NUL-terminated. +fun int TagsOfStyle=4031(int style, stringresult tags) + +# Retrieve a description of a style. +# Result is NUL-terminated. +fun int DescriptionOfStyle=4032(int style, stringresult description) + # Notifications # Type of modification and the action which caused the modification. # These are defined as a bit mask to make it easy to specify which notifications are wanted. @@ -2917,6 +2938,8 @@ val SCLEX_TEHEX=119 val SCLEX_JSON=120 val SCLEX_EDIFACT=121 val SCLEX_INDENT=122 +val SCLEX_MAXIMA=123 +val SCLEX_LPEG=999
# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a # value assigned in sequence from SCLEX_AUTOMATIC+1. @@ -2944,7 +2967,11 @@ val SCE_P_FSTRING=16 val SCE_P_FCHARACTER=17 val SCE_P_FTRIPLE=18 val SCE_P_FTRIPLEDOUBLE=19 -# Lexical states for SCLEX_CPP, SCLEX_BULLANT, SCLEX_COBOL, SCLEX_TACL, SCLEX_TAL +# Lexical states for SCLEX_CPP +# Lexical states for SCLEX_BULLANT +# Lexical states for SCLEX_COBOL +# Lexical states for SCLEX_TACL +# Lexical states for SCLEX_TAL lex Cpp=SCLEX_CPP SCE_C_ lex BullAnt=SCLEX_BULLANT SCE_C_ lex COBOL=SCLEX_COBOL SCE_C_ @@ -3397,6 +3424,10 @@ val SCE_DIFF_POSITION=4 val SCE_DIFF_DELETED=5 val SCE_DIFF_ADDED=6 val SCE_DIFF_CHANGED=7 +val SCE_DIFF_PATCH_ADD=8 +val SCE_DIFF_PATCH_DELETE=9 +val SCE_DIFF_REMOVED_PATCH_ADD=10 +val SCE_DIFF_REMOVED_PATCH_DELETE=11 # Lexical states for SCLEX_CONF (Apache Configuration Files Lexer) lex Conf=SCLEX_CONF SCE_CONF_ val SCE_CONF_DEFAULT=0 @@ -3532,6 +3563,16 @@ val SCE_MATLAB_STRING=5 val SCE_MATLAB_OPERATOR=6 val SCE_MATLAB_IDENTIFIER=7 val SCE_MATLAB_DOUBLEQUOTESTRING=8 +# Lexical states for SCLEX_MAXIMA +lex Maxima=SCLEX_MAXIMA SCE_MAXIMA_ +val SCE_MAXIMA_OPERATOR=0 +val SCE_MAXIMA_COMMANDENDING=1 +val SCE_MAXIMA_COMMENT=2 +val SCE_MAXIMA_NUMBER=3 +val SCE_MAXIMA_STRING=4 +val SCE_MAXIMA_COMMAND=5 +val SCE_MAXIMA_VARIABLE=6 +val SCE_MAXIMA_UNKNOWN=7 # Lexical states for SCLEX_SCRIPTOL lex Sol=SCLEX_SCRIPTOL SCE_SCRIPTOL_ val SCE_SCRIPTOL_DEFAULT=0 @@ -4855,13 +4896,25 @@ evt void FocusIn=2028(void) 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. +# There are no provisional APIs currently.
cat Provisional
cat Deprecated
+# Divide each styling byte into lexical class bits (default: 5) and indicator +# bits (default: 3). If a lexer requires more than 32 lexical states, then this +# is used to expand the possible states. +set void SetStyleBits=2090(int bits,) + +# Retrieve number of bits in style bytes used to hold the lexical state. +get int GetStyleBits=2091(,) + +# Retrieve the number of bits the current lexer needs for styling. +get int GetStyleBitsNeeded=4011(,) + # Deprecated in 3.5.5
# Always interpret keyboard input as Unicode
Modified: scintilla/lexers/LexAbaqus.cxx 2 lines changed, 0 insertions(+), 2 deletions(-) =================================================================== @@ -26,9 +26,7 @@ #include "CharacterSet.h" #include "LexerModule.h"
-#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif
static inline bool IsAKeywordChar(const int ch) { return (ch < 0x80 && (isalnum(ch) || (ch == '_') || (ch == ' ')));
Modified: scintilla/lexers/LexAda.cxx 2 lines changed, 0 insertions(+), 2 deletions(-) =================================================================== @@ -25,9 +25,7 @@ #include "CharacterSet.h" #include "LexerModule.h"
-#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif
/* * Interface
Modified: scintilla/lexers/LexAsm.cxx 5 lines changed, 2 insertions(+), 3 deletions(-) =================================================================== @@ -30,10 +30,9 @@ #include "CharacterSet.h" #include "LexerModule.h" #include "OptionSet.h" +#include "DefaultLexer.h"
-#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif
static inline bool IsAWordChar(const int ch) { return (ch < 0x80) && (isalnum(ch) || ch == '.' || @@ -139,7 +138,7 @@ struct OptionSetAsm : public OptionSet<OptionsAsm> { } };
-class LexerAsm : public ILexer { +class LexerAsm : public DefaultLexer { WordList cpuInstruction; WordList mathInstruction; WordList registers;
Modified: scintilla/lexers/LexBash.cxx 2 lines changed, 0 insertions(+), 2 deletions(-) =================================================================== @@ -23,9 +23,7 @@ #include "CharacterSet.h" #include "LexerModule.h"
-#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif
#define HERE_DELIM_MAX 256
Modified: scintilla/lexers/LexBasic.cxx 5 lines changed, 2 insertions(+), 3 deletions(-) =================================================================== @@ -37,10 +37,9 @@ #include "CharacterSet.h" #include "LexerModule.h" #include "OptionSet.h" +#include "DefaultLexer.h"
-#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif
/* Bits: * 1 - whitespace @@ -226,7 +225,7 @@ struct OptionSetBasic : public OptionSet<OptionsBasic> { } };
-class LexerBasic : public ILexer { +class LexerBasic : public DefaultLexer { char comment_char; int (*CheckFoldPoint)(char const *, int &); WordList keywordlists[4];
Modified: scintilla/lexers/LexBatch.cxx 2 lines changed, 0 insertions(+), 2 deletions(-) =================================================================== @@ -23,9 +23,7 @@ #include "CharacterSet.h" #include "LexerModule.h"
-#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif
static bool Is0To9(char ch) { return (ch >= '0') && (ch <= '9');
Modified: scintilla/lexers/LexCOBOL.cxx 2 lines changed, 0 insertions(+), 2 deletions(-) =================================================================== @@ -26,9 +26,7 @@ #include "CharacterSet.h" #include "LexerModule.h"
-#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif
#define IN_DIVISION 0x01 #define IN_DECLARATIVES 0x02
Modified: scintilla/lexers/LexCPP.cxx 183 lines changed, 132 insertions(+), 51 deletions(-) =================================================================== @@ -13,6 +13,7 @@ #include <assert.h> #include <ctype.h>
+#include <utility> #include <string> #include <vector> #include <map> @@ -22,6 +23,7 @@ #include "Scintilla.h" #include "SciLexer.h"
+#include "StringCopy.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" @@ -32,14 +34,12 @@ #include "SparseState.h" #include "SubStyles.h"
-#ifdef SCI_NAMESPACE using namespace Scintilla; -#endif
namespace { // Use an unnamed namespace to protect the functions and classes from name conflicts
-bool IsSpaceEquiv(int state) { +bool IsSpaceEquiv(int state) noexcept { return (state <= SCE_C_COMMENTDOC) || // including SCE_C_DEFAULT, SCE_C_COMMENT, SCE_C_COMMENTLINE (state == SCE_C_COMMENTLINEDOC) || (state == SCE_C_COMMENTDOCKEYWORD) || @@ -53,8 +53,8 @@ bool IsSpaceEquiv(int state) { // a = b+++/ptn/... // Putting a space between the '++' post-inc operator and the '+' binary op // fixes this, and is highly recommended for readability anyway. -bool FollowsPostfixOperator(StyleContext &sc, LexAccessor &styler) { - Sci_Position pos = static_cast<Sci_Position>(sc.currentPos); +bool FollowsPostfixOperator(const StyleContext &sc, LexAccessor &styler) { + Sci_Position pos = sc.currentPos; while (--pos > 0) { const char ch = styler[pos]; if (ch == '+' || ch == '-') { @@ -64,10 +64,10 @@ bool FollowsPostfixOperator(StyleContext &sc, LexAccessor &styler) { return false; }
-bool followsReturnKeyword(StyleContext &sc, LexAccessor &styler) { +bool followsReturnKeyword(const StyleContext &sc, LexAccessor &styler) { // Don't look at styles, so no need to flush. - Sci_Position pos = static_cast<Sci_Position>(sc.currentPos); - Sci_Position currentLine = styler.GetLine(pos); + Sci_Position pos = sc.currentPos; + const Sci_Position currentLine = styler.GetLine(pos); const Sci_Position lineStartPos = styler.LineStart(currentLine); while (--pos > lineStartPos) { const char ch = styler.SafeGetCharAt(pos); @@ -86,11 +86,11 @@ bool followsReturnKeyword(StyleContext &sc, LexAccessor &styler) { return !*s; }
-bool IsSpaceOrTab(int ch) { +bool IsSpaceOrTab(int ch) noexcept { return ch == ' ' || ch == '\t'; }
-bool OnlySpaceOrTab(const std::string &s) { +bool OnlySpaceOrTab(const std::string &s) noexcept { for (const char ch : s) { if (!IsSpaceOrTab(ch)) return false; @@ -102,7 +102,7 @@ std::vectorstd::string StringSplit(const std::string &text, int separator) { std::vectorstd::string vs(text.empty() ? 0 : 1); for (const char ch : text) { if (ch == separator) { - vs.push_back(std::string()); + vs.emplace_back(); } else { vs.back() += ch; } @@ -144,8 +144,8 @@ void highlightTaskMarker(StyleContext &sc, LexAccessor &styler, int activity, const WordList &markerList, bool caseSensitive){ if ((isoperator(sc.chPrev) || IsASpace(sc.chPrev)) && markerList.Length()) { const int lengthMarker = 50; - char marker[lengthMarker+1]; - Sci_Position currPos = static_cast<Sci_Position>(sc.currentPos); + char marker[lengthMarker+1] = ""; + const Sci_Position currPos = static_cast<Sci_Position>(sc.currentPos); int i = 0; while (i < lengthMarker) { const char ch = styler.SafeGetCharAt(currPos + i); @@ -155,7 +155,7 @@ void highlightTaskMarker(StyleContext &sc, LexAccessor &styler, if (caseSensitive) marker[i] = ch; else - marker[i] = static_cast<char>(tolower(ch)); + marker[i] = MakeLowerCase(ch); i++; } marker[i] = '\0'; @@ -216,7 +216,7 @@ std::string GetRestOfLine(LexAccessor &styler, Sci_Position start, bool allowSpa return restOfLine; }
-bool IsStreamCommentStyle(int style) { +bool IsStreamCommentStyle(int style) noexcept { return style == SCE_C_COMMENT || style == SCE_C_COMMENTDOC || style == SCE_C_COMMENTDOCKEYWORD || @@ -238,22 +238,22 @@ class LinePPState { int state; int ifTaken; int level; - bool ValidLevel() const { + bool ValidLevel() const noexcept { return level >= 0 && level < 32; } - int maskLevel() const { + int maskLevel() const noexcept { return 1 << level; } public: LinePPState() : state(0), ifTaken(0), level(-1) { } - bool IsInactive() const { + bool IsInactive() const noexcept { return state != 0; } - bool CurrentIfTaken() const { + bool CurrentIfTaken() const noexcept { return (ifTaken & maskLevel()) != 0; } - void StartSection(bool on) { + void StartSection(bool on) noexcept { level++; if (ValidLevel()) { if (on) { @@ -265,14 +265,14 @@ class LinePPState { } } } - void EndSection() { + void EndSection() noexcept { if (ValidLevel()) { state &= ~maskLevel(); ifTaken &= ~maskLevel(); } level--; } - void InvertCurrentLevel() { + void InvertCurrentLevel() noexcept { if (ValidLevel()) { state ^= maskLevel(); ifTaken |= maskLevel(); @@ -413,7 +413,7 @@ struct OptionSetCPP : public OptionSet<OptionsCPP> {
DefineProperty("fold.cpp.explicit.anywhere", &OptionsCPP::foldExplicitAnywhere, "Set this property to 1 to enable explicit fold points anywhere, not just in line comments."); - + DefineProperty("fold.cpp.preprocessor.at.else", &OptionsCPP::foldPreprocessorAtElse, "This option enables folding on a preprocessor #else or #endif line of an #if statement.");
@@ -432,9 +432,41 @@ struct OptionSetCPP : public OptionSet<OptionsCPP> {
const char styleSubable[] = {SCE_C_IDENTIFIER, SCE_C_COMMENTDOCKEYWORD, 0};
+LexicalClass lexicalClasses[] = { + // Lexer Cpp SCLEX_CPP SCE_C_: + 0, "SCE_C_DEFAULT", "default", "White space", + 1, "SCE_C_COMMENT", "comment", "Comment: /* */.", + 2, "SCE_C_COMMENTLINE", "comment line", "Line Comment: //.", + 3, "SCE_C_COMMENTDOC", "comment documentation", "Doc comment: block comments beginning with /** or /*!", + 4, "SCE_C_NUMBER", "literal numeric", "Number", + 5, "SCE_C_WORD", "keyword", "Keyword", + 6, "SCE_C_STRING", "literal string", "Double quoted string", + 7, "SCE_C_CHARACTER", "literal string character", "Single quoted string", + 8, "SCE_C_UUID", "literal uuid", "UUIDs (only in IDL)", + 9, "SCE_C_PREPROCESSOR", "preprocessor", "Preprocessor", + 10, "SCE_C_OPERATOR", "operator", "Operators", + 11, "SCE_C_IDENTIFIER", "identifier", "Identifiers", + 12, "SCE_C_STRINGEOL", "error literal string", "End of line where string is not closed", + 13, "SCE_C_VERBATIM", "literal string multiline raw", "Verbatim strings for C#", + 14, "SCE_C_REGEX", "literal regex", "Regular expressions for JavaScript", + 15, "SCE_C_COMMENTLINEDOC", "comment documentation line", "Doc Comment Line: line comments beginning with /// or //!.", + 16, "SCE_C_WORD2", "identifier", "Keywords2", + 17, "SCE_C_COMMENTDOCKEYWORD", "comment@@ Diff output truncated at 100000 characters. @@
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).