Update Scintilla to version 3.7.5 (#1503)
* Update Scintilla to version 3.7.5 This now requires a C++11-capable compiler. Closes #1308. * Test using newer dist on Travis Since Scintilla needs C++11 * Add debugging code for when configure fails * Workaround a pkg-config-corsswrapper bug on Ubuntu 14.04 See https://bugs.launchpad.net/ubuntu/+source/mingw-w64/+bug/1327242master
parent
b2668dae67
commit
18360460ab
|
@ -1,5 +1,6 @@
|
|||
# we use both C and C++, so advertize C++
|
||||
language: cpp
|
||||
dist: trusty
|
||||
compiler:
|
||||
- gcc
|
||||
env:
|
||||
|
@ -13,6 +14,8 @@ install:
|
|||
- sudo apt-get install -y intltool libtool
|
||||
- test -n "$MINGW" || sudo apt-get install -y libgtk2.0-dev libgtk-3-dev
|
||||
- test -z "$MINGW" || sudo apt-get install -y mingw-w64-tools g++-mingw-w64-i686 gcc-mingw-w64-i686 binutils-mingw-w64-i686
|
||||
# fix broken pkg-config-crosswrapper, see https://bugs.launchpad.net/ubuntu/+source/mingw-w64/+bug/1327242
|
||||
- test -z "$MINGW" || sudo sed -e 's/PKG_CONFIG_PATH=/&$PKG_CONFIG_PATH:/' -i /usr/bin/i686-w64-mingw32-pkg-config
|
||||
- sudo apt-get install -y python-docutils rst2pdf
|
||||
# try not to install doxygen-latex because we don't need it and it's huge
|
||||
- sudo apt-get install -y --no-install-recommends doxygen
|
||||
|
@ -29,7 +32,7 @@ script:
|
|||
else
|
||||
mkdir _build &&
|
||||
cd _build &&
|
||||
../configure --enable-gtk3=$GTK3 &&
|
||||
{ ../configure --enable-gtk3=$GTK3 || { cat config.log; exit 1; } ; } &&
|
||||
make -j2 &&
|
||||
make -j2 check;
|
||||
fi
|
||||
|
|
|
@ -31,6 +31,7 @@ AM_PROG_CC_C_O
|
|||
|
||||
AC_PROG_CXX
|
||||
GEANY_PROG_CXX
|
||||
AX_CXX_COMPILE_STDCXX_11
|
||||
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
|
|
|
@ -0,0 +1,142 @@
|
|||
# ============================================================================
|
||||
# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
|
||||
# ============================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional])
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# Check for baseline language coverage in the compiler for the C++11
|
||||
# standard; if necessary, add switches to CXXFLAGS to enable support.
|
||||
#
|
||||
# The first argument, if specified, indicates whether you insist on an
|
||||
# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
|
||||
# -std=c++11). If neither is specified, you get whatever works, with
|
||||
# preference for an extended mode.
|
||||
#
|
||||
# The second argument, if specified 'mandatory' or if left unspecified,
|
||||
# indicates that baseline C++11 support is required and that the macro
|
||||
# should error out if no mode with that support is found. If specified
|
||||
# 'optional', then configuration proceeds regardless, after defining
|
||||
# HAVE_CXX11 if and only if a supporting mode is found.
|
||||
#
|
||||
# LICENSE
|
||||
#
|
||||
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
|
||||
# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
|
||||
# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
|
||||
# Copyright (c) 2014 Alexey Sokolov <sokolov@google.com>
|
||||
#
|
||||
# Copying and distribution of this file, with or without modification, are
|
||||
# permitted in any medium without royalty provided the copyright notice
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 4
|
||||
|
||||
m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [[
|
||||
template <typename T>
|
||||
struct check
|
||||
{
|
||||
static_assert(sizeof(int) <= sizeof(T), "not big enough");
|
||||
};
|
||||
|
||||
struct Base {
|
||||
virtual void f() {}
|
||||
};
|
||||
struct Child : public Base {
|
||||
virtual void f() override {}
|
||||
};
|
||||
|
||||
typedef check<check<bool>> right_angle_brackets;
|
||||
|
||||
int a;
|
||||
decltype(a) b;
|
||||
|
||||
typedef check<int> check_type;
|
||||
check_type c;
|
||||
check_type&& cr = static_cast<check_type&&>(c);
|
||||
|
||||
auto d = a;
|
||||
auto l = [](){};
|
||||
]])
|
||||
|
||||
AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
|
||||
m4_if([$1], [], [],
|
||||
[$1], [ext], [],
|
||||
[$1], [noext], [],
|
||||
[m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl
|
||||
m4_if([$2], [], [ax_cxx_compile_cxx11_required=true],
|
||||
[$2], [mandatory], [ax_cxx_compile_cxx11_required=true],
|
||||
[$2], [optional], [ax_cxx_compile_cxx11_required=false],
|
||||
[m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_11])])
|
||||
AC_LANG_PUSH([C++])dnl
|
||||
ac_success=no
|
||||
AC_CACHE_CHECK(whether $CXX supports C++11 features by default,
|
||||
ax_cv_cxx_compile_cxx11,
|
||||
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
|
||||
[ax_cv_cxx_compile_cxx11=yes],
|
||||
[ax_cv_cxx_compile_cxx11=no])])
|
||||
if test x$ax_cv_cxx_compile_cxx11 = xyes; then
|
||||
ac_success=yes
|
||||
fi
|
||||
|
||||
m4_if([$1], [noext], [], [dnl
|
||||
if test x$ac_success = xno; then
|
||||
for switch in -std=gnu++11 -std=gnu++0x; do
|
||||
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
|
||||
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
|
||||
$cachevar,
|
||||
[ac_save_CXXFLAGS="$CXXFLAGS"
|
||||
CXXFLAGS="$CXXFLAGS $switch"
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
|
||||
[eval $cachevar=yes],
|
||||
[eval $cachevar=no])
|
||||
CXXFLAGS="$ac_save_CXXFLAGS"])
|
||||
if eval test x\$$cachevar = xyes; then
|
||||
CXXFLAGS="$CXXFLAGS $switch"
|
||||
ac_success=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi])
|
||||
|
||||
m4_if([$1], [ext], [], [dnl
|
||||
if test x$ac_success = xno; then
|
||||
for switch in -std=c++11 -std=c++0x; do
|
||||
cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
|
||||
AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
|
||||
$cachevar,
|
||||
[ac_save_CXXFLAGS="$CXXFLAGS"
|
||||
CXXFLAGS="$CXXFLAGS $switch"
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
|
||||
[eval $cachevar=yes],
|
||||
[eval $cachevar=no])
|
||||
CXXFLAGS="$ac_save_CXXFLAGS"])
|
||||
if eval test x\$$cachevar = xyes; then
|
||||
CXXFLAGS="$CXXFLAGS $switch"
|
||||
ac_success=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi])
|
||||
AC_LANG_POP([C++])
|
||||
if test x$ax_cxx_compile_cxx11_required = xtrue; then
|
||||
if test x$ac_success = xno; then
|
||||
AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.])
|
||||
fi
|
||||
else
|
||||
if test x$ac_success = xno; then
|
||||
HAVE_CXX11=0
|
||||
AC_MSG_NOTICE([No compiler with C++11 support was found])
|
||||
else
|
||||
HAVE_CXX11=1
|
||||
AC_DEFINE(HAVE_CXX11,1,
|
||||
[define if the compiler supports basic C++11 syntax])
|
||||
fi
|
||||
|
||||
AC_SUBST(HAVE_CXX11)
|
||||
fi
|
||||
])
|
|
@ -142,6 +142,7 @@ src/Style.h \
|
|||
src/UniConversion.cxx \
|
||||
src/UniConversion.h \
|
||||
src/UnicodeFromUTF8.h \
|
||||
src/UniqueString.h \
|
||||
src/ViewStyle.cxx \
|
||||
src/ViewStyle.h \
|
||||
src/XPM.cxx \
|
||||
|
|
|
@ -3,15 +3,16 @@
|
|||
// Copyright 1998-2004 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <cmath>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
|
||||
#include <glib.h>
|
||||
|
@ -162,49 +163,50 @@ class SurfaceImpl : public Surface {
|
|||
void SetConverter(int characterSet_);
|
||||
public:
|
||||
SurfaceImpl();
|
||||
virtual ~SurfaceImpl();
|
||||
~SurfaceImpl() override;
|
||||
|
||||
void Init(WindowID wid);
|
||||
void Init(SurfaceID sid, WindowID wid);
|
||||
void InitPixMap(int width, int height, Surface *surface_, WindowID wid);
|
||||
void Init(WindowID wid) override;
|
||||
void Init(SurfaceID sid, WindowID wid) override;
|
||||
void InitPixMap(int width, int height, Surface *surface_, WindowID wid) override;
|
||||
|
||||
void Release();
|
||||
bool Initialised();
|
||||
void PenColour(ColourDesired fore);
|
||||
int LogPixelsY();
|
||||
int DeviceHeightFont(int points);
|
||||
void MoveTo(int x_, int y_);
|
||||
void LineTo(int x_, int y_);
|
||||
void Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired back);
|
||||
void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back);
|
||||
void FillRectangle(PRectangle rc, ColourDesired back);
|
||||
void FillRectangle(PRectangle rc, Surface &surfacePattern);
|
||||
void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back);
|
||||
void Clear();
|
||||
void Release() override;
|
||||
bool Initialised() override;
|
||||
void PenColour(ColourDesired fore) override;
|
||||
int LogPixelsY() override;
|
||||
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 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);
|
||||
void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage);
|
||||
void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back);
|
||||
void Copy(PRectangle rc, Point from, Surface &surfaceSource);
|
||||
ColourDesired outline, int alphaOutline, int flags) 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;
|
||||
|
||||
void DrawTextBase(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore);
|
||||
void DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back);
|
||||
void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back);
|
||||
void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore);
|
||||
void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions);
|
||||
XYPOSITION WidthText(Font &font_, const char *s, int len);
|
||||
XYPOSITION WidthChar(Font &font_, char ch);
|
||||
XYPOSITION Ascent(Font &font_);
|
||||
XYPOSITION Descent(Font &font_);
|
||||
XYPOSITION InternalLeading(Font &font_);
|
||||
XYPOSITION ExternalLeading(Font &font_);
|
||||
XYPOSITION Height(Font &font_);
|
||||
XYPOSITION AverageCharWidth(Font &font_);
|
||||
void DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back) override;
|
||||
void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back) override;
|
||||
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;
|
||||
|
||||
void SetClip(PRectangle rc);
|
||||
void FlushCachedState();
|
||||
void SetClip(PRectangle rc) override;
|
||||
void FlushCachedState() override;
|
||||
|
||||
void SetUnicodeMode(bool unicodeMode_);
|
||||
void SetDBCSMode(int codePage);
|
||||
void SetUnicodeMode(bool unicodeMode_) override;
|
||||
void SetDBCSMode(int codePage) override;
|
||||
};
|
||||
#ifdef SCI_NAMESPACE
|
||||
}
|
||||
|
@ -276,10 +278,10 @@ x(0), y(0), inited(false), createdGC(false)
|
|||
}
|
||||
|
||||
SurfaceImpl::~SurfaceImpl() {
|
||||
Release();
|
||||
Clear();
|
||||
}
|
||||
|
||||
void SurfaceImpl::Release() {
|
||||
void SurfaceImpl::Clear() {
|
||||
et = singleByte;
|
||||
if (createdGC) {
|
||||
createdGC = false;
|
||||
|
@ -303,6 +305,10 @@ void SurfaceImpl::Release() {
|
|||
createdGC = false;
|
||||
}
|
||||
|
||||
void SurfaceImpl::Release() {
|
||||
Clear();
|
||||
}
|
||||
|
||||
bool SurfaceImpl::Initialised() {
|
||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 8, 0)
|
||||
if (inited && context) {
|
||||
|
@ -1235,7 +1241,7 @@ public:
|
|||
#endif
|
||||
doubleClickAction(NULL), doubleClickActionData(NULL) {
|
||||
}
|
||||
virtual ~ListBoxX() {
|
||||
~ListBoxX() override {
|
||||
if (pixhash) {
|
||||
g_hash_table_foreach((GHashTable *) pixhash, list_image_free, NULL);
|
||||
g_hash_table_destroy((GHashTable *) pixhash);
|
||||
|
@ -1251,30 +1257,30 @@ public:
|
|||
}
|
||||
#endif
|
||||
}
|
||||
virtual void SetFont(Font &font);
|
||||
virtual void Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_, int technology_);
|
||||
virtual void SetAverageCharWidth(int width);
|
||||
virtual void SetVisibleRows(int rows);
|
||||
virtual int GetVisibleRows() const;
|
||||
void SetFont(Font &font) override;
|
||||
void Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_, int technology_) override;
|
||||
void SetAverageCharWidth(int width) override;
|
||||
void SetVisibleRows(int rows) override;
|
||||
int GetVisibleRows() const override;
|
||||
int GetRowHeight();
|
||||
virtual PRectangle GetDesiredRect();
|
||||
virtual int CaretFromEdge();
|
||||
virtual void Clear();
|
||||
virtual void Append(char *s, int type = -1);
|
||||
virtual int Length();
|
||||
virtual void Select(int n);
|
||||
virtual int GetSelection();
|
||||
virtual int Find(const char *prefix);
|
||||
virtual void GetValue(int n, char *value, int len);
|
||||
PRectangle GetDesiredRect() override;
|
||||
int CaretFromEdge() override;
|
||||
void Clear() override;
|
||||
void Append(char *s, int type = -1) override;
|
||||
int Length() override;
|
||||
void Select(int n) override;
|
||||
int GetSelection() override;
|
||||
int Find(const char *prefix) override;
|
||||
void GetValue(int n, char *value, int len) override;
|
||||
void RegisterRGBA(int type, RGBAImage *image);
|
||||
virtual void RegisterImage(int type, const char *xpm_data);
|
||||
virtual void RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage);
|
||||
virtual void ClearRegisteredImages();
|
||||
virtual void SetDoubleClickAction(CallBackAction action, void *data) {
|
||||
void RegisterImage(int type, const char *xpm_data) override;
|
||||
void RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage) override;
|
||||
void ClearRegisteredImages() override;
|
||||
void SetDoubleClickAction(CallBackAction action, void *data) override {
|
||||
doubleClickAction = action;
|
||||
doubleClickActionData = data;
|
||||
}
|
||||
virtual void SetList(const char *listText, char separator, char typesep);
|
||||
void SetList(const char *listText, char separator, char typesep) override;
|
||||
};
|
||||
|
||||
ListBox *ListBox::Allocate() {
|
||||
|
@ -1505,13 +1511,13 @@ void ListBoxX::Create(Window &parent, int, Point, int, bool, int) {
|
|||
GTK_WINDOW(top));
|
||||
}
|
||||
|
||||
void ListBoxX::SetFont(Font &scint_font) {
|
||||
void ListBoxX::SetFont(Font &font) {
|
||||
// Only do for Pango font as there have been crashes for GDK fonts
|
||||
if (Created() && PFont(scint_font)->pfd) {
|
||||
if (Created() && PFont(font)->pfd) {
|
||||
// Current font is Pango font
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
if (cssProvider) {
|
||||
PangoFontDescription *pfd = PFont(scint_font)->pfd;
|
||||
PangoFontDescription *pfd = PFont(font)->pfd;
|
||||
std::ostringstream ssFontSetting;
|
||||
ssFontSetting << "GtkTreeView, treeview { ";
|
||||
ssFontSetting << "font-family: " << pango_font_description_get_family(pfd) << "; ";
|
||||
|
@ -1532,7 +1538,7 @@ void ListBoxX::SetFont(Font &scint_font) {
|
|||
ssFontSetting.str().c_str(), -1, NULL);
|
||||
}
|
||||
#else
|
||||
gtk_widget_modify_font(PWidget(list), PFont(scint_font)->pfd);
|
||||
gtk_widget_modify_font(PWidget(list), PFont(font)->pfd);
|
||||
#endif
|
||||
gtk_cell_renderer_text_set_fixed_height_from_font(GTK_CELL_RENDERER_TEXT(renderer), -1);
|
||||
gtk_cell_renderer_text_set_fixed_height_from_font(GTK_CELL_RENDERER_TEXT(renderer), 1);
|
||||
|
@ -1918,14 +1924,14 @@ static void MenuPositionFunc(GtkMenu *, gint *x, gint *y, gboolean *, gpointer u
|
|||
}
|
||||
#endif
|
||||
|
||||
void Menu::Show(Point pt, Window &wnd) {
|
||||
void Menu::Show(Point pt, Window &w) {
|
||||
GtkMenu *widget = static_cast<GtkMenu *>(mid);
|
||||
gtk_widget_show_all(GTK_WIDGET(widget));
|
||||
#if GTK_CHECK_VERSION(3,22,0)
|
||||
// Rely on GTK+ to do the right thing with positioning
|
||||
gtk_menu_popup_at_pointer(widget, NULL);
|
||||
#else
|
||||
GdkRectangle rcMonitor = MonitorRectangleForWidget(PWidget(wnd.GetID()));
|
||||
GdkRectangle rcMonitor = MonitorRectangleForWidget(PWidget(w.GetID()));
|
||||
GtkRequisition requisition;
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
gtk_widget_get_preferred_size(GTK_WIDGET(widget), NULL, &requisition);
|
||||
|
@ -1959,13 +1965,13 @@ public:
|
|||
m = g_module_open(modulePath, G_MODULE_BIND_LAZY);
|
||||
}
|
||||
|
||||
virtual ~DynamicLibraryImpl() {
|
||||
~DynamicLibraryImpl() override {
|
||||
if (m != NULL)
|
||||
g_module_close(m);
|
||||
}
|
||||
|
||||
// Use g_module_symbol to get a pointer to the relevant function.
|
||||
virtual Function FindFunction(const char *name) {
|
||||
Function FindFunction(const char *name) override {
|
||||
if (m != NULL) {
|
||||
gpointer fn_address = NULL;
|
||||
gboolean status = g_module_symbol(m, name, &fn_address);
|
||||
|
@ -1978,7 +1984,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
virtual bool IsValid() {
|
||||
bool IsValid() override {
|
||||
return m != NULL;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -3,13 +3,14 @@
|
|||
// Copyright 1998-2004 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <cctype>
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <cmath>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <new>
|
||||
|
@ -17,6 +18,7 @@
|
|||
#include <vector>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#include <glib.h>
|
||||
#include <gmodule.h>
|
||||
|
@ -44,6 +46,7 @@
|
|||
#include "LexerModule.h"
|
||||
#endif
|
||||
#include "Position.h"
|
||||
#include "UniqueString.h"
|
||||
#include "SplitVector.h"
|
||||
#include "Partitioning.h"
|
||||
#include "RunStyles.h"
|
||||
|
@ -174,6 +177,7 @@ ScintillaGTK::ScintillaGTK(_ScintillaObject *sci_) :
|
|||
rgnUpdate(0),
|
||||
repaintFullWindow(false),
|
||||
styleIdleID(0),
|
||||
accessibilityEnabled(SC_ACCESSIBILITY_ENABLED),
|
||||
accessible(0) {
|
||||
sci = sci_;
|
||||
wMain = GTK_WIDGET(sci);
|
||||
|
@ -202,7 +206,7 @@ ScintillaGTK::ScintillaGTK(_ScintillaObject *sci_) :
|
|||
lastWheelMouseTime.tv_sec = 0;
|
||||
lastWheelMouseTime.tv_usec = 0;
|
||||
|
||||
Initialise();
|
||||
Init();
|
||||
}
|
||||
|
||||
ScintillaGTK::~ScintillaGTK() {
|
||||
|
@ -546,8 +550,7 @@ void ScintillaGTK::SizeAllocate(GtkWidget *widget, GtkAllocation *allocation) {
|
|||
}
|
||||
}
|
||||
|
||||
void ScintillaGTK::Initialise() {
|
||||
//Platform::DebugPrintf("ScintillaGTK::Initialise\n");
|
||||
void ScintillaGTK::Init() {
|
||||
parentClass = reinterpret_cast<GtkWidgetClass *>(
|
||||
g_type_class_ref(gtk_container_get_type()));
|
||||
|
||||
|
@ -874,6 +877,19 @@ sptr_t ScintillaGTK::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
|
|||
return ret;
|
||||
}
|
||||
|
||||
case SCI_GETACCESSIBILITY:
|
||||
return accessibilityEnabled;
|
||||
|
||||
case SCI_SETACCESSIBILITY:
|
||||
accessibilityEnabled = wParam;
|
||||
if (accessible) {
|
||||
ScintillaGTKAccessible *sciAccessible = ScintillaGTKAccessible::FromAccessible(accessible);
|
||||
if (sciAccessible) {
|
||||
sciAccessible->SetAccessibility();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return ScintillaBase::WndProc(iMessage, wParam, lParam);
|
||||
}
|
||||
|
@ -1014,17 +1030,19 @@ PRectangle ScintillaGTK::GetClientRectangle() const {
|
|||
return rc;
|
||||
}
|
||||
|
||||
void ScintillaGTK::ScrollText(int linesToMove) {
|
||||
int diff = vs.lineHeight * -linesToMove;
|
||||
//Platform::DebugPrintf("ScintillaGTK::ScrollText %d %d %0d,%0d %0d,%0d\n", linesToMove, diff,
|
||||
// rc.left, rc.top, rc.right, rc.bottom);
|
||||
GtkWidget *wi = PWidget(wText);
|
||||
void ScintillaGTK::ScrollText(Sci::Line linesToMove) {
|
||||
NotifyUpdateUI();
|
||||
|
||||
#if GTK_CHECK_VERSION(3,22,0)
|
||||
Redraw();
|
||||
#else
|
||||
GtkWidget *wi = PWidget(wText);
|
||||
if (IS_WIDGET_REALIZED(wi)) {
|
||||
const int diff = vs.lineHeight * -linesToMove;
|
||||
gdk_window_scroll(WindowFromWidget(wi), 0, -diff);
|
||||
gdk_window_process_updates(WindowFromWidget(wi), FALSE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ScintillaGTK::SetVerticalScrollPos() {
|
||||
|
@ -1037,7 +1055,7 @@ void ScintillaGTK::SetHorizontalScrollPos() {
|
|||
gtk_adjustment_set_value(GTK_ADJUSTMENT(adjustmenth), xOffset);
|
||||
}
|
||||
|
||||
bool ScintillaGTK::ModifyScrollBars(int nMax, int nPage) {
|
||||
bool ScintillaGTK::ModifyScrollBars(Sci::Line nMax, Sci::Line nPage) {
|
||||
bool modified = false;
|
||||
int pageScroll = LinesToScroll();
|
||||
|
||||
|
@ -1133,7 +1151,7 @@ public:
|
|||
explicit CaseFolderDBCS(const char *charSet_) : charSet(charSet_) {
|
||||
StandardASCII();
|
||||
}
|
||||
virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) {
|
||||
size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) override {
|
||||
if ((lenMixed == 1) && (sizeFolded > 0)) {
|
||||
folded[0] = mapping[static_cast<unsigned char>(mixed[0])];
|
||||
return 1;
|
||||
|
@ -1278,7 +1296,7 @@ void ScintillaGTK::Paste() {
|
|||
class Helper : GObjectWatcher {
|
||||
ScintillaGTK *sci;
|
||||
|
||||
virtual void Destroyed() {
|
||||
void Destroyed() override {
|
||||
sci = 0;
|
||||
}
|
||||
|
||||
|
@ -1483,24 +1501,24 @@ void ScintillaGTK::GetSelection(GtkSelectionData *selection_data, guint info, Se
|
|||
// GDK on Win32 expands any \n into \r\n, so make a copy of
|
||||
// the clip text now with newlines converted to \n. Use { } to hide symbols
|
||||
// from code below
|
||||
SelectionText *newline_normalized = NULL;
|
||||
std::unique_ptr<SelectionText> newline_normalized;
|
||||
{
|
||||
std::string tmpstr = Document::TransformLineEnds(text->Data(), text->Length(), SC_EOL_LF);
|
||||
newline_normalized = new SelectionText();
|
||||
newline_normalized.reset(new SelectionText());
|
||||
newline_normalized->Copy(tmpstr, SC_CP_UTF8, 0, text->rectangular, false);
|
||||
text = newline_normalized;
|
||||
text = newline_normalized.get();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Convert text to utf8 if it isn't already
|
||||
SelectionText *converted = 0;
|
||||
std::unique_ptr<SelectionText> converted;
|
||||
if ((text->codePage != SC_CP_UTF8) && (info == TARGET_UTF8_STRING)) {
|
||||
const char *charSet = ::CharacterSetID(text->characterSet);
|
||||
if (*charSet) {
|
||||
std::string tmputf = ConvertText(text->Data(), text->Length(), "UTF-8", charSet, false);
|
||||
converted = new SelectionText();
|
||||
converted.reset(new SelectionText());
|
||||
converted->Copy(tmputf, SC_CP_UTF8, 0, text->rectangular, false);
|
||||
text = converted;
|
||||
text = converted.get();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1525,11 +1543,6 @@ void ScintillaGTK::GetSelection(GtkSelectionData *selection_data, guint info, Se
|
|||
static_cast<GdkAtom>(GDK_SELECTION_TYPE_STRING),
|
||||
8, reinterpret_cast<const unsigned char *>(textData), len);
|
||||
}
|
||||
delete converted;
|
||||
|
||||
#if PLAT_GTK_WIN32
|
||||
delete newline_normalized;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ScintillaGTK::StoreOnClipboard(SelectionText *clipText) {
|
||||
|
@ -1801,7 +1814,7 @@ gint ScintillaGTK::ScrollEvent(GtkWidget *widget, GdkEventScroll *event) {
|
|||
return FALSE;
|
||||
|
||||
#if defined(GDK_WINDOWING_WAYLAND)
|
||||
if (event->direction == GDK_SCROLL_SMOOTH && GDK_IS_WAYLAND_WINDOW (event->window)) {
|
||||
if (event->direction == GDK_SCROLL_SMOOTH && GDK_IS_WAYLAND_WINDOW(event->window)) {
|
||||
const int smoothScrollFactor = 4;
|
||||
sciThis->smoothScrollY += event->delta_y * smoothScrollFactor;
|
||||
sciThis->smoothScrollX += event->delta_x * smoothScrollFactor;;
|
||||
|
@ -2212,7 +2225,7 @@ void ScintillaGTK::DrawImeIndicator(int indicator, int len) {
|
|||
if (indicator < 8 || indicator > INDIC_MAX) {
|
||||
return;
|
||||
}
|
||||
pdoc->decorations.SetCurrentIndicator(indicator);
|
||||
pdoc->DecorationSetCurrentIndicator(indicator);
|
||||
for (size_t r=0; r<sel.Count(); r++) {
|
||||
int positionInsert = sel.Range(r).Start().Position();
|
||||
pdoc->DecorationFillRange(positionInsert - len, 1, len);
|
||||
|
@ -2323,12 +2336,13 @@ void ScintillaGTK::PreeditChangedInlineThis() {
|
|||
|
||||
view.imeCaretBlockOverride = false; // If backspace.
|
||||
|
||||
bool initialCompose = false;
|
||||
if (pdoc->TentativeActive()) {
|
||||
pdoc->TentativeUndo();
|
||||
} else {
|
||||
// No tentative undo means start of this composition so
|
||||
// fill in any virtual spaces.
|
||||
ClearBeforeTentativeStart();
|
||||
initialCompose = true;
|
||||
}
|
||||
|
||||
PreEditString preeditStr(im_context);
|
||||
|
@ -2345,6 +2359,8 @@ void ScintillaGTK::PreeditChangedInlineThis() {
|
|||
return;
|
||||
}
|
||||
|
||||
if (initialCompose)
|
||||
ClearBeforeTentativeStart();
|
||||
pdoc->TentativeStart(); // TentativeActive() from now on
|
||||
|
||||
std::vector<int> indicator = MapImeIndicators(preeditStr.attrs, preeditStr.str);
|
||||
|
@ -2513,13 +2529,10 @@ gboolean ScintillaGTK::DrawTextThis(cairo_t *cr) {
|
|||
rcPaint.bottom = y2;
|
||||
PRectangle rcClient = GetClientRectangle();
|
||||
paintingAllText = rcPaint.Contains(rcClient);
|
||||
Surface *surfaceWindow = Surface::Allocate(SC_TECHNOLOGY_DEFAULT);
|
||||
if (surfaceWindow) {
|
||||
surfaceWindow->Init(cr, PWidget(wText));
|
||||
Paint(surfaceWindow, rcPaint);
|
||||
surfaceWindow->Release();
|
||||
delete surfaceWindow;
|
||||
}
|
||||
std::unique_ptr<Surface> surfaceWindow(Surface::Allocate(SC_TECHNOLOGY_DEFAULT));
|
||||
surfaceWindow->Init(cr, PWidget(wText));
|
||||
Paint(surfaceWindow.get(), rcPaint);
|
||||
surfaceWindow->Release();
|
||||
if ((paintState == paintAbandoned) || repaintFullWindow) {
|
||||
// Painting area was insufficient to cover new styling or brace highlight positions
|
||||
FullPaint();
|
||||
|
@ -2603,15 +2616,12 @@ gboolean ScintillaGTK::ExposeTextThis(GtkWidget * /*widget*/, GdkEventExpose *os
|
|||
rgnUpdate = gdk_region_copy(ose->region);
|
||||
PRectangle rcClient = GetClientRectangle();
|
||||
paintingAllText = rcPaint.Contains(rcClient);
|
||||
Surface *surfaceWindow = Surface::Allocate(SC_TECHNOLOGY_DEFAULT);
|
||||
if (surfaceWindow) {
|
||||
cairo_t *cr = gdk_cairo_create(PWindow(wText));
|
||||
surfaceWindow->Init(cr, PWidget(wText));
|
||||
Paint(surfaceWindow, rcPaint);
|
||||
surfaceWindow->Release();
|
||||
delete surfaceWindow;
|
||||
cairo_destroy(cr);
|
||||
}
|
||||
std::unique_ptr<Surface> surfaceWindow(Surface::Allocate(SC_TECHNOLOGY_DEFAULT));
|
||||
cairo_t *cr = gdk_cairo_create(PWindow(wText));
|
||||
surfaceWindow->Init(cr, PWidget(wText));
|
||||
Paint(surfaceWindow.get(), rcPaint);
|
||||
surfaceWindow->Release();
|
||||
cairo_destroy(cr);
|
||||
if (paintState == paintAbandoned) {
|
||||
// Painting area was insufficient to cover new styling or brace highlight positions
|
||||
FullPaint();
|
||||
|
@ -2745,7 +2755,7 @@ gboolean ScintillaGTK::DragMotion(GtkWidget *widget, GdkDragContext *context,
|
|||
void ScintillaGTK::DragLeave(GtkWidget *widget, GdkDragContext * /*context*/, guint) {
|
||||
ScintillaGTK *sciThis = FromWidget(widget);
|
||||
try {
|
||||
sciThis->SetDragPosition(SelectionPosition(invalidPosition));
|
||||
sciThis->SetDragPosition(SelectionPosition(Sci::invalidPosition));
|
||||
//Platform::DebugPrintf("DragLeave %x\n", sciThis);
|
||||
} catch (...) {
|
||||
sciThis->errorStatus = SC_STATUS_FAILURE;
|
||||
|
@ -2758,7 +2768,7 @@ void ScintillaGTK::DragEnd(GtkWidget *widget, GdkDragContext * /*context*/) {
|
|||
// If drag did not result in drop here or elsewhere
|
||||
if (!sciThis->dragWasDropped)
|
||||
sciThis->SetEmptySelection(sciThis->posDrag);
|
||||
sciThis->SetDragPosition(SelectionPosition(invalidPosition));
|
||||
sciThis->SetDragPosition(SelectionPosition(Sci::invalidPosition));
|
||||
//Platform::DebugPrintf("DragEnd %x %d\n", sciThis, sciThis->dragWasDropped);
|
||||
sciThis->inDragDrop = ddNone;
|
||||
} catch (...) {
|
||||
|
@ -2771,7 +2781,7 @@ gboolean ScintillaGTK::Drop(GtkWidget *widget, GdkDragContext * /*context*/,
|
|||
ScintillaGTK *sciThis = FromWidget(widget);
|
||||
try {
|
||||
//Platform::DebugPrintf("Drop %x\n", sciThis);
|
||||
sciThis->SetDragPosition(SelectionPosition(invalidPosition));
|
||||
sciThis->SetDragPosition(SelectionPosition(Sci::invalidPosition));
|
||||
} catch (...) {
|
||||
sciThis->errorStatus = SC_STATUS_FAILURE;
|
||||
}
|
||||
|
@ -2783,7 +2793,7 @@ void ScintillaGTK::DragDataReceived(GtkWidget *widget, GdkDragContext * /*contex
|
|||
ScintillaGTK *sciThis = FromWidget(widget);
|
||||
try {
|
||||
sciThis->ReceivedDrop(selection_data);
|
||||
sciThis->SetDragPosition(SelectionPosition(invalidPosition));
|
||||
sciThis->SetDragPosition(SelectionPosition(Sci::invalidPosition));
|
||||
} catch (...) {
|
||||
sciThis->errorStatus = SC_STATUS_FAILURE;
|
||||
}
|
||||
|
@ -2814,7 +2824,7 @@ void ScintillaGTK::DragDataGet(GtkWidget *widget, GdkDragContext *context,
|
|||
}
|
||||
sciThis->ClearSelection();
|
||||
}
|
||||
sciThis->SetDragPosition(SelectionPosition(invalidPosition));
|
||||
sciThis->SetDragPosition(SelectionPosition(Sci::invalidPosition));
|
||||
} catch (...) {
|
||||
sciThis->errorStatus = SC_STATUS_FAILURE;
|
||||
}
|
||||
|
@ -2852,7 +2862,7 @@ void ScintillaGTK::IdleWork() {
|
|||
styleIdleID = 0;
|
||||
}
|
||||
|
||||
void ScintillaGTK::QueueIdleWork(WorkNeeded::workItems items, int upTo) {
|
||||
void ScintillaGTK::QueueIdleWork(WorkNeeded::workItems items, Sci::Position upTo) {
|
||||
Editor::QueueIdleWork(items, upTo);
|
||||
if (!styleIdleID) {
|
||||
// Only allow one style needed to be queued
|
||||
|
@ -2909,15 +2919,12 @@ gboolean ScintillaGTK::PressCT(GtkWidget *widget, GdkEventButton *event, Scintil
|
|||
|
||||
gboolean ScintillaGTK::DrawCT(GtkWidget *widget, cairo_t *cr, CallTip *ctip) {
|
||||
try {
|
||||
Surface *surfaceWindow = Surface::Allocate(SC_TECHNOLOGY_DEFAULT);
|
||||
if (surfaceWindow) {
|
||||
surfaceWindow->Init(cr, widget);
|
||||
surfaceWindow->SetUnicodeMode(SC_CP_UTF8 == ctip->codePage);
|
||||
surfaceWindow->SetDBCSMode(ctip->codePage);
|
||||
ctip->PaintCT(surfaceWindow);
|
||||
surfaceWindow->Release();
|
||||
delete surfaceWindow;
|
||||
}
|
||||
std::unique_ptr<Surface> surfaceWindow(Surface::Allocate(SC_TECHNOLOGY_DEFAULT));
|
||||
surfaceWindow->Init(cr, widget);
|
||||
surfaceWindow->SetUnicodeMode(SC_CP_UTF8 == ctip->codePage);
|
||||
surfaceWindow->SetDBCSMode(ctip->codePage);
|
||||
ctip->PaintCT(surfaceWindow.get());
|
||||
surfaceWindow->Release();
|
||||
} catch (...) {
|
||||
// No pointer back to Scintilla to save status
|
||||
}
|
||||
|
@ -2928,17 +2935,14 @@ gboolean ScintillaGTK::DrawCT(GtkWidget *widget, cairo_t *cr, CallTip *ctip) {
|
|||
|
||||
gboolean ScintillaGTK::ExposeCT(GtkWidget *widget, GdkEventExpose * /*ose*/, CallTip *ctip) {
|
||||
try {
|
||||
Surface *surfaceWindow = Surface::Allocate(SC_TECHNOLOGY_DEFAULT);
|
||||
if (surfaceWindow) {
|
||||
cairo_t *cr = gdk_cairo_create(WindowFromWidget(widget));
|
||||
surfaceWindow->Init(cr, widget);
|
||||
surfaceWindow->SetUnicodeMode(SC_CP_UTF8 == ctip->codePage);
|
||||
surfaceWindow->SetDBCSMode(ctip->codePage);
|
||||
ctip->PaintCT(surfaceWindow);
|
||||
surfaceWindow->Release();
|
||||
delete surfaceWindow;
|
||||
cairo_destroy(cr);
|
||||
}
|
||||
std::unique_ptr<Surface> surfaceWindow(Surface::Allocate(SC_TECHNOLOGY_DEFAULT));
|
||||
cairo_t *cr = gdk_cairo_create(WindowFromWidget(widget));
|
||||
surfaceWindow->Init(cr, widget);
|
||||
surfaceWindow->SetUnicodeMode(SC_CP_UTF8 == ctip->codePage);
|
||||
surfaceWindow->SetDBCSMode(ctip->codePage);
|
||||
ctip->PaintCT(surfaceWindow.get());
|
||||
surfaceWindow->Release();
|
||||
cairo_destroy(cr);
|
||||
} catch (...) {
|
||||
// No pointer back to Scintilla to save status
|
||||
}
|
||||
|
@ -3027,7 +3031,7 @@ void ScintillaGTK::ClassInit(OBJECT_CLASS* object_class, GtkWidgetClass *widget_
|
|||
|
||||
// Define default signal handlers for the class: Could move more
|
||||
// of the signal handlers here (those that currently attached to wDraw
|
||||
// in Initialise() may require coordinate translation?)
|
||||
// in Init() may require coordinate translation?)
|
||||
|
||||
object_class->dispose = Dispose;
|
||||
object_class->finalize = Destroy;
|
||||
|
|
|
@ -68,31 +68,31 @@ class ScintillaGTK : public ScintillaBase {
|
|||
bool repaintFullWindow;
|
||||
|
||||
guint styleIdleID;
|
||||
int accessibilityEnabled;
|
||||
AtkObject *accessible;
|
||||
|
||||
// Private so ScintillaGTK objects can not be copied
|
||||
ScintillaGTK(const ScintillaGTK &);
|
||||
ScintillaGTK &operator=(const ScintillaGTK &);
|
||||
|
||||
public:
|
||||
explicit ScintillaGTK(_ScintillaObject *sci_);
|
||||
// Deleted so ScintillaGTK objects can not be copied.
|
||||
ScintillaGTK(const ScintillaGTK &) = delete;
|
||||
ScintillaGTK &operator=(const ScintillaGTK &) = delete;
|
||||
virtual ~ScintillaGTK();
|
||||
static ScintillaGTK *FromWidget(GtkWidget *widget);
|
||||
static void ClassInit(OBJECT_CLASS* object_class, GtkWidgetClass *widget_class, GtkContainerClass *container_class);
|
||||
private:
|
||||
virtual void Initialise();
|
||||
virtual void Finalise();
|
||||
virtual bool AbandonPaint();
|
||||
virtual void DisplayCursor(Window::Cursor c);
|
||||
virtual bool DragThreshold(Point ptStart, Point ptNow);
|
||||
virtual void StartDrag();
|
||||
void Init();
|
||||
void Finalise() override;
|
||||
bool AbandonPaint() override;
|
||||
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;
|
||||
virtual bool ValidCodePage(int codePage) const;
|
||||
bool ValidCodePage(int codePage) const override;
|
||||
public: // Public for scintilla_send_message
|
||||
virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
|
||||
sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override;
|
||||
private:
|
||||
virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
|
||||
sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override;
|
||||
struct TimeThunk {
|
||||
TickReason reason;
|
||||
ScintillaGTK *scintilla;
|
||||
|
@ -100,41 +100,41 @@ private:
|
|||
TimeThunk() : reason(tickCaret), scintilla(NULL), timer(0) {}
|
||||
};
|
||||
TimeThunk timers[tickDwell+1];
|
||||
virtual bool FineTickerAvailable();
|
||||
virtual bool FineTickerRunning(TickReason reason);
|
||||
virtual void FineTickerStart(TickReason reason, int millis, int tolerance);
|
||||
virtual void FineTickerCancel(TickReason reason);
|
||||
virtual bool SetIdle(bool on);
|
||||
virtual void SetMouseCapture(bool on);
|
||||
virtual bool HaveMouseCapture();
|
||||
virtual bool PaintContains(PRectangle rc);
|
||||
bool FineTickerAvailable() override;
|
||||
bool FineTickerRunning(TickReason reason) override;
|
||||
void FineTickerStart(TickReason reason, int millis, int tolerance) override;
|
||||
void FineTickerCancel(TickReason reason) override;
|
||||
bool SetIdle(bool on) override;
|
||||
void SetMouseCapture(bool on) override;
|
||||
bool HaveMouseCapture() override;
|
||||
bool PaintContains(PRectangle rc) override;
|
||||
void FullPaint();
|
||||
virtual PRectangle GetClientRectangle() const;
|
||||
virtual void ScrollText(int linesToMove);
|
||||
virtual void SetVerticalScrollPos();
|
||||
virtual void SetHorizontalScrollPos();
|
||||
virtual bool ModifyScrollBars(int nMax, int nPage);
|
||||
void ReconfigureScrollBars();
|
||||
virtual void NotifyChange();
|
||||
virtual void NotifyFocus(bool focus);
|
||||
virtual void NotifyParent(SCNotification scn);
|
||||
PRectangle GetClientRectangle() const override;
|
||||
void ScrollText(Sci::Line linesToMove) override;
|
||||
void SetVerticalScrollPos() override;
|
||||
void SetHorizontalScrollPos() override;
|
||||
bool ModifyScrollBars(Sci::Line nMax, Sci::Line nPage) override;
|
||||
void ReconfigureScrollBars() override;
|
||||
void NotifyChange() override;
|
||||
void NotifyFocus(bool focus) override;
|
||||
void NotifyParent(SCNotification scn) override;
|
||||
void NotifyKey(int key, int modifiers);
|
||||
void NotifyURIDropped(const char *list);
|
||||
const char *CharacterSetID() const;
|
||||
virtual CaseFolder *CaseFolderForEncoding();
|
||||
virtual std::string CaseMapString(const std::string &s, int caseMapping);
|
||||
virtual int KeyDefault(int key, int modifiers);
|
||||
virtual void CopyToClipboard(const SelectionText &selectedText);
|
||||
virtual void Copy();
|
||||
virtual void Paste();
|
||||
virtual void CreateCallTipWindow(PRectangle rc);
|
||||
virtual void AddToPopUp(const char *label, int cmd = 0, bool enabled = true);
|
||||
CaseFolder *CaseFolderForEncoding() override;
|
||||
std::string CaseMapString(const std::string &s, int caseMapping) override;
|
||||
int KeyDefault(int key, int modifiers) override;
|
||||
void CopyToClipboard(const SelectionText &selectedText) override;
|
||||
void Copy() override;
|
||||
void Paste() override;
|
||||
void CreateCallTipWindow(PRectangle rc) override;
|
||||
void AddToPopUp(const char *label, int cmd = 0, bool enabled = true) override;
|
||||
bool OwnPrimarySelection();
|
||||
virtual void ClaimSelection();
|
||||
void ClaimSelection() override;
|
||||
void GetGtkSelectionText(GtkSelectionData *selectionData, SelectionText &selText);
|
||||
void ReceivedSelection(GtkSelectionData *selection_data);
|
||||
void ReceivedDrop(GtkSelectionData *selection_data);
|
||||
static void GetSelection(GtkSelectionData *selection_data, guint info, SelectionText *selected);
|
||||
static void GetSelection(GtkSelectionData *selection_data, guint info, SelectionText *text);
|
||||
void StoreOnClipboard(SelectionText *clipText);
|
||||
static void ClipboardGetSelection(GtkClipboard* clip, GtkSelectionData *selection_data, guint info, void *data);
|
||||
static void ClipboardClearSelection(GtkClipboard* clip, void *data);
|
||||
|
@ -196,7 +196,7 @@ private:
|
|||
static AtkObject* GetAccessible(GtkWidget *widget);
|
||||
|
||||
bool KoreanIME();
|
||||
void CommitThis(char *str);
|
||||
void CommitThis(char *commitStr);
|
||||
static void Commit(GtkIMContext *context, char *str, ScintillaGTK *sciThis);
|
||||
void PreeditChangedInlineThis();
|
||||
void PreeditChangedWindowedThis();
|
||||
|
@ -229,15 +229,15 @@ private:
|
|||
static gboolean TimeOut(gpointer ptt);
|
||||
static gboolean IdleCallback(gpointer pSci);
|
||||
static gboolean StyleIdle(gpointer pSci);
|
||||
virtual void IdleWork();
|
||||
virtual void QueueIdleWork(WorkNeeded::workItems items, int upTo);
|
||||
virtual void SetDocPointer(Document *document);
|
||||
void IdleWork() override;
|
||||
void QueueIdleWork(WorkNeeded::workItems items, Sci::Position upTo) override;
|
||||
void SetDocPointer(Document *document) override;
|
||||
static void PopUpCB(GtkMenuItem *menuItem, ScintillaGTK *sciThis);
|
||||
|
||||
#if GTK_CHECK_VERSION(3,0,0)
|
||||
static gboolean DrawCT(GtkWidget *widget, cairo_t *cr, CallTip *ctip);
|
||||
#else
|
||||
static gboolean ExposeCT(GtkWidget *widget, GdkEventExpose *ose, CallTip *ct);
|
||||
static gboolean ExposeCT(GtkWidget *widget, GdkEventExpose *ose, CallTip *ctip);
|
||||
#endif
|
||||
static gboolean PressCT(GtkWidget *widget, GdkEventButton *event, ScintillaGTK *sciThis);
|
||||
|
||||
|
|
|
@ -51,8 +51,9 @@
|
|||
|
||||
// FIXME: optimize character/byte offset conversion (with a cache?)
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <new>
|
||||
|
@ -60,6 +61,7 @@
|
|||
#include <vector>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
@ -93,6 +95,7 @@
|
|||
#include "LexerModule.h"
|
||||
#endif
|
||||
#include "Position.h"
|
||||
#include "UniqueString.h"
|
||||
#include "SplitVector.h"
|
||||
#include "Partitioning.h"
|
||||
#include "RunStyles.h"
|
||||
|
@ -167,7 +170,7 @@ ScintillaGTKAccessible::~ScintillaGTKAccessible() {
|
|||
}
|
||||
}
|
||||
|
||||
gchar *ScintillaGTKAccessible::GetTextRangeUTF8(Position startByte, Position endByte) {
|
||||
gchar *ScintillaGTKAccessible::GetTextRangeUTF8(Sci::Position startByte, Sci::Position endByte) {
|
||||
g_return_val_if_fail(startByte >= 0, NULL);
|
||||
// FIXME: should we swap start/end if necessary?
|
||||
g_return_val_if_fail(endByte >= startByte, NULL);
|
||||
|
@ -195,7 +198,7 @@ gchar *ScintillaGTKAccessible::GetTextRangeUTF8(Position startByte, Position end
|
|||
}
|
||||
|
||||
gchar *ScintillaGTKAccessible::GetText(int startChar, int endChar) {
|
||||
Position startByte, endByte;
|
||||
Sci::Position startByte, endByte;
|
||||
if (endChar == -1) {
|
||||
startByte = ByteOffsetFromCharacterOffset(startChar);
|
||||
endByte = sci->pdoc->Length();
|
||||
|
@ -209,8 +212,8 @@ gchar *ScintillaGTKAccessible::GetTextAfterOffset(int charOffset,
|
|||
AtkTextBoundary boundaryType, int *startChar, int *endChar) {
|
||||
g_return_val_if_fail(charOffset >= 0, NULL);
|
||||
|
||||
Position startByte, endByte;
|
||||
Position byteOffset = ByteOffsetFromCharacterOffset(charOffset);
|
||||
Sci::Position startByte, endByte;
|
||||
Sci::Position byteOffset = ByteOffsetFromCharacterOffset(charOffset);
|
||||
|
||||
switch (boundaryType) {
|
||||
case ATK_TEXT_BOUNDARY_CHAR:
|
||||
|
@ -260,8 +263,8 @@ gchar *ScintillaGTKAccessible::GetTextBeforeOffset(int charOffset,
|
|||
AtkTextBoundary boundaryType, int *startChar, int *endChar) {
|
||||
g_return_val_if_fail(charOffset >= 0, NULL);
|
||||
|
||||
Position startByte, endByte;
|
||||
Position byteOffset = ByteOffsetFromCharacterOffset(charOffset);
|
||||
Sci::Position startByte, endByte;
|
||||
Sci::Position byteOffset = ByteOffsetFromCharacterOffset(charOffset);
|
||||
|
||||
switch (boundaryType) {
|
||||
case ATK_TEXT_BOUNDARY_CHAR:
|
||||
|
@ -322,8 +325,8 @@ gchar *ScintillaGTKAccessible::GetTextAtOffset(int charOffset,
|
|||
AtkTextBoundary boundaryType, int *startChar, int *endChar) {
|
||||
g_return_val_if_fail(charOffset >= 0, NULL);
|
||||
|
||||
Position startByte, endByte;
|
||||
Position byteOffset = ByteOffsetFromCharacterOffset(charOffset);
|
||||
Sci::Position startByte, endByte;
|
||||
Sci::Position byteOffset = ByteOffsetFromCharacterOffset(charOffset);
|
||||
|
||||
switch (boundaryType) {
|
||||
case ATK_TEXT_BOUNDARY_CHAR:
|
||||
|
@ -385,8 +388,8 @@ gchar *ScintillaGTKAccessible::GetStringAtOffset(int charOffset,
|
|||
AtkTextGranularity granularity, int *startChar, int *endChar) {
|
||||
g_return_val_if_fail(charOffset >= 0, NULL);
|
||||
|
||||
Position startByte, endByte;
|
||||
Position byteOffset = ByteOffsetFromCharacterOffset(charOffset);
|
||||
Sci::Position startByte, endByte;
|
||||
Sci::Position byteOffset = ByteOffsetFromCharacterOffset(charOffset);
|
||||
|
||||
switch (granularity) {
|
||||
case ATK_TEXT_GRANULARITY_CHAR:
|
||||
|
@ -416,8 +419,8 @@ gchar *ScintillaGTKAccessible::GetStringAtOffset(int charOffset,
|
|||
gunichar ScintillaGTKAccessible::GetCharacterAtOffset(int charOffset) {
|
||||
g_return_val_if_fail(charOffset >= 0, 0);
|
||||
|
||||
Position startByte = ByteOffsetFromCharacterOffset(charOffset);
|
||||
Position endByte = PositionAfter(startByte);
|
||||
Sci::Position startByte = ByteOffsetFromCharacterOffset(charOffset);
|
||||
Sci::Position endByte = PositionAfter(startByte);
|
||||
gchar *ch = GetTextRangeUTF8(startByte, endByte);
|
||||
gunichar unichar = g_utf8_get_char_validated(ch, -1);
|
||||
g_free(ch);
|
||||
|
@ -465,7 +468,7 @@ void ScintillaGTKAccessible::GetCharacterExtents(int charOffset,
|
|||
gint *x, gint *y, gint *width, gint *height, AtkCoordType coords) {
|
||||
*x = *y = *height = *width = 0;
|
||||
|
||||
Position byteOffset = ByteOffsetFromCharacterOffset(charOffset);
|
||||
Sci::Position byteOffset = ByteOffsetFromCharacterOffset(charOffset);
|
||||
|
||||
// FIXME: should we handle scrolling?
|
||||
*x = sci->WndProc(SCI_POINTXFROMPOSITION, 0, byteOffset);
|
||||
|
@ -549,7 +552,7 @@ AtkAttributeSet *ScintillaGTKAccessible::GetAttributesForStyle(unsigned int styl
|
|||
AtkAttributeSet *ScintillaGTKAccessible::GetRunAttributes(int charOffset, int *startChar, int *endChar) {
|
||||
g_return_val_if_fail(charOffset >= -1, NULL);
|
||||
|
||||
Position byteOffset;
|
||||
Sci::Position byteOffset;
|
||||
if (charOffset == -1) {
|
||||
byteOffset = sci->WndProc(SCI_GETCURRENTPOS, 0, 0);
|
||||
} else {
|
||||
|
@ -561,11 +564,11 @@ AtkAttributeSet *ScintillaGTKAccessible::GetRunAttributes(int charOffset, int *s
|
|||
|
||||
const char style = StyleAt(byteOffset, true);
|
||||
// compute the range for this style
|
||||
Position startByte = byteOffset;
|
||||
Sci::Position startByte = byteOffset;
|
||||
// when going backwards, we know the style is already computed
|
||||
while (startByte > 0 && sci->pdoc->StyleAt((startByte) - 1) == style)
|
||||
(startByte)--;
|
||||
Position endByte = byteOffset + 1;
|
||||
Sci::Position endByte = byteOffset + 1;
|
||||
while (endByte < length && StyleAt(endByte, true) == style)
|
||||
(endByte)++;
|
||||
|
||||
|
@ -585,8 +588,8 @@ gchar *ScintillaGTKAccessible::GetSelection(gint selection_num, int *startChar,
|
|||
if (selection_num < 0 || (unsigned int) selection_num >= sci->sel.Count())
|
||||
return NULL;
|
||||
|
||||
Position startByte = sci->sel.Range(selection_num).Start().Position();
|
||||
Position endByte = sci->sel.Range(selection_num).End().Position();
|
||||
Sci::Position startByte = sci->sel.Range(selection_num).Start().Position();
|
||||
Sci::Position endByte = sci->sel.Range(selection_num).End().Position();
|
||||
|
||||
CharacterRangeFromByteRange(startByte, endByte, startChar, endChar);
|
||||
return GetTextRangeUTF8(startByte, endByte);
|
||||
|
@ -594,7 +597,7 @@ gchar *ScintillaGTKAccessible::GetSelection(gint selection_num, int *startChar,
|
|||
|
||||
gboolean ScintillaGTKAccessible::AddSelection(int startChar, int endChar) {
|
||||
size_t n_selections = sci->sel.Count();
|
||||
Position startByte, endByte;
|
||||
Sci::Position startByte, endByte;
|
||||
ByteRangeFromCharacterRange(startChar, endChar, startByte, endByte);
|
||||
// use WndProc() to set the selections so it notifies as needed
|
||||
if (n_selections > 1 || ! sci->sel.Empty()) {
|
||||
|
@ -626,7 +629,7 @@ gboolean ScintillaGTKAccessible::SetSelection(gint selection_num, int startChar,
|
|||
if (selection_num < 0 || (unsigned int) selection_num >= sci->sel.Count())
|
||||
return FALSE;
|
||||
|
||||
Position startByte, endByte;
|
||||
Sci::Position startByte, endByte;
|
||||
ByteRangeFromCharacterRange(startChar, endChar, startByte, endByte);
|
||||
|
||||
sci->WndProc(SCI_SETSELECTIONNSTART, selection_num, startByte);
|
||||
|
@ -667,7 +670,7 @@ void ScintillaGTKAccessible::SetTextContents(const gchar *contents) {
|
|||
}
|
||||
}
|
||||
|
||||
bool ScintillaGTKAccessible::InsertStringUTF8(Position bytePos, const gchar *utf8, int lengthBytes) {
|
||||
bool ScintillaGTKAccessible::InsertStringUTF8(Sci::Position bytePos, const gchar *utf8, Sci::Position lengthBytes) {
|
||||
if (sci->pdoc->IsReadOnly()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -687,7 +690,7 @@ bool ScintillaGTKAccessible::InsertStringUTF8(Position bytePos, const gchar *utf
|
|||
}
|
||||
|
||||
void ScintillaGTKAccessible::InsertText(const gchar *text, int lengthBytes, int *charPosition) {
|
||||
Position bytePosition = ByteOffsetFromCharacterOffset(*charPosition);
|
||||
Sci::Position bytePosition = ByteOffsetFromCharacterOffset(*charPosition);
|
||||
|
||||
// FIXME: should we update the target?
|
||||
if (InsertStringUTF8(bytePosition, text, lengthBytes)) {
|
||||
|
@ -696,7 +699,7 @@ void ScintillaGTKAccessible::InsertText(const gchar *text, int lengthBytes, int
|
|||
}
|
||||
|
||||
void ScintillaGTKAccessible::CopyText(int startChar, int endChar) {
|
||||
Position startByte, endByte;
|
||||
Sci::Position startByte, endByte;
|
||||
ByteRangeFromCharacterRange(startChar, endChar, startByte, endByte);
|
||||
sci->CopyRangeToClipboard(startByte, endByte);
|
||||
}
|
||||
|
@ -715,7 +718,7 @@ void ScintillaGTKAccessible::DeleteText(int startChar, int endChar) {
|
|||
g_return_if_fail(endChar >= startChar);
|
||||
|
||||
if (! sci->pdoc->IsReadOnly()) {
|
||||
Position startByte, endByte;
|
||||
Sci::Position startByte, endByte;
|
||||
ByteRangeFromCharacterRange(startChar, endChar, startByte, endByte);
|
||||
|
||||
if (! sci->RangeContainsProtected(startByte, endByte)) {
|
||||
|
@ -734,13 +737,13 @@ void ScintillaGTKAccessible::PasteText(int charPosition) {
|
|||
// has always done that without problems, so let's guess it's a fairly safe bet.
|
||||
struct Helper : GObjectWatcher {
|
||||
ScintillaGTKAccessible *scia;
|
||||
Position bytePosition;
|
||||
Sci::Position bytePosition;
|
||||
|
||||
virtual void Destroyed() {
|
||||
void Destroyed() override {
|
||||
scia = 0;
|
||||
}
|
||||
|
||||
Helper(ScintillaGTKAccessible *scia_, Position bytePos_) :
|
||||
Helper(ScintillaGTKAccessible *scia_, Sci::Position bytePos_) :
|
||||
GObjectWatcher(G_OBJECT(scia_->sci->sci)),
|
||||
scia(scia_),
|
||||
bytePosition(bytePos_) {
|
||||
|
@ -756,7 +759,7 @@ void ScintillaGTKAccessible::PasteText(int charPosition) {
|
|||
len = convertedText.length();
|
||||
text = convertedText.c_str();
|
||||
}
|
||||
scia->InsertStringUTF8(bytePosition, text, static_cast<int>(len));
|
||||
scia->InsertStringUTF8(bytePosition, text, static_cast<Sci::Position>(len));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -787,10 +790,14 @@ void ScintillaGTKAccessible::AtkEditableTextIface::init(::AtkEditableTextIface *
|
|||
//~ iface->set_run_attributes = SetRunAttributes;
|
||||
}
|
||||
|
||||
bool ScintillaGTKAccessible::Enabled() const {
|
||||
return sci->accessibilityEnabled == SC_ACCESSIBILITY_ENABLED;
|
||||
}
|
||||
|
||||
// Callbacks
|
||||
|
||||
void ScintillaGTKAccessible::UpdateCursor() {
|
||||
Position pos = sci->WndProc(SCI_GETCURRENTPOS, 0, 0);
|
||||
Sci::Position pos = sci->WndProc(SCI_GETCURRENTPOS, 0, 0);
|
||||
if (old_pos != pos) {
|
||||
int charPosition = CharacterOffsetFromByteOffset(pos);
|
||||
g_signal_emit_by_name(accessible, "text-caret-moved", charPosition);
|
||||
|
@ -819,6 +826,10 @@ void ScintillaGTKAccessible::UpdateCursor() {
|
|||
}
|
||||
|
||||
void ScintillaGTKAccessible::ChangeDocument(Document *oldDoc, Document *newDoc) {
|
||||
if (!Enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (oldDoc == newDoc) {
|
||||
return;
|
||||
}
|
||||
|
@ -853,12 +864,20 @@ void ScintillaGTKAccessible::NotifyReadOnly() {
|
|||
#endif
|
||||
}
|
||||
|
||||
void ScintillaGTKAccessible::SetAccessibility() {
|
||||
// Called by ScintillaGTK when application has enabled or disabled accessibility
|
||||
character_offsets.resize(0);
|
||||
character_offsets.push_back(0);
|
||||
}
|
||||
|
||||
void ScintillaGTKAccessible::Notify(GtkWidget *, gint, SCNotification *nt) {
|
||||
if (!Enabled())
|
||||
return;
|
||||
switch (nt->nmhdr.code) {
|
||||
case SCN_MODIFIED: {
|
||||
if (nt->modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT)) {
|
||||
// invalidate character offset cache if applicable
|
||||
const Position line = sci->pdoc->LineFromPosition(nt->position);
|
||||
const Sci::Line line = sci->pdoc->LineFromPosition(nt->position);
|
||||
if (character_offsets.size() > static_cast<size_t>(line + 1)) {
|
||||
character_offsets.resize(line + 1);
|
||||
}
|
||||
|
|
|
@ -21,14 +21,15 @@ private:
|
|||
ScintillaGTK *sci;
|
||||
|
||||
// cache holding character offset for each line start, see CharacterOffsetFromByteOffset()
|
||||
std::vector<Position> character_offsets;
|
||||
std::vector<Sci::Position> character_offsets;
|
||||
|
||||
// cached length of the deletion, in characters (see Notify())
|
||||
int deletionLengthChar;
|
||||
// local state for comparing
|
||||
Position old_pos;
|
||||
Sci::Position old_pos;
|
||||
std::vector<SelectionRange> old_sels;
|
||||
|
||||
bool Enabled() const;
|
||||
void UpdateCursor();
|
||||
void Notify(GtkWidget *widget, gint code, SCNotification *nt);
|
||||
static void SciNotify(GtkWidget *widget, gint code, SCNotification *nt, gpointer data) {
|
||||
|
@ -37,8 +38,8 @@ private:
|
|||
} catch (...) {}
|
||||
}
|
||||
|
||||
Position ByteOffsetFromCharacterOffset(Position startByte, int characterOffset) {
|
||||
Position pos = sci->pdoc->GetRelativePosition(startByte, characterOffset);
|
||||
Sci::Position ByteOffsetFromCharacterOffset(Sci::Position startByte, int characterOffset) {
|
||||
Sci::Position pos = sci->pdoc->GetRelativePosition(startByte, characterOffset);
|
||||
if (pos == INVALID_POSITION) {
|
||||
// clamp invalid positions inside the document
|
||||
if (characterOffset > 0) {
|
||||
|
@ -50,51 +51,51 @@ private:
|
|||
return pos;
|
||||
}
|
||||
|
||||
Position ByteOffsetFromCharacterOffset(int characterOffset) {
|
||||
Sci::Position ByteOffsetFromCharacterOffset(Sci::Position characterOffset) {
|
||||
return ByteOffsetFromCharacterOffset(0, characterOffset);
|
||||
}
|
||||
|
||||
int CharacterOffsetFromByteOffset(Position byteOffset) {
|
||||
const Position line = sci->pdoc->LineFromPosition(byteOffset);
|
||||
Sci::Position CharacterOffsetFromByteOffset(Sci::Position byteOffset) {
|
||||
const Sci::Line line = sci->pdoc->LineFromPosition(byteOffset);
|
||||
if (character_offsets.size() <= static_cast<size_t>(line)) {
|
||||
if (character_offsets.empty())
|
||||
character_offsets.push_back(0);
|
||||
for (Position i = character_offsets.size(); i <= line; i++) {
|
||||
const Position start = sci->pdoc->LineStart(i - 1);
|
||||
const Position end = sci->pdoc->LineStart(i);
|
||||
for (Sci::Position i = character_offsets.size(); i <= line; i++) {
|
||||
const Sci::Position start = sci->pdoc->LineStart(i - 1);
|
||||
const Sci::Position end = sci->pdoc->LineStart(i);
|
||||
character_offsets.push_back(character_offsets[i - 1] + sci->pdoc->CountCharacters(start, end));
|
||||
}
|
||||
}
|
||||
const Position lineStart = sci->pdoc->LineStart(line);
|
||||
const Sci::Position lineStart = sci->pdoc->LineStart(line);
|
||||
return character_offsets[line] + sci->pdoc->CountCharacters(lineStart, byteOffset);
|
||||
}
|
||||
|
||||
void CharacterRangeFromByteRange(Position startByte, Position endByte, int *startChar, int *endChar) {
|
||||
void CharacterRangeFromByteRange(Sci::Position startByte, Sci::Position endByte, int *startChar, int *endChar) {
|
||||
*startChar = CharacterOffsetFromByteOffset(startByte);
|
||||
*endChar = *startChar + sci->pdoc->CountCharacters(startByte, endByte);
|
||||
}
|
||||
|
||||
void ByteRangeFromCharacterRange(int startChar, int endChar, Position& startByte, Position& endByte) {
|
||||
void ByteRangeFromCharacterRange(int startChar, int endChar, Sci::Position& startByte, Sci::Position& endByte) {
|
||||
startByte = ByteOffsetFromCharacterOffset(startChar);
|
||||
endByte = ByteOffsetFromCharacterOffset(startByte, endChar - startChar);
|
||||
}
|
||||
|
||||
Position PositionBefore(Position pos) {
|
||||
Sci::Position PositionBefore(Sci::Position pos) {
|
||||
return sci->pdoc->MovePositionOutsideChar(pos - 1, -1, true);
|
||||
}
|
||||
|
||||
Position PositionAfter(Position pos) {
|
||||
Sci::Position PositionAfter(Sci::Position pos) {
|
||||
return sci->pdoc->MovePositionOutsideChar(pos + 1, 1, true);
|
||||
}
|
||||
|
||||
int StyleAt(Position position, bool ensureStyle = false) {
|
||||
int StyleAt(Sci::Position position, bool ensureStyle = false) {
|
||||
if (ensureStyle)
|
||||
sci->pdoc->EnsureStyledTo(position);
|
||||
return sci->pdoc->StyleAt(position);
|
||||
}
|
||||
|
||||
// For AtkText
|
||||
gchar *GetTextRangeUTF8(Position startByte, Position endByte);
|
||||
gchar *GetTextRangeUTF8(Sci::Position startByte, Sci::Position endByte);
|
||||
gchar *GetText(int startChar, int endChar);
|
||||
gchar *GetTextAfterOffset(int charOffset, AtkTextBoundary boundaryType, int *startChar, int *endChar);
|
||||
gchar *GetTextBeforeOffset(int charOffset, AtkTextBoundary boundaryType, int *startChar, int *endChar);
|
||||
|
@ -108,7 +109,7 @@ private:
|
|||
gboolean SetCaretOffset(int charOffset);
|
||||
gint GetOffsetAtPoint(gint x, gint y, AtkCoordType coords);
|
||||
void GetCharacterExtents(int charOffset, gint *x, gint *y, gint *width, gint *height, AtkCoordType coords);
|
||||
AtkAttributeSet *GetAttributesForStyle(unsigned int style);
|
||||
AtkAttributeSet *GetAttributesForStyle(unsigned int styleNum);
|
||||
AtkAttributeSet *GetRunAttributes(int charOffset, int *startChar, int *endChar);
|
||||
AtkAttributeSet *GetDefaultAttributes();
|
||||
gint GetNSelections();
|
||||
|
@ -117,16 +118,16 @@ private:
|
|||
gboolean RemoveSelection(int selection_num);
|
||||
gboolean SetSelection(gint selection_num, int startChar, int endChar);
|
||||
// for AtkEditableText
|
||||
bool InsertStringUTF8(Position bytePos, const gchar *utf8, int lengthBytes);
|
||||
bool InsertStringUTF8(Sci::Position bytePos, const gchar *utf8, Sci::Position lengthBytes);
|
||||
void SetTextContents(const gchar *contents);
|
||||
void InsertText(const gchar *contents, int lengthBytes, int *charPosition);
|
||||
void InsertText(const gchar *text, int lengthBytes, int *charPosition);
|
||||
void CopyText(int startChar, int endChar);
|
||||
void CutText(int startChar, int endChar);
|
||||
void DeleteText(int startChar, int endChar);
|
||||
void PasteText(int charPosition);
|
||||
|
||||
public:
|
||||
ScintillaGTKAccessible(GtkAccessible *accessible, GtkWidget *widget);
|
||||
ScintillaGTKAccessible(GtkAccessible *accessible_, GtkWidget *widget_);
|
||||
~ScintillaGTKAccessible();
|
||||
|
||||
static ScintillaGTKAccessible *FromAccessible(GtkAccessible *accessible);
|
||||
|
@ -136,6 +137,7 @@ public:
|
|||
// So ScintillaGTK can notify us
|
||||
void ChangeDocument(Document *oldDoc, Document *newDoc);
|
||||
void NotifyReadOnly();
|
||||
void SetAccessibility();
|
||||
|
||||
// Helper GtkWidget methods
|
||||
static AtkObject *WidgetGetAccessibleImpl(GtkWidget *widget, AtkObject **cache, gpointer widget_parent_class);
|
||||
|
|
|
@ -78,7 +78,7 @@ namespace Scintilla {
|
|||
typedef float XYPOSITION;
|
||||
typedef double XYACCUMULATOR;
|
||||
inline int RoundXYPosition(XYPOSITION xyPos) {
|
||||
return int(xyPos + 0.5);
|
||||
return static_cast<int>(xyPos + 0.5);
|
||||
}
|
||||
|
||||
// Underlying the implementation of the platform classes are platform specific types.
|
||||
|
@ -136,7 +136,7 @@ public:
|
|||
|
||||
// Other automatically defined methods (assignment, copy constructor, destructor) are fine
|
||||
|
||||
bool operator==(PRectangle &rc) const {
|
||||
bool operator==(const PRectangle &rc) const {
|
||||
return (rc.left == left) && (rc.right == right) &&
|
||||
(rc.top == top) && (rc.bottom == bottom);
|
||||
}
|
||||
|
@ -363,6 +363,14 @@ public:
|
|||
virtual ~Window();
|
||||
Window &operator=(WindowID wid_) {
|
||||
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; }
|
||||
|
|
|
@ -134,6 +134,7 @@
|
|||
#define SCLEX_TEHEX 119
|
||||
#define SCLEX_JSON 120
|
||||
#define SCLEX_EDIFACT 121
|
||||
#define SCLEX_INDENT 122
|
||||
#define SCLEX_AUTOMATIC 1000
|
||||
#define SCE_P_DEFAULT 0
|
||||
#define SCE_P_COMMENTLINE 1
|
||||
|
|
|
@ -329,6 +329,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
|||
#define SCI_SETCARETLINEVISIBLE 2096
|
||||
#define SCI_GETCARETLINEBACK 2097
|
||||
#define SCI_SETCARETLINEBACK 2098
|
||||
#define SCI_GETCARETLINEFRAME 2704
|
||||
#define SCI_SETCARETLINEFRAME 2705
|
||||
#define SCI_STYLESETCHANGEABLE 2099
|
||||
#define SCI_AUTOCSHOW 2100
|
||||
#define SCI_AUTOCCANCEL 2101
|
||||
|
@ -593,6 +595,10 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
|||
#define SCI_LINESSPLIT 2289
|
||||
#define SCI_SETFOLDMARGINCOLOUR 2290
|
||||
#define SCI_SETFOLDMARGINHICOLOUR 2291
|
||||
#define SC_ACCESSIBILITY_DISABLED 0
|
||||
#define SC_ACCESSIBILITY_ENABLED 1
|
||||
#define SCI_SETACCESSIBILITY 2702
|
||||
#define SCI_GETACCESSIBILITY 2703
|
||||
#define SCI_LINEDOWN 2300
|
||||
#define SCI_LINEDOWNEXTEND 2301
|
||||
#define SCI_LINEUP 2302
|
||||
|
@ -634,6 +640,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
|||
#define SCI_LINECUT 2337
|
||||
#define SCI_LINEDELETE 2338
|
||||
#define SCI_LINETRANSPOSE 2339
|
||||
#define SCI_LINEREVERSE 2354
|
||||
#define SCI_LINEDUPLICATE 2404
|
||||
#define SCI_LOWERCASE 2340
|
||||
#define SCI_UPPERCASE 2341
|
||||
|
|
|
@ -415,8 +415,7 @@ set void SetMargins=2252(int margins,)
|
|||
# How many margins are there?.
|
||||
get int GetMargins=2253(,)
|
||||
|
||||
# Styles in range 32..38 are predefined for parts of the UI and are not used as normal styles.
|
||||
# Style 39 is for future use.
|
||||
# Styles in range 32..39 are predefined for parts of the UI and are not used as normal styles.
|
||||
enu StylesCommon=STYLE_
|
||||
val STYLE_DEFAULT=32
|
||||
val STYLE_LINENUMBER=33
|
||||
|
@ -732,6 +731,14 @@ get colour GetCaretLineBack=2097(,)
|
|||
# Set the colour of the background of the line containing the caret.
|
||||
set void SetCaretLineBack=2098(colour back,)
|
||||
|
||||
# Retrieve the caret line frame width.
|
||||
# Width = 0 means this option is disabled.
|
||||
get int GetCaretLineFrame=2704(,)
|
||||
|
||||
# Display the caret line framed.
|
||||
# Set width != 0 to enable this option and width = 0 to disable it.
|
||||
set void SetCaretLineFrame=2705(int width,)
|
||||
|
||||
# Set a style to be changeable or not (read only).
|
||||
# Experimental feature, currently buggy.
|
||||
set void StyleSetChangeable=2099(int style, bool changeable)
|
||||
|
@ -1215,7 +1222,7 @@ fun void ToggleFold=2231(int line,)
|
|||
# Switch a header line between expanded and contracted and show some text after the line.
|
||||
fun void ToggleFoldShowText=2700(int line, string text)
|
||||
|
||||
enu foldDisplayTextStyle=SC_FOLDDISPLAYTEXTSTYLE_
|
||||
enu FoldDisplayTextStyle=SC_FOLDDISPLAYTEXT_
|
||||
val SC_FOLDDISPLAYTEXT_HIDDEN=0
|
||||
val SC_FOLDDISPLAYTEXT_STANDARD=1
|
||||
val SC_FOLDDISPLAYTEXT_BOXED=2
|
||||
|
@ -1477,6 +1484,16 @@ fun void SetFoldMarginColour=2290(bool useSetting, colour back)
|
|||
# Set the other colour used as a chequerboard pattern in the fold margin
|
||||
fun void SetFoldMarginHiColour=2291(bool useSetting, colour fore)
|
||||
|
||||
enu Accessibility=SC_ACCESSIBILITY_
|
||||
val SC_ACCESSIBILITY_DISABLED=0
|
||||
val SC_ACCESSIBILITY_ENABLED=1
|
||||
|
||||
# Enable or disable accessibility.
|
||||
set void SetAccessibility=2702(int accessibility,)
|
||||
|
||||
# Report accessibility status.
|
||||
get int GetAccessibility=2703(,)
|
||||
|
||||
## New messages go here
|
||||
|
||||
## Start of key messages
|
||||
|
@ -1605,6 +1622,9 @@ fun void LineDelete=2338(,)
|
|||
# Switch the current line with the previous.
|
||||
fun void LineTranspose=2339(,)
|
||||
|
||||
# Reverse order of selected lines.
|
||||
fun void LineReverse=2354(,)
|
||||
|
||||
# Duplicate the current line.
|
||||
fun void LineDuplicate=2404(,)
|
||||
|
||||
|
@ -1832,6 +1852,7 @@ fun void WordPartRight=2392(,)
|
|||
fun void WordPartRightExtend=2393(,)
|
||||
|
||||
# Constants for use with SetVisiblePolicy, similar to SetCaretPolicy.
|
||||
enu VisiblePolicy=VISIBLE_
|
||||
val VISIBLE_SLOP=0x01
|
||||
val VISIBLE_STRICT=0x04
|
||||
# Set the way the display area is determined when a particular line
|
||||
|
@ -1844,8 +1865,10 @@ fun void DelLineLeft=2395(,)
|
|||
# Delete forwards from the current position to the end of the line.
|
||||
fun void DelLineRight=2396(,)
|
||||
|
||||
# Get and Set the xOffset (ie, horizontal scroll position).
|
||||
# Set the xOffset (ie, horizontal scroll position).
|
||||
set void SetXOffset=2397(int xOffset,)
|
||||
|
||||
# Get the xOffset (ie, horizontal scroll position).
|
||||
get int GetXOffset=2398(,)
|
||||
|
||||
# Set the last x chosen value to be the caret x position.
|
||||
|
@ -2117,6 +2140,7 @@ get bool GetPasteConvertEndings=2468(,)
|
|||
# Duplicate the selection. If selection empty duplicate the line containing the caret.
|
||||
fun void SelectionDuplicate=2469(,)
|
||||
|
||||
enu Alpha=SC_ALPHA_
|
||||
val SC_ALPHA_TRANSPARENT=0
|
||||
val SC_ALPHA_OPAQUE=255
|
||||
val SC_ALPHA_NOALPHA=256
|
||||
|
@ -2515,6 +2539,7 @@ fun void ScrollToStart=2628(,)
|
|||
# Scroll to end of document.
|
||||
fun void ScrollToEnd=2629(,)
|
||||
|
||||
enu Technology=SC_TECHNOLOGY_
|
||||
val SC_TECHNOLOGY_DEFAULT=0
|
||||
val SC_TECHNOLOGY_DIRECTWRITE=1
|
||||
val SC_TECHNOLOGY_DIRECTWRITERETAIN=2
|
||||
|
@ -2891,6 +2916,7 @@ val SCLEX_IHEX=118
|
|||
val SCLEX_TEHEX=119
|
||||
val SCLEX_JSON=120
|
||||
val SCLEX_EDIFACT=121
|
||||
val SCLEX_INDENT=122
|
||||
|
||||
# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
|
||||
# value assigned in sequence from SCLEX_AUTOMATIC+1.
|
||||
|
@ -4811,7 +4837,7 @@ evt void MacroRecord=2009(int message, int wParam, int lParam)
|
|||
evt void MarginClick=2010(int modifiers, int position, int margin)
|
||||
evt void NeedShown=2011(int position, int length)
|
||||
evt void Painted=2013(void)
|
||||
evt void UserListSelection=2014(int listType, string text, int positionint, int ch, CompletionMethods listCompletionMethod)
|
||||
evt void UserListSelection=2014(int listType, string text, int position, int ch, CompletionMethods listCompletionMethod)
|
||||
evt void URIDropped=2015(string text)
|
||||
evt void DwellStart=2016(int position, int x, int y)
|
||||
evt void DwellEnd=2017(int position, int x, int y)
|
||||
|
|
|
@ -157,30 +157,30 @@ public:
|
|||
}
|
||||
virtual ~LexerAsm() {
|
||||
}
|
||||
void SCI_METHOD Release() {
|
||||
void SCI_METHOD Release() override {
|
||||
delete this;
|
||||
}
|
||||
int SCI_METHOD Version() const {
|
||||
int SCI_METHOD Version() const override {
|
||||
return lvOriginal;
|
||||
}
|
||||
const char * SCI_METHOD PropertyNames() {
|
||||
const char * SCI_METHOD PropertyNames() override {
|
||||
return osAsm.PropertyNames();
|
||||
}
|
||||
int SCI_METHOD PropertyType(const char *name) {
|
||||
int SCI_METHOD PropertyType(const char *name) override {
|
||||
return osAsm.PropertyType(name);
|
||||
}
|
||||
const char * SCI_METHOD DescribeProperty(const char *name) {
|
||||
const char * SCI_METHOD DescribeProperty(const char *name) override {
|
||||
return osAsm.DescribeProperty(name);
|
||||
}
|
||||
Sci_Position SCI_METHOD PropertySet(const char *key, const char *val);
|
||||
const char * SCI_METHOD DescribeWordListSets() {
|
||||
Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override;
|
||||
const char * SCI_METHOD DescribeWordListSets() override {
|
||||
return osAsm.DescribeWordListSets();
|
||||
}
|
||||
Sci_Position SCI_METHOD WordListSet(int n, const char *wl);
|
||||
void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess);
|
||||
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess);
|
||||
Sci_Position SCI_METHOD WordListSet(int n, const char *wl) override;
|
||||
void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override;
|
||||
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override;
|
||||
|
||||
void * SCI_METHOD PrivateCall(int, void *) {
|
||||
void * SCI_METHOD PrivateCall(int, void *) override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -97,13 +97,26 @@ static int opposite(int ch) {
|
|||
}
|
||||
|
||||
static int GlobScan(StyleContext &sc) {
|
||||
// forward scan for a glob-like (...), no whitespace allowed
|
||||
// forward scan for zsh globs, disambiguate versus bash arrays
|
||||
// complex expressions may still fail, e.g. unbalanced () '' "" etc
|
||||
int c, sLen = 0;
|
||||
int pCount = 0;
|
||||
int hash = 0;
|
||||
while ((c = sc.GetRelativeCharacter(++sLen)) != 0) {
|
||||
if (IsASpace(c)) {
|
||||
return 0;
|
||||
} else if (c == '\'' || c == '\"') {
|
||||
if (hash != 2) return 0;
|
||||
} else if (c == '#' && hash == 0) {
|
||||
hash = (sLen == 1) ? 2:1;
|
||||
} else if (c == '(') {
|
||||
pCount++;
|
||||
} else if (c == ')') {
|
||||
return sLen;
|
||||
if (pCount == 0) {
|
||||
if (hash) return sLen;
|
||||
return 0;
|
||||
}
|
||||
pCount--;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -240,30 +240,30 @@ public:
|
|||
}
|
||||
virtual ~LexerBasic() {
|
||||
}
|
||||
void SCI_METHOD Release() {
|
||||
void SCI_METHOD Release() override {
|
||||
delete this;
|
||||
}
|
||||
int SCI_METHOD Version() const {
|
||||
int SCI_METHOD Version() const override {
|
||||
return lvOriginal;
|
||||
}
|
||||
const char * SCI_METHOD PropertyNames() {
|
||||
const char * SCI_METHOD PropertyNames() override {
|
||||
return osBasic.PropertyNames();
|
||||
}
|
||||
int SCI_METHOD PropertyType(const char *name) {
|
||||
int SCI_METHOD PropertyType(const char *name) override {
|
||||
return osBasic.PropertyType(name);
|
||||
}
|
||||
const char * SCI_METHOD DescribeProperty(const char *name) {
|
||||
const char * SCI_METHOD DescribeProperty(const char *name) override {
|
||||
return osBasic.DescribeProperty(name);
|
||||
}
|
||||
Sci_Position SCI_METHOD PropertySet(const char *key, const char *val);
|
||||
const char * SCI_METHOD DescribeWordListSets() {
|
||||
Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override;
|
||||
const char * SCI_METHOD DescribeWordListSets() override {
|
||||
return osBasic.DescribeWordListSets();
|
||||
}
|
||||
Sci_Position SCI_METHOD WordListSet(int n, const char *wl);
|
||||
void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess);
|
||||
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess);
|
||||
Sci_Position SCI_METHOD WordListSet(int n, const char *wl) override;
|
||||
void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override;
|
||||
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override;
|
||||
|
||||
void * SCI_METHOD PrivateCall(int, void *) {
|
||||
void * SCI_METHOD PrivateCall(int, void *) override {
|
||||
return 0;
|
||||
}
|
||||
static ILexer *LexerFactoryBlitzBasic() {
|
||||
|
|
|
@ -54,9 +54,9 @@ bool IsSpaceEquiv(int state) {
|
|||
// 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 = (Sci_Position) sc.currentPos;
|
||||
Sci_Position pos = static_cast<Sci_Position>(sc.currentPos);
|
||||
while (--pos > 0) {
|
||||
char ch = styler[pos];
|
||||
const char ch = styler[pos];
|
||||
if (ch == '+' || ch == '-') {
|
||||
return styler[pos - 1] == ch;
|
||||
}
|
||||
|
@ -66,11 +66,11 @@ bool FollowsPostfixOperator(StyleContext &sc, LexAccessor &styler) {
|
|||
|
||||
bool followsReturnKeyword(StyleContext &sc, LexAccessor &styler) {
|
||||
// Don't look at styles, so no need to flush.
|
||||
Sci_Position pos = (Sci_Position) sc.currentPos;
|
||||
Sci_Position pos = static_cast<Sci_Position>(sc.currentPos);
|
||||
Sci_Position currentLine = styler.GetLine(pos);
|
||||
Sci_Position lineStartPos = styler.LineStart(currentLine);
|
||||
const Sci_Position lineStartPos = styler.LineStart(currentLine);
|
||||
while (--pos > lineStartPos) {
|
||||
char ch = styler.SafeGetCharAt(pos);
|
||||
const char ch = styler.SafeGetCharAt(pos);
|
||||
if (ch != ' ' && ch != '\t') {
|
||||
break;
|
||||
}
|
||||
|
@ -91,8 +91,8 @@ bool IsSpaceOrTab(int ch) {
|
|||
}
|
||||
|
||||
bool OnlySpaceOrTab(const std::string &s) {
|
||||
for (std::string::const_iterator it = s.begin(); it != s.end(); ++it) {
|
||||
if (!IsSpaceOrTab(*it))
|
||||
for (const char ch : s) {
|
||||
if (!IsSpaceOrTab(ch))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -100,11 +100,11 @@ bool OnlySpaceOrTab(const std::string &s) {
|
|||
|
||||
std::vector<std::string> StringSplit(const std::string &text, int separator) {
|
||||
std::vector<std::string> vs(text.empty() ? 0 : 1);
|
||||
for (std::string::const_iterator it = text.begin(); it != text.end(); ++it) {
|
||||
if (*it == separator) {
|
||||
for (const char ch : text) {
|
||||
if (ch == separator) {
|
||||
vs.push_back(std::string());
|
||||
} else {
|
||||
vs.back() += *it;
|
||||
vs.back() += ch;
|
||||
}
|
||||
}
|
||||
return vs;
|
||||
|
@ -141,14 +141,14 @@ BracketPair FindBracketPair(std::vector<std::string> &tokens) {
|
|||
}
|
||||
|
||||
void highlightTaskMarker(StyleContext &sc, LexAccessor &styler,
|
||||
int activity, WordList &markerList, bool caseSensitive){
|
||||
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 = (Sci_Position) sc.currentPos;
|
||||
Sci_Position currPos = static_cast<Sci_Position>(sc.currentPos);
|
||||
int i = 0;
|
||||
while (i < lengthMarker) {
|
||||
char ch = styler.SafeGetCharAt(currPos + i);
|
||||
const char ch = styler.SafeGetCharAt(currPos + i);
|
||||
if (IsASpace(ch) || isoperator(ch)) {
|
||||
break;
|
||||
}
|
||||
|
@ -203,9 +203,9 @@ std::string GetRestOfLine(LexAccessor &styler, Sci_Position start, bool allowSpa
|
|||
std::string restOfLine;
|
||||
Sci_Position i =0;
|
||||
char ch = styler.SafeGetCharAt(start, '\n');
|
||||
Sci_Position endLine = styler.LineEnd(styler.GetLine(start));
|
||||
const Sci_Position endLine = styler.LineEnd(styler.GetLine(start));
|
||||
while (((start+i) < endLine) && (ch != '\r')) {
|
||||
char chNext = styler.SafeGetCharAt(start + i + 1, '\n');
|
||||
const char chNext = styler.SafeGetCharAt(start + i + 1, '\n');
|
||||
if (ch == '/' && (chNext == '/' || chNext == '*'))
|
||||
break;
|
||||
if (allowSpace || (ch != ' '))
|
||||
|
@ -485,64 +485,64 @@ public:
|
|||
}
|
||||
virtual ~LexerCPP() {
|
||||
}
|
||||
void SCI_METHOD Release() {
|
||||
void SCI_METHOD Release() override {
|
||||
delete this;
|
||||
}
|
||||
int SCI_METHOD Version() const {
|
||||
int SCI_METHOD Version() const override {
|
||||
return lvSubStyles;
|
||||
}
|
||||
const char * SCI_METHOD PropertyNames() {
|
||||
const char * SCI_METHOD PropertyNames() override {
|
||||
return osCPP.PropertyNames();
|
||||
}
|
||||
int SCI_METHOD PropertyType(const char *name) {
|
||||
int SCI_METHOD PropertyType(const char *name) override {
|
||||
return osCPP.PropertyType(name);
|
||||
}
|
||||
const char * SCI_METHOD DescribeProperty(const char *name) {
|
||||
const char * SCI_METHOD DescribeProperty(const char *name) override {
|
||||
return osCPP.DescribeProperty(name);
|
||||
}
|
||||
Sci_Position SCI_METHOD PropertySet(const char *key, const char *val);
|
||||
const char * SCI_METHOD DescribeWordListSets() {
|
||||
Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override;
|
||||
const char * SCI_METHOD DescribeWordListSets() override {
|
||||
return osCPP.DescribeWordListSets();
|
||||
}
|
||||
Sci_Position SCI_METHOD WordListSet(int n, const char *wl);
|
||||
void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess);
|
||||
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess);
|
||||
Sci_Position SCI_METHOD WordListSet(int n, const char *wl) override;
|
||||
void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override;
|
||||
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override;
|
||||
|
||||
void * SCI_METHOD PrivateCall(int, void *) {
|
||||
void * SCI_METHOD PrivateCall(int, void *) override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SCI_METHOD LineEndTypesSupported() {
|
||||
int SCI_METHOD LineEndTypesSupported() override {
|
||||
return SC_LINE_END_TYPE_UNICODE;
|
||||
}
|
||||
|
||||
int SCI_METHOD AllocateSubStyles(int styleBase, int numberStyles) {
|
||||
int SCI_METHOD AllocateSubStyles(int styleBase, int numberStyles) override {
|
||||
return subStyles.Allocate(styleBase, numberStyles);
|
||||
}
|
||||
int SCI_METHOD SubStylesStart(int styleBase) {
|
||||
int SCI_METHOD SubStylesStart(int styleBase) override {
|
||||
return subStyles.Start(styleBase);
|
||||
}
|
||||
int SCI_METHOD SubStylesLength(int styleBase) {
|
||||
int SCI_METHOD SubStylesLength(int styleBase) override {
|
||||
return subStyles.Length(styleBase);
|
||||
}
|
||||
int SCI_METHOD StyleFromSubStyle(int subStyle) {
|
||||
int styleBase = subStyles.BaseStyle(MaskActive(subStyle));
|
||||
int active = subStyle & activeFlag;
|
||||
int SCI_METHOD StyleFromSubStyle(int subStyle) override {
|
||||
const int styleBase = subStyles.BaseStyle(MaskActive(subStyle));
|
||||
const int active = subStyle & activeFlag;
|
||||
return styleBase | active;
|
||||
}
|
||||
int SCI_METHOD PrimaryStyleFromStyle(int style) {
|
||||
int SCI_METHOD PrimaryStyleFromStyle(int style) override {
|
||||
return MaskActive(style);
|
||||
}
|
||||
void SCI_METHOD FreeSubStyles() {
|
||||
void SCI_METHOD FreeSubStyles() override {
|
||||
subStyles.Free();
|
||||
}
|
||||
void SCI_METHOD SetIdentifiers(int style, const char *identifiers) {
|
||||
void SCI_METHOD SetIdentifiers(int style, const char *identifiers) override {
|
||||
subStyles.SetIdentifiers(style, identifiers);
|
||||
}
|
||||
int SCI_METHOD DistanceToSecondaryStyles() {
|
||||
int SCI_METHOD DistanceToSecondaryStyles() override {
|
||||
return activeFlag;
|
||||
}
|
||||
const char * SCI_METHOD GetSubStyleBases() {
|
||||
const char * SCI_METHOD GetSubStyleBases() override {
|
||||
return styleSubable;
|
||||
}
|
||||
|
||||
|
@ -637,7 +637,7 @@ Sci_Position SCI_METHOD LexerCPP::WordListSet(int n, const char *wl) {
|
|||
struct After {
|
||||
Sci_Position line;
|
||||
explicit After(Sci_Position line_) : line(line_) {}
|
||||
bool operator()(PPDefinition &p) const {
|
||||
bool operator()(const PPDefinition &p) const {
|
||||
return p.line > line;
|
||||
}
|
||||
};
|
||||
|
@ -709,11 +709,11 @@ void SCI_METHOD LexerCPP::Lex(Sci_PositionU startPos, Sci_Position length, int i
|
|||
}
|
||||
|
||||
SymbolTable preprocessorDefinitions = preprocessorDefinitionsStart;
|
||||
for (std::vector<PPDefinition>::iterator itDef = ppDefineHistory.begin(); itDef != ppDefineHistory.end(); ++itDef) {
|
||||
if (itDef->isUndef)
|
||||
preprocessorDefinitions.erase(itDef->key);
|
||||
for (const PPDefinition &ppDef : ppDefineHistory) {
|
||||
if (ppDef.isUndef)
|
||||
preprocessorDefinitions.erase(ppDef.key);
|
||||
else
|
||||
preprocessorDefinitions[itDef->key] = SymbolValue(itDef->value, itDef->arguments);
|
||||
preprocessorDefinitions[ppDef.key] = SymbolValue(ppDef.value, ppDef.arguments);
|
||||
}
|
||||
|
||||
std::string rawStringTerminator = rawStringTerminators.ValueAt(lineCurrent-1);
|
||||
|
@ -829,7 +829,7 @@ void SCI_METHOD LexerCPP::Lex(Sci_PositionU startPos, Sci_Position length, int i
|
|||
const bool raw = literalString && sc.chPrev == 'R' && !setInvalidRawFirst.Contains(sc.chNext);
|
||||
if (raw)
|
||||
s[lenS--] = '\0';
|
||||
bool valid =
|
||||
const bool valid =
|
||||
(lenS == 0) ||
|
||||
((lenS == 1) && ((s[0] == 'L') || (s[0] == 'u') || (s[0] == 'U'))) ||
|
||||
((lenS == 2) && literalString && (s[0] == 'u') && (s[1] == '8'));
|
||||
|
@ -1198,7 +1198,7 @@ void SCI_METHOD LexerCPP::Lex(Sci_PositionU startPos, Sci_Position length, int i
|
|||
if (!preproc.CurrentIfTaken()) {
|
||||
// Similar to #if
|
||||
std::string restOfLine = GetRestOfLine(styler, sc.currentPos + 2, true);
|
||||
bool ifGood = EvaluateExpression(restOfLine, preprocessorDefinitions);
|
||||
const bool ifGood = EvaluateExpression(restOfLine, preprocessorDefinitions);
|
||||
if (ifGood) {
|
||||
preproc.InvertCurrentLevel();
|
||||
activitySet = preproc.IsInactive() ? activeFlag : 0;
|
||||
|
@ -1294,7 +1294,7 @@ void SCI_METHOD LexerCPP::Fold(Sci_PositionU startPos, Sci_Position length, int
|
|||
|
||||
LexAccessor styler(pAccess);
|
||||
|
||||
Sci_PositionU endPos = startPos + length;
|
||||
const Sci_PositionU endPos = startPos + length;
|
||||
int visibleChars = 0;
|
||||
bool inLineComment = false;
|
||||
Sci_Position lineCurrent = styler.GetLine(startPos);
|
||||
|
@ -1309,12 +1309,12 @@ void SCI_METHOD LexerCPP::Fold(Sci_PositionU startPos, Sci_Position length, int
|
|||
int style = MaskActive(initStyle);
|
||||
const bool userDefinedFoldMarkers = !options.foldExplicitStart.empty() && !options.foldExplicitEnd.empty();
|
||||
for (Sci_PositionU i = startPos; i < endPos; i++) {
|
||||
char ch = chNext;
|
||||
const char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
int stylePrev = style;
|
||||
const int stylePrev = style;
|
||||
style = styleNext;
|
||||
styleNext = MaskActive(styler.StyleAt(i + 1));
|
||||
bool atEOL = i == (lineStartNext-1);
|
||||
const bool atEOL = i == (lineStartNext-1);
|
||||
if ((style == SCE_C_COMMENTLINE) || (style == SCE_C_COMMENTLINEDOC))
|
||||
inLineComment = true;
|
||||
if (options.foldComment && options.foldCommentMultiline && IsStreamCommentStyle(style) && !inLineComment) {
|
||||
|
@ -1334,7 +1334,7 @@ void SCI_METHOD LexerCPP::Fold(Sci_PositionU startPos, Sci_Position length, int
|
|||
}
|
||||
} else {
|
||||
if ((ch == '/') && (chNext == '/')) {
|
||||
char chNext2 = styler.SafeGetCharAt(i + 2);
|
||||
const char chNext2 = styler.SafeGetCharAt(i + 2);
|
||||
if (chNext2 == '{') {
|
||||
levelNext++;
|
||||
} else if (chNext2 == '}') {
|
||||
|
@ -1537,14 +1537,14 @@ void LexerCPP::EvaluateTokens(std::vector<std::string> &tokens, const SymbolTabl
|
|||
for (int prec=precArithmetic; prec <= precLogical; prec++) {
|
||||
// Looking at 3 tokens at a time so end at 2 before end
|
||||
for (size_t k=0; (k+2)<tokens.size();) {
|
||||
char chOp = tokens[k+1][0];
|
||||
const char chOp = tokens[k+1][0];
|
||||
if (
|
||||
((prec==precArithmetic) && setArithmethicOp.Contains(chOp)) ||
|
||||
((prec==precRelative) && setRelOp.Contains(chOp)) ||
|
||||
((prec==precLogical) && setLogicalOp.Contains(chOp))
|
||||
) {
|
||||
int valA = atoi(tokens[k].c_str());
|
||||
int valB = atoi(tokens[k+2].c_str());
|
||||
const int valA = atoi(tokens[k].c_str());
|
||||
const int valB = atoi(tokens[k+2].c_str());
|
||||
int result = 0;
|
||||
if (tokens[k+1] == "+")
|
||||
result = valA + valB;
|
||||
|
@ -1631,7 +1631,7 @@ bool LexerCPP::EvaluateExpression(const std::string &expr, const SymbolTable &pr
|
|||
EvaluateTokens(tokens, preprocessorDefinitions);
|
||||
|
||||
// "0" or "" -> false else true
|
||||
bool isFalse = tokens.empty() ||
|
||||
const bool isFalse = tokens.empty() ||
|
||||
((tokens.size() == 1) && ((tokens[0] == "") || tokens[0] == "0"));
|
||||
return !isFalse;
|
||||
}
|
||||
|
|
|
@ -162,30 +162,30 @@ public:
|
|||
}
|
||||
virtual ~LexerD() {
|
||||
}
|
||||
void SCI_METHOD Release() {
|
||||
void SCI_METHOD Release() override {
|
||||
delete this;
|
||||
}
|
||||
int SCI_METHOD Version() const {
|
||||
int SCI_METHOD Version() const override {
|
||||
return lvOriginal;
|
||||
}
|
||||
const char * SCI_METHOD PropertyNames() {
|
||||
const char * SCI_METHOD PropertyNames() override {
|
||||
return osD.PropertyNames();
|
||||
}
|
||||
int SCI_METHOD PropertyType(const char *name) {
|
||||
int SCI_METHOD PropertyType(const char *name) override {
|
||||
return osD.PropertyType(name);
|
||||
}
|
||||
const char * SCI_METHOD DescribeProperty(const char *name) {
|
||||
const char * SCI_METHOD DescribeProperty(const char *name) override {
|
||||
return osD.DescribeProperty(name);
|
||||
}
|
||||
Sci_Position SCI_METHOD PropertySet(const char *key, const char *val);
|
||||
const char * SCI_METHOD DescribeWordListSets() {
|
||||
Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override;
|
||||
const char * SCI_METHOD DescribeWordListSets() override {
|
||||
return osD.DescribeWordListSets();
|
||||
}
|
||||
Sci_Position SCI_METHOD WordListSet(int n, const char *wl);
|
||||
void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess);
|
||||
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess);
|
||||
Sci_Position SCI_METHOD WordListSet(int n, const char *wl) override;
|
||||
void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override;
|
||||
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override;
|
||||
|
||||
void * SCI_METHOD PrivateCall(int, void *) {
|
||||
void * SCI_METHOD PrivateCall(int, void *) override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ static void FoldDiffDoc(Sci_PositionU startPos, Sci_Position length, int, WordLi
|
|||
int nextLevel;
|
||||
|
||||
do {
|
||||
int lineType = styler.StyleAt(curLineStart);
|
||||
const int lineType = styler.StyleAt(curLineStart);
|
||||
if (lineType == SCE_DIFF_COMMAND)
|
||||
nextLevel = SC_FOLDLEVELBASE | SC_FOLDLEVELHEADERFLAG;
|
||||
else if (lineType == SCE_DIFF_HEADER)
|
||||
|
|
|
@ -120,14 +120,6 @@ static void ColouriseFortranDoc(Sci_PositionU startPos, Sci_Position length, int
|
|||
continue;
|
||||
}
|
||||
/***************************************/
|
||||
// Hanndle preprocessor directives
|
||||
if (sc.ch == '#' && numNonBlank == 1)
|
||||
{
|
||||
sc.SetState(SCE_F_PREPROCESSOR);
|
||||
while (!sc.atLineEnd && sc.More())
|
||||
sc.Forward(); // Until line end
|
||||
}
|
||||
/***************************************/
|
||||
// Handle line continuation generically.
|
||||
if (!isFixFormat && sc.ch == '&' && sc.state != SCE_F_COMMENT) {
|
||||
char chTemp = ' ';
|
||||
|
@ -143,7 +135,11 @@ static void ColouriseFortranDoc(Sci_PositionU startPos, Sci_Position length, int
|
|||
int currentState = sc.state;
|
||||
sc.SetState(SCE_F_CONTINUATION);
|
||||
sc.ForwardSetState(SCE_F_DEFAULT);
|
||||
while (IsASpace(sc.ch) && sc.More()) sc.Forward();
|
||||
while (IsASpace(sc.ch) && sc.More()) {
|
||||
sc.Forward();
|
||||
if (sc.atLineStart) numNonBlank = 0;
|
||||
if (!IsASpaceOrTab(sc.ch)) numNonBlank ++;
|
||||
}
|
||||
if (sc.ch == '&') {
|
||||
sc.SetState(SCE_F_CONTINUATION);
|
||||
sc.Forward();
|
||||
|
@ -152,6 +148,14 @@ static void ColouriseFortranDoc(Sci_PositionU startPos, Sci_Position length, int
|
|||
}
|
||||
}
|
||||
/***************************************/
|
||||
// Hanndle preprocessor directives
|
||||
if (sc.ch == '#' && numNonBlank == 1)
|
||||
{
|
||||
sc.SetState(SCE_F_PREPROCESSOR);
|
||||
while (!sc.atLineEnd && sc.More())
|
||||
sc.Forward(); // Until line end
|
||||
}
|
||||
/***************************************/
|
||||
// Determine if the current state should terminate.
|
||||
if (sc.state == SCE_F_OPERATOR) {
|
||||
sc.SetState(SCE_F_DEFAULT);
|
||||
|
@ -223,7 +227,7 @@ static void ColouriseFortranDoc(Sci_PositionU startPos, Sci_Position length, int
|
|||
if (sc.state == SCE_F_DEFAULT) {
|
||||
if (sc.ch == '!') {
|
||||
if (sc.MatchIgnoreCase("!dec$") || sc.MatchIgnoreCase("!dir$") ||
|
||||
sc.MatchIgnoreCase("!ms$") || sc.chNext == '$') {
|
||||
sc.MatchIgnoreCase("!ms$") || sc.chNext == '$') {
|
||||
sc.SetState(SCE_F_PREPROCESSOR);
|
||||
} else {
|
||||
sc.SetState(SCE_F_COMMENT);
|
||||
|
@ -233,7 +237,7 @@ static void ColouriseFortranDoc(Sci_PositionU startPos, Sci_Position length, int
|
|||
} else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
|
||||
sc.SetState(SCE_F_NUMBER);
|
||||
} else if ((tolower(sc.ch) == 'b' || tolower(sc.ch) == 'o' ||
|
||||
tolower(sc.ch) == 'z') && (sc.chNext == '\"' || sc.chNext == '\'')) {
|
||||
tolower(sc.ch) == 'z') && (sc.chNext == '\"' || sc.chNext == '\'')) {
|
||||
sc.SetState(SCE_F_NUMBER);
|
||||
sc.Forward();
|
||||
} else if (sc.ch == '.' && isalpha(sc.chNext)) {
|
||||
|
@ -252,6 +256,165 @@ static void ColouriseFortranDoc(Sci_PositionU startPos, Sci_Position length, int
|
|||
sc.Complete();
|
||||
}
|
||||
/***************************************/
|
||||
static void CheckLevelCommentLine(const unsigned int nComL,
|
||||
int nComColB[], int nComColF[], int &nComCur,
|
||||
bool comLineB[], bool comLineF[], bool &comLineCur,
|
||||
int &levelDeltaNext) {
|
||||
levelDeltaNext = 0;
|
||||
if (!comLineCur) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!comLineF[0] || nComColF[0] != nComCur) {
|
||||
unsigned int i=0;
|
||||
for (; i<nComL; i++) {
|
||||
if (!comLineB[i] || nComColB[i] != nComCur) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == nComL) {
|
||||
levelDeltaNext = -1;
|
||||
}
|
||||
}
|
||||
else if (!comLineB[0] || nComColB[0] != nComCur) {
|
||||
unsigned int i=0;
|
||||
for (; i<nComL; i++) {
|
||||
if (!comLineF[i] || nComColF[i] != nComCur) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == nComL) {
|
||||
levelDeltaNext = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
/***************************************/
|
||||
static void GetIfLineComment(Accessor &styler, bool isFixFormat, const Sci_Position line, bool &isComLine, Sci_Position &comCol) {
|
||||
Sci_Position col = 0;
|
||||
isComLine = false;
|
||||
Sci_Position pos = styler.LineStart(line);
|
||||
Sci_Position len = styler.Length();
|
||||
while(pos<len) {
|
||||
char ch = styler.SafeGetCharAt(pos);
|
||||
if (ch == '!' || (isFixFormat && col == 0 && (tolower(ch) == 'c' || ch == '*'))) {
|
||||
isComLine = true;
|
||||
comCol = col;
|
||||
break;
|
||||
}
|
||||
else if (!IsABlank(ch) || IsALineEnd(ch)) {
|
||||
break;
|
||||
}
|
||||
pos++;
|
||||
col++;
|
||||
}
|
||||
}
|
||||
/***************************************/
|
||||
static void StepCommentLine(Accessor &styler, bool isFixFormat, Sci_Position lineCurrent, const unsigned int nComL,
|
||||
Sci_Position nComColB[], Sci_Position nComColF[], Sci_Position &nComCur,
|
||||
bool comLineB[], bool comLineF[], bool &comLineCur) {
|
||||
Sci_Position nLineTotal = styler.GetLine(styler.Length()-1) + 1;
|
||||
if (lineCurrent >= nLineTotal) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i=nComL-2; i>=0; i--) {
|
||||
nComColB[i+1] = nComColB[i];
|
||||
comLineB[i+1] = comLineB[i];
|
||||
}
|
||||
nComColB[0] = nComCur;
|
||||
comLineB[0] = comLineCur;
|
||||
nComCur = nComColF[0];
|
||||
comLineCur = comLineF[0];
|
||||
for (unsigned int i=0; i+1<nComL; i++) {
|
||||
nComColF[i] = nComColF[i+1];
|
||||
comLineF[i] = comLineF[i+1];
|
||||
}
|
||||
Sci_Position chL = lineCurrent + nComL;
|
||||
if (chL < nLineTotal) {
|
||||
GetIfLineComment(styler, isFixFormat, chL, comLineF[nComL-1], nComColF[nComL-1]);
|
||||
}
|
||||
else {
|
||||
comLineF[nComL-1] = false;
|
||||
}
|
||||
}
|
||||
/***************************************/
|
||||
static void CheckBackComLines(Accessor &styler, bool isFixFormat, Sci_Position lineCurrent, const unsigned int nComL,
|
||||
Sci_Position nComColB[], Sci_Position nComColF[], Sci_Position nComCur,
|
||||
bool comLineB[], bool comLineF[], bool &comLineCur) {
|
||||
unsigned int nLines = nComL + nComL + 1;
|
||||
bool* comL = new bool[nLines];
|
||||
Sci_Position* nComCol = new Sci_Position[nLines];
|
||||
bool comL0;
|
||||
Sci_Position nComCol0;
|
||||
GetIfLineComment(styler, isFixFormat, lineCurrent-nComL-1, comL0, nComCol0);
|
||||
for (unsigned int i=0; i<nComL; i++) {
|
||||
unsigned copyTo = nComL - i - 1;
|
||||
comL[copyTo] = comLineB[i];
|
||||
nComCol[copyTo] = nComColB[i];
|
||||
}
|
||||
assert(nComL < nLines);
|
||||
comL[nComL] = comLineCur;
|
||||
nComCol[nComL] = nComCur;
|
||||
for (unsigned int i=0; i<nComL; i++) {
|
||||
unsigned copyTo = i + nComL + 1;
|
||||
comL[copyTo] = comLineF[i];
|
||||
nComCol[copyTo] = nComColF[i];
|
||||
}
|
||||
|
||||
Sci_Position lineC = lineCurrent - nComL + 1;
|
||||
unsigned int iStart;
|
||||
if (lineC <= 0) {
|
||||
lineC = 0;
|
||||
iStart = nComL - lineCurrent;
|
||||
}
|
||||
else {
|
||||
iStart = 1;
|
||||
}
|
||||
bool levChanged = false;
|
||||
int lev = styler.LevelAt(lineC) & SC_FOLDLEVELNUMBERMASK;
|
||||
|
||||
for (unsigned int i=iStart; i<=nComL; i++) {
|
||||
if (comL[i] && (!comL[i-1] || nComCol[i] != nComCol[i-1])) {
|
||||
bool increase = true;
|
||||
unsigned int until = i + nComL;
|
||||
for (unsigned int j=i+1; j<=until; j++) {
|
||||
if (!comL[j] || nComCol[j] != nComCol[i]) {
|
||||
increase = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
lev = styler.LevelAt(lineC) & SC_FOLDLEVELNUMBERMASK;
|
||||
if (increase) {
|
||||
int levH = lev | SC_FOLDLEVELHEADERFLAG;
|
||||
lev += 1;
|
||||
if (levH != styler.LevelAt(lineC)) {
|
||||
styler.SetLevel(lineC, levH);
|
||||
}
|
||||
for (Sci_Position j=lineC+1; j<=lineCurrent; j++) {
|
||||
if (lev != styler.LevelAt(j)) {
|
||||
styler.SetLevel(j, lev);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
else {
|
||||
if (lev != styler.LevelAt(lineC)) {
|
||||
styler.SetLevel(lineC, lev);
|
||||
}
|
||||
}
|
||||
levChanged = true;
|
||||
}
|
||||
else if (levChanged && comL[i]) {
|
||||
if (lev != styler.LevelAt(lineC)) {
|
||||
styler.SetLevel(lineC, lev);
|
||||
}
|
||||
}
|
||||
lineC++;
|
||||
}
|
||||
delete[] comL;
|
||||
delete[] nComCol;
|
||||
}
|
||||
/***************************************/
|
||||
// To determine the folding level depending on keywords
|
||||
static int classifyFoldPointFortran(const char* s, const char* prevWord, const char chNextNonBlank) {
|
||||
int lev = 0;
|
||||
|
@ -298,29 +461,62 @@ static int classifyFoldPointFortran(const char* s, const char* prevWord, const c
|
|||
// Folding the code
|
||||
static void FoldFortranDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
|
||||
Accessor &styler, bool isFixFormat) {
|
||||
//
|
||||
// bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
|
||||
// Do not know how to fold the comment at the moment.
|
||||
//
|
||||
|
||||
bool foldComment = styler.GetPropertyInt("fold.comment", 1) != 0;
|
||||
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
|
||||
Sci_PositionU endPos = startPos + length;
|
||||
int visibleChars = 0;
|
||||
Sci_Position lineCurrent = styler.GetLine(startPos);
|
||||
int levelCurrent;
|
||||
bool isPrevLine;
|
||||
if (lineCurrent > 0) {
|
||||
lineCurrent--;
|
||||
startPos = styler.LineStart(lineCurrent);
|
||||
levelCurrent = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
|
||||
isPrevLine = true;
|
||||
} else {
|
||||
levelCurrent = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
|
||||
isPrevLine = false;
|
||||
}
|
||||
char chNext = styler[startPos];
|
||||
int styleNext = styler.StyleAt(startPos);
|
||||
int style = initStyle;
|
||||
int levelDeltaNext = 0;
|
||||
|
||||
const unsigned int nComL = 3; // defines how many comment lines should be before they are folded
|
||||
Sci_Position nComColB[nComL];
|
||||
Sci_Position nComColF[nComL] = {};
|
||||
Sci_Position nComCur;
|
||||
bool comLineB[nComL];
|
||||
bool comLineF[nComL];
|
||||
bool comLineCur;
|
||||
Sci_Position nLineTotal = styler.GetLine(styler.Length()-1) + 1;
|
||||
if (foldComment) {
|
||||
for (unsigned int i=0; i<nComL; i++) {
|
||||
Sci_Position chL = lineCurrent-(i+1);
|
||||
if (chL < 0) {
|
||||
comLineB[i] = false;
|
||||
break;
|
||||
}
|
||||
GetIfLineComment(styler, isFixFormat, chL, comLineB[i], nComColB[i]);
|
||||
if (!comLineB[i]) {
|
||||
for (unsigned int j=i+1; j<nComL; j++) {
|
||||
comLineB[j] = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (unsigned int i=0; i<nComL; i++) {
|
||||
Sci_Position chL = lineCurrent+i+1;
|
||||
if (chL >= nLineTotal) {
|
||||
comLineF[i] = false;
|
||||
break;
|
||||
}
|
||||
GetIfLineComment(styler, isFixFormat, chL, comLineF[i], nComColF[i]);
|
||||
}
|
||||
GetIfLineComment(styler, isFixFormat, lineCurrent, comLineCur, nComCur);
|
||||
CheckBackComLines(styler, isFixFormat, lineCurrent, nComL, nComColB, nComColF, nComCur,
|
||||
comLineB, comLineF, comLineCur);
|
||||
}
|
||||
int levelCurrent = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
|
||||
|
||||
/***************************************/
|
||||
Sci_Position lastStart = 0;
|
||||
char prevWord[32] = "";
|
||||
|
@ -463,6 +659,11 @@ static void FoldFortranDoc(Sci_PositionU startPos, Sci_Position length, int init
|
|||
}
|
||||
}
|
||||
if (atEOL) {
|
||||
if (foldComment) {
|
||||
int ldNext;
|
||||
CheckLevelCommentLine(nComL, nComColB, nComColF, nComCur, comLineB, comLineF, comLineCur, ldNext);
|
||||
levelDeltaNext += ldNext;
|
||||
}
|
||||
int lev = levelCurrent;
|
||||
if (visibleChars == 0 && foldCompact)
|
||||
lev |= SC_FOLDLEVELWHITEFLAG;
|
||||
|
@ -477,6 +678,11 @@ static void FoldFortranDoc(Sci_PositionU startPos, Sci_Position length, int init
|
|||
visibleChars = 0;
|
||||
strcpy(prevWord, "");
|
||||
isPrevLine = false;
|
||||
|
||||
if (foldComment) {
|
||||
StepCommentLine(styler, isFixFormat, lineCurrent, nComL, nComColB, nComColF, nComCur,
|
||||
comLineB, comLineF, comLineCur);
|
||||
}
|
||||
}
|
||||
/***************************************/
|
||||
if (!isspacechar(ch)) visibleChars++;
|
||||
|
|
|
@ -490,9 +490,9 @@ static bool isMakoBlockEnd(const int ch, const int chNext, const char *blockType
|
|||
return ((ch == '/') && (chNext == '>'));
|
||||
} else if (0 == strcmp(blockType, "%")) {
|
||||
if (ch == '/' && isLineEnd(chNext))
|
||||
return 1;
|
||||
return true;
|
||||
else
|
||||
return isLineEnd(ch);
|
||||
return isLineEnd(ch);
|
||||
} else if (0 == strcmp(blockType, "{")) {
|
||||
return ch == '}';
|
||||
} else {
|
||||
|
@ -502,13 +502,13 @@ static bool isMakoBlockEnd(const int ch, const int chNext, const char *blockType
|
|||
|
||||
static bool isDjangoBlockEnd(const int ch, const int chNext, const char *blockType) {
|
||||
if (strlen(blockType) == 0) {
|
||||
return 0;
|
||||
return false;
|
||||
} else if (0 == strcmp(blockType, "%")) {
|
||||
return ((ch == '%') && (chNext == '}'));
|
||||
} else if (0 == strcmp(blockType, "{")) {
|
||||
return ((ch == '}') && (chNext == '}'));
|
||||
} else {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -396,39 +396,39 @@ public:
|
|||
{}
|
||||
virtual ~LexerHaskell() {}
|
||||
|
||||
void SCI_METHOD Release() {
|
||||
void SCI_METHOD Release() override {
|
||||
delete this;
|
||||
}
|
||||
|
||||
int SCI_METHOD Version() const {
|
||||
int SCI_METHOD Version() const override {
|
||||
return lvOriginal;
|
||||
}
|
||||
|
||||
const char * SCI_METHOD PropertyNames() {
|
||||
const char * SCI_METHOD PropertyNames() override {
|
||||
return osHaskell.PropertyNames();
|
||||
}
|
||||
|
||||
int SCI_METHOD PropertyType(const char *name) {
|
||||
int SCI_METHOD PropertyType(const char *name) override {
|
||||
return osHaskell.PropertyType(name);
|
||||
}
|
||||
|
||||
const char * SCI_METHOD DescribeProperty(const char *name) {
|
||||
const char * SCI_METHOD DescribeProperty(const char *name) override {
|
||||
return osHaskell.DescribeProperty(name);
|
||||
}
|
||||
|
||||
Sci_Position SCI_METHOD PropertySet(const char *key, const char *val);
|
||||
Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override;
|
||||
|
||||
const char * SCI_METHOD DescribeWordListSets() {
|
||||
const char * SCI_METHOD DescribeWordListSets() override {
|
||||
return osHaskell.DescribeWordListSets();
|
||||
}
|
||||
|
||||
Sci_Position SCI_METHOD WordListSet(int n, const char *wl);
|
||||
Sci_Position SCI_METHOD WordListSet(int n, const char *wl) override;
|
||||
|
||||
void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess);
|
||||
void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override;
|
||||
|
||||
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess);
|
||||
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override;
|
||||
|
||||
void * SCI_METHOD PrivateCall(int, void *) {
|
||||
void * SCI_METHOD PrivateCall(int, void *) override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -81,8 +81,8 @@ public:
|
|||
static ILexer *LexerFactoryLaTeX() {
|
||||
return new LexerLaTeX();
|
||||
}
|
||||
void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess);
|
||||
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess);
|
||||
void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override;
|
||||
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override;
|
||||
};
|
||||
|
||||
static bool latexIsSpecial(int ch) {
|
||||
|
|
|
@ -48,14 +48,14 @@ static void ColouriseLuaDoc(
|
|||
WordList *keywordlists[],
|
||||
Accessor &styler) {
|
||||
|
||||
WordList &keywords = *keywordlists[0];
|
||||
WordList &keywords2 = *keywordlists[1];
|
||||
WordList &keywords3 = *keywordlists[2];
|
||||
WordList &keywords4 = *keywordlists[3];
|
||||
WordList &keywords5 = *keywordlists[4];
|
||||
WordList &keywords6 = *keywordlists[5];
|
||||
WordList &keywords7 = *keywordlists[6];
|
||||
WordList &keywords8 = *keywordlists[7];
|
||||
const WordList &keywords = *keywordlists[0];
|
||||
const WordList &keywords2 = *keywordlists[1];
|
||||
const WordList &keywords3 = *keywordlists[2];
|
||||
const WordList &keywords4 = *keywordlists[3];
|
||||
const WordList &keywords5 = *keywordlists[4];
|
||||
const WordList &keywords6 = *keywordlists[5];
|
||||
const WordList &keywords7 = *keywordlists[6];
|
||||
const WordList &keywords8 = *keywordlists[7];
|
||||
|
||||
// Accepts accented characters
|
||||
CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true);
|
||||
|
@ -77,7 +77,7 @@ static void ColouriseLuaDoc(
|
|||
int stringWs = 0;
|
||||
if (initStyle == SCE_LUA_LITERALSTRING || initStyle == SCE_LUA_COMMENT ||
|
||||
initStyle == SCE_LUA_STRING || initStyle == SCE_LUA_CHARACTER) {
|
||||
int lineState = styler.GetLineState(currentLine - 1);
|
||||
const int lineState = styler.GetLineState(currentLine - 1);
|
||||
nestLevel = lineState >> 9;
|
||||
sepCount = lineState & 0xFF;
|
||||
stringWs = lineState & 0x100;
|
||||
|
@ -257,7 +257,7 @@ static void ColouriseLuaDoc(
|
|||
}
|
||||
} else if (sc.state == SCE_LUA_LITERALSTRING || sc.state == SCE_LUA_COMMENT) {
|
||||
if (sc.ch == '[') {
|
||||
int sep = LongDelimCheck(sc);
|
||||
const int sep = LongDelimCheck(sc);
|
||||
if (sep == 1 && sepCount == 1) { // [[-only allowed to nest
|
||||
nestLevel++;
|
||||
sc.Forward();
|
||||
|
@ -349,21 +349,21 @@ static void ColouriseLuaDoc(
|
|||
|
||||
static void FoldLuaDoc(Sci_PositionU startPos, Sci_Position length, int /* initStyle */, WordList *[],
|
||||
Accessor &styler) {
|
||||
Sci_PositionU lengthDoc = startPos + length;
|
||||
const Sci_PositionU lengthDoc = startPos + length;
|
||||
int visibleChars = 0;
|
||||
Sci_Position lineCurrent = styler.GetLine(startPos);
|
||||
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
|
||||
int levelCurrent = levelPrev;
|
||||
char chNext = styler[startPos];
|
||||
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
|
||||
const bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
|
||||
int styleNext = styler.StyleAt(startPos);
|
||||
|
||||
for (Sci_PositionU i = startPos; i < lengthDoc; i++) {
|
||||
char ch = chNext;
|
||||
const char ch = chNext;
|
||||
chNext = styler.SafeGetCharAt(i + 1);
|
||||
int style = styleNext;
|
||||
const int style = styleNext;
|
||||
styleNext = styler.StyleAt(i + 1);
|
||||
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
|
||||
const bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
|
||||
if (style == SCE_LUA_WORD) {
|
||||
if (ch == 'i' || ch == 'd' || ch == 'f' || ch == 'e' || ch == 'r' || ch == 'u') {
|
||||
char s[10] = "";
|
||||
|
|
|
@ -415,30 +415,30 @@ public:
|
|||
}
|
||||
virtual ~LexerPerl() {
|
||||
}
|
||||
void SCI_METHOD Release() {
|
||||
void SCI_METHOD Release() override {
|
||||
delete this;
|
||||
}
|
||||
int SCI_METHOD Version() const {
|
||||
int SCI_METHOD Version() const override {
|
||||
return lvOriginal;
|
||||
}
|
||||
const char *SCI_METHOD PropertyNames() {
|
||||
const char *SCI_METHOD PropertyNames() override {
|
||||
return osPerl.PropertyNames();
|
||||
}
|
||||
int SCI_METHOD PropertyType(const char *name) {
|
||||
int SCI_METHOD PropertyType(const char *name) override {
|
||||
return osPerl.PropertyType(name);
|
||||
}
|
||||
const char *SCI_METHOD DescribeProperty(const char *name) {
|
||||
const char *SCI_METHOD DescribeProperty(const char *name) override {
|
||||
return osPerl.DescribeProperty(name);
|
||||
}
|
||||
Sci_Position SCI_METHOD PropertySet(const char *key, const char *val);
|
||||
const char *SCI_METHOD DescribeWordListSets() {
|
||||
Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override;
|
||||
const char *SCI_METHOD DescribeWordListSets() override {
|
||||
return osPerl.DescribeWordListSets();
|
||||
}
|
||||
Sci_Position SCI_METHOD WordListSet(int n, const char *wl);
|
||||
void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess);
|
||||
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess);
|
||||
Sci_Position SCI_METHOD WordListSet(int n, const char *wl) override;
|
||||
void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override;
|
||||
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override;
|
||||
|
||||
void *SCI_METHOD PrivateCall(int, void *) {
|
||||
void *SCI_METHOD PrivateCall(int, void *) override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ static inline bool IsAWordChar(int ch) {
|
|||
}
|
||||
|
||||
static void ColourisePowerShellDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler) {
|
||||
WordList *keywordlists[], Accessor &styler) {
|
||||
|
||||
WordList &keywords = *keywordlists[0];
|
||||
WordList &keywords2 = *keywordlists[1];
|
||||
|
@ -53,8 +53,8 @@ static void ColourisePowerShellDoc(Sci_PositionU startPos, Sci_Position length,
|
|||
sc.SetState(SCE_POWERSHELL_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_POWERSHELL_COMMENTSTREAM) {
|
||||
if(sc.atLineStart) {
|
||||
while(IsASpaceOrTab(sc.ch)) {
|
||||
if (sc.atLineStart) {
|
||||
while (IsASpaceOrTab(sc.ch)) {
|
||||
sc.Forward();
|
||||
}
|
||||
if (sc.ch == '.' && IsAWordChar(sc.chNext)) {
|
||||
|
@ -65,7 +65,7 @@ static void ColourisePowerShellDoc(Sci_PositionU startPos, Sci_Position length,
|
|||
sc.ForwardSetState(SCE_POWERSHELL_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_POWERSHELL_COMMENTDOCKEYWORD) {
|
||||
if(!IsAWordChar(sc.ch)) {
|
||||
if (!IsAWordChar(sc.ch)) {
|
||||
char s[100];
|
||||
sc.GetCurrentLowered(s, sizeof(s));
|
||||
if (!keywords6.InList(s + 1)) {
|
||||
|
@ -77,11 +77,15 @@ static void ColourisePowerShellDoc(Sci_PositionU startPos, Sci_Position length,
|
|||
// This is a doubles quotes string
|
||||
if (sc.ch == '\"') {
|
||||
sc.ForwardSetState(SCE_POWERSHELL_DEFAULT);
|
||||
} else if (sc.ch == '`') {
|
||||
sc.Forward(); // skip next escaped character
|
||||
}
|
||||
} else if (sc.state == SCE_POWERSHELL_CHARACTER) {
|
||||
// This is a single quote string
|
||||
if (sc.ch == '\'') {
|
||||
sc.ForwardSetState(SCE_POWERSHELL_DEFAULT);
|
||||
} else if (sc.ch == '`') {
|
||||
sc.Forward(); // skip next escaped character
|
||||
}
|
||||
} else if (sc.state == SCE_POWERSHELL_HERE_STRING) {
|
||||
// This is a doubles quotes here-string
|
||||
|
@ -161,7 +165,7 @@ static void ColourisePowerShellDoc(Sci_PositionU startPos, Sci_Position length,
|
|||
// level store to make it easy to pick up with each increment
|
||||
// and to make it possible to fiddle the current level for "} else {".
|
||||
static void FoldPowerShellDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
|
||||
WordList *[], Accessor &styler) {
|
||||
WordList *[], Accessor &styler) {
|
||||
bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
|
||||
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
|
||||
bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) != 0;
|
||||
|
@ -236,7 +240,7 @@ static void FoldPowerShellDoc(Sci_PositionU startPos, Sci_Position length, int i
|
|||
}
|
||||
}
|
||||
|
||||
static const char * const powershellWordLists[] = {
|
||||
static const char *const powershellWordLists[] = {
|
||||
"Commands",
|
||||
"Cmdlets",
|
||||
"Aliases",
|
||||
|
|
|
@ -37,7 +37,7 @@ static inline bool isassignchar(unsigned char ch) {
|
|||
}
|
||||
|
||||
static void ColourisePropsLine(
|
||||
char *lineBuffer,
|
||||
const char *lineBuffer,
|
||||
Sci_PositionU lengthLine,
|
||||
Sci_PositionU startLine,
|
||||
Sci_PositionU endPos,
|
||||
|
@ -91,7 +91,7 @@ static void ColourisePropsDoc(Sci_PositionU startPos, Sci_Position length, int,
|
|||
// For properties files, set to 0 to style all lines that start with whitespace in the default style.
|
||||
// This is not suitable for SciTE .properties files which use indentation for flow control but
|
||||
// can be used for RFC2822 text where indentation is used for continuation lines.
|
||||
bool allowInitialSpaces = styler.GetPropertyInt("lexer.props.allow.initial.spaces", 1) != 0;
|
||||
const bool allowInitialSpaces = styler.GetPropertyInt("lexer.props.allow.initial.spaces", 1) != 0;
|
||||
|
||||
for (Sci_PositionU i = startPos; i < startPos + length; i++) {
|
||||
lineBuffer[linePos++] = styler[i];
|
||||
|
@ -111,9 +111,9 @@ static void ColourisePropsDoc(Sci_PositionU startPos, Sci_Position length, int,
|
|||
// adaption by ksc, using the "} else {" trick of 1.53
|
||||
// 030721
|
||||
static void FoldPropsDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[], Accessor &styler) {
|
||||
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
|
||||
const bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
|
||||
|
||||
Sci_PositionU endPos = startPos + length;
|
||||
const Sci_PositionU endPos = startPos + length;
|
||||
int visibleChars = 0;
|
||||
Sci_Position lineCurrent = styler.GetLine(startPos);
|
||||
|
||||
|
@ -123,12 +123,12 @@ static void FoldPropsDoc(Sci_PositionU startPos, Sci_Position length, int, WordL
|
|||
int lev;
|
||||
|
||||
for (Sci_PositionU i = startPos; i < endPos; i++) {
|
||||
char ch = chNext;
|
||||
const char ch = chNext;
|
||||
chNext = styler[i+1];
|
||||
|
||||
int style = styleNext;
|
||||
const int style = styleNext;
|
||||
styleNext = styler.StyleAt(i + 1);
|
||||
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
|
||||
const bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
|
||||
|
||||
if (style == SCE_PROPS_SECTION) {
|
||||
headerPoint = true;
|
||||
|
@ -138,7 +138,7 @@ static void FoldPropsDoc(Sci_PositionU startPos, Sci_Position length, int, WordL
|
|||
lev = SC_FOLDLEVELBASE;
|
||||
|
||||
if (lineCurrent > 0) {
|
||||
int levelPrevious = styler.LevelAt(lineCurrent - 1);
|
||||
const int levelPrevious = styler.LevelAt(lineCurrent - 1);
|
||||
|
||||
if (levelPrevious & SC_FOLDLEVELHEADERFLAG) {
|
||||
lev = SC_FOLDLEVELBASE + 1;
|
||||
|
@ -169,7 +169,7 @@ static void FoldPropsDoc(Sci_PositionU startPos, Sci_Position length, int, WordL
|
|||
}
|
||||
|
||||
if (lineCurrent > 0) {
|
||||
int levelPrevious = styler.LevelAt(lineCurrent - 1);
|
||||
const int levelPrevious = styler.LevelAt(lineCurrent - 1);
|
||||
if (levelPrevious & SC_FOLDLEVELHEADERFLAG) {
|
||||
lev = SC_FOLDLEVELBASE + 1;
|
||||
} else {
|
||||
|
|
|
@ -36,7 +36,29 @@ using namespace Scintilla;
|
|||
#endif
|
||||
|
||||
namespace {
|
||||
// Use an unnamed namespace to protect the functions and classes from name conflicts
|
||||
// Use an unnamed namespace to protect the functions and classes from name conflicts
|
||||
|
||||
/* Notes on f-strings: f-strings are strings prefixed with f (e.g. f'') that may
|
||||
have arbitrary expressions in {}. The tokens in the expressions are lexed as if
|
||||
they were outside of any string. Expressions may contain { and } characters as
|
||||
long as there is a closing } for every {, may be 2+ lines in a triple quoted
|
||||
string, and may have a formatting specifier following a ! or :, but both !
|
||||
and : are valid inside of a bracketed expression and != is a valid
|
||||
expression token even outside of a bracketed expression.
|
||||
|
||||
When in an f-string expression, the lexer keeps track of the state value of
|
||||
the f-string and the nesting count for the expression (# of [, (, { seen - # of
|
||||
}, ), ] seen). f-strings may be nested (e.g. f'{ a + f"{1+2}"') so a stack of
|
||||
states and nesting counts is kept. If a f-string expression continues beyond
|
||||
the end of a line, this stack is saved in a std::map that maps a line number to
|
||||
the stack at the end of that line. std::vector is used for the stack.
|
||||
|
||||
The PEP for f-strings is at https://www.python.org/dev/peps/pep-0498/
|
||||
*/
|
||||
struct SingleFStringExpState {
|
||||
int state;
|
||||
int nestingCount;
|
||||
};
|
||||
|
||||
/* kwCDef, kwCTypeName only used for Cython */
|
||||
enum kwType { kwOther, kwClass, kwDef, kwImport, kwCDef, kwCTypeName, kwCPDef };
|
||||
|
@ -86,27 +108,46 @@ bool IsPyTripleQuoteStringState(int st) {
|
|||
(st == SCE_P_FTRIPLE) || (st == SCE_P_FTRIPLEDOUBLE));
|
||||
}
|
||||
|
||||
void PushStateToStack(int state, int *stack, int stackSize) {
|
||||
for (int i = stackSize-1; i > 0; i--) {
|
||||
stack[i] = stack[i-1];
|
||||
}
|
||||
stack[0] = state;
|
||||
char GetPyStringQuoteChar(int st) {
|
||||
if ((st == SCE_P_CHARACTER) || (st == SCE_P_FCHARACTER) ||
|
||||
(st == SCE_P_TRIPLE) || (st == SCE_P_FTRIPLE))
|
||||
return '\'';
|
||||
if ((st == SCE_P_STRING) || (st == SCE_P_FSTRING) ||
|
||||
(st == SCE_P_TRIPLEDOUBLE) || (st == SCE_P_FTRIPLEDOUBLE))
|
||||
return '"';
|
||||
|
||||
return '\0';
|
||||
}
|
||||
|
||||
int PopFromStateStack(int *stack, int stackSize) {
|
||||
int top = stack[0];
|
||||
for (int i = 0; i < stackSize - 1; i++) {
|
||||
stack[i] = stack[i+1];
|
||||
void PushStateToStack(int state, std::vector<SingleFStringExpState> &stack, SingleFStringExpState *¤tFStringExp) {
|
||||
SingleFStringExpState single = {state, 0};
|
||||
stack.push_back(single);
|
||||
|
||||
currentFStringExp = &stack.back();
|
||||
}
|
||||
|
||||
int PopFromStateStack(std::vector<SingleFStringExpState> &stack, SingleFStringExpState *¤tFStringExp) {
|
||||
int state = 0;
|
||||
|
||||
if (!stack.empty()) {
|
||||
state = stack.back().state;
|
||||
stack.pop_back();
|
||||
}
|
||||
stack[stackSize-1] = 0;
|
||||
return top;
|
||||
|
||||
if (stack.empty()) {
|
||||
currentFStringExp = NULL;
|
||||
} else {
|
||||
currentFStringExp = &stack.back();
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
/* Return the state to use for the string starting at i; *nextIndex will be set to the first index following the quote(s) */
|
||||
int GetPyStringState(Accessor &styler, Sci_Position i, Sci_PositionU *nextIndex, literalsAllowed allowed) {
|
||||
char ch = styler.SafeGetCharAt(i);
|
||||
char chNext = styler.SafeGetCharAt(i + 1);
|
||||
int firstIsF = (ch == 'f' || ch == 'F');
|
||||
const int firstIsF = (ch == 'f' || ch == 'F');
|
||||
|
||||
// Advance beyond r, u, or ur prefix (or r, b, or br in Python 2.7+ and r, f, or fr in Python 3.6+), but bail if there are any unexpected chars
|
||||
if (ch == 'r' || ch == 'R') {
|
||||
|
@ -151,11 +192,8 @@ inline bool IsAWordChar(int ch, bool unicodeIdentifiers) {
|
|||
if (!unicodeIdentifiers)
|
||||
return false;
|
||||
|
||||
// Approximation, Python uses the XID_Continue set from unicode data
|
||||
// see http://unicode.org/reports/tr31/
|
||||
CharacterCategory c = CategoriseCharacter(ch);
|
||||
return (c == ccLl || c == ccLu || c == ccLt || c == ccLm || c == ccLo
|
||||
|| c == ccNl || c == ccMn || c == ccMc || c == ccNd || c == ccPc);
|
||||
// Python uses the XID_Continue set from unicode data
|
||||
return IsXidContinue(ch);
|
||||
}
|
||||
|
||||
inline bool IsAWordStart(int ch, bool unicodeIdentifiers) {
|
||||
|
@ -165,18 +203,15 @@ inline bool IsAWordStart(int ch, bool unicodeIdentifiers) {
|
|||
if (!unicodeIdentifiers)
|
||||
return false;
|
||||
|
||||
// Approximation, Python uses the XID_Start set from unicode data
|
||||
// see http://unicode.org/reports/tr31/
|
||||
CharacterCategory c = CategoriseCharacter(ch);
|
||||
return (c == ccLl || c == ccLu || c == ccLt || c == ccLm || c == ccLo
|
||||
|| c == ccNl);
|
||||
// Python uses the XID_Start set from unicode data
|
||||
return IsXidStart(ch);
|
||||
}
|
||||
|
||||
static bool IsFirstNonWhitespace(Sci_Position pos, Accessor &styler) {
|
||||
Sci_Position line = styler.GetLine(pos);
|
||||
Sci_Position start_pos = styler.LineStart(line);
|
||||
for (Sci_Position i = start_pos; i < pos; i++) {
|
||||
char ch = styler[i];
|
||||
const char ch = styler[i];
|
||||
if (!(ch == ' ' || ch == '\t'))
|
||||
return false;
|
||||
}
|
||||
|
@ -230,42 +265,42 @@ static const char *const pythonWordListDesc[] = {
|
|||
struct OptionSetPython : public OptionSet<OptionsPython> {
|
||||
OptionSetPython() {
|
||||
DefineProperty("tab.timmy.whinge.level", &OptionsPython::whingeLevel,
|
||||
"For Python code, checks whether indenting is consistent. "
|
||||
"The default, 0 turns off indentation checking, "
|
||||
"1 checks whether each line is potentially inconsistent with the previous line, "
|
||||
"2 checks whether any space characters occur before a tab character in the indentation, "
|
||||
"3 checks whether any spaces are in the indentation, and "
|
||||
"4 checks for any tab characters in the indentation. "
|
||||
"1 is a good level to use.");
|
||||
"For Python code, checks whether indenting is consistent. "
|
||||
"The default, 0 turns off indentation checking, "
|
||||
"1 checks whether each line is potentially inconsistent with the previous line, "
|
||||
"2 checks whether any space characters occur before a tab character in the indentation, "
|
||||
"3 checks whether any spaces are in the indentation, and "
|
||||
"4 checks for any tab characters in the indentation. "
|
||||
"1 is a good level to use.");
|
||||
|
||||
DefineProperty("lexer.python.literals.binary", &OptionsPython::base2or8Literals,
|
||||
"Set to 0 to not recognise Python 3 binary and octal literals: 0b1011 0o712.");
|
||||
"Set to 0 to not recognise Python 3 binary and octal literals: 0b1011 0o712.");
|
||||
|
||||
DefineProperty("lexer.python.strings.u", &OptionsPython::stringsU,
|
||||
"Set to 0 to not recognise Python Unicode literals u\"x\" as used before Python 3.");
|
||||
"Set to 0 to not recognise Python Unicode literals u\"x\" as used before Python 3.");
|
||||
|
||||
DefineProperty("lexer.python.strings.b", &OptionsPython::stringsB,
|
||||
"Set to 0 to not recognise Python 3 bytes literals b\"x\".");
|
||||
"Set to 0 to not recognise Python 3 bytes literals b\"x\".");
|
||||
|
||||
DefineProperty("lexer.python.strings.f", &OptionsPython::stringsF,
|
||||
"Set to 0 to not recognise Python 3.6 f-string literals f\"var={var}\".");
|
||||
"Set to 0 to not recognise Python 3.6 f-string literals f\"var={var}\".");
|
||||
|
||||
DefineProperty("lexer.python.strings.over.newline", &OptionsPython::stringsOverNewline,
|
||||
"Set to 1 to allow strings to span newline characters.");
|
||||
"Set to 1 to allow strings to span newline characters.");
|
||||
|
||||
DefineProperty("lexer.python.keywords2.no.sub.identifiers", &OptionsPython::keywords2NoSubIdentifiers,
|
||||
"When enabled, it will not style keywords2 items that are used as a sub-identifier. "
|
||||
"Example: when set, will not highlight \"foo.open\" when \"open\" is a keywords2 item.");
|
||||
"When enabled, it will not style keywords2 items that are used as a sub-identifier. "
|
||||
"Example: when set, will not highlight \"foo.open\" when \"open\" is a keywords2 item.");
|
||||
|
||||
DefineProperty("fold", &OptionsPython::fold);
|
||||
|
||||
DefineProperty("fold.quotes.python", &OptionsPython::foldQuotes,
|
||||
"This option enables folding multi-line quoted strings when using the Python lexer.");
|
||||
"This option enables folding multi-line quoted strings when using the Python lexer.");
|
||||
|
||||
DefineProperty("fold.compact", &OptionsPython::foldCompact);
|
||||
|
||||
DefineProperty("lexer.python.unicode.identifiers", &OptionsPython::unicodeIdentifiers,
|
||||
"Set to 0 to not recognise Python 3 unicode identifiers.");
|
||||
"Set to 0 to not recognise Python 3 unicode identifiers.");
|
||||
|
||||
DefineWordListSets(pythonWordListDesc);
|
||||
}
|
||||
|
@ -282,69 +317,70 @@ class LexerPython : public ILexerWithSubStyles {
|
|||
OptionSetPython osPython;
|
||||
enum { ssIdentifier };
|
||||
SubStyles subStyles;
|
||||
std::map<int, std::vector<SingleFStringExpState> > ftripleStateAtEol;
|
||||
public:
|
||||
explicit LexerPython() :
|
||||
subStyles(styleSubable, 0x80, 0x40, 0) {
|
||||
}
|
||||
virtual ~LexerPython() {
|
||||
}
|
||||
void SCI_METHOD Release() {
|
||||
void SCI_METHOD Release() override {
|
||||
delete this;
|
||||
}
|
||||
int SCI_METHOD Version() const {
|
||||
int SCI_METHOD Version() const override {
|
||||
return lvSubStyles;
|
||||
}
|
||||
const char * SCI_METHOD PropertyNames() {
|
||||
const char *SCI_METHOD PropertyNames() override {
|
||||
return osPython.PropertyNames();
|
||||
}
|
||||
int SCI_METHOD PropertyType(const char *name) {
|
||||
int SCI_METHOD PropertyType(const char *name) override {
|
||||
return osPython.PropertyType(name);
|
||||
}
|
||||
const char * SCI_METHOD DescribeProperty(const char *name) {
|
||||
const char *SCI_METHOD DescribeProperty(const char *name) override {
|
||||
return osPython.DescribeProperty(name);
|
||||
}
|
||||
Sci_Position SCI_METHOD PropertySet(const char *key, const char *val);
|
||||
const char * SCI_METHOD DescribeWordListSets() {
|
||||
Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override;
|
||||
const char *SCI_METHOD DescribeWordListSets() override {
|
||||
return osPython.DescribeWordListSets();
|
||||
}
|
||||
Sci_Position SCI_METHOD WordListSet(int n, const char *wl);
|
||||
void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess);
|
||||
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess);
|
||||
Sci_Position SCI_METHOD WordListSet(int n, const char *wl) override;
|
||||
void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override;
|
||||
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override;
|
||||
|
||||
void * SCI_METHOD PrivateCall(int, void *) {
|
||||
void *SCI_METHOD PrivateCall(int, void *) override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SCI_METHOD LineEndTypesSupported() {
|
||||
int SCI_METHOD LineEndTypesSupported() override {
|
||||
return SC_LINE_END_TYPE_UNICODE;
|
||||
}
|
||||
|
||||
int SCI_METHOD AllocateSubStyles(int styleBase, int numberStyles) {
|
||||
int SCI_METHOD AllocateSubStyles(int styleBase, int numberStyles) override {
|
||||
return subStyles.Allocate(styleBase, numberStyles);
|
||||
}
|
||||
int SCI_METHOD SubStylesStart(int styleBase) {
|
||||
int SCI_METHOD SubStylesStart(int styleBase) override {
|
||||
return subStyles.Start(styleBase);
|
||||
}
|
||||
int SCI_METHOD SubStylesLength(int styleBase) {
|
||||
int SCI_METHOD SubStylesLength(int styleBase) override {
|
||||
return subStyles.Length(styleBase);
|
||||
}
|
||||
int SCI_METHOD StyleFromSubStyle(int subStyle) {
|
||||
int styleBase = subStyles.BaseStyle(subStyle);
|
||||
int SCI_METHOD StyleFromSubStyle(int subStyle) override {
|
||||
const int styleBase = subStyles.BaseStyle(subStyle);
|
||||
return styleBase;
|
||||
}
|
||||
int SCI_METHOD PrimaryStyleFromStyle(int style) {
|
||||
int SCI_METHOD PrimaryStyleFromStyle(int style) override {
|
||||
return style;
|
||||
}
|
||||
void SCI_METHOD FreeSubStyles() {
|
||||
void SCI_METHOD FreeSubStyles() override {
|
||||
subStyles.Free();
|
||||
}
|
||||
void SCI_METHOD SetIdentifiers(int style, const char *identifiers) {
|
||||
void SCI_METHOD SetIdentifiers(int style, const char *identifiers) override {
|
||||
subStyles.SetIdentifiers(style, identifiers);
|
||||
}
|
||||
int SCI_METHOD DistanceToSecondaryStyles() {
|
||||
int SCI_METHOD DistanceToSecondaryStyles() override {
|
||||
return 0;
|
||||
}
|
||||
const char * SCI_METHOD GetSubStyleBases() {
|
||||
const char *SCI_METHOD GetSubStyleBases() override {
|
||||
return styleSubable;
|
||||
}
|
||||
|
||||
|
@ -353,7 +389,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
void ProcessLineEnd(StyleContext &sc, int *fstringStateStack, bool &inContinuedString) const;
|
||||
void ProcessLineEnd(StyleContext &sc, std::vector<SingleFStringExpState> &fstringStateStack, SingleFStringExpState *¤tFStringExp, bool &inContinuedString);
|
||||
};
|
||||
|
||||
Sci_Position SCI_METHOD LexerPython::PropertySet(const char *key, const char *val) {
|
||||
|
@ -385,15 +421,34 @@ Sci_Position SCI_METHOD LexerPython::WordListSet(int n, const char *wl) {
|
|||
return firstModification;
|
||||
}
|
||||
|
||||
void LexerPython::ProcessLineEnd(StyleContext &sc, int *fstringStateStack, bool &inContinuedString) const {
|
||||
// Restore to to outermost string state if in an f-string expression and
|
||||
// let code below decide what to do
|
||||
while (fstringStateStack[0] != 0) {
|
||||
sc.SetState(PopFromStateStack(fstringStateStack, 4));
|
||||
void LexerPython::ProcessLineEnd(StyleContext &sc, std::vector<SingleFStringExpState> &fstringStateStack, SingleFStringExpState *¤tFStringExp, bool &inContinuedString) {
|
||||
long deepestSingleStateIndex = -1;
|
||||
unsigned long i;
|
||||
|
||||
// Find the deepest single quote state because that string will end; no \ continuation in f-string
|
||||
for (i = 0; i < fstringStateStack.size(); i++) {
|
||||
if (IsPySingleQuoteStringState(fstringStateStack[i].state)) {
|
||||
deepestSingleStateIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (deepestSingleStateIndex != -1) {
|
||||
sc.SetState(fstringStateStack[deepestSingleStateIndex].state);
|
||||
while (fstringStateStack.size() > static_cast<unsigned long>(deepestSingleStateIndex)) {
|
||||
PopFromStateStack(fstringStateStack, currentFStringExp);
|
||||
}
|
||||
}
|
||||
if (!fstringStateStack.empty()) {
|
||||
std::pair<int, std::vector<SingleFStringExpState> > val;
|
||||
val.first = sc.currentLine;
|
||||
val.second = fstringStateStack;
|
||||
|
||||
ftripleStateAtEol.insert(val);
|
||||
}
|
||||
|
||||
if ((sc.state == SCE_P_DEFAULT)
|
||||
|| IsPyTripleQuoteStringState(sc.state)) {
|
||||
|| IsPyTripleQuoteStringState(sc.state)) {
|
||||
// Perform colourisation of white space and triple quoted strings at end of each line to allow
|
||||
// tab marking to work inside white space and triple quoted strings
|
||||
sc.SetState(sc.state);
|
||||
|
@ -411,9 +466,11 @@ void LexerPython::ProcessLineEnd(StyleContext &sc, int *fstringStateStack, bool
|
|||
void SCI_METHOD LexerPython::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) {
|
||||
Accessor styler(pAccess, NULL);
|
||||
|
||||
// Track whether in f-string expression; an array is used for a stack to
|
||||
// Track whether in f-string expression; vector is used for a stack to
|
||||
// handle nested f-strings such as f"""{f'''{f"{f'{1}'}"}'''}"""
|
||||
int fstringStateStack[4] = { 0, };
|
||||
std::vector<SingleFStringExpState> fstringStateStack;
|
||||
SingleFStringExpState *currentFStringExp = NULL;
|
||||
|
||||
const Sci_Position endPos = startPos + length;
|
||||
|
||||
// Backtrack to previous line in case need to fix its tab whinging
|
||||
|
@ -424,10 +481,10 @@ void SCI_METHOD LexerPython::Lex(Sci_PositionU startPos, Sci_Position length, in
|
|||
// Look for backslash-continued lines
|
||||
while (lineCurrent > 0) {
|
||||
Sci_Position eolPos = styler.LineStart(lineCurrent) - 1;
|
||||
int eolStyle = styler.StyleAt(eolPos);
|
||||
const int eolStyle = styler.StyleAt(eolPos);
|
||||
if (eolStyle == SCE_P_STRING
|
||||
|| eolStyle == SCE_P_CHARACTER
|
||||
|| eolStyle == SCE_P_STRINGEOL) {
|
||||
|| eolStyle == SCE_P_CHARACTER
|
||||
|| eolStyle == SCE_P_STRINGEOL) {
|
||||
lineCurrent -= 1;
|
||||
} else {
|
||||
break;
|
||||
|
@ -445,6 +502,18 @@ void SCI_METHOD LexerPython::Lex(Sci_PositionU startPos, Sci_Position length, in
|
|||
initStyle = SCE_P_DEFAULT;
|
||||
}
|
||||
|
||||
// Set up fstate stack from last line and remove any subsequent ftriple at eol states
|
||||
std::map<int, std::vector<SingleFStringExpState> >::iterator it;
|
||||
it = ftripleStateAtEol.find(lineCurrent - 1);
|
||||
if (it != ftripleStateAtEol.end() && !it->second.empty()) {
|
||||
fstringStateStack = it->second;
|
||||
currentFStringExp = &fstringStateStack.back();
|
||||
}
|
||||
it = ftripleStateAtEol.lower_bound(lineCurrent);
|
||||
if (it != ftripleStateAtEol.end()) {
|
||||
ftripleStateAtEol.erase(it, ftripleStateAtEol.end());
|
||||
}
|
||||
|
||||
kwType kwLast = kwOther;
|
||||
int spaceFlags = 0;
|
||||
styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
|
||||
|
@ -479,7 +548,7 @@ void SCI_METHOD LexerPython::Lex(Sci_PositionU startPos, Sci_Position length, in
|
|||
}
|
||||
|
||||
if (sc.atLineEnd) {
|
||||
ProcessLineEnd(sc, fstringStateStack, inContinuedString);
|
||||
ProcessLineEnd(sc, fstringStateStack, currentFStringExp, inContinuedString);
|
||||
lineCurrent++;
|
||||
if (!sc.More())
|
||||
break;
|
||||
|
@ -493,7 +562,7 @@ void SCI_METHOD LexerPython::Lex(Sci_PositionU startPos, Sci_Position length, in
|
|||
sc.SetState(SCE_P_DEFAULT);
|
||||
} else if (sc.state == SCE_P_NUMBER) {
|
||||
if (!IsAWordChar(sc.ch, false) &&
|
||||
!(!base_n_number && ((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E')))) {
|
||||
!(!base_n_number && ((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E')))) {
|
||||
sc.SetState(SCE_P_DEFAULT);
|
||||
}
|
||||
} else if (sc.state == SCE_P_IDENTIFIER) {
|
||||
|
@ -583,12 +652,7 @@ void SCI_METHOD LexerPython::Lex(Sci_PositionU startPos, Sci_Position length, in
|
|||
// Don't roll over the newline.
|
||||
sc.Forward();
|
||||
}
|
||||
} else if (((sc.state == SCE_P_STRING || sc.state == SCE_P_FSTRING))
|
||||
&& (sc.ch == '\"')) {
|
||||
sc.ForwardSetState(SCE_P_DEFAULT);
|
||||
needEOLCheck = true;
|
||||
} else if (((sc.state == SCE_P_CHARACTER) || (sc.state == SCE_P_FCHARACTER))
|
||||
&& (sc.ch == '\'')) {
|
||||
} else if (sc.ch == GetPyStringQuoteChar(sc.state)) {
|
||||
sc.ForwardSetState(SCE_P_DEFAULT);
|
||||
needEOLCheck = true;
|
||||
}
|
||||
|
@ -611,18 +675,50 @@ void SCI_METHOD LexerPython::Lex(Sci_PositionU startPos, Sci_Position length, in
|
|||
needEOLCheck = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Note if used and not if else because string states also match
|
||||
// some of the above clauses
|
||||
if (IsPyFStringState(sc.state) && sc.ch == '{') {
|
||||
if (sc.chNext == '{') {
|
||||
sc.Forward();
|
||||
} else {
|
||||
PushStateToStack(sc.state, fstringStateStack, ELEMENTS(fstringStateStack));
|
||||
PushStateToStack(sc.state, fstringStateStack, currentFStringExp);
|
||||
sc.ForwardSetState(SCE_P_DEFAULT);
|
||||
}
|
||||
needEOLCheck = true;
|
||||
}
|
||||
|
||||
// If in an f-string expression, check for the ending quote(s)
|
||||
// and end f-string to handle syntactically incorrect cases like
|
||||
// f'{' and f"""{"""
|
||||
if (!fstringStateStack.empty() && (sc.ch == '\'' || sc.ch == '"')) {
|
||||
long matching_stack_i = -1;
|
||||
for (unsigned long stack_i = 0; stack_i < fstringStateStack.size() && matching_stack_i == -1; stack_i++) {
|
||||
const int stack_state = fstringStateStack[stack_i].state;
|
||||
const char quote = GetPyStringQuoteChar(stack_state);
|
||||
if (sc.ch == quote) {
|
||||
if (IsPySingleQuoteStringState(stack_state)) {
|
||||
matching_stack_i = stack_i;
|
||||
} else if (quote == '"' ? sc.Match("\"\"\"") : sc.Match("'''")) {
|
||||
matching_stack_i = stack_i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (matching_stack_i != -1) {
|
||||
sc.SetState(fstringStateStack[matching_stack_i].state);
|
||||
if (IsPyTripleQuoteStringState(fstringStateStack[matching_stack_i].state)) {
|
||||
sc.Forward();
|
||||
sc.Forward();
|
||||
}
|
||||
sc.ForwardSetState(SCE_P_DEFAULT);
|
||||
needEOLCheck = true;
|
||||
|
||||
while (fstringStateStack.size() > static_cast<unsigned long>(matching_stack_i)) {
|
||||
PopFromStateStack(fstringStateStack, currentFStringExp);
|
||||
}
|
||||
}
|
||||
}
|
||||
// End of code to find the end of a state
|
||||
|
||||
if (!indentGood && !IsASpaceOrTab(sc.ch)) {
|
||||
|
@ -638,16 +734,24 @@ void SCI_METHOD LexerPython::Lex(Sci_PositionU startPos, Sci_Position length, in
|
|||
|
||||
// State exit code may have moved on to end of line
|
||||
if (needEOLCheck && sc.atLineEnd) {
|
||||
ProcessLineEnd(sc, fstringStateStack, inContinuedString);
|
||||
ProcessLineEnd(sc, fstringStateStack, currentFStringExp, inContinuedString);
|
||||
lineCurrent++;
|
||||
styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
|
||||
if (!sc.More())
|
||||
break;
|
||||
}
|
||||
|
||||
// If in f-string expression, check for } to resume f-string state
|
||||
if (fstringStateStack[0] != 0 && sc.ch == '}') {
|
||||
sc.SetState(PopFromStateStack(fstringStateStack, ELEMENTS(fstringStateStack)));
|
||||
// If in f-string expression, check for }, :, ! to resume f-string state or update nesting count
|
||||
if (currentFStringExp != NULL && !IsPySingleQuoteStringState(sc.state) && !IsPyTripleQuoteStringState(sc.state)) {
|
||||
if (currentFStringExp->nestingCount == 0 && (sc.ch == '}' || sc.ch == ':' || (sc.ch == '!' && sc.chNext != '='))) {
|
||||
sc.SetState(PopFromStateStack(fstringStateStack, currentFStringExp));
|
||||
} else {
|
||||
if (sc.ch == '{' || sc.ch == '[' || sc.ch == '(') {
|
||||
currentFStringExp->nestingCount++;
|
||||
} else if (sc.ch == '}' || sc.ch == ']' || sc.ch == ')') {
|
||||
currentFStringExp->nestingCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for a new state starting character
|
||||
|
@ -657,7 +761,7 @@ void SCI_METHOD LexerPython::Lex(Sci_PositionU startPos, Sci_Position length, in
|
|||
base_n_number = true;
|
||||
sc.SetState(SCE_P_NUMBER);
|
||||
} else if (sc.ch == '0' &&
|
||||
(sc.chNext == 'o' || sc.chNext == 'O' || sc.chNext == 'b' || sc.chNext == 'B')) {
|
||||
(sc.chNext == 'o' || sc.chNext == 'O' || sc.chNext == 'b' || sc.chNext == 'B')) {
|
||||
if (options.base2or8Literals) {
|
||||
base_n_number = true;
|
||||
sc.SetState(SCE_P_NUMBER);
|
||||
|
@ -695,9 +799,9 @@ void SCI_METHOD LexerPython::Lex(Sci_PositionU startPos, Sci_Position length, in
|
|||
|
||||
static bool IsCommentLine(Sci_Position line, Accessor &styler) {
|
||||
Sci_Position pos = styler.LineStart(line);
|
||||
Sci_Position eol_pos = styler.LineStart(line + 1) - 1;
|
||||
const Sci_Position eol_pos = styler.LineStart(line + 1) - 1;
|
||||
for (Sci_Position i = pos; i < eol_pos; i++) {
|
||||
char ch = styler[i];
|
||||
const char ch = styler[i];
|
||||
if (ch == '#')
|
||||
return true;
|
||||
else if (ch != ' ' && ch != '\t')
|
||||
|
@ -706,8 +810,8 @@ static bool IsCommentLine(Sci_Position line, Accessor &styler) {
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool IsQuoteLine(Sci_Position line, Accessor &styler) {
|
||||
int style = styler.StyleAt(styler.LineStart(line)) & 31;
|
||||
static bool IsQuoteLine(Sci_Position line, const Accessor &styler) {
|
||||
const int style = styler.StyleAt(styler.LineStart(line)) & 31;
|
||||
return ((style == SCE_P_TRIPLE) || (style == SCE_P_TRIPLEDOUBLE));
|
||||
}
|
||||
|
||||
|
@ -733,8 +837,8 @@ void SCI_METHOD LexerPython::Fold(Sci_PositionU startPos, Sci_Position length, i
|
|||
lineCurrent--;
|
||||
indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL);
|
||||
if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG) &&
|
||||
(!IsCommentLine(lineCurrent, styler)) &&
|
||||
(!IsQuoteLine(lineCurrent, styler)))
|
||||
(!IsCommentLine(lineCurrent, styler)) &&
|
||||
(!IsQuoteLine(lineCurrent, styler)))
|
||||
break;
|
||||
}
|
||||
int indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK;
|
||||
|
@ -760,7 +864,7 @@ void SCI_METHOD LexerPython::Fold(Sci_PositionU startPos, Sci_Position length, i
|
|||
// Information about next line is only available if not at end of document
|
||||
indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
|
||||
Sci_Position lookAtPos = (styler.LineStart(lineNext) == styler.Length()) ? styler.Length() - 1 : styler.LineStart(lineNext);
|
||||
int style = styler.StyleAt(lookAtPos) & 31;
|
||||
const int style = styler.StyleAt(lookAtPos) & 31;
|
||||
quote = options.foldQuotes && ((style == SCE_P_TRIPLE) || (style == SCE_P_TRIPLEDOUBLE));
|
||||
}
|
||||
const int quote_start = (quote && !prevQuote);
|
||||
|
@ -783,19 +887,25 @@ void SCI_METHOD LexerPython::Fold(Sci_PositionU startPos, Sci_Position length, i
|
|||
// Skip past any blank lines for next indent level info; we skip also
|
||||
// comments (all comments, not just those starting in column 0)
|
||||
// which effectively folds them into surrounding code rather
|
||||
// than screwing up folding.
|
||||
// than screwing up folding. If comments end file, use the min
|
||||
// comment indent as the level after
|
||||
|
||||
int minCommentLevel = indentCurrentLevel;
|
||||
while (!quote &&
|
||||
(lineNext < docLines) &&
|
||||
((indentNext & SC_FOLDLEVELWHITEFLAG) ||
|
||||
(lineNext <= docLines && IsCommentLine(lineNext, styler)))) {
|
||||
(lineNext < docLines) &&
|
||||
((indentNext & SC_FOLDLEVELWHITEFLAG) ||
|
||||
(lineNext <= docLines && IsCommentLine(lineNext, styler)))) {
|
||||
|
||||
if (IsCommentLine(lineNext, styler) && indentNext < minCommentLevel) {
|
||||
minCommentLevel = indentNext;
|
||||
}
|
||||
|
||||
lineNext++;
|
||||
indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
|
||||
}
|
||||
|
||||
const int levelAfterComments = indentNext & SC_FOLDLEVELNUMBERMASK;
|
||||
const int levelBeforeComments = Maximum(indentCurrentLevel,levelAfterComments);
|
||||
const int levelAfterComments = ((lineNext < docLines) ? indentNext & SC_FOLDLEVELNUMBERMASK : minCommentLevel);
|
||||
const int levelBeforeComments = Maximum(indentCurrentLevel, levelAfterComments);
|
||||
|
||||
// Now set all the indent levels on the lines we skipped
|
||||
// Do this from end to start. Once we encounter one line
|
||||
|
@ -806,7 +916,7 @@ void SCI_METHOD LexerPython::Fold(Sci_PositionU startPos, Sci_Position length, i
|
|||
int skipLevel = levelAfterComments;
|
||||
|
||||
while (--skipLine > lineCurrent) {
|
||||
int skipLineIndent = styler.IndentAmount(skipLine, &spaceFlags, NULL);
|
||||
const int skipLineIndent = styler.IndentAmount(skipLine, &spaceFlags, NULL);
|
||||
|
||||
if (options.foldCompact) {
|
||||
if ((skipLineIndent & SC_FOLDLEVELNUMBERMASK) > levelAfterComments)
|
||||
|
@ -817,8 +927,8 @@ void SCI_METHOD LexerPython::Fold(Sci_PositionU startPos, Sci_Position length, i
|
|||
styler.SetLevel(skipLine, skipLevel | whiteFlag);
|
||||
} else {
|
||||
if ((skipLineIndent & SC_FOLDLEVELNUMBERMASK) > levelAfterComments &&
|
||||
!(skipLineIndent & SC_FOLDLEVELWHITEFLAG) &&
|
||||
!IsCommentLine(skipLine, styler))
|
||||
!(skipLineIndent & SC_FOLDLEVELWHITEFLAG) &&
|
||||
!IsCommentLine(skipLine, styler))
|
||||
skipLevel = levelBeforeComments;
|
||||
|
||||
styler.SetLevel(skipLine, skipLevel);
|
||||
|
@ -846,4 +956,4 @@ void SCI_METHOD LexerPython::Fold(Sci_PositionU startPos, Sci_Position length, i
|
|||
}
|
||||
|
||||
LexerModule lmPython(SCLEX_PYTHON, LexerPython::LexerFactoryPython, "python",
|
||||
pythonWordListDesc);
|
||||
pythonWordListDesc);
|
||||
|
|
|
@ -123,29 +123,29 @@ class LexerRust : public ILexer {
|
|||
public:
|
||||
virtual ~LexerRust() {
|
||||
}
|
||||
void SCI_METHOD Release() {
|
||||
void SCI_METHOD Release() override {
|
||||
delete this;
|
||||
}
|
||||
int SCI_METHOD Version() const {
|
||||
int SCI_METHOD Version() const override {
|
||||
return lvOriginal;
|
||||
}
|
||||
const char * SCI_METHOD PropertyNames() {
|
||||
const char * SCI_METHOD PropertyNames() override {
|
||||
return osRust.PropertyNames();
|
||||
}
|
||||
int SCI_METHOD PropertyType(const char *name) {
|
||||
int SCI_METHOD PropertyType(const char *name) override {
|
||||
return osRust.PropertyType(name);
|
||||
}
|
||||
const char * SCI_METHOD DescribeProperty(const char *name) {
|
||||
const char * SCI_METHOD DescribeProperty(const char *name) override {
|
||||
return osRust.DescribeProperty(name);
|
||||
}
|
||||
Sci_Position SCI_METHOD PropertySet(const char *key, const char *val);
|
||||
const char * SCI_METHOD DescribeWordListSets() {
|
||||
Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override;
|
||||
const char * SCI_METHOD DescribeWordListSets() override {
|
||||
return osRust.DescribeWordListSets();
|
||||
}
|
||||
Sci_Position SCI_METHOD WordListSet(int n, const char *wl);
|
||||
void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess);
|
||||
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess);
|
||||
void * SCI_METHOD PrivateCall(int, void *) {
|
||||
Sci_Position SCI_METHOD WordListSet(int n, const char *wl) override;
|
||||
void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override;
|
||||
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override;
|
||||
void * SCI_METHOD PrivateCall(int, void *) override {
|
||||
return 0;
|
||||
}
|
||||
static ILexer *LexerFactoryRust() {
|
||||
|
|
|
@ -308,42 +308,42 @@ public :
|
|||
|
||||
virtual ~LexerSQL() {}
|
||||
|
||||
int SCI_METHOD Version () const {
|
||||
int SCI_METHOD Version () const override {
|
||||
return lvOriginal;
|
||||
}
|
||||
|
||||
void SCI_METHOD Release() {
|
||||
void SCI_METHOD Release() override {
|
||||
delete this;
|
||||
}
|
||||
|
||||
const char * SCI_METHOD PropertyNames() {
|
||||
const char * SCI_METHOD PropertyNames() override {
|
||||
return osSQL.PropertyNames();
|
||||
}
|
||||
|
||||
int SCI_METHOD PropertyType(const char *name) {
|
||||
int SCI_METHOD PropertyType(const char *name) override {
|
||||
return osSQL.PropertyType(name);
|
||||
}
|
||||
|
||||
const char * SCI_METHOD DescribeProperty(const char *name) {
|
||||
const char * SCI_METHOD DescribeProperty(const char *name) override {
|
||||
return osSQL.DescribeProperty(name);
|
||||
}
|
||||
|
||||
Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) {
|
||||
Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override {
|
||||
if (osSQL.PropertySet(&options, key, val)) {
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char * SCI_METHOD DescribeWordListSets() {
|
||||
const char * SCI_METHOD DescribeWordListSets() override {
|
||||
return osSQL.DescribeWordListSets();
|
||||
}
|
||||
|
||||
Sci_Position SCI_METHOD WordListSet(int n, const char *wl);
|
||||
void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess);
|
||||
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess);
|
||||
Sci_Position SCI_METHOD WordListSet(int n, const char *wl) override;
|
||||
void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) override;
|
||||
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) override;
|
||||
|
||||
void * SCI_METHOD PrivateCall(int, void *) {
|
||||
void * SCI_METHOD PrivateCall(int, void *) override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -398,15 +398,17 @@ static void FoldNoBoxVHDLDoc(
|
|||
strcmp(s, "entity") == 0 ||
|
||||
strcmp(s, "configuration") == 0 )
|
||||
{
|
||||
if (strcmp(prevWord, "end") != 0 && lastStart)
|
||||
if (strcmp(prevWord, "end") != 0)
|
||||
{ // check for instantiated unit by backward searching for the colon.
|
||||
Sci_PositionU pos = lastStart;
|
||||
char chAtPos, styleAtPos;
|
||||
char chAtPos=0, styleAtPos;
|
||||
do{// skip white spaces
|
||||
if(!pos)
|
||||
break;
|
||||
pos--;
|
||||
styleAtPos = styler.StyleAt(pos);
|
||||
chAtPos = styler.SafeGetCharAt(pos);
|
||||
}while(pos>0 &&
|
||||
}while(pos &&
|
||||
(chAtPos == ' ' || chAtPos == '\t' ||
|
||||
chAtPos == '\n' || chAtPos == '\r' ||
|
||||
IsCommentStyle(styleAtPos)));
|
||||
|
|
|
@ -217,63 +217,63 @@ public:
|
|||
subStyles(styleSubable, 0x80, 0x40, activeFlag) {
|
||||
}
|
||||
virtual ~LexerVerilog() {}
|
||||
int SCI_METHOD Version() const {
|
||||
int SCI_METHOD Version() const override {
|
||||
return lvSubStyles;
|
||||
}
|
||||
void SCI_METHOD Release() {
|
||||
void SCI_METHOD Release() override {
|
||||
delete this;
|
||||
}
|
||||
const char* SCI_METHOD PropertyNames() {
|
||||
const char* SCI_METHOD PropertyNames() override {
|
||||
return osVerilog.PropertyNames();
|
||||
}
|
||||
int SCI_METHOD PropertyType(const char* name) {
|
||||
int SCI_METHOD PropertyType(const char* name) override {
|
||||
return osVerilog.PropertyType(name);
|
||||
}
|
||||
const char* SCI_METHOD DescribeProperty(const char* name) {
|
||||
const char* SCI_METHOD DescribeProperty(const char* name) override {
|
||||
return osVerilog.DescribeProperty(name);
|
||||
}
|
||||
Sci_Position SCI_METHOD PropertySet(const char* key, const char* val) {
|
||||
Sci_Position SCI_METHOD PropertySet(const char* key, const char* val) override {
|
||||
return osVerilog.PropertySet(&options, key, val);
|
||||
}
|
||||
const char* SCI_METHOD DescribeWordListSets() {
|
||||
const char* SCI_METHOD DescribeWordListSets() override {
|
||||
return osVerilog.DescribeWordListSets();
|
||||
}
|
||||
Sci_Position SCI_METHOD WordListSet(int n, const char* wl);
|
||||
void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess);
|
||||
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess);
|
||||
void* SCI_METHOD PrivateCall(int, void*) {
|
||||
Sci_Position SCI_METHOD WordListSet(int n, const char* wl) override;
|
||||
void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override;
|
||||
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) override;
|
||||
void* SCI_METHOD PrivateCall(int, void*) override {
|
||||
return 0;
|
||||
}
|
||||
int SCI_METHOD LineEndTypesSupported() {
|
||||
int SCI_METHOD LineEndTypesSupported() override {
|
||||
return SC_LINE_END_TYPE_UNICODE;
|
||||
}
|
||||
int SCI_METHOD AllocateSubStyles(int styleBase, int numberStyles) {
|
||||
int SCI_METHOD AllocateSubStyles(int styleBase, int numberStyles) override {
|
||||
return subStyles.Allocate(styleBase, numberStyles);
|
||||
}
|
||||
int SCI_METHOD SubStylesStart(int styleBase) {
|
||||
int SCI_METHOD SubStylesStart(int styleBase) override {
|
||||
return subStyles.Start(styleBase);
|
||||
}
|
||||
int SCI_METHOD SubStylesLength(int styleBase) {
|
||||
int SCI_METHOD SubStylesLength(int styleBase) override {
|
||||
return subStyles.Length(styleBase);
|
||||
}
|
||||
int SCI_METHOD StyleFromSubStyle(int subStyle) {
|
||||
int SCI_METHOD StyleFromSubStyle(int subStyle) override {
|
||||
int styleBase = subStyles.BaseStyle(MaskActive(subStyle));
|
||||
int active = subStyle & activeFlag;
|
||||
return styleBase | active;
|
||||
}
|
||||
int SCI_METHOD PrimaryStyleFromStyle(int style) {
|
||||
int SCI_METHOD PrimaryStyleFromStyle(int style) override {
|
||||
return MaskActive(style);
|
||||
}
|
||||
void SCI_METHOD FreeSubStyles() {
|
||||
void SCI_METHOD FreeSubStyles() override {
|
||||
subStyles.Free();
|
||||
}
|
||||
void SCI_METHOD SetIdentifiers(int style, const char *identifiers) {
|
||||
void SCI_METHOD SetIdentifiers(int style, const char *identifiers) override {
|
||||
subStyles.SetIdentifiers(style, identifiers);
|
||||
}
|
||||
int SCI_METHOD DistanceToSecondaryStyles() {
|
||||
int SCI_METHOD DistanceToSecondaryStyles() override {
|
||||
return activeFlag;
|
||||
}
|
||||
const char * SCI_METHOD GetSubStyleBases() {
|
||||
const char * SCI_METHOD GetSubStyleBases() override {
|
||||
return styleSubable;
|
||||
}
|
||||
static ILexer* LexerFactoryVerilog() {
|
||||
|
|
|
@ -98,7 +98,7 @@ static void ColouriseYAMLLine(
|
|||
}
|
||||
}
|
||||
styler.SetLineState(currentLine, 0);
|
||||
if (strncmp(lineBuffer, "---", 3) == 0) { // Document marker
|
||||
if (strncmp(lineBuffer, "---", 3) == 0 || strncmp(lineBuffer, "...", 3) == 0) { // Document marker
|
||||
styler.SetLineState(currentLine, YAML_STATE_DOCUMENT);
|
||||
styler.ColourTo(endPos, SCE_YAML_DOCUMENT);
|
||||
return;
|
||||
|
@ -119,6 +119,10 @@ static void ColouriseYAMLLine(
|
|||
while (i < lengthLine) {
|
||||
if (lineBuffer[i] == '\'' || lineBuffer[i] == '\"') {
|
||||
bInQuotes = !bInQuotes;
|
||||
} else if (lineBuffer[i] == '#' && isspacechar(lineBuffer[i - 1]) && !bInQuotes) {
|
||||
styler.ColourTo(startLine + i - 1, SCE_YAML_DEFAULT);
|
||||
styler.ColourTo(endPos, SCE_YAML_COMMENT);
|
||||
return;
|
||||
} else if (lineBuffer[i] == ':' && !bInQuotes) {
|
||||
styler.ColourTo(startLine + i - 1, SCE_YAML_IDENTIFIER);
|
||||
styler.ColourTo(startLine + i, SCE_YAML_OPERATOR);
|
||||
|
|
|
@ -5,12 +5,8 @@
|
|||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
#include "ILexer.h"
|
||||
#include "Scintilla.h"
|
||||
|
@ -33,7 +29,7 @@ int Accessor::GetPropertyInt(const char *key, int defaultValue) const {
|
|||
}
|
||||
|
||||
int Accessor::IndentAmount(Sci_Position line, int *flags, PFNIsCommentLeader pfnIsCommentLeader) {
|
||||
Sci_Position end = Length();
|
||||
const Sci_Position end = Length();
|
||||
int spaceFlags = 0;
|
||||
|
||||
// Determines the indentation level of the current line and also checks for consistent
|
||||
|
@ -48,7 +44,7 @@ int Accessor::IndentAmount(Sci_Position line, int *flags, PFNIsCommentLeader pfn
|
|||
Sci_Position posPrev = inPrevPrefix ? LineStart(line-1) : 0;
|
||||
while ((ch == ' ' || ch == '\t') && (pos < end)) {
|
||||
if (inPrevPrefix) {
|
||||
char chPrev = (*this)[posPrev++];
|
||||
const char chPrev = (*this)[posPrev++];
|
||||
if (chPrev == ' ' || chPrev == '\t') {
|
||||
if (chPrev != ch)
|
||||
spaceFlags |= wsInconsistent;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -24,6 +24,12 @@ enum CharacterCategory {
|
|||
|
||||
CharacterCategory CategoriseCharacter(int character);
|
||||
|
||||
// Common definitions of allowable characters in identifiers from UAX #31.
|
||||
bool IsIdStart(int character);
|
||||
bool IsIdContinue(int character);
|
||||
bool IsXidStart(int character);
|
||||
bool IsXidContinue(int character);
|
||||
|
||||
#ifdef SCI_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -6,11 +6,8 @@
|
|||
// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
#include "CharacterSet.h"
|
||||
|
||||
|
@ -25,8 +22,8 @@ namespace Scintilla {
|
|||
int CompareCaseInsensitive(const char *a, const char *b) {
|
||||
while (*a && *b) {
|
||||
if (*a != *b) {
|
||||
char upperA = static_cast<char>(MakeUpperCase(*a));
|
||||
char upperB = static_cast<char>(MakeUpperCase(*b));
|
||||
const char upperA = static_cast<char>(MakeUpperCase(*a));
|
||||
const char upperB = static_cast<char>(MakeUpperCase(*b));
|
||||
if (upperA != upperB)
|
||||
return upperA - upperB;
|
||||
}
|
||||
|
@ -40,8 +37,8 @@ int CompareCaseInsensitive(const char *a, const char *b) {
|
|||
int CompareNCaseInsensitive(const char *a, const char *b, size_t len) {
|
||||
while (*a && *b && len) {
|
||||
if (*a != *b) {
|
||||
char upperA = static_cast<char>(MakeUpperCase(*a));
|
||||
char upperB = static_cast<char>(MakeUpperCase(*b));
|
||||
const char upperA = static_cast<char>(MakeUpperCase(*a));
|
||||
const char upperB = static_cast<char>(MakeUpperCase(*b));
|
||||
if (upperA != upperB)
|
||||
return upperA - upperB;
|
||||
}
|
||||
|
|
|
@ -48,6 +48,17 @@ public:
|
|||
bset[i] = other.bset[i];
|
||||
}
|
||||
}
|
||||
CharacterSet &operator=(CharacterSet &&other) {
|
||||
if (this != &other) {
|
||||
delete []bset;
|
||||
size = other.size;
|
||||
valueAfter = other.valueAfter;
|
||||
bset = other.bset;
|
||||
other.size = 0;
|
||||
other.bset = nullptr;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
~CharacterSet() {
|
||||
delete []bset;
|
||||
bset = 0;
|
||||
|
|
|
@ -125,7 +125,7 @@ public:
|
|||
} else {
|
||||
// Old interface means only '\r', '\n' and '\r\n' line ends.
|
||||
Sci_Position startNext = pAccess->LineStart(line+1);
|
||||
char chLineEnd = SafeGetCharAt(startNext-1);
|
||||
const char chLineEnd = SafeGetCharAt(startNext-1);
|
||||
if (chLineEnd == '\n' && (SafeGetCharAt(startNext-2) == '\r'))
|
||||
return startNext - 2;
|
||||
else
|
||||
|
|
|
@ -5,12 +5,9 @@
|
|||
// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
#include "ILexer.h"
|
||||
#include "Scintilla.h"
|
||||
|
|
|
@ -5,12 +5,8 @@
|
|||
// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
|
|
@ -53,9 +53,9 @@ public:
|
|||
|
||||
ILexer *Create() const;
|
||||
|
||||
virtual void Lex(Sci_PositionU startPos, Sci_Position length, int initStyle,
|
||||
virtual void Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler) const;
|
||||
virtual void Fold(Sci_PositionU startPos, Sci_Position length, int initStyle,
|
||||
virtual void Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle,
|
||||
WordList *keywordlists[], Accessor &styler) const;
|
||||
|
||||
friend class Catalogue;
|
||||
|
|
|
@ -5,12 +5,8 @@
|
|||
// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
#include "ILexer.h"
|
||||
#include "Scintilla.h"
|
||||
|
@ -46,20 +42,20 @@ Sci_Position SCI_METHOD LexerNoExceptions::WordListSet(int n, const char *wl) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
void SCI_METHOD LexerNoExceptions::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) {
|
||||
void SCI_METHOD LexerNoExceptions::Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) {
|
||||
try {
|
||||
Accessor astyler(pAccess, &props);
|
||||
Lexer(startPos, length, initStyle, pAccess, astyler);
|
||||
Lexer(startPos, lengthDoc, initStyle, pAccess, astyler);
|
||||
astyler.Flush();
|
||||
} catch (...) {
|
||||
// Should not throw into caller as may be compiled with different compiler or options
|
||||
pAccess->SetErrorStatus(SC_STATUS_FAILURE);
|
||||
}
|
||||
}
|
||||
void SCI_METHOD LexerNoExceptions::Fold(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) {
|
||||
void SCI_METHOD LexerNoExceptions::Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) {
|
||||
try {
|
||||
Accessor astyler(pAccess, &props);
|
||||
Folder(startPos, length, initStyle, pAccess, astyler);
|
||||
Folder(startPos, lengthDoc, initStyle, pAccess, astyler);
|
||||
astyler.Flush();
|
||||
} catch (...) {
|
||||
// Should not throw into caller as may be compiled with different compiler or options
|
||||
|
|
|
@ -5,12 +5,8 @@
|
|||
// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
|
|
@ -7,9 +7,8 @@
|
|||
|
||||
// Maintain a dictionary of properties
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
|
|
@ -5,11 +5,9 @@
|
|||
// Copyright 1998-2004 by Neil Hodgson <neilh@scintilla.org>
|
||||
// This file is in the public domain.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
|
||||
#include "ILexer.h"
|
||||
|
||||
|
|
|
@ -27,8 +27,6 @@ class StyleContext {
|
|||
Sci_PositionU currentPosLastRelative;
|
||||
Sci_Position offsetRelative;
|
||||
|
||||
StyleContext &operator=(const StyleContext &);
|
||||
|
||||
void GetNextChar() {
|
||||
if (multiByteAccess) {
|
||||
chNext = multiByteAccess->GetCharacterAndWidth(currentPos+width, &widthNext);
|
||||
|
@ -97,6 +95,9 @@ public:
|
|||
|
||||
GetNextChar();
|
||||
}
|
||||
// Deleted so StyleContext objects can not be copied.
|
||||
StyleContext(const StyleContext &) = delete;
|
||||
StyleContext &operator=(const StyleContext &) = delete;
|
||||
void Complete() {
|
||||
styler.ColourTo(currentPos - ((currentPos > lengthDocument) ? 2 : 1), state);
|
||||
styler.Flush();
|
||||
|
@ -130,7 +131,7 @@ public:
|
|||
}
|
||||
}
|
||||
void ForwardBytes(Sci_Position nb) {
|
||||
Sci_PositionU forwardPos = currentPos + nb;
|
||||
const Sci_PositionU forwardPos = currentPos + nb;
|
||||
while (forwardPos > currentPos) {
|
||||
Forward();
|
||||
}
|
||||
|
@ -165,7 +166,7 @@ public:
|
|||
}
|
||||
Sci_Position diffRelative = n - offsetRelative;
|
||||
Sci_Position posNew = multiByteAccess->GetRelativePosition(posRelative, diffRelative);
|
||||
int chReturn = multiByteAccess->GetCharacterAndWidth(posNew, 0);
|
||||
const int chReturn = multiByteAccess->GetCharacterAndWidth(posNew, 0);
|
||||
posRelative = posNew;
|
||||
currentPosLastRelative = currentPos;
|
||||
offsetRelative = n;
|
||||
|
|
|
@ -5,11 +5,9 @@
|
|||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <ctype.h>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -37,7 +35,7 @@ static char **ArrayFromWordList(char *wordlist, int *len, bool onlyLineEnds = fa
|
|||
wordSeparator[static_cast<unsigned int>('\t')] = true;
|
||||
}
|
||||
for (int j = 0; wordlist[j]; j++) {
|
||||
int curr = static_cast<unsigned char>(wordlist[j]);
|
||||
const int curr = static_cast<unsigned char>(wordlist[j]);
|
||||
if (!wordSeparator[curr] && wordSeparator[prev])
|
||||
words++;
|
||||
prev = curr;
|
||||
|
@ -59,6 +57,7 @@ static char **ArrayFromWordList(char *wordlist, int *len, bool onlyLineEnds = fa
|
|||
prev = wordlist[k];
|
||||
}
|
||||
}
|
||||
assert(wordsStore < (words + 1));
|
||||
keywords[wordsStore] = &wordlist[slen];
|
||||
*len = wordsStore;
|
||||
return keywords;
|
||||
|
@ -146,7 +145,7 @@ void WordList::Set(const char *s) {
|
|||
bool WordList::InList(const char *s) const {
|
||||
if (0 == words)
|
||||
return false;
|
||||
unsigned char firstChar = s[0];
|
||||
const unsigned char firstChar = s[0];
|
||||
int j = starts[firstChar];
|
||||
if (j >= 0) {
|
||||
while (static_cast<unsigned char>(words[j][0]) == firstChar) {
|
||||
|
@ -188,7 +187,7 @@ bool WordList::InList(const char *s) const {
|
|||
bool WordList::InListAbbreviated(const char *s, const char marker) const {
|
||||
if (0 == words)
|
||||
return false;
|
||||
unsigned char firstChar = s[0];
|
||||
const unsigned char firstChar = s[0];
|
||||
int j = starts[firstChar];
|
||||
if (j >= 0) {
|
||||
while (static_cast<unsigned char>(words[j][0]) == firstChar) {
|
||||
|
@ -242,7 +241,7 @@ bool WordList::InListAbbreviated(const char *s, const char marker) const {
|
|||
bool WordList::InListAbridged(const char *s, const char marker) const {
|
||||
if (0 == words)
|
||||
return false;
|
||||
unsigned char firstChar = s[0];
|
||||
const unsigned char firstChar = s[0];
|
||||
int j = starts[firstChar];
|
||||
if (j >= 0) {
|
||||
while (static_cast<unsigned char>(words[j][0]) == firstChar) {
|
||||
|
|
|
@ -62,7 +62,7 @@ diff --git scintilla/src/Catalogue.cxx scintilla/src/Catalogue.cxx
|
|||
index ed47aa8..e58f1ab 100644
|
||||
--- scintilla/src/Catalogue.cxx
|
||||
+++ scintilla/src/Catalogue.cxx
|
||||
@@ -77,122 +77,50 @@ int Scintilla_LinkLexers() {
|
||||
@@ -77,123 +77,50 @@ int Scintilla_LinkLexers() {
|
||||
|
||||
//++Autogenerated -- run scripts/LexGen.py to regenerate
|
||||
//**\(\tLINK_LEXER(\*);\n\)
|
||||
|
@ -115,6 +115,7 @@ index ed47aa8..e58f1ab 100644
|
|||
LINK_LEXER(lmHaskell);
|
||||
LINK_LEXER(lmHTML);
|
||||
- LINK_LEXER(lmIHex);
|
||||
- LINK_LEXER(lmIndent);
|
||||
- LINK_LEXER(lmInno);
|
||||
- LINK_LEXER(lmJSON);
|
||||
- LINK_LEXER(lmKix);
|
||||
|
|
|
@ -5,15 +5,16 @@
|
|||
// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
|
@ -32,7 +33,6 @@ AutoComplete::AutoComplete() :
|
|||
typesep('?'),
|
||||
ignoreCase(false),
|
||||
chooseSingle(false),
|
||||
lb(0),
|
||||
posStart(0),
|
||||
startLen(0),
|
||||
cancelAtStartPos(true),
|
||||
|
@ -42,14 +42,12 @@ AutoComplete::AutoComplete() :
|
|||
widthLBDefault(100),
|
||||
heightLBDefault(100),
|
||||
autoSort(SC_ORDER_PRESORTED) {
|
||||
lb = ListBox::Allocate();
|
||||
lb.reset(ListBox::Allocate());
|
||||
}
|
||||
|
||||
AutoComplete::~AutoComplete() {
|
||||
if (lb) {
|
||||
lb->Destroy();
|
||||
delete lb;
|
||||
lb = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +56,7 @@ bool AutoComplete::Active() const {
|
|||
}
|
||||
|
||||
void AutoComplete::Start(Window &parent, int ctrlID,
|
||||
int position, Point location, int startLen_,
|
||||
Sci::Position position, Point location, int startLen_,
|
||||
int lineHeight, bool unicodeMode, int technology) {
|
||||
if (active) {
|
||||
Cancel();
|
||||
|
@ -131,9 +129,9 @@ struct Sorter {
|
|||
}
|
||||
|
||||
bool operator()(int a, int b) {
|
||||
int lenA = indices[a * 2 + 1] - indices[a * 2];
|
||||
int lenB = indices[b * 2 + 1] - indices[b * 2];
|
||||
int len = std::min(lenA, lenB);
|
||||
const int lenA = indices[a * 2 + 1] - indices[a * 2];
|
||||
const int lenB = indices[b * 2 + 1] - indices[b * 2];
|
||||
const int len = std::min(lenA, lenB);
|
||||
int cmp;
|
||||
if (ac->ignoreCase)
|
||||
cmp = CompareNCaseInsensitive(list + indices[a * 2], list + indices[b * 2], len);
|
||||
|
@ -156,7 +154,7 @@ void AutoComplete::SetList(const char *list) {
|
|||
|
||||
Sorter IndexSort(this, list);
|
||||
sortMatrix.clear();
|
||||
for (int i = 0; i < (int)IndexSort.indices.size() / 2; ++i)
|
||||
for (int i = 0; i < static_cast<int>(IndexSort.indices.size()) / 2; ++i)
|
||||
sortMatrix.push_back(i);
|
||||
std::sort(sortMatrix.begin(), sortMatrix.end(), IndexSort);
|
||||
if (autoSort == SC_ORDER_CUSTOM || sortMatrix.size() < 2) {
|
||||
|
@ -186,7 +184,7 @@ void AutoComplete::SetList(const char *list) {
|
|||
item[wordLen] = '\0';
|
||||
sortedList += item;
|
||||
}
|
||||
for (int i = 0; i < (int)sortMatrix.size(); ++i)
|
||||
for (int i = 0; i < static_cast<int>(sortMatrix.size()); ++i)
|
||||
sortMatrix[i] = i;
|
||||
lb->SetList(sortedList.c_str(), separator, typesep);
|
||||
}
|
||||
|
@ -217,7 +215,7 @@ void AutoComplete::Cancel() {
|
|||
|
||||
|
||||
void AutoComplete::Move(int delta) {
|
||||
int count = lb->Length();
|
||||
const int count = lb->Length();
|
||||
int current = lb->GetSelection();
|
||||
current += delta;
|
||||
if (current >= count)
|
||||
|
|
|
@ -27,8 +27,8 @@ public:
|
|||
|
||||
bool ignoreCase;
|
||||
bool chooseSingle;
|
||||
ListBox *lb;
|
||||
int posStart;
|
||||
std::unique_ptr<ListBox> lb;
|
||||
Sci::Position posStart;
|
||||
int startLen;
|
||||
/// Should autocompletion be canceled if editor's currentPos <= startPos?
|
||||
bool cancelAtStartPos;
|
||||
|
@ -50,7 +50,7 @@ public:
|
|||
bool Active() const;
|
||||
|
||||
/// Display the auto completion list positioned to be near a character position
|
||||
void Start(Window &parent, int ctrlID, int position, Point location,
|
||||
void Start(Window &parent, int ctrlID, Sci::Position position, Point location,
|
||||
int startLen_, int lineHeight, bool unicodeMode, int technology);
|
||||
|
||||
/// The stop chars are characters which, when typed, cause the auto completion list to disappear
|
||||
|
|
|
@ -5,12 +5,14 @@
|
|||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
|
@ -89,7 +91,7 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
|
|||
int posStart, int posEnd, int ytext, PRectangle rcClient,
|
||||
bool highlight, bool draw) {
|
||||
s += posStart;
|
||||
int len = posEnd - posStart;
|
||||
const int len = posEnd - posStart;
|
||||
|
||||
// Divide the text into sections that are all text, or that are
|
||||
// single arrows or single tab characters (if tabSize > 0).
|
||||
|
@ -112,7 +114,7 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
|
|||
if (endSeg > startSeg) {
|
||||
if (IsArrowCharacter(s[startSeg])) {
|
||||
xEnd = x + widthArrow;
|
||||
bool upArrow = s[startSeg] == '\001';
|
||||
const bool upArrow = s[startSeg] == '\001';
|
||||
rcClient.left = static_cast<XYPOSITION>(x);
|
||||
rcClient.right = static_cast<XYPOSITION>(xEnd);
|
||||
if (draw) {
|
||||
|
@ -188,14 +190,14 @@ int CallTip::PaintContents(Surface *surfaceWindow, bool draw) {
|
|||
chunkEnd = chunkVal + strlen(chunkVal);
|
||||
moreChunks = false;
|
||||
}
|
||||
int chunkOffset = static_cast<int>(chunkVal - val.c_str());
|
||||
int chunkLength = static_cast<int>(chunkEnd - chunkVal);
|
||||
int chunkEndOffset = chunkOffset + chunkLength;
|
||||
int thisStartHighlight = Platform::Maximum(startHighlight, chunkOffset);
|
||||
thisStartHighlight = Platform::Minimum(thisStartHighlight, chunkEndOffset);
|
||||
const int chunkOffset = static_cast<int>(chunkVal - val.c_str());
|
||||
const int chunkLength = static_cast<int>(chunkEnd - chunkVal);
|
||||
const int chunkEndOffset = chunkOffset + chunkLength;
|
||||
int thisStartHighlight = std::max(startHighlight, chunkOffset);
|
||||
thisStartHighlight = std::min(thisStartHighlight, chunkEndOffset);
|
||||
thisStartHighlight -= chunkOffset;
|
||||
int thisEndHighlight = Platform::Maximum(endHighlight, chunkOffset);
|
||||
thisEndHighlight = Platform::Minimum(thisEndHighlight, chunkEndOffset);
|
||||
int thisEndHighlight = std::max(endHighlight, chunkOffset);
|
||||
thisEndHighlight = std::min(thisEndHighlight, chunkEndOffset);
|
||||
thisEndHighlight -= chunkOffset;
|
||||
rcClient.top = static_cast<XYPOSITION>(ytext - ascent - 1);
|
||||
|
||||
|
@ -211,7 +213,7 @@ int CallTip::PaintContents(Surface *surfaceWindow, bool draw) {
|
|||
chunkVal = chunkEnd + 1;
|
||||
ytext += lineHeight;
|
||||
rcClient.bottom += lineHeight;
|
||||
maxWidth = Platform::Maximum(maxWidth, x);
|
||||
maxWidth = std::max(maxWidth, x);
|
||||
}
|
||||
return maxWidth;
|
||||
}
|
||||
|
@ -250,16 +252,14 @@ void CallTip::MouseClick(Point pt) {
|
|||
clickPlace = 2;
|
||||
}
|
||||
|
||||
PRectangle CallTip::CallTipStart(int pos, Point pt, int textHeight, const char *defn,
|
||||
PRectangle CallTip::CallTipStart(Sci::Position pos, Point pt, int textHeight, const char *defn,
|
||||
const char *faceName, int size,
|
||||
int codePage_, int characterSet,
|
||||
int technology, Window &wParent) {
|
||||
clickPlace = 0;
|
||||
val = defn;
|
||||
codePage = codePage_;
|
||||
Surface *surfaceMeasure = Surface::Allocate(technology);
|
||||
if (!surfaceMeasure)
|
||||
return PRectangle();
|
||||
std::unique_ptr<Surface> surfaceMeasure(Surface::Allocate(technology));
|
||||
surfaceMeasure->Init(wParent.GetID());
|
||||
surfaceMeasure->SetUnicodeMode(SC_CP_UTF8 == codePage);
|
||||
surfaceMeasure->SetDBCSMode(codePage);
|
||||
|
@ -278,7 +278,7 @@ PRectangle CallTip::CallTipStart(int pos, Point pt, int textHeight, const char *
|
|||
rectUp = PRectangle(0,0,0,0);
|
||||
rectDown = PRectangle(0,0,0,0);
|
||||
offsetMain = insetX; // changed to right edge of any arrows
|
||||
int width = PaintContents(surfaceMeasure, false) + insetX;
|
||||
const int width = PaintContents(surfaceMeasure.get(), false) + insetX;
|
||||
while ((newline = strchr(look, '\n')) != NULL) {
|
||||
look = newline + 1;
|
||||
numLines++;
|
||||
|
@ -289,7 +289,6 @@ PRectangle CallTip::CallTipStart(int pos, Point pt, int textHeight, const char *
|
|||
// rectangle is aligned to the right edge of the last arrow encountered in
|
||||
// the tip text, else to the tip text left edge.
|
||||
int height = lineHeight * numLines - static_cast<int>(surfaceMeasure->InternalLeading(font)) + borderHeight * 2;
|
||||
delete surfaceMeasure;
|
||||
if (above) {
|
||||
return PRectangle(pt.x - offsetMain, pt.y - verticalOffset - height, pt.x + width - offsetMain, pt.y - verticalOffset);
|
||||
} else {
|
||||
|
|
|
@ -27,21 +27,18 @@ class CallTip {
|
|||
bool useStyleCallTip; // if true, STYLE_CALLTIP should be used
|
||||
bool above; // if true, display calltip above text
|
||||
|
||||
// Private so CallTip objects can not be copied
|
||||
CallTip(const CallTip &);
|
||||
CallTip &operator=(const CallTip &);
|
||||
void DrawChunk(Surface *surface, int &x, const char *s,
|
||||
int posStart, int posEnd, int ytext, PRectangle rcClient,
|
||||
bool highlight, bool draw);
|
||||
int PaintContents(Surface *surfaceWindow, bool draw);
|
||||
bool IsTabCharacter(char c) const;
|
||||
bool IsTabCharacter(char ch) const;
|
||||
int NextTabPos(int x) const;
|
||||
|
||||
public:
|
||||
Window wCallTip;
|
||||
Window wDraw;
|
||||
bool inCallTipMode;
|
||||
int posStartCallTip;
|
||||
Sci::Position posStartCallTip;
|
||||
ColourDesired colourBG;
|
||||
ColourDesired colourUnSel;
|
||||
ColourDesired colourSel;
|
||||
|
@ -56,6 +53,9 @@ public:
|
|||
int verticalOffset; // pixel offset up or down of the calltip with respect to the line
|
||||
|
||||
CallTip();
|
||||
// Deleted so CallTip objects can not be copied.
|
||||
CallTip(const CallTip &) = delete;
|
||||
CallTip &operator=(const CallTip &) = delete;
|
||||
~CallTip();
|
||||
|
||||
void PaintCT(Surface *surfaceWindow);
|
||||
|
@ -63,7 +63,7 @@ public:
|
|||
void MouseClick(Point pt);
|
||||
|
||||
/// Setup the calltip and return a rectangle of the area required.
|
||||
PRectangle CallTipStart(int pos, Point pt, int textHeight, const char *defn,
|
||||
PRectangle CallTipStart(Sci::Position pos, Point pt, int textHeight, const char *defn,
|
||||
const char *faceName, int size, int codePage_,
|
||||
int characterSet, int technology, Window &wParent);
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ int symmetricCaseConversionRanges[] = {
|
|||
1121,1120,17,2,
|
||||
1163,1162,27,2,
|
||||
1218,1217,7,2,
|
||||
1233,1232,44,2,
|
||||
1233,1232,48,2,
|
||||
1377,1329,38,1,
|
||||
7681,7680,75,2,
|
||||
7841,7840,48,2,
|
||||
|
@ -72,13 +72,17 @@ int symmetricCaseConversionRanges[] = {
|
|||
11393,11392,50,2,
|
||||
11520,4256,38,1,
|
||||
42561,42560,23,2,
|
||||
42625,42624,12,2,
|
||||
42625,42624,14,2,
|
||||
42787,42786,7,2,
|
||||
42803,42802,31,2,
|
||||
42879,42878,5,2,
|
||||
42913,42912,5,2,
|
||||
42903,42902,10,2,
|
||||
65345,65313,26,1,
|
||||
66600,66560,40,1,
|
||||
66776,66736,36,1,
|
||||
68800,68736,51,1,
|
||||
71872,71840,32,1,
|
||||
125218,125184,34,1,
|
||||
|
||||
//--Autogenerated -- end of section automatically generated
|
||||
};
|
||||
|
@ -137,13 +141,17 @@ int symmetricCaseConversions[] = {
|
|||
599,394,
|
||||
601,399,
|
||||
603,400,
|
||||
604,42923,
|
||||
608,403,
|
||||
609,42924,
|
||||
611,404,
|
||||
613,42893,
|
||||
614,42922,
|
||||
616,407,
|
||||
617,406,
|
||||
618,42926,
|
||||
619,11362,
|
||||
620,42925,
|
||||
623,412,
|
||||
625,11374,
|
||||
626,413,
|
||||
|
@ -151,12 +159,15 @@ int symmetricCaseConversions[] = {
|
|||
637,11364,
|
||||
640,422,
|
||||
643,425,
|
||||
647,42929,
|
||||
648,430,
|
||||
649,580,
|
||||
650,433,
|
||||
651,434,
|
||||
652,581,
|
||||
658,439,
|
||||
669,42930,
|
||||
670,42928,
|
||||
881,880,
|
||||
883,882,
|
||||
887,886,
|
||||
|
@ -172,6 +183,7 @@ int symmetricCaseConversions[] = {
|
|||
974,911,
|
||||
983,975,
|
||||
1010,1017,
|
||||
1011,895,
|
||||
1016,1015,
|
||||
1019,1018,
|
||||
1231,1216,
|
||||
|
@ -222,6 +234,9 @@ int symmetricCaseConversions[] = {
|
|||
42892,42891,
|
||||
42897,42896,
|
||||
42899,42898,
|
||||
42933,42932,
|
||||
42935,42934,
|
||||
43859,42931,
|
||||
|
||||
//--Autogenerated -- end of section automatically generated
|
||||
};
|
||||
|
@ -259,6 +274,107 @@ const char *complexCaseConversions =
|
|||
"\xcf\xb4|\xce\xb8||\xce\xb8|"
|
||||
"\xcf\xb5|\xce\xb5|\xce\x95||"
|
||||
"\xd6\x87|\xd5\xa5\xd6\x82|\xd4\xb5\xd5\x92||"
|
||||
"\xe1\x8e\xa0|||\xea\xad\xb0|"
|
||||
"\xe1\x8e\xa1|||\xea\xad\xb1|"
|
||||
"\xe1\x8e\xa2|||\xea\xad\xb2|"
|
||||
"\xe1\x8e\xa3|||\xea\xad\xb3|"
|
||||
"\xe1\x8e\xa4|||\xea\xad\xb4|"
|
||||
"\xe1\x8e\xa5|||\xea\xad\xb5|"
|
||||
"\xe1\x8e\xa6|||\xea\xad\xb6|"
|
||||
"\xe1\x8e\xa7|||\xea\xad\xb7|"
|
||||
"\xe1\x8e\xa8|||\xea\xad\xb8|"
|
||||
"\xe1\x8e\xa9|||\xea\xad\xb9|"
|
||||
"\xe1\x8e\xaa|||\xea\xad\xba|"
|
||||
"\xe1\x8e\xab|||\xea\xad\xbb|"
|
||||
"\xe1\x8e\xac|||\xea\xad\xbc|"
|
||||
"\xe1\x8e\xad|||\xea\xad\xbd|"
|
||||
"\xe1\x8e\xae|||\xea\xad\xbe|"
|
||||
"\xe1\x8e\xaf|||\xea\xad\xbf|"
|
||||
"\xe1\x8e\xb0|||\xea\xae\x80|"
|
||||
"\xe1\x8e\xb1|||\xea\xae\x81|"
|
||||
"\xe1\x8e\xb2|||\xea\xae\x82|"
|
||||
"\xe1\x8e\xb3|||\xea\xae\x83|"
|
||||
"\xe1\x8e\xb4|||\xea\xae\x84|"
|
||||
"\xe1\x8e\xb5|||\xea\xae\x85|"
|
||||
"\xe1\x8e\xb6|||\xea\xae\x86|"
|
||||
"\xe1\x8e\xb7|||\xea\xae\x87|"
|
||||
"\xe1\x8e\xb8|||\xea\xae\x88|"
|
||||
"\xe1\x8e\xb9|||\xea\xae\x89|"
|
||||
"\xe1\x8e\xba|||\xea\xae\x8a|"
|
||||
"\xe1\x8e\xbb|||\xea\xae\x8b|"
|
||||
"\xe1\x8e\xbc|||\xea\xae\x8c|"
|
||||
"\xe1\x8e\xbd|||\xea\xae\x8d|"
|
||||
"\xe1\x8e\xbe|||\xea\xae\x8e|"
|
||||
"\xe1\x8e\xbf|||\xea\xae\x8f|"
|
||||
"\xe1\x8f\x80|||\xea\xae\x90|"
|
||||
"\xe1\x8f\x81|||\xea\xae\x91|"
|
||||
"\xe1\x8f\x82|||\xea\xae\x92|"
|
||||
"\xe1\x8f\x83|||\xea\xae\x93|"
|
||||
"\xe1\x8f\x84|||\xea\xae\x94|"
|
||||
"\xe1\x8f\x85|||\xea\xae\x95|"
|
||||
"\xe1\x8f\x86|||\xea\xae\x96|"
|
||||
"\xe1\x8f\x87|||\xea\xae\x97|"
|
||||
"\xe1\x8f\x88|||\xea\xae\x98|"
|
||||
"\xe1\x8f\x89|||\xea\xae\x99|"
|
||||
"\xe1\x8f\x8a|||\xea\xae\x9a|"
|
||||
"\xe1\x8f\x8b|||\xea\xae\x9b|"
|
||||
"\xe1\x8f\x8c|||\xea\xae\x9c|"
|
||||
"\xe1\x8f\x8d|||\xea\xae\x9d|"
|
||||
"\xe1\x8f\x8e|||\xea\xae\x9e|"
|
||||
"\xe1\x8f\x8f|||\xea\xae\x9f|"
|
||||
"\xe1\x8f\x90|||\xea\xae\xa0|"
|
||||
"\xe1\x8f\x91|||\xea\xae\xa1|"
|
||||
"\xe1\x8f\x92|||\xea\xae\xa2|"
|
||||
"\xe1\x8f\x93|||\xea\xae\xa3|"
|
||||
"\xe1\x8f\x94|||\xea\xae\xa4|"
|
||||
"\xe1\x8f\x95|||\xea\xae\xa5|"
|
||||
"\xe1\x8f\x96|||\xea\xae\xa6|"
|
||||
"\xe1\x8f\x97|||\xea\xae\xa7|"
|
||||
"\xe1\x8f\x98|||\xea\xae\xa8|"
|
||||
"\xe1\x8f\x99|||\xea\xae\xa9|"
|
||||
"\xe1\x8f\x9a|||\xea\xae\xaa|"
|
||||
"\xe1\x8f\x9b|||\xea\xae\xab|"
|
||||
"\xe1\x8f\x9c|||\xea\xae\xac|"
|
||||
"\xe1\x8f\x9d|||\xea\xae\xad|"
|
||||
"\xe1\x8f\x9e|||\xea\xae\xae|"
|
||||
"\xe1\x8f\x9f|||\xea\xae\xaf|"
|
||||
"\xe1\x8f\xa0|||\xea\xae\xb0|"
|
||||
"\xe1\x8f\xa1|||\xea\xae\xb1|"
|
||||
"\xe1\x8f\xa2|||\xea\xae\xb2|"
|
||||
"\xe1\x8f\xa3|||\xea\xae\xb3|"
|
||||
"\xe1\x8f\xa4|||\xea\xae\xb4|"
|
||||
"\xe1\x8f\xa5|||\xea\xae\xb5|"
|
||||
"\xe1\x8f\xa6|||\xea\xae\xb6|"
|
||||
"\xe1\x8f\xa7|||\xea\xae\xb7|"
|
||||
"\xe1\x8f\xa8|||\xea\xae\xb8|"
|
||||
"\xe1\x8f\xa9|||\xea\xae\xb9|"
|
||||
"\xe1\x8f\xaa|||\xea\xae\xba|"
|
||||
"\xe1\x8f\xab|||\xea\xae\xbb|"
|
||||
"\xe1\x8f\xac|||\xea\xae\xbc|"
|
||||
"\xe1\x8f\xad|||\xea\xae\xbd|"
|
||||
"\xe1\x8f\xae|||\xea\xae\xbe|"
|
||||
"\xe1\x8f\xaf|||\xea\xae\xbf|"
|
||||
"\xe1\x8f\xb0|||\xe1\x8f\xb8|"
|
||||
"\xe1\x8f\xb1|||\xe1\x8f\xb9|"
|
||||
"\xe1\x8f\xb2|||\xe1\x8f\xba|"
|
||||
"\xe1\x8f\xb3|||\xe1\x8f\xbb|"
|
||||
"\xe1\x8f\xb4|||\xe1\x8f\xbc|"
|
||||
"\xe1\x8f\xb5|||\xe1\x8f\xbd|"
|
||||
"\xe1\x8f\xb8|\xe1\x8f\xb0|\xe1\x8f\xb0||"
|
||||
"\xe1\x8f\xb9|\xe1\x8f\xb1|\xe1\x8f\xb1||"
|
||||
"\xe1\x8f\xba|\xe1\x8f\xb2|\xe1\x8f\xb2||"
|
||||
"\xe1\x8f\xbb|\xe1\x8f\xb3|\xe1\x8f\xb3||"
|
||||
"\xe1\x8f\xbc|\xe1\x8f\xb4|\xe1\x8f\xb4||"
|
||||
"\xe1\x8f\xbd|\xe1\x8f\xb5|\xe1\x8f\xb5||"
|
||||
"\xe1\xb2\x80|\xd0\xb2|\xd0\x92||"
|
||||
"\xe1\xb2\x81|\xd0\xb4|\xd0\x94||"
|
||||
"\xe1\xb2\x82|\xd0\xbe|\xd0\x9e||"
|
||||
"\xe1\xb2\x83|\xd1\x81|\xd0\xa1||"
|
||||
"\xe1\xb2\x84|\xd1\x82|\xd0\xa2||"
|
||||
"\xe1\xb2\x85|\xd1\x82|\xd0\xa2||"
|
||||
"\xe1\xb2\x86|\xd1\x8a|\xd0\xaa||"
|
||||
"\xe1\xb2\x87|\xd1\xa3|\xd1\xa2||"
|
||||
"\xe1\xb2\x88|\xea\x99\x8b|\xea\x99\x8a||"
|
||||
"\xe1\xba\x96|h\xcc\xb1|H\xcc\xb1||"
|
||||
"\xe1\xba\x97|t\xcc\x88|T\xcc\x88||"
|
||||
"\xe1\xba\x98|w\xcc\x8a|W\xcc\x8a||"
|
||||
|
@ -349,6 +465,86 @@ const char *complexCaseConversions =
|
|||
"\xe2\x84\xa6|\xcf\x89||\xcf\x89|"
|
||||
"\xe2\x84\xaa|k||k|"
|
||||
"\xe2\x84\xab|\xc3\xa5||\xc3\xa5|"
|
||||
"\xea\xad\xb0|\xe1\x8e\xa0|\xe1\x8e\xa0||"
|
||||
"\xea\xad\xb1|\xe1\x8e\xa1|\xe1\x8e\xa1||"
|
||||
"\xea\xad\xb2|\xe1\x8e\xa2|\xe1\x8e\xa2||"
|
||||
"\xea\xad\xb3|\xe1\x8e\xa3|\xe1\x8e\xa3||"
|
||||
"\xea\xad\xb4|\xe1\x8e\xa4|\xe1\x8e\xa4||"
|
||||
"\xea\xad\xb5|\xe1\x8e\xa5|\xe1\x8e\xa5||"
|
||||
"\xea\xad\xb6|\xe1\x8e\xa6|\xe1\x8e\xa6||"
|
||||
"\xea\xad\xb7|\xe1\x8e\xa7|\xe1\x8e\xa7||"
|
||||
"\xea\xad\xb8|\xe1\x8e\xa8|\xe1\x8e\xa8||"
|
||||
"\xea\xad\xb9|\xe1\x8e\xa9|\xe1\x8e\xa9||"
|
||||
"\xea\xad\xba|\xe1\x8e\xaa|\xe1\x8e\xaa||"
|
||||
"\xea\xad\xbb|\xe1\x8e\xab|\xe1\x8e\xab||"
|
||||
"\xea\xad\xbc|\xe1\x8e\xac|\xe1\x8e\xac||"
|
||||
"\xea\xad\xbd|\xe1\x8e\xad|\xe1\x8e\xad||"
|
||||
"\xea\xad\xbe|\xe1\x8e\xae|\xe1\x8e\xae||"
|
||||
"\xea\xad\xbf|\xe1\x8e\xaf|\xe1\x8e\xaf||"
|
||||
"\xea\xae\x80|\xe1\x8e\xb0|\xe1\x8e\xb0||"
|
||||
"\xea\xae\x81|\xe1\x8e\xb1|\xe1\x8e\xb1||"
|
||||
"\xea\xae\x82|\xe1\x8e\xb2|\xe1\x8e\xb2||"
|
||||
"\xea\xae\x83|\xe1\x8e\xb3|\xe1\x8e\xb3||"
|
||||
"\xea\xae\x84|\xe1\x8e\xb4|\xe1\x8e\xb4||"
|
||||
"\xea\xae\x85|\xe1\x8e\xb5|\xe1\x8e\xb5||"
|
||||
"\xea\xae\x86|\xe1\x8e\xb6|\xe1\x8e\xb6||"
|
||||
"\xea\xae\x87|\xe1\x8e\xb7|\xe1\x8e\xb7||"
|
||||
"\xea\xae\x88|\xe1\x8e\xb8|\xe1\x8e\xb8||"
|
||||
"\xea\xae\x89|\xe1\x8e\xb9|\xe1\x8e\xb9||"
|
||||
"\xea\xae\x8a|\xe1\x8e\xba|\xe1\x8e\xba||"
|
||||
"\xea\xae\x8b|\xe1\x8e\xbb|\xe1\x8e\xbb||"
|
||||
"\xea\xae\x8c|\xe1\x8e\xbc|\xe1\x8e\xbc||"
|
||||
"\xea\xae\x8d|\xe1\x8e\xbd|\xe1\x8e\xbd||"
|
||||
"\xea\xae\x8e|\xe1\x8e\xbe|\xe1\x8e\xbe||"
|
||||
"\xea\xae\x8f|\xe1\x8e\xbf|\xe1\x8e\xbf||"
|
||||
"\xea\xae\x90|\xe1\x8f\x80|\xe1\x8f\x80||"
|
||||
"\xea\xae\x91|\xe1\x8f\x81|\xe1\x8f\x81||"
|
||||
"\xea\xae\x92|\xe1\x8f\x82|\xe1\x8f\x82||"
|
||||
"\xea\xae\x93|\xe1\x8f\x83|\xe1\x8f\x83||"
|
||||
"\xea\xae\x94|\xe1\x8f\x84|\xe1\x8f\x84||"
|
||||
"\xea\xae\x95|\xe1\x8f\x85|\xe1\x8f\x85||"
|
||||
"\xea\xae\x96|\xe1\x8f\x86|\xe1\x8f\x86||"
|
||||
"\xea\xae\x97|\xe1\x8f\x87|\xe1\x8f\x87||"
|
||||
"\xea\xae\x98|\xe1\x8f\x88|\xe1\x8f\x88||"
|
||||
"\xea\xae\x99|\xe1\x8f\x89|\xe1\x8f\x89||"
|
||||
"\xea\xae\x9a|\xe1\x8f\x8a|\xe1\x8f\x8a||"
|
||||
"\xea\xae\x9b|\xe1\x8f\x8b|\xe1\x8f\x8b||"
|
||||
"\xea\xae\x9c|\xe1\x8f\x8c|\xe1\x8f\x8c||"
|
||||
"\xea\xae\x9d|\xe1\x8f\x8d|\xe1\x8f\x8d||"
|
||||
"\xea\xae\x9e|\xe1\x8f\x8e|\xe1\x8f\x8e||"
|
||||
"\xea\xae\x9f|\xe1\x8f\x8f|\xe1\x8f\x8f||"
|
||||
"\xea\xae\xa0|\xe1\x8f\x90|\xe1\x8f\x90||"
|
||||
"\xea\xae\xa1|\xe1\x8f\x91|\xe1\x8f\x91||"
|
||||
"\xea\xae\xa2|\xe1\x8f\x92|\xe1\x8f\x92||"
|
||||
"\xea\xae\xa3|\xe1\x8f\x93|\xe1\x8f\x93||"
|
||||
"\xea\xae\xa4|\xe1\x8f\x94|\xe1\x8f\x94||"
|
||||
"\xea\xae\xa5|\xe1\x8f\x95|\xe1\x8f\x95||"
|
||||
"\xea\xae\xa6|\xe1\x8f\x96|\xe1\x8f\x96||"
|
||||
"\xea\xae\xa7|\xe1\x8f\x97|\xe1\x8f\x97||"
|
||||
"\xea\xae\xa8|\xe1\x8f\x98|\xe1\x8f\x98||"
|
||||
"\xea\xae\xa9|\xe1\x8f\x99|\xe1\x8f\x99||"
|
||||
"\xea\xae\xaa|\xe1\x8f\x9a|\xe1\x8f\x9a||"
|
||||
"\xea\xae\xab|\xe1\x8f\x9b|\xe1\x8f\x9b||"
|
||||
"\xea\xae\xac|\xe1\x8f\x9c|\xe1\x8f\x9c||"
|
||||
"\xea\xae\xad|\xe1\x8f\x9d|\xe1\x8f\x9d||"
|
||||
"\xea\xae\xae|\xe1\x8f\x9e|\xe1\x8f\x9e||"
|
||||
"\xea\xae\xaf|\xe1\x8f\x9f|\xe1\x8f\x9f||"
|
||||
"\xea\xae\xb0|\xe1\x8f\xa0|\xe1\x8f\xa0||"
|
||||
"\xea\xae\xb1|\xe1\x8f\xa1|\xe1\x8f\xa1||"
|
||||
"\xea\xae\xb2|\xe1\x8f\xa2|\xe1\x8f\xa2||"
|
||||
"\xea\xae\xb3|\xe1\x8f\xa3|\xe1\x8f\xa3||"
|
||||
"\xea\xae\xb4|\xe1\x8f\xa4|\xe1\x8f\xa4||"
|
||||
"\xea\xae\xb5|\xe1\x8f\xa5|\xe1\x8f\xa5||"
|
||||
"\xea\xae\xb6|\xe1\x8f\xa6|\xe1\x8f\xa6||"
|
||||
"\xea\xae\xb7|\xe1\x8f\xa7|\xe1\x8f\xa7||"
|
||||
"\xea\xae\xb8|\xe1\x8f\xa8|\xe1\x8f\xa8||"
|
||||
"\xea\xae\xb9|\xe1\x8f\xa9|\xe1\x8f\xa9||"
|
||||
"\xea\xae\xba|\xe1\x8f\xaa|\xe1\x8f\xaa||"
|
||||
"\xea\xae\xbb|\xe1\x8f\xab|\xe1\x8f\xab||"
|
||||
"\xea\xae\xbc|\xe1\x8f\xac|\xe1\x8f\xac||"
|
||||
"\xea\xae\xbd|\xe1\x8f\xad|\xe1\x8f\xad||"
|
||||
"\xea\xae\xbe|\xe1\x8f\xae|\xe1\x8f\xae||"
|
||||
"\xea\xae\xbf|\xe1\x8f\xaf|\xe1\x8f\xaf||"
|
||||
"\xef\xac\x80|ff|FF||"
|
||||
"\xef\xac\x81|fi|FI||"
|
||||
"\xef\xac\x82|fl|FL||"
|
||||
|
@ -410,7 +606,7 @@ public:
|
|||
else
|
||||
return 0;
|
||||
}
|
||||
size_t CaseConvertString(char *converted, size_t sizeConverted, const char *mixed, size_t lenMixed) {
|
||||
size_t CaseConvertString(char *converted, size_t sizeConverted, const char *mixed, size_t lenMixed) override {
|
||||
size_t lenConverted = 0;
|
||||
size_t mixedPos = 0;
|
||||
unsigned char bytes[UTF8MaxBytes + 1];
|
||||
|
@ -457,9 +653,9 @@ public:
|
|||
std::sort(characterToConversion.begin(), characterToConversion.end());
|
||||
characters.reserve(characterToConversion.size());
|
||||
conversions.reserve(characterToConversion.size());
|
||||
for (CharacterToConversion::iterator it = characterToConversion.begin(); it != characterToConversion.end(); ++it) {
|
||||
characters.push_back(it->character);
|
||||
conversions.push_back(it->conversion);
|
||||
for (const CharacterConversion &chConv : characterToConversion) {
|
||||
characters.push_back(chConv.character);
|
||||
conversions.push_back(chConv.conversion);
|
||||
}
|
||||
// Empty the original calculated data completely
|
||||
CharacterToConversion().swap(characterToConversion);
|
||||
|
@ -512,18 +708,18 @@ void AddSymmetric(enum CaseConversion conversion, int lower,int upper) {
|
|||
void SetupConversions(enum CaseConversion conversion) {
|
||||
// First initialize for the symmetric ranges
|
||||
for (size_t i=0; i<ELEMENTS(symmetricCaseConversionRanges);) {
|
||||
int lower = symmetricCaseConversionRanges[i++];
|
||||
int upper = symmetricCaseConversionRanges[i++];
|
||||
int length = symmetricCaseConversionRanges[i++];
|
||||
int pitch = symmetricCaseConversionRanges[i++];
|
||||
const int lower = symmetricCaseConversionRanges[i++];
|
||||
const int upper = symmetricCaseConversionRanges[i++];
|
||||
const int length = symmetricCaseConversionRanges[i++];
|
||||
const int pitch = symmetricCaseConversionRanges[i++];
|
||||
for (int j=0; j<length*pitch; j+=pitch) {
|
||||
AddSymmetric(conversion, lower+j, upper+j);
|
||||
}
|
||||
}
|
||||
// Add the symmetric singletons
|
||||
for (size_t i=0; i<ELEMENTS(symmetricCaseConversions);) {
|
||||
int lower = symmetricCaseConversions[i++];
|
||||
int upper = symmetricCaseConversions[i++];
|
||||
const int lower = symmetricCaseConversions[i++];
|
||||
const int upper = symmetricCaseConversions[i++];
|
||||
AddSymmetric(conversion, lower, upper);
|
||||
}
|
||||
// Add the complex cases
|
||||
|
|
|
@ -24,7 +24,7 @@ protected:
|
|||
public:
|
||||
CaseFolderTable();
|
||||
virtual ~CaseFolderTable();
|
||||
virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed);
|
||||
size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) override;
|
||||
void SetTranslation(char ch, char chTranslation);
|
||||
void StandardASCII();
|
||||
};
|
||||
|
@ -35,7 +35,7 @@ class CaseFolderUnicode : public CaseFolderTable {
|
|||
ICaseConverter *converter;
|
||||
public:
|
||||
CaseFolderUnicode();
|
||||
virtual size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed);
|
||||
size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) override;
|
||||
};
|
||||
|
||||
#ifdef SCI_NAMESPACE
|
||||
|
|
|
@ -5,12 +5,9 @@
|
|||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
|
@ -31,10 +28,9 @@ static int nextLanguage = SCLEX_AUTOMATIC+1;
|
|||
|
||||
const LexerModule *Catalogue::Find(int language) {
|
||||
Scintilla_LinkLexers();
|
||||
for (std::vector<LexerModule *>::iterator it=lexerCatalogue.begin();
|
||||
it != lexerCatalogue.end(); ++it) {
|
||||
if ((*it)->GetLanguage() == language) {
|
||||
return *it;
|
||||
for (const LexerModule *lm : lexerCatalogue) {
|
||||
if (lm->GetLanguage() == language) {
|
||||
return lm;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -43,10 +39,9 @@ const LexerModule *Catalogue::Find(int language) {
|
|||
const LexerModule *Catalogue::Find(const char *languageName) {
|
||||
Scintilla_LinkLexers();
|
||||
if (languageName) {
|
||||
for (std::vector<LexerModule *>::iterator it=lexerCatalogue.begin();
|
||||
it != lexerCatalogue.end(); ++it) {
|
||||
if ((*it)->languageName && (0 == strcmp((*it)->languageName, languageName))) {
|
||||
return *it;
|
||||
for (const LexerModule *lm : lexerCatalogue) {
|
||||
if (lm->languageName && (0 == strcmp(lm->languageName, languageName))) {
|
||||
return lm;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,13 +5,16 @@
|
|||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <cstdarg>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
|
@ -45,11 +48,11 @@ void LineVector::SetPerLine(PerLine *pl) {
|
|||
perLine = pl;
|
||||
}
|
||||
|
||||
void LineVector::InsertText(int line, int delta) {
|
||||
void LineVector::InsertText(Sci::Line line, Sci::Position delta) {
|
||||
starts.InsertText(line, delta);
|
||||
}
|
||||
|
||||
void LineVector::InsertLine(int line, int position, bool lineStart) {
|
||||
void LineVector::InsertLine(Sci::Line line, Sci::Position position, bool lineStart) {
|
||||
starts.InsertPartition(line, position);
|
||||
if (perLine) {
|
||||
if ((line > 0) && lineStart)
|
||||
|
@ -58,66 +61,54 @@ void LineVector::InsertLine(int line, int position, bool lineStart) {
|
|||
}
|
||||
}
|
||||
|
||||
void LineVector::SetLineStart(int line, int position) {
|
||||
void LineVector::SetLineStart(Sci::Line line, Sci::Position position) {
|
||||
starts.SetPartitionStartPosition(line, position);
|
||||
}
|
||||
|
||||
void LineVector::RemoveLine(int line) {
|
||||
void LineVector::RemoveLine(Sci::Line line) {
|
||||
starts.RemovePartition(line);
|
||||
if (perLine) {
|
||||
perLine->RemoveLine(line);
|
||||
}
|
||||
}
|
||||
|
||||
int LineVector::LineFromPosition(int pos) const {
|
||||
Sci::Line LineVector::LineFromPosition(Sci::Position pos) const {
|
||||
return starts.PartitionFromPosition(pos);
|
||||
}
|
||||
|
||||
Action::Action() {
|
||||
at = startAction;
|
||||
position = 0;
|
||||
data = 0;
|
||||
lenData = 0;
|
||||
mayCoalesce = false;
|
||||
}
|
||||
|
||||
Action::~Action() {
|
||||
Destroy();
|
||||
Action::Action(Action &&other) {
|
||||
at = other.at;
|
||||
position = other.position;
|
||||
data = std::move(other.data);
|
||||
lenData = other.lenData;
|
||||
mayCoalesce = other.mayCoalesce;
|
||||
}
|
||||
|
||||
void Action::Create(actionType at_, int position_, const char *data_, int lenData_, bool mayCoalesce_) {
|
||||
delete []data;
|
||||
data = NULL;
|
||||
Action::~Action() {
|
||||
}
|
||||
|
||||
void Action::Create(actionType at_, Sci::Position position_, const char *data_, Sci::Position lenData_, bool mayCoalesce_) {
|
||||
data = nullptr;
|
||||
position = position_;
|
||||
at = at_;
|
||||
if (lenData_) {
|
||||
data = new char[lenData_];
|
||||
memcpy(data, data_, lenData_);
|
||||
data = std::unique_ptr<char []>(new char[lenData_]);
|
||||
memcpy(&data[0], data_, lenData_);
|
||||
}
|
||||
lenData = lenData_;
|
||||
mayCoalesce = mayCoalesce_;
|
||||
}
|
||||
|
||||
void Action::Destroy() {
|
||||
delete []data;
|
||||
data = 0;
|
||||
}
|
||||
|
||||
void Action::Grab(Action *source) {
|
||||
delete []data;
|
||||
|
||||
position = source->position;
|
||||
at = source->at;
|
||||
data = source->data;
|
||||
lenData = source->lenData;
|
||||
mayCoalesce = source->mayCoalesce;
|
||||
|
||||
// Ownership of source data transferred to this
|
||||
source->position = 0;
|
||||
source->at = startAction;
|
||||
source->data = 0;
|
||||
source->lenData = 0;
|
||||
source->mayCoalesce = true;
|
||||
void Action::Clear() {
|
||||
data = nullptr;
|
||||
lenData = 0;
|
||||
}
|
||||
|
||||
// The undo history stores a sequence of user operations that represent the user's view of the
|
||||
|
@ -140,8 +131,7 @@ void Action::Grab(Action *source) {
|
|||
|
||||
UndoHistory::UndoHistory() {
|
||||
|
||||
lenActions = 100;
|
||||
actions = new Action[lenActions];
|
||||
actions.resize(3);
|
||||
maxAction = 0;
|
||||
currentAction = 0;
|
||||
undoSequenceDepth = 0;
|
||||
|
@ -152,26 +142,18 @@ UndoHistory::UndoHistory() {
|
|||
}
|
||||
|
||||
UndoHistory::~UndoHistory() {
|
||||
delete []actions;
|
||||
actions = 0;
|
||||
}
|
||||
|
||||
void UndoHistory::EnsureUndoRoom() {
|
||||
// Have to test that there is room for 2 more actions in the array
|
||||
// as two actions may be created by the calling function
|
||||
if (currentAction >= (lenActions - 2)) {
|
||||
if (static_cast<size_t>(currentAction) >= (actions.size() - 2)) {
|
||||
// Run out of undo nodes so extend the array
|
||||
int lenActionsNew = lenActions * 2;
|
||||
Action *actionsNew = new Action[lenActionsNew];
|
||||
for (int act = 0; act <= currentAction; act++)
|
||||
actionsNew[act].Grab(&actions[act]);
|
||||
delete []actions;
|
||||
lenActions = lenActionsNew;
|
||||
actions = actionsNew;
|
||||
actions.resize(actions.size() * 2);
|
||||
}
|
||||
}
|
||||
|
||||
const char *UndoHistory::AppendAction(actionType at, int position, const char *data, int lengthData,
|
||||
const char *UndoHistory::AppendAction(actionType at, Sci::Position position, const char *data, Sci::Position lengthData,
|
||||
bool &startSequence, bool mayCoalesce) {
|
||||
EnsureUndoRoom();
|
||||
//Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, lengthData, currentAction);
|
||||
|
@ -193,10 +175,6 @@ const char *UndoHistory::AppendAction(actionType at, int position, const char *d
|
|||
}
|
||||
// See if current action can be coalesced into previous action
|
||||
// Will work if both are inserts or deletes and position is same
|
||||
#if defined(_MSC_VER) && defined(_PREFAST_)
|
||||
// Visual Studio 2013 Code Analysis wrongly believes actions can be NULL at its next reference
|
||||
__analysis_assume(actions);
|
||||
#endif
|
||||
if ((currentAction == savePoint) || (currentAction == tentativePoint)) {
|
||||
currentAction++;
|
||||
} else if (!actions[currentAction].mayCoalesce) {
|
||||
|
@ -239,12 +217,12 @@ const char *UndoHistory::AppendAction(actionType at, int position, const char *d
|
|||
currentAction++;
|
||||
}
|
||||
startSequence = oldCurrentAction != currentAction;
|
||||
int actionWithData = currentAction;
|
||||
const int actionWithData = currentAction;
|
||||
actions[currentAction].Create(at, position, data, lengthData, mayCoalesce);
|
||||
currentAction++;
|
||||
actions[currentAction].Create(startAction);
|
||||
maxAction = currentAction;
|
||||
return actions[actionWithData].data;
|
||||
return actions[actionWithData].data.get();
|
||||
}
|
||||
|
||||
void UndoHistory::BeginUndoAction() {
|
||||
|
@ -280,7 +258,7 @@ void UndoHistory::DropUndoSequence() {
|
|||
|
||||
void UndoHistory::DeleteUndoHistory() {
|
||||
for (int i = 1; i < maxAction; i++)
|
||||
actions[i].Destroy();
|
||||
actions[i].Clear();
|
||||
maxAction = 0;
|
||||
currentAction = 0;
|
||||
actions[currentAction].Create(startAction);
|
||||
|
@ -347,12 +325,12 @@ bool UndoHistory::CanRedo() const {
|
|||
|
||||
int UndoHistory::StartRedo() {
|
||||
// Drop any leading startAction
|
||||
if (actions[currentAction].at == startAction && currentAction < maxAction)
|
||||
if (currentAction < maxAction && actions[currentAction].at == startAction)
|
||||
currentAction++;
|
||||
|
||||
// Count the steps in this action
|
||||
int act = currentAction;
|
||||
while (actions[act].at != startAction && act < maxAction) {
|
||||
while (act < maxAction && actions[act].at != startAction) {
|
||||
act++;
|
||||
}
|
||||
return act - currentAction;
|
||||
|
@ -375,11 +353,11 @@ CellBuffer::CellBuffer() {
|
|||
CellBuffer::~CellBuffer() {
|
||||
}
|
||||
|
||||
char CellBuffer::CharAt(int position) const {
|
||||
char CellBuffer::CharAt(Sci::Position position) const {
|
||||
return substance.ValueAt(position);
|
||||
}
|
||||
|
||||
void CellBuffer::GetCharRange(char *buffer, int position, int lengthRetrieve) const {
|
||||
void CellBuffer::GetCharRange(char *buffer, Sci::Position position, Sci::Position lengthRetrieve) const {
|
||||
if (lengthRetrieve <= 0)
|
||||
return;
|
||||
if (position < 0)
|
||||
|
@ -392,11 +370,11 @@ void CellBuffer::GetCharRange(char *buffer, int position, int lengthRetrieve) co
|
|||
substance.GetRange(buffer, position, lengthRetrieve);
|
||||
}
|
||||
|
||||
char CellBuffer::StyleAt(int position) const {
|
||||
char CellBuffer::StyleAt(Sci::Position position) const {
|
||||
return style.ValueAt(position);
|
||||
}
|
||||
|
||||
void CellBuffer::GetStyleRange(unsigned char *buffer, int position, int lengthRetrieve) const {
|
||||
void CellBuffer::GetStyleRange(unsigned char *buffer, Sci::Position position, Sci::Position lengthRetrieve) const {
|
||||
if (lengthRetrieve < 0)
|
||||
return;
|
||||
if (position < 0)
|
||||
|
@ -413,16 +391,16 @@ const char *CellBuffer::BufferPointer() {
|
|||
return substance.BufferPointer();
|
||||
}
|
||||
|
||||
const char *CellBuffer::RangePointer(int position, int rangeLength) {
|
||||
const char *CellBuffer::RangePointer(Sci::Position position, Sci::Position rangeLength) {
|
||||
return substance.RangePointer(position, rangeLength);
|
||||
}
|
||||
|
||||
int CellBuffer::GapPosition() const {
|
||||
Sci::Position CellBuffer::GapPosition() const {
|
||||
return substance.GapPosition();
|
||||
}
|
||||
|
||||
// The char* returned is to an allocation owned by the undo history
|
||||
const char *CellBuffer::InsertString(int position, const char *s, int insertLength, bool &startSequence) {
|
||||
const char *CellBuffer::InsertString(Sci::Position position, const char *s, Sci::Position insertLength, bool &startSequence) {
|
||||
// InsertString and DeleteChars are the bottleneck though which all changes occur
|
||||
const char *data = s;
|
||||
if (!readOnly) {
|
||||
|
@ -437,8 +415,8 @@ const char *CellBuffer::InsertString(int position, const char *s, int insertLeng
|
|||
return data;
|
||||
}
|
||||
|
||||
bool CellBuffer::SetStyleAt(int position, char styleValue) {
|
||||
char curVal = style.ValueAt(position);
|
||||
bool CellBuffer::SetStyleAt(Sci::Position position, char styleValue) {
|
||||
const char curVal = style.ValueAt(position);
|
||||
if (curVal != styleValue) {
|
||||
style.SetValueAt(position, styleValue);
|
||||
return true;
|
||||
|
@ -447,12 +425,12 @@ bool CellBuffer::SetStyleAt(int position, char styleValue) {
|
|||
}
|
||||
}
|
||||
|
||||
bool CellBuffer::SetStyleFor(int position, int lengthStyle, char styleValue) {
|
||||
bool CellBuffer::SetStyleFor(Sci::Position position, Sci::Position lengthStyle, char styleValue) {
|
||||
bool changed = false;
|
||||
PLATFORM_ASSERT(lengthStyle == 0 ||
|
||||
(lengthStyle > 0 && lengthStyle + position <= style.Length()));
|
||||
while (lengthStyle--) {
|
||||
char curVal = style.ValueAt(position);
|
||||
const char curVal = style.ValueAt(position);
|
||||
if (curVal != styleValue) {
|
||||
style.SetValueAt(position, styleValue);
|
||||
changed = true;
|
||||
|
@ -463,7 +441,7 @@ bool CellBuffer::SetStyleFor(int position, int lengthStyle, char styleValue) {
|
|||
}
|
||||
|
||||
// The char* returned is to an allocation owned by the undo history
|
||||
const char *CellBuffer::DeleteChars(int position, int deleteLength, bool &startSequence) {
|
||||
const char *CellBuffer::DeleteChars(Sci::Position position, Sci::Position deleteLength, bool &startSequence) {
|
||||
// InsertString and DeleteChars are the bottleneck though which all changes occur
|
||||
PLATFORM_ASSERT(deleteLength > 0);
|
||||
const char *data = 0;
|
||||
|
@ -480,11 +458,11 @@ const char *CellBuffer::DeleteChars(int position, int deleteLength, bool &startS
|
|||
return data;
|
||||
}
|
||||
|
||||
int CellBuffer::Length() const {
|
||||
Sci::Position CellBuffer::Length() const {
|
||||
return substance.Length();
|
||||
}
|
||||
|
||||
void CellBuffer::Allocate(int newSize) {
|
||||
void CellBuffer::Allocate(Sci::Position newSize) {
|
||||
substance.ReAllocate(newSize);
|
||||
style.ReAllocate(newSize);
|
||||
}
|
||||
|
@ -496,15 +474,15 @@ void CellBuffer::SetLineEndTypes(int utf8LineEnds_) {
|
|||
}
|
||||
}
|
||||
|
||||
bool CellBuffer::ContainsLineEnd(const char *s, int length) const {
|
||||
bool CellBuffer::ContainsLineEnd(const char *s, Sci::Position length) const {
|
||||
unsigned char chBeforePrev = 0;
|
||||
unsigned char chPrev = 0;
|
||||
for (int i = 0; i < length; i++) {
|
||||
for (Sci::Position i = 0; i < length; i++) {
|
||||
const unsigned char ch = s[i];
|
||||
if ((ch == '\r') || (ch == '\n')) {
|
||||
return true;
|
||||
} else if (utf8LineEnds) {
|
||||
unsigned char back3[3] = { chBeforePrev, chPrev, ch };
|
||||
const unsigned char back3[3] = { chBeforePrev, chPrev, ch };
|
||||
if (UTF8IsSeparator(back3) || UTF8IsNEL(back3 + 1)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -519,11 +497,11 @@ void CellBuffer::SetPerLine(PerLine *pl) {
|
|||
lv.SetPerLine(pl);
|
||||
}
|
||||
|
||||
int CellBuffer::Lines() const {
|
||||
Sci::Line CellBuffer::Lines() const {
|
||||
return lv.Lines();
|
||||
}
|
||||
|
||||
int CellBuffer::LineStart(int line) const {
|
||||
Sci::Position CellBuffer::LineStart(Sci::Line line) const {
|
||||
if (line < 0)
|
||||
return 0;
|
||||
else if (line >= Lines())
|
||||
|
@ -566,16 +544,16 @@ bool CellBuffer::TentativeActive() const {
|
|||
|
||||
// Without undo
|
||||
|
||||
void CellBuffer::InsertLine(int line, int position, bool lineStart) {
|
||||
void CellBuffer::InsertLine(Sci::Line line, Sci::Position position, bool lineStart) {
|
||||
lv.InsertLine(line, position, lineStart);
|
||||
}
|
||||
|
||||
void CellBuffer::RemoveLine(int line) {
|
||||
void CellBuffer::RemoveLine(Sci::Line line) {
|
||||
lv.RemoveLine(line);
|
||||
}
|
||||
|
||||
bool CellBuffer::UTF8LineEndOverlaps(int position) const {
|
||||
unsigned char bytes[] = {
|
||||
bool CellBuffer::UTF8LineEndOverlaps(Sci::Position position) const {
|
||||
const unsigned char bytes[] = {
|
||||
static_cast<unsigned char>(substance.ValueAt(position-2)),
|
||||
static_cast<unsigned char>(substance.ValueAt(position-1)),
|
||||
static_cast<unsigned char>(substance.ValueAt(position)),
|
||||
|
@ -588,15 +566,15 @@ void CellBuffer::ResetLineEnds() {
|
|||
// Reinitialize line data -- too much work to preserve
|
||||
lv.Init();
|
||||
|
||||
int position = 0;
|
||||
int length = Length();
|
||||
int lineInsert = 1;
|
||||
Sci::Position position = 0;
|
||||
Sci::Position length = Length();
|
||||
Sci::Line lineInsert = 1;
|
||||
bool atLineStart = true;
|
||||
lv.InsertText(lineInsert-1, length);
|
||||
unsigned char chBeforePrev = 0;
|
||||
unsigned char chPrev = 0;
|
||||
for (int i = 0; i < length; i++) {
|
||||
unsigned char ch = substance.ValueAt(position + i);
|
||||
for (Sci::Position i = 0; i < length; i++) {
|
||||
const unsigned char ch = substance.ValueAt(position + i);
|
||||
if (ch == '\r') {
|
||||
InsertLine(lineInsert, (position + i) + 1, atLineStart);
|
||||
lineInsert++;
|
||||
|
@ -609,7 +587,7 @@ void CellBuffer::ResetLineEnds() {
|
|||
lineInsert++;
|
||||
}
|
||||
} else if (utf8LineEnds) {
|
||||
unsigned char back3[3] = {chBeforePrev, chPrev, ch};
|
||||
const unsigned char back3[3] = {chBeforePrev, chPrev, ch};
|
||||
if (UTF8IsSeparator(back3) || UTF8IsNEL(back3+1)) {
|
||||
InsertLine(lineInsert, (position + i) + 1, atLineStart);
|
||||
lineInsert++;
|
||||
|
@ -620,12 +598,12 @@ void CellBuffer::ResetLineEnds() {
|
|||
}
|
||||
}
|
||||
|
||||
void CellBuffer::BasicInsertString(int position, const char *s, int insertLength) {
|
||||
void CellBuffer::BasicInsertString(Sci::Position position, const char *s, Sci::Position insertLength) {
|
||||
if (insertLength == 0)
|
||||
return;
|
||||
PLATFORM_ASSERT(insertLength > 0);
|
||||
|
||||
unsigned char chAfter = substance.ValueAt(position);
|
||||
const unsigned char chAfter = substance.ValueAt(position);
|
||||
bool breakingUTF8LineEnd = false;
|
||||
if (utf8LineEnds && UTF8IsTrailByte(chAfter)) {
|
||||
breakingUTF8LineEnd = UTF8LineEndOverlaps(position);
|
||||
|
@ -634,7 +612,7 @@ void CellBuffer::BasicInsertString(int position, const char *s, int insertLength
|
|||
substance.InsertFromArray(position, s, 0, insertLength);
|
||||
style.InsertValue(position, insertLength, 0);
|
||||
|
||||
int lineInsert = lv.LineFromPosition(position) + 1;
|
||||
Sci::Line lineInsert = lv.LineFromPosition(position) + 1;
|
||||
bool atLineStart = lv.LineStart(lineInsert-1) == position;
|
||||
// Point all the lines after the insertion point further along in the buffer
|
||||
lv.InsertText(lineInsert-1, insertLength);
|
||||
|
@ -649,7 +627,7 @@ void CellBuffer::BasicInsertString(int position, const char *s, int insertLength
|
|||
RemoveLine(lineInsert);
|
||||
}
|
||||
unsigned char ch = ' ';
|
||||
for (int i = 0; i < insertLength; i++) {
|
||||
for (Sci::Position i = 0; i < insertLength; i++) {
|
||||
ch = s[i];
|
||||
if (ch == '\r') {
|
||||
InsertLine(lineInsert, (position + i) + 1, atLineStart);
|
||||
|
@ -663,7 +641,7 @@ void CellBuffer::BasicInsertString(int position, const char *s, int insertLength
|
|||
lineInsert++;
|
||||
}
|
||||
} else if (utf8LineEnds) {
|
||||
unsigned char back3[3] = {chBeforePrev, chPrev, ch};
|
||||
const unsigned char back3[3] = {chBeforePrev, chPrev, ch};
|
||||
if (UTF8IsSeparator(back3) || UTF8IsNEL(back3+1)) {
|
||||
InsertLine(lineInsert, (position + i) + 1, atLineStart);
|
||||
lineInsert++;
|
||||
|
@ -681,8 +659,8 @@ void CellBuffer::BasicInsertString(int position, const char *s, int insertLength
|
|||
} else if (utf8LineEnds && !UTF8IsAscii(chAfter)) {
|
||||
// May have end of UTF-8 line end in buffer and start in insertion
|
||||
for (int j = 0; j < UTF8SeparatorLength-1; j++) {
|
||||
unsigned char chAt = substance.ValueAt(position + insertLength + j);
|
||||
unsigned char back3[3] = {chBeforePrev, chPrev, chAt};
|
||||
const unsigned char chAt = substance.ValueAt(position + insertLength + j);
|
||||
const unsigned char back3[3] = {chBeforePrev, chPrev, chAt};
|
||||
if (UTF8IsSeparator(back3)) {
|
||||
InsertLine(lineInsert, (position + insertLength + j) + 1, atLineStart);
|
||||
lineInsert++;
|
||||
|
@ -697,7 +675,7 @@ void CellBuffer::BasicInsertString(int position, const char *s, int insertLength
|
|||
}
|
||||
}
|
||||
|
||||
void CellBuffer::BasicDeleteChars(int position, int deleteLength) {
|
||||
void CellBuffer::BasicDeleteChars(Sci::Position position, Sci::Position deleteLength) {
|
||||
if (deleteLength == 0)
|
||||
return;
|
||||
|
||||
|
@ -709,10 +687,10 @@ void CellBuffer::BasicDeleteChars(int position, int deleteLength) {
|
|||
// Have to fix up line positions before doing deletion as looking at text in buffer
|
||||
// to work out which lines have been removed
|
||||
|
||||
int lineRemove = lv.LineFromPosition(position) + 1;
|
||||
Sci::Line lineRemove = lv.LineFromPosition(position) + 1;
|
||||
lv.InsertText(lineRemove-1, - (deleteLength));
|
||||
unsigned char chPrev = substance.ValueAt(position - 1);
|
||||
unsigned char chBefore = chPrev;
|
||||
const unsigned char chPrev = substance.ValueAt(position - 1);
|
||||
const unsigned char chBefore = chPrev;
|
||||
unsigned char chNext = substance.ValueAt(position);
|
||||
bool ignoreNL = false;
|
||||
if (chPrev == '\r' && chNext == '\n') {
|
||||
|
@ -728,7 +706,7 @@ void CellBuffer::BasicDeleteChars(int position, int deleteLength) {
|
|||
}
|
||||
|
||||
unsigned char ch = chNext;
|
||||
for (int i = 0; i < deleteLength; i++) {
|
||||
for (Sci::Position i = 0; i < deleteLength; i++) {
|
||||
chNext = substance.ValueAt(position + i + 1);
|
||||
if (ch == '\r') {
|
||||
if (chNext != '\n') {
|
||||
|
@ -742,7 +720,7 @@ void CellBuffer::BasicDeleteChars(int position, int deleteLength) {
|
|||
}
|
||||
} else if (utf8LineEnds) {
|
||||
if (!UTF8IsAscii(ch)) {
|
||||
unsigned char next3[3] = {ch, chNext,
|
||||
const unsigned char next3[3] = {ch, chNext,
|
||||
static_cast<unsigned char>(substance.ValueAt(position + i + 2))};
|
||||
if (UTF8IsSeparator(next3) || UTF8IsNEL(next3)) {
|
||||
RemoveLine(lineRemove);
|
||||
|
@ -754,7 +732,7 @@ void CellBuffer::BasicDeleteChars(int position, int deleteLength) {
|
|||
}
|
||||
// May have to fix up end if last deletion causes cr to be next to lf
|
||||
// or removes one of a crlf pair
|
||||
char chAfter = substance.ValueAt(position + deleteLength);
|
||||
const char chAfter = substance.ValueAt(position + deleteLength);
|
||||
if (chBefore == '\r' && chAfter == '\n') {
|
||||
// Using lineRemove-1 as cr ended line before start of deletion
|
||||
RemoveLine(lineRemove - 1);
|
||||
|
@ -783,7 +761,7 @@ void CellBuffer::EndUndoAction() {
|
|||
uh.EndUndoAction();
|
||||
}
|
||||
|
||||
void CellBuffer::AddUndoAction(int token, bool mayCoalesce) {
|
||||
void CellBuffer::AddUndoAction(Sci::Position token, bool mayCoalesce) {
|
||||
bool startSequence;
|
||||
uh.AppendAction(containerAction, token, 0, 0, startSequence, mayCoalesce);
|
||||
}
|
||||
|
@ -813,7 +791,7 @@ void CellBuffer::PerformUndoStep() {
|
|||
}
|
||||
BasicDeleteChars(actionStep.position, actionStep.lenData);
|
||||
} else if (actionStep.at == removeAction) {
|
||||
BasicInsertString(actionStep.position, actionStep.data, actionStep.lenData);
|
||||
BasicInsertString(actionStep.position, actionStep.data.get(), actionStep.lenData);
|
||||
}
|
||||
uh.CompletedUndoStep();
|
||||
}
|
||||
|
@ -833,7 +811,7 @@ const Action &CellBuffer::GetRedoStep() const {
|
|||
void CellBuffer::PerformRedoStep() {
|
||||
const Action &actionStep = uh.GetRedoStep();
|
||||
if (actionStep.at == insertAction) {
|
||||
BasicInsertString(actionStep.position, actionStep.data, actionStep.lenData);
|
||||
BasicInsertString(actionStep.position, actionStep.data.get(), actionStep.lenData);
|
||||
} else if (actionStep.at == removeAction) {
|
||||
BasicDeleteChars(actionStep.position, actionStep.lenData);
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@ class PerLine {
|
|||
public:
|
||||
virtual ~PerLine() {}
|
||||
virtual void Init()=0;
|
||||
virtual void InsertLine(int line)=0;
|
||||
virtual void RemoveLine(int line)=0;
|
||||
virtual void InsertLine(Sci::Line line)=0;
|
||||
virtual void RemoveLine(Sci::Line line)=0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -32,19 +32,22 @@ class LineVector {
|
|||
public:
|
||||
|
||||
LineVector();
|
||||
// Deleted so LineVector objects can not be copied.
|
||||
LineVector(const LineVector &) = delete;
|
||||
void operator=(const LineVector &) = delete;
|
||||
~LineVector();
|
||||
void Init();
|
||||
void SetPerLine(PerLine *pl);
|
||||
|
||||
void InsertText(int line, int delta);
|
||||
void InsertLine(int line, int position, bool lineStart);
|
||||
void SetLineStart(int line, int position);
|
||||
void RemoveLine(int line);
|
||||
int Lines() const {
|
||||
void InsertText(Sci::Line line, Sci::Position delta);
|
||||
void InsertLine(Sci::Line line, Sci::Position position, bool lineStart);
|
||||
void SetLineStart(Sci::Line line, Sci::Position position);
|
||||
void RemoveLine(Sci::Line line);
|
||||
Sci::Line Lines() const {
|
||||
return starts.Partitions();
|
||||
}
|
||||
int LineFromPosition(int pos) const;
|
||||
int LineStart(int line) const {
|
||||
Sci::Line LineFromPosition(Sci::Position pos) const;
|
||||
Sci::Position LineStart(Sci::Line line) const {
|
||||
return starts.PositionFromPartition(line);
|
||||
}
|
||||
};
|
||||
|
@ -57,24 +60,29 @@ enum actionType { insertAction, removeAction, startAction, containerAction };
|
|||
class Action {
|
||||
public:
|
||||
actionType at;
|
||||
int position;
|
||||
char *data;
|
||||
int lenData;
|
||||
Sci::Position position;
|
||||
std::unique_ptr<char[]> data;
|
||||
Sci::Position lenData;
|
||||
bool mayCoalesce;
|
||||
|
||||
Action();
|
||||
// Deleted so Action objects can not be copied.
|
||||
Action(const Action &other) = delete;
|
||||
Action &operator=(const Action &other) = delete;
|
||||
Action &operator=(const Action &&other) = delete;
|
||||
// Move constructor allows vector to be resized without reallocating.
|
||||
// Could use =default but MSVC 2013 warns.
|
||||
Action(Action &&other);
|
||||
~Action();
|
||||
void Create(actionType at_, int position_=0, const char *data_=0, int lenData_=0, bool mayCoalesce_=true);
|
||||
void Destroy();
|
||||
void Grab(Action *source);
|
||||
void Create(actionType at_, Sci::Position position_=0, const char *data_=0, Sci::Position lenData_=0, bool mayCoalesce_=true);
|
||||
void Clear();
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class UndoHistory {
|
||||
Action *actions;
|
||||
int lenActions;
|
||||
std::vector<Action> actions;
|
||||
int maxAction;
|
||||
int currentAction;
|
||||
int undoSequenceDepth;
|
||||
|
@ -83,14 +91,14 @@ class UndoHistory {
|
|||
|
||||
void EnsureUndoRoom();
|
||||
|
||||
// Private so UndoHistory objects can not be copied
|
||||
UndoHistory(const UndoHistory &);
|
||||
|
||||
public:
|
||||
UndoHistory();
|
||||
// Deleted so UndoHistory objects can not be copied.
|
||||
UndoHistory(const UndoHistory &) = delete;
|
||||
void operator=(const UndoHistory &) = delete;
|
||||
~UndoHistory();
|
||||
|
||||
const char *AppendAction(actionType at, int position, const char *data, int length, bool &startSequence, bool mayCoalesce=true);
|
||||
const char *AppendAction(actionType at, Sci::Position position, const char *data, Sci::Position lengthData, bool &startSequence, bool mayCoalesce=true);
|
||||
|
||||
void BeginUndoAction();
|
||||
void EndUndoAction();
|
||||
|
@ -137,45 +145,48 @@ private:
|
|||
|
||||
LineVector lv;
|
||||
|
||||
bool UTF8LineEndOverlaps(int position) const;
|
||||
bool UTF8LineEndOverlaps(Sci::Position position) const;
|
||||
void ResetLineEnds();
|
||||
/// Actions without undo
|
||||
void BasicInsertString(int position, const char *s, int insertLength);
|
||||
void BasicDeleteChars(int position, int deleteLength);
|
||||
void BasicInsertString(Sci::Position position, const char *s, Sci::Position insertLength);
|
||||
void BasicDeleteChars(Sci::Position position, Sci::Position deleteLength);
|
||||
|
||||
public:
|
||||
|
||||
CellBuffer();
|
||||
// Deleted so CellBuffer objects can not be copied.
|
||||
CellBuffer(const CellBuffer &) = delete;
|
||||
void operator=(const CellBuffer &) = delete;
|
||||
~CellBuffer();
|
||||
|
||||
/// Retrieving positions outside the range of the buffer works and returns 0
|
||||
char CharAt(int position) const;
|
||||
void GetCharRange(char *buffer, int position, int lengthRetrieve) const;
|
||||
char StyleAt(int position) const;
|
||||
void GetStyleRange(unsigned char *buffer, int position, int lengthRetrieve) const;
|
||||
char CharAt(Sci::Position position) const;
|
||||
void GetCharRange(char *buffer, Sci::Position position, Sci::Position lengthRetrieve) const;
|
||||
char StyleAt(Sci::Position position) const;
|
||||
void GetStyleRange(unsigned char *buffer, Sci::Position position, Sci::Position lengthRetrieve) const;
|
||||
const char *BufferPointer();
|
||||
const char *RangePointer(int position, int rangeLength);
|
||||
int GapPosition() const;
|
||||
const char *RangePointer(Sci::Position position, Sci::Position rangeLength);
|
||||
Sci::Position GapPosition() const;
|
||||
|
||||
int Length() const;
|
||||
void Allocate(int newSize);
|
||||
Sci::Position Length() const;
|
||||
void Allocate(Sci::Position newSize);
|
||||
int GetLineEndTypes() const { return utf8LineEnds; }
|
||||
void SetLineEndTypes(int utf8LineEnds_);
|
||||
bool ContainsLineEnd(const char *s, int length) const;
|
||||
bool ContainsLineEnd(const char *s, Sci::Position length) const;
|
||||
void SetPerLine(PerLine *pl);
|
||||
int Lines() const;
|
||||
int LineStart(int line) const;
|
||||
int LineFromPosition(int pos) const { return lv.LineFromPosition(pos); }
|
||||
void InsertLine(int line, int position, bool lineStart);
|
||||
void RemoveLine(int line);
|
||||
const char *InsertString(int position, const char *s, int insertLength, bool &startSequence);
|
||||
Sci::Line Lines() const;
|
||||
Sci::Position LineStart(Sci::Line line) const;
|
||||
Sci::Line LineFromPosition(Sci::Position pos) const { return lv.LineFromPosition(pos); }
|
||||
void InsertLine(Sci::Line line, Sci::Position position, bool lineStart);
|
||||
void RemoveLine(Sci::Line line);
|
||||
const char *InsertString(Sci::Position position, const char *s, Sci::Position insertLength, bool &startSequence);
|
||||
|
||||
/// Setting styles for positions outside the range of the buffer is safe and has no effect.
|
||||
/// @return true if the style of a character is changed.
|
||||
bool SetStyleAt(int position, char styleValue);
|
||||
bool SetStyleFor(int position, int length, char styleValue);
|
||||
bool SetStyleAt(Sci::Position position, char styleValue);
|
||||
bool SetStyleFor(Sci::Position position, Sci::Position lengthStyle, char styleValue);
|
||||
|
||||
const char *DeleteChars(int position, int deleteLength, bool &startSequence);
|
||||
const char *DeleteChars(Sci::Position position, Sci::Position deleteLength, bool &startSequence);
|
||||
|
||||
bool IsReadOnly() const;
|
||||
void SetReadOnly(bool set);
|
||||
|
@ -194,7 +205,7 @@ public:
|
|||
bool IsCollectingUndo() const;
|
||||
void BeginUndoAction();
|
||||
void EndUndoAction();
|
||||
void AddUndoAction(int token, bool mayCoalesce);
|
||||
void AddUndoAction(Sci::Position token, bool mayCoalesce);
|
||||
void DeleteUndoHistory();
|
||||
|
||||
/// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
// Copyright 2006 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <cstdlib>
|
||||
#include <cctype>
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
enum cc { ccSpace, ccNewLine, ccWord, ccPunctuation };
|
||||
void SetDefaultCharClasses(bool includeWordClass);
|
||||
void SetCharClasses(const unsigned char *chars, cc newCharClass);
|
||||
int GetCharsOfClass(cc charClass, unsigned char *buffer) const;
|
||||
int GetCharsOfClass(cc characterClass, unsigned char *buffer) const;
|
||||
cc GetClass(unsigned char ch) const { return static_cast<cc>(charClass[ch]);}
|
||||
bool IsWord(unsigned char ch) const { return static_cast<cc>(charClass[ch]) == ccWord;}
|
||||
|
||||
|
|
|
@ -5,15 +5,19 @@
|
|||
// Copyright 1998-2007 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <cstddef>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include "Position.h"
|
||||
#include "UniqueString.h"
|
||||
#include "SplitVector.h"
|
||||
#include "Partitioning.h"
|
||||
#include "RunStyles.h"
|
||||
|
@ -24,8 +28,7 @@
|
|||
using namespace Scintilla;
|
||||
#endif
|
||||
|
||||
ContractionState::ContractionState() : visible(0), expanded(0), heights(0), foldDisplayTexts(0), displayLines(0), linesInDocument(1) {
|
||||
//InsertLine(0);
|
||||
ContractionState::ContractionState() : linesInDocument(1) {
|
||||
}
|
||||
|
||||
ContractionState::~ContractionState() {
|
||||
|
@ -34,30 +37,25 @@ ContractionState::~ContractionState() {
|
|||
|
||||
void ContractionState::EnsureData() {
|
||||
if (OneToOne()) {
|
||||
visible = new RunStyles();
|
||||
expanded = new RunStyles();
|
||||
heights = new RunStyles();
|
||||
foldDisplayTexts = new SparseVector<const char *>();
|
||||
displayLines = new Partitioning(4);
|
||||
visible.reset(new RunStyles());
|
||||
expanded.reset(new RunStyles());
|
||||
heights.reset(new RunStyles());
|
||||
foldDisplayTexts.reset(new SparseVector<UniqueString>());
|
||||
displayLines.reset(new Partitioning(4));
|
||||
InsertLines(0, linesInDocument);
|
||||
}
|
||||
}
|
||||
|
||||
void ContractionState::Clear() {
|
||||
delete visible;
|
||||
visible = 0;
|
||||
delete expanded;
|
||||
expanded = 0;
|
||||
delete heights;
|
||||
heights = 0;
|
||||
delete foldDisplayTexts;
|
||||
foldDisplayTexts = 0;
|
||||
delete displayLines;
|
||||
displayLines = 0;
|
||||
visible.reset();
|
||||
expanded.reset();
|
||||
heights.reset();
|
||||
foldDisplayTexts.reset();
|
||||
displayLines.reset();
|
||||
linesInDocument = 1;
|
||||
}
|
||||
|
||||
int ContractionState::LinesInDoc() const {
|
||||
Sci::Line ContractionState::LinesInDoc() const {
|
||||
if (OneToOne()) {
|
||||
return linesInDocument;
|
||||
} else {
|
||||
|
@ -65,7 +63,7 @@ int ContractionState::LinesInDoc() const {
|
|||
}
|
||||
}
|
||||
|
||||
int ContractionState::LinesDisplayed() const {
|
||||
Sci::Line ContractionState::LinesDisplayed() const {
|
||||
if (OneToOne()) {
|
||||
return linesInDocument;
|
||||
} else {
|
||||
|
@ -73,7 +71,7 @@ int ContractionState::LinesDisplayed() const {
|
|||
}
|
||||
}
|
||||
|
||||
int ContractionState::DisplayFromDoc(int lineDoc) const {
|
||||
Sci::Line ContractionState::DisplayFromDoc(Sci::Line lineDoc) const {
|
||||
if (OneToOne()) {
|
||||
return (lineDoc <= linesInDocument) ? lineDoc : linesInDocument;
|
||||
} else {
|
||||
|
@ -83,11 +81,11 @@ int ContractionState::DisplayFromDoc(int lineDoc) const {
|
|||
}
|
||||
}
|
||||
|
||||
int ContractionState::DisplayLastFromDoc(int lineDoc) const {
|
||||
Sci::Line ContractionState::DisplayLastFromDoc(Sci::Line lineDoc) const {
|
||||
return DisplayFromDoc(lineDoc) + GetHeight(lineDoc) - 1;
|
||||
}
|
||||
|
||||
int ContractionState::DocFromDisplay(int lineDisplay) const {
|
||||
Sci::Line ContractionState::DocFromDisplay(Sci::Line lineDisplay) const {
|
||||
if (OneToOne()) {
|
||||
return lineDisplay;
|
||||
} else {
|
||||
|
@ -97,13 +95,13 @@ int ContractionState::DocFromDisplay(int lineDisplay) const {
|
|||
if (lineDisplay > LinesDisplayed()) {
|
||||
return displayLines->PartitionFromPosition(LinesDisplayed());
|
||||
}
|
||||
int lineDoc = displayLines->PartitionFromPosition(lineDisplay);
|
||||
Sci::Line lineDoc = displayLines->PartitionFromPosition(lineDisplay);
|
||||
PLATFORM_ASSERT(GetVisible(lineDoc));
|
||||
return lineDoc;
|
||||
}
|
||||
}
|
||||
|
||||
void ContractionState::InsertLine(int lineDoc) {
|
||||
void ContractionState::InsertLine(Sci::Line lineDoc) {
|
||||
if (OneToOne()) {
|
||||
linesInDocument++;
|
||||
} else {
|
||||
|
@ -114,21 +112,21 @@ void ContractionState::InsertLine(int lineDoc) {
|
|||
heights->InsertSpace(lineDoc, 1);
|
||||
heights->SetValueAt(lineDoc, 1);
|
||||
foldDisplayTexts->InsertSpace(lineDoc, 1);
|
||||
foldDisplayTexts->SetValueAt(lineDoc, NULL);
|
||||
int lineDisplay = DisplayFromDoc(lineDoc);
|
||||
foldDisplayTexts->SetValueAt(lineDoc, nullptr);
|
||||
Sci::Line lineDisplay = DisplayFromDoc(lineDoc);
|
||||
displayLines->InsertPartition(lineDoc, lineDisplay);
|
||||
displayLines->InsertText(lineDoc, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void ContractionState::InsertLines(int lineDoc, int lineCount) {
|
||||
void ContractionState::InsertLines(Sci::Line lineDoc, Sci::Line lineCount) {
|
||||
for (int l = 0; l < lineCount; l++) {
|
||||
InsertLine(lineDoc + l);
|
||||
}
|
||||
Check();
|
||||
}
|
||||
|
||||
void ContractionState::DeleteLine(int lineDoc) {
|
||||
void ContractionState::DeleteLine(Sci::Line lineDoc) {
|
||||
if (OneToOne()) {
|
||||
linesInDocument--;
|
||||
} else {
|
||||
|
@ -143,14 +141,14 @@ void ContractionState::DeleteLine(int lineDoc) {
|
|||
}
|
||||
}
|
||||
|
||||
void ContractionState::DeleteLines(int lineDoc, int lineCount) {
|
||||
for (int l = 0; l < lineCount; l++) {
|
||||
void ContractionState::DeleteLines(Sci::Line lineDoc, Sci::Line lineCount) {
|
||||
for (Sci::Line l = 0; l < lineCount; l++) {
|
||||
DeleteLine(lineDoc);
|
||||
}
|
||||
Check();
|
||||
}
|
||||
|
||||
bool ContractionState::GetVisible(int lineDoc) const {
|
||||
bool ContractionState::GetVisible(Sci::Line lineDoc) const {
|
||||
if (OneToOne()) {
|
||||
return true;
|
||||
} else {
|
||||
|
@ -160,15 +158,15 @@ bool ContractionState::GetVisible(int lineDoc) const {
|
|||
}
|
||||
}
|
||||
|
||||
bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool isVisible) {
|
||||
bool ContractionState::SetVisible(Sci::Line lineDocStart, Sci::Line lineDocEnd, bool isVisible) {
|
||||
if (OneToOne() && isVisible) {
|
||||
return false;
|
||||
} else {
|
||||
EnsureData();
|
||||
int delta = 0;
|
||||
Sci::Line delta = 0;
|
||||
Check();
|
||||
if ((lineDocStart <= lineDocEnd) && (lineDocStart >= 0) && (lineDocEnd < LinesInDoc())) {
|
||||
for (int line = lineDocStart; line <= lineDocEnd; line++) {
|
||||
for (Sci::Line line = lineDocStart; line <= lineDocEnd; line++) {
|
||||
if (GetVisible(line) != isVisible) {
|
||||
int difference = isVisible ? heights->ValueAt(line) : -heights->ValueAt(line);
|
||||
visible->SetValueAt(line, isVisible ? 1 : 0);
|
||||
|
@ -192,16 +190,16 @@ bool ContractionState::HiddenLines() const {
|
|||
}
|
||||
}
|
||||
|
||||
const char *ContractionState::GetFoldDisplayText(int lineDoc) const {
|
||||
const char *ContractionState::GetFoldDisplayText(Sci::Line lineDoc) const {
|
||||
Check();
|
||||
return foldDisplayTexts->ValueAt(lineDoc);
|
||||
return foldDisplayTexts->ValueAt(lineDoc).get();
|
||||
}
|
||||
|
||||
bool ContractionState::SetFoldDisplayText(int lineDoc, const char *text) {
|
||||
bool ContractionState::SetFoldDisplayText(Sci::Line lineDoc, const char *text) {
|
||||
EnsureData();
|
||||
const char *foldText = foldDisplayTexts->ValueAt(lineDoc);
|
||||
if (!foldText || 0 != strcmp(text, foldText)) {
|
||||
foldDisplayTexts->SetValueAt(lineDoc, text);
|
||||
const char *foldText = foldDisplayTexts->ValueAt(lineDoc).get();
|
||||
if (!foldText || !text || 0 != strcmp(text, foldText)) {
|
||||
foldDisplayTexts->SetValueAt(lineDoc, UniqueStringCopy(text));
|
||||
Check();
|
||||
return true;
|
||||
} else {
|
||||
|
@ -210,7 +208,7 @@ bool ContractionState::SetFoldDisplayText(int lineDoc, const char *text) {
|
|||
}
|
||||
}
|
||||
|
||||
bool ContractionState::GetExpanded(int lineDoc) const {
|
||||
bool ContractionState::GetExpanded(Sci::Line lineDoc) const {
|
||||
if (OneToOne()) {
|
||||
return true;
|
||||
} else {
|
||||
|
@ -219,7 +217,7 @@ bool ContractionState::GetExpanded(int lineDoc) const {
|
|||
}
|
||||
}
|
||||
|
||||
bool ContractionState::SetExpanded(int lineDoc, bool isExpanded) {
|
||||
bool ContractionState::SetExpanded(Sci::Line lineDoc, bool isExpanded) {
|
||||
if (OneToOne() && isExpanded) {
|
||||
return false;
|
||||
} else {
|
||||
|
@ -235,11 +233,11 @@ bool ContractionState::SetExpanded(int lineDoc, bool isExpanded) {
|
|||
}
|
||||
}
|
||||
|
||||
bool ContractionState::GetFoldDisplayTextShown(int lineDoc) const {
|
||||
bool ContractionState::GetFoldDisplayTextShown(Sci::Line lineDoc) const {
|
||||
return !GetExpanded(lineDoc) && GetFoldDisplayText(lineDoc);
|
||||
}
|
||||
|
||||
int ContractionState::ContractedNext(int lineDocStart) const {
|
||||
Sci::Line ContractionState::ContractedNext(Sci::Line lineDocStart) const {
|
||||
if (OneToOne()) {
|
||||
return -1;
|
||||
} else {
|
||||
|
@ -247,7 +245,7 @@ int ContractionState::ContractedNext(int lineDocStart) const {
|
|||
if (!expanded->ValueAt(lineDocStart)) {
|
||||
return lineDocStart;
|
||||
} else {
|
||||
int lineDocNextChange = expanded->EndRun(lineDocStart);
|
||||
Sci::Line lineDocNextChange = expanded->EndRun(lineDocStart);
|
||||
if (lineDocNextChange < LinesInDoc())
|
||||
return lineDocNextChange;
|
||||
else
|
||||
|
@ -256,7 +254,7 @@ int ContractionState::ContractedNext(int lineDocStart) const {
|
|||
}
|
||||
}
|
||||
|
||||
int ContractionState::GetHeight(int lineDoc) const {
|
||||
int ContractionState::GetHeight(Sci::Line lineDoc) const {
|
||||
if (OneToOne()) {
|
||||
return 1;
|
||||
} else {
|
||||
|
@ -266,7 +264,7 @@ int ContractionState::GetHeight(int lineDoc) const {
|
|||
|
||||
// Set the number of display lines needed for this line.
|
||||
// Return true if this is a change.
|
||||
bool ContractionState::SetHeight(int lineDoc, int height) {
|
||||
bool ContractionState::SetHeight(Sci::Line lineDoc, int height) {
|
||||
if (OneToOne() && (height == 1)) {
|
||||
return false;
|
||||
} else if (lineDoc < LinesInDoc()) {
|
||||
|
@ -288,7 +286,7 @@ bool ContractionState::SetHeight(int lineDoc, int height) {
|
|||
}
|
||||
|
||||
void ContractionState::ShowAll() {
|
||||
int lines = LinesInDoc();
|
||||
Sci::Line lines = LinesInDoc();
|
||||
Clear();
|
||||
linesInDocument = lines;
|
||||
}
|
||||
|
@ -297,14 +295,14 @@ void ContractionState::ShowAll() {
|
|||
|
||||
void ContractionState::Check() const {
|
||||
#ifdef CHECK_CORRECTNESS
|
||||
for (int vline = 0; vline < LinesDisplayed(); vline++) {
|
||||
const int lineDoc = DocFromDisplay(vline);
|
||||
for (Sci::Line vline = 0; vline < LinesDisplayed(); vline++) {
|
||||
const Sci::Line lineDoc = DocFromDisplay(vline);
|
||||
PLATFORM_ASSERT(GetVisible(lineDoc));
|
||||
}
|
||||
for (int lineDoc = 0; lineDoc < LinesInDoc(); lineDoc++) {
|
||||
const int displayThis = DisplayFromDoc(lineDoc);
|
||||
const int displayNext = DisplayFromDoc(lineDoc + 1);
|
||||
const int height = displayNext - displayThis;
|
||||
for (Sci::Line lineDoc = 0; lineDoc < LinesInDoc(); lineDoc++) {
|
||||
const Sci::Line displayThis = DisplayFromDoc(lineDoc);
|
||||
const Sci::Line displayNext = DisplayFromDoc(lineDoc + 1);
|
||||
const Sci::Line height = displayNext - displayThis;
|
||||
PLATFORM_ASSERT(height >= 0);
|
||||
if (GetVisible(lineDoc)) {
|
||||
PLATFORM_ASSERT(GetHeight(lineDoc) == height);
|
||||
|
|
|
@ -19,52 +19,55 @@ class SparseVector;
|
|||
*/
|
||||
class ContractionState {
|
||||
// These contain 1 element for every document line.
|
||||
RunStyles *visible;
|
||||
RunStyles *expanded;
|
||||
RunStyles *heights;
|
||||
SparseVector<const char *> *foldDisplayTexts;
|
||||
Partitioning *displayLines;
|
||||
int linesInDocument;
|
||||
std::unique_ptr<RunStyles> visible;
|
||||
std::unique_ptr<RunStyles> expanded;
|
||||
std::unique_ptr<RunStyles> heights;
|
||||
std::unique_ptr<SparseVector<UniqueString>> foldDisplayTexts;
|
||||
std::unique_ptr<Partitioning> displayLines;
|
||||
Sci::Line linesInDocument;
|
||||
|
||||
void EnsureData();
|
||||
|
||||
bool OneToOne() const {
|
||||
// True when each document line is exactly one display line so need for
|
||||
// complex data structures.
|
||||
return visible == 0;
|
||||
return visible == nullptr;
|
||||
}
|
||||
|
||||
public:
|
||||
ContractionState();
|
||||
// Deleted so ContractionState objects can not be copied.
|
||||
ContractionState(const ContractionState &) = delete;
|
||||
void operator=(const ContractionState &) = delete;
|
||||
virtual ~ContractionState();
|
||||
|
||||
void Clear();
|
||||
|
||||
int LinesInDoc() const;
|
||||
int LinesDisplayed() const;
|
||||
int DisplayFromDoc(int lineDoc) const;
|
||||
int DisplayLastFromDoc(int lineDoc) const;
|
||||
int DocFromDisplay(int lineDisplay) const;
|
||||
Sci::Line LinesInDoc() const;
|
||||
Sci::Line LinesDisplayed() const;
|
||||
Sci::Line DisplayFromDoc(Sci::Line lineDoc) const;
|
||||
Sci::Line DisplayLastFromDoc(Sci::Line lineDoc) const;
|
||||
Sci::Line DocFromDisplay(Sci::Line lineDisplay) const;
|
||||
|
||||
void InsertLine(int lineDoc);
|
||||
void InsertLines(int lineDoc, int lineCount);
|
||||
void DeleteLine(int lineDoc);
|
||||
void DeleteLines(int lineDoc, int lineCount);
|
||||
void InsertLine(Sci::Line lineDoc);
|
||||
void InsertLines(Sci::Line lineDoc, Sci::Line lineCount);
|
||||
void DeleteLine(Sci::Line lineDoc);
|
||||
void DeleteLines(Sci::Line lineDoc, Sci::Line lineCount);
|
||||
|
||||
bool GetVisible(int lineDoc) const;
|
||||
bool SetVisible(int lineDocStart, int lineDocEnd, bool isVisible);
|
||||
bool GetVisible(Sci::Line lineDoc) const;
|
||||
bool SetVisible(Sci::Line lineDocStart, Sci::Line lineDocEnd, bool isVisible);
|
||||
bool HiddenLines() const;
|
||||
|
||||
const char *GetFoldDisplayText(int lineDoc) const;
|
||||
bool SetFoldDisplayText(int lineDoc, const char *text);
|
||||
const char *GetFoldDisplayText(Sci::Line lineDoc) const;
|
||||
bool SetFoldDisplayText(Sci::Line lineDoc, const char *text);
|
||||
|
||||
bool GetExpanded(int lineDoc) const;
|
||||
bool SetExpanded(int lineDoc, bool isExpanded);
|
||||
bool GetFoldDisplayTextShown(int lineDoc) const;
|
||||
int ContractedNext(int lineDocStart) const;
|
||||
bool GetExpanded(Sci::Line lineDoc) const;
|
||||
bool SetExpanded(Sci::Line lineDoc, bool isExpanded);
|
||||
bool GetFoldDisplayTextShown(Sci::Line lineDoc) const;
|
||||
Sci::Line ContractedNext(Sci::Line lineDocStart) const;
|
||||
|
||||
int GetHeight(int lineDoc) const;
|
||||
bool SetHeight(int lineDoc, int height);
|
||||
int GetHeight(Sci::Line lineDoc) const;
|
||||
bool SetHeight(Sci::Line lineDoc, int height);
|
||||
|
||||
void ShowAll();
|
||||
void Check() const;
|
||||
|
|
|
@ -4,13 +4,16 @@
|
|||
// Copyright 1998-2007 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <cstdarg>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
|
@ -25,7 +28,7 @@
|
|||
using namespace Scintilla;
|
||||
#endif
|
||||
|
||||
Decoration::Decoration(int indicator_) : next(0), indicator(indicator_) {
|
||||
Decoration::Decoration(int indicator_) : indicator(indicator_) {
|
||||
}
|
||||
|
||||
Decoration::~Decoration() {
|
||||
|
@ -35,74 +38,48 @@ bool Decoration::Empty() const {
|
|||
return (rs.Runs() == 1) && (rs.AllSameAs(0));
|
||||
}
|
||||
|
||||
DecorationList::DecorationList() : currentIndicator(0), currentValue(1), current(0),
|
||||
lengthDocument(0), root(0), clickNotified(false) {
|
||||
DecorationList::DecorationList() : currentIndicator(0), currentValue(1), current(nullptr),
|
||||
lengthDocument(0), clickNotified(false) {
|
||||
}
|
||||
|
||||
DecorationList::~DecorationList() {
|
||||
Decoration *deco = root;
|
||||
while (deco) {
|
||||
Decoration *decoNext = deco->next;
|
||||
delete deco;
|
||||
deco = decoNext;
|
||||
}
|
||||
root = 0;
|
||||
current = 0;
|
||||
current = nullptr;
|
||||
}
|
||||
|
||||
Decoration *DecorationList::DecorationFromIndicator(int indicator) {
|
||||
for (Decoration *deco=root; deco; deco = deco->next) {
|
||||
if (deco->indicator == indicator) {
|
||||
return deco;
|
||||
for (const std::unique_ptr<Decoration> &deco : decorationList) {
|
||||
if (deco->Indicator() == indicator) {
|
||||
return deco.get();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Decoration *DecorationList::Create(int indicator, int length) {
|
||||
currentIndicator = indicator;
|
||||
Decoration *decoNew = new Decoration(indicator);
|
||||
std::unique_ptr<Decoration> decoNew(new Decoration(indicator));
|
||||
decoNew->rs.InsertSpace(0, length);
|
||||
|
||||
Decoration *decoPrev = 0;
|
||||
Decoration *deco = root;
|
||||
std::vector<std::unique_ptr<Decoration>>::iterator it = std::lower_bound(
|
||||
decorationList.begin(), decorationList.end(), decoNew,
|
||||
[](const std::unique_ptr<Decoration> &a, const std::unique_ptr<Decoration> &b) {
|
||||
return a->Indicator() < b->Indicator();
|
||||
});
|
||||
std::vector<std::unique_ptr<Decoration>>::iterator itAdded =
|
||||
decorationList.insert(it, std::move(decoNew));
|
||||
|
||||
while (deco && (deco->indicator < indicator)) {
|
||||
decoPrev = deco;
|
||||
deco = deco->next;
|
||||
}
|
||||
if (decoPrev == 0) {
|
||||
decoNew->next = root;
|
||||
root = decoNew;
|
||||
} else {
|
||||
decoNew->next = deco;
|
||||
decoPrev->next = decoNew;
|
||||
}
|
||||
return decoNew;
|
||||
SetView();
|
||||
|
||||
return itAdded->get();
|
||||
}
|
||||
|
||||
void DecorationList::Delete(int indicator) {
|
||||
Decoration *decoToDelete = 0;
|
||||
if (root) {
|
||||
if (root->indicator == indicator) {
|
||||
decoToDelete = root;
|
||||
root = root->next;
|
||||
} else {
|
||||
Decoration *deco=root;
|
||||
while (deco->next && !decoToDelete) {
|
||||
if (deco->next && deco->next->indicator == indicator) {
|
||||
decoToDelete = deco->next;
|
||||
deco->next = decoToDelete->next;
|
||||
} else {
|
||||
deco = deco->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (decoToDelete) {
|
||||
delete decoToDelete;
|
||||
current = 0;
|
||||
}
|
||||
decorationList.erase(std::remove_if(decorationList.begin(), decorationList.end(),
|
||||
[=](const std::unique_ptr<Decoration> &deco) {
|
||||
return deco->Indicator() == indicator;
|
||||
}), decorationList.end());
|
||||
current = nullptr;
|
||||
SetView();
|
||||
}
|
||||
|
||||
void DecorationList::SetCurrentIndicator(int indicator) {
|
||||
|
@ -122,7 +99,7 @@ bool DecorationList::FillRange(int &position, int value, int &fillLength) {
|
|||
current = Create(currentIndicator, lengthDocument);
|
||||
}
|
||||
}
|
||||
bool changed = current->rs.FillRange(position, value, fillLength);
|
||||
const bool changed = current->rs.FillRange(position, value, fillLength);
|
||||
if (current->Empty()) {
|
||||
Delete(currentIndicator);
|
||||
}
|
||||
|
@ -132,7 +109,7 @@ bool DecorationList::FillRange(int &position, int value, int &fillLength) {
|
|||
void DecorationList::InsertSpace(int position, int insertLength) {
|
||||
const bool atEnd = position == lengthDocument;
|
||||
lengthDocument += insertLength;
|
||||
for (Decoration *deco=root; deco; deco = deco->next) {
|
||||
for (const std::unique_ptr<Decoration> &deco : decorationList) {
|
||||
deco->rs.InsertSpace(position, insertLength);
|
||||
if (atEnd) {
|
||||
deco->rs.FillRange(position, 0, insertLength);
|
||||
|
@ -142,31 +119,50 @@ void DecorationList::InsertSpace(int position, int insertLength) {
|
|||
|
||||
void DecorationList::DeleteRange(int position, int deleteLength) {
|
||||
lengthDocument -= deleteLength;
|
||||
Decoration *deco;
|
||||
for (deco=root; deco; deco = deco->next) {
|
||||
for (const std::unique_ptr<Decoration> &deco : decorationList) {
|
||||
deco->rs.DeleteRange(position, deleteLength);
|
||||
}
|
||||
DeleteAnyEmpty();
|
||||
if (decorationList.size() != decorationView.size()) {
|
||||
// One or more empty decorations deleted so update view.
|
||||
current = nullptr;
|
||||
SetView();
|
||||
}
|
||||
}
|
||||
|
||||
void DecorationList::DeleteLexerDecorations() {
|
||||
decorationList.erase(std::remove_if(decorationList.begin(), decorationList.end(),
|
||||
[=](const std::unique_ptr<Decoration> &deco) {
|
||||
return deco->Indicator() < INDIC_CONTAINER;
|
||||
}), decorationList.end());
|
||||
current = nullptr;
|
||||
SetView();
|
||||
}
|
||||
|
||||
void DecorationList::DeleteAnyEmpty() {
|
||||
Decoration *deco = root;
|
||||
while (deco) {
|
||||
if ((lengthDocument == 0) || deco->Empty()) {
|
||||
Delete(deco->indicator);
|
||||
deco = root;
|
||||
} else {
|
||||
deco = deco->next;
|
||||
}
|
||||
if (lengthDocument == 0) {
|
||||
decorationList.clear();
|
||||
} else {
|
||||
decorationList.erase(std::remove_if(decorationList.begin(), decorationList.end(),
|
||||
[=](const std::unique_ptr<Decoration> &deco) {
|
||||
return deco->Empty();
|
||||
}), decorationList.end());
|
||||
}
|
||||
}
|
||||
|
||||
void DecorationList::SetView() {
|
||||
decorationView.clear();
|
||||
for (const std::unique_ptr<Decoration> &deco : decorationList) {
|
||||
decorationView.push_back(deco.get());
|
||||
}
|
||||
}
|
||||
|
||||
int DecorationList::AllOnFor(int position) const {
|
||||
int mask = 0;
|
||||
for (Decoration *deco=root; deco; deco = deco->next) {
|
||||
for (const std::unique_ptr<Decoration> &deco : decorationList) {
|
||||
if (deco->rs.ValueAt(position)) {
|
||||
if (deco->indicator < INDIC_IME) {
|
||||
mask |= 1 << deco->indicator;
|
||||
if (deco->Indicator() < INDIC_IME) {
|
||||
mask |= 1 << deco->Indicator();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -174,7 +170,7 @@ int DecorationList::AllOnFor(int position) const {
|
|||
}
|
||||
|
||||
int DecorationList::ValueAt(int indicator, int position) {
|
||||
Decoration *deco = DecorationFromIndicator(indicator);
|
||||
const Decoration *deco = DecorationFromIndicator(indicator);
|
||||
if (deco) {
|
||||
return deco->rs.ValueAt(position);
|
||||
}
|
||||
|
@ -182,7 +178,7 @@ int DecorationList::ValueAt(int indicator, int position) {
|
|||
}
|
||||
|
||||
int DecorationList::Start(int indicator, int position) {
|
||||
Decoration *deco = DecorationFromIndicator(indicator);
|
||||
const Decoration *deco = DecorationFromIndicator(indicator);
|
||||
if (deco) {
|
||||
return deco->rs.StartRun(position);
|
||||
}
|
||||
|
@ -190,7 +186,7 @@ int DecorationList::Start(int indicator, int position) {
|
|||
}
|
||||
|
||||
int DecorationList::End(int indicator, int position) {
|
||||
Decoration *deco = DecorationFromIndicator(indicator);
|
||||
const Decoration *deco = DecorationFromIndicator(indicator);
|
||||
if (deco) {
|
||||
return deco->rs.EndRun(position);
|
||||
}
|
||||
|
|
|
@ -12,33 +12,41 @@ namespace Scintilla {
|
|||
#endif
|
||||
|
||||
class Decoration {
|
||||
public:
|
||||
Decoration *next;
|
||||
RunStyles rs;
|
||||
int indicator;
|
||||
public:
|
||||
RunStyles rs;
|
||||
|
||||
explicit Decoration(int indicator_);
|
||||
~Decoration();
|
||||
|
||||
bool Empty() const;
|
||||
int Indicator() const {
|
||||
return indicator;
|
||||
}
|
||||
};
|
||||
|
||||
class DecorationList {
|
||||
int currentIndicator;
|
||||
int currentValue;
|
||||
Decoration *current;
|
||||
Decoration *current; // Cached so FillRange doesn't have to search for each call.
|
||||
int lengthDocument;
|
||||
// Ordered by indicator
|
||||
std::vector<std::unique_ptr<Decoration>> decorationList;
|
||||
std::vector<const Decoration*> decorationView; // Read-only view of decorationList
|
||||
bool clickNotified;
|
||||
|
||||
Decoration *DecorationFromIndicator(int indicator);
|
||||
Decoration *Create(int indicator, int length);
|
||||
void Delete(int indicator);
|
||||
void DeleteAnyEmpty();
|
||||
void SetView();
|
||||
public:
|
||||
Decoration *root;
|
||||
bool clickNotified;
|
||||
|
||||
DecorationList();
|
||||
~DecorationList();
|
||||
|
||||
const std::vector<const Decoration*> &View() const { return decorationView; }
|
||||
|
||||
void SetCurrentIndicator(int indicator);
|
||||
int GetCurrentIndicator() const { return currentIndicator; }
|
||||
|
||||
|
@ -51,10 +59,19 @@ public:
|
|||
void InsertSpace(int position, int insertLength);
|
||||
void DeleteRange(int position, int deleteLength);
|
||||
|
||||
void DeleteLexerDecorations();
|
||||
|
||||
int AllOnFor(int position) const;
|
||||
int ValueAt(int indicator, int position);
|
||||
int Start(int indicator, int position);
|
||||
int End(int indicator, int position);
|
||||
|
||||
bool ClickNotified() const {
|
||||
return clickNotified;
|
||||
}
|
||||
void SetClickNotified(bool notified) {
|
||||
clickNotified = notified;
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef SCI_NAMESPACE
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -12,13 +12,6 @@
|
|||
namespace Scintilla {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A Position is a position within a document between two characters or at the beginning or end.
|
||||
* Sometimes used as a character index where it identifies the character after the position.
|
||||
*/
|
||||
typedef int Position;
|
||||
const Position invalidPosition = -1;
|
||||
|
||||
enum EncodingFamily { efEightBit, efUnicode, efDBCS };
|
||||
|
||||
/**
|
||||
|
@ -29,13 +22,13 @@ enum EncodingFamily { efEightBit, efUnicode, efDBCS };
|
|||
*/
|
||||
class Range {
|
||||
public:
|
||||
Position start;
|
||||
Position end;
|
||||
Sci::Position start;
|
||||
Sci::Position end;
|
||||
|
||||
explicit Range(Position pos=0) :
|
||||
explicit Range(Sci::Position pos=0) :
|
||||
start(pos), end(pos) {
|
||||
}
|
||||
Range(Position start_, Position end_) :
|
||||
Range(Sci::Position start_, Sci::Position end_) :
|
||||
start(start_), end(end_) {
|
||||
}
|
||||
|
||||
|
@ -44,19 +37,19 @@ public:
|
|||
}
|
||||
|
||||
bool Valid() const {
|
||||
return (start != invalidPosition) && (end != invalidPosition);
|
||||
return (start != Sci::invalidPosition) && (end != Sci::invalidPosition);
|
||||
}
|
||||
|
||||
Position First() const {
|
||||
Sci::Position First() const {
|
||||
return (start <= end) ? start : end;
|
||||
}
|
||||
|
||||
Position Last() const {
|
||||
Sci::Position Last() const {
|
||||
return (start > end) ? start : end;
|
||||
}
|
||||
|
||||
// Is the position within the range?
|
||||
bool Contains(Position pos) const {
|
||||
bool Contains(Sci::Position pos) const {
|
||||
if (start < end) {
|
||||
return (pos >= start && pos <= end);
|
||||
} else {
|
||||
|
@ -65,7 +58,7 @@ public:
|
|||
}
|
||||
|
||||
// Is the character after pos within the range?
|
||||
bool ContainsCharacter(Position pos) const {
|
||||
bool ContainsCharacter(Sci::Position pos) const {
|
||||
if (start < end) {
|
||||
return (pos >= start && pos < end);
|
||||
} else {
|
||||
|
@ -97,11 +90,11 @@ class RegexSearchBase {
|
|||
public:
|
||||
virtual ~RegexSearchBase() {}
|
||||
|
||||
virtual long FindText(Document *doc, int minPos, int maxPos, const char *s,
|
||||
bool caseSensitive, bool word, bool wordStart, int flags, int *length) = 0;
|
||||
virtual long FindText(Document *doc, Sci::Position minPos, Sci::Position maxPos, const char *s,
|
||||
bool caseSensitive, bool word, bool wordStart, int flags, Sci::Position *length) = 0;
|
||||
|
||||
///@return String with the substitutions, must remain valid until the next call or destruction
|
||||
virtual const char *SubstituteByPosition(Document *doc, const char *text, int *length) = 0;
|
||||
virtual const char *SubstituteByPosition(Document *doc, const char *text, Sci::Position *length) = 0;
|
||||
};
|
||||
|
||||
/// Factory function for RegexSearchBase
|
||||
|
@ -142,34 +135,38 @@ public:
|
|||
firstChangeableLineAfter = -1;
|
||||
}
|
||||
|
||||
bool NeedsDrawing(int line) const {
|
||||
bool NeedsDrawing(Sci::Line line) const {
|
||||
return isEnabled && (line <= firstChangeableLineBefore || line >= firstChangeableLineAfter);
|
||||
}
|
||||
|
||||
bool IsFoldBlockHighlighted(int line) const {
|
||||
bool IsFoldBlockHighlighted(Sci::Line line) const {
|
||||
return isEnabled && beginFoldBlock != -1 && beginFoldBlock <= line && line <= endFoldBlock;
|
||||
}
|
||||
|
||||
bool IsHeadOfFoldBlock(int line) const {
|
||||
bool IsHeadOfFoldBlock(Sci::Line line) const {
|
||||
return beginFoldBlock == line && line < endFoldBlock;
|
||||
}
|
||||
|
||||
bool IsBodyOfFoldBlock(int line) const {
|
||||
bool IsBodyOfFoldBlock(Sci::Line line) const {
|
||||
return beginFoldBlock != -1 && beginFoldBlock < line && line < endFoldBlock;
|
||||
}
|
||||
|
||||
bool IsTailOfFoldBlock(int line) const {
|
||||
bool IsTailOfFoldBlock(Sci::Line line) const {
|
||||
return beginFoldBlock != -1 && beginFoldBlock < line && line == endFoldBlock;
|
||||
}
|
||||
|
||||
int beginFoldBlock; // Begin of current fold block
|
||||
int endFoldBlock; // End of current fold block
|
||||
int firstChangeableLineBefore; // First line that triggers repaint before starting line that determined current fold block
|
||||
int firstChangeableLineAfter; // First line that triggers repaint after starting line that determined current fold block
|
||||
Sci::Line beginFoldBlock; // Begin of current fold block
|
||||
Sci::Line endFoldBlock; // End of current fold block
|
||||
Sci::Line firstChangeableLineBefore; // First line that triggers repaint before starting line that determined current fold block
|
||||
Sci::Line firstChangeableLineAfter; // First line that triggers repaint after starting line that determined current fold block
|
||||
bool isEnabled;
|
||||
};
|
||||
|
||||
class Document;
|
||||
class LineMarkers;
|
||||
class LineLevels;
|
||||
class LineState;
|
||||
class LineAnnotation;
|
||||
|
||||
inline int LevelNumber(int level) {
|
||||
return level & SC_FOLDLEVELNUMBERMASK;
|
||||
|
@ -185,7 +182,7 @@ public:
|
|||
}
|
||||
virtual ~LexInterface() {
|
||||
}
|
||||
void Colourise(int start, int end);
|
||||
void Colourise(Sci::Position start, Sci::Position end);
|
||||
int LineEndTypesSupported();
|
||||
bool UseContainerLexing() const {
|
||||
return instance == 0;
|
||||
|
@ -217,8 +214,8 @@ private:
|
|||
int refCount;
|
||||
CellBuffer cb;
|
||||
CharClassify charClass;
|
||||
CaseFolder *pcf;
|
||||
int endStyled;
|
||||
std::unique_ptr<CaseFolder> pcf;
|
||||
Sci::Position endStyled;
|
||||
int styleClock;
|
||||
int enteredModification;
|
||||
int enteredStyling;
|
||||
|
@ -231,10 +228,16 @@ private:
|
|||
|
||||
// ldSize is not real data - it is for dimensions and loops
|
||||
enum lineData { ldMarkers, ldLevels, ldState, ldMargin, ldAnnotation, ldSize };
|
||||
PerLine *perLineData[ldSize];
|
||||
std::unique_ptr<PerLine> perLineData[ldSize];
|
||||
LineMarkers *Markers() const;
|
||||
LineLevels *Levels() const;
|
||||
LineState *States() const;
|
||||
LineAnnotation *Margins() const;
|
||||
LineAnnotation *Annotations() const;
|
||||
|
||||
bool matchesValid;
|
||||
RegexSearchBase *regex;
|
||||
std::unique_ptr<RegexSearchBase> regex;
|
||||
std::unique_ptr<LexInterface> pli;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -250,8 +253,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
LexInterface *pli;
|
||||
|
||||
int eolMode;
|
||||
/// Can also be SC_CP_UTF8 to enable UTF-8 mode
|
||||
int dbcsCodePage;
|
||||
|
@ -267,6 +268,9 @@ public:
|
|||
DecorationList decorations;
|
||||
|
||||
Document();
|
||||
// Deleted so Document objects can not be copied.
|
||||
Document(const Document &) = delete;
|
||||
void operator=(const Document &) = delete;
|
||||
virtual ~Document();
|
||||
|
||||
int AddRef();
|
||||
|
@ -278,8 +282,8 @@ public:
|
|||
int GetLineEndTypesAllowed() const { return cb.GetLineEndTypes(); }
|
||||
bool SetLineEndTypesAllowed(int lineEndBitSet_);
|
||||
int GetLineEndTypesActive() const { return cb.GetLineEndTypes(); }
|
||||
virtual void InsertLine(int line);
|
||||
virtual void RemoveLine(int line);
|
||||
virtual void InsertLine(Sci::Line line);
|
||||
virtual void RemoveLine(Sci::Line line);
|
||||
|
||||
int SCI_METHOD Version() const {
|
||||
return dvLineEnd;
|
||||
|
@ -288,18 +292,18 @@ public:
|
|||
void SCI_METHOD SetErrorStatus(int status);
|
||||
|
||||
Sci_Position SCI_METHOD LineFromPosition(Sci_Position pos) const;
|
||||
int ClampPositionIntoDocument(int pos) const;
|
||||
bool ContainsLineEnd(const char *s, int length) const { return cb.ContainsLineEnd(s, length); }
|
||||
bool IsCrLf(int pos) const;
|
||||
int LenChar(int pos);
|
||||
bool InGoodUTF8(int pos, int &start, int &end) const;
|
||||
int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true) const;
|
||||
int NextPosition(int pos, int moveDir) const;
|
||||
bool NextCharacter(int &pos, int moveDir) const; // Returns true if pos changed
|
||||
Document::CharacterExtracted CharacterAfter(int position) const;
|
||||
Document::CharacterExtracted CharacterBefore(int position) const;
|
||||
Sci::Position ClampPositionIntoDocument(Sci::Position pos) const;
|
||||
bool ContainsLineEnd(const char *s, Sci::Position length) const { return cb.ContainsLineEnd(s, length); }
|
||||
bool IsCrLf(Sci::Position pos) const;
|
||||
int LenChar(Sci::Position pos);
|
||||
bool InGoodUTF8(Sci::Position pos, Sci::Position &start, Sci::Position &end) const;
|
||||
Sci::Position MovePositionOutsideChar(Sci::Position pos, Sci::Position moveDir, bool checkLineEnd=true) const;
|
||||
Sci::Position NextPosition(Sci::Position pos, int moveDir) const;
|
||||
bool NextCharacter(Sci::Position &pos, int moveDir) const; // Returns true if pos changed
|
||||
Document::CharacterExtracted CharacterAfter(Sci::Position position) const;
|
||||
Document::CharacterExtracted CharacterBefore(Sci::Position position) const;
|
||||
Sci_Position SCI_METHOD GetRelativePosition(Sci_Position positionStart, Sci_Position characterOffset) const;
|
||||
int GetRelativePositionUTF16(int positionStart, int characterOffset) const;
|
||||
Sci::Position GetRelativePositionUTF16(Sci::Position positionStart, Sci::Position characterOffset) const;
|
||||
int SCI_METHOD GetCharacterAndWidth(Sci_Position position, Sci_Position *pWidth) const;
|
||||
int SCI_METHOD CodePage() const;
|
||||
bool SCI_METHOD IsDBCSLeadByte(char ch) const;
|
||||
|
@ -307,15 +311,15 @@ public:
|
|||
EncodingFamily CodePageFamily() const;
|
||||
|
||||
// Gateways to modifying document
|
||||
void ModifiedAt(int pos);
|
||||
void ModifiedAt(Sci::Position pos);
|
||||
void CheckReadOnly();
|
||||
bool DeleteChars(int pos, int len);
|
||||
int InsertString(int position, const char *s, int insertLength);
|
||||
void ChangeInsertion(const char *s, int length);
|
||||
bool DeleteChars(Sci::Position pos, Sci::Position len);
|
||||
Sci::Position InsertString(Sci::Position position, const char *s, Sci::Position insertLength);
|
||||
void ChangeInsertion(const char *s, Sci::Position length);
|
||||
int SCI_METHOD AddData(char *data, Sci_Position length);
|
||||
void * SCI_METHOD ConvertToDocument();
|
||||
int Undo();
|
||||
int Redo();
|
||||
Sci::Position Undo();
|
||||
Sci::Position Redo();
|
||||
bool CanUndo() const { return cb.CanUndo(); }
|
||||
bool CanRedo() const { return cb.CanRedo(); }
|
||||
void DeleteUndoHistory() { cb.DeleteUndoHistory(); }
|
||||
|
@ -325,7 +329,7 @@ public:
|
|||
bool IsCollectingUndo() const { return cb.IsCollectingUndo(); }
|
||||
void BeginUndoAction() { cb.BeginUndoAction(); }
|
||||
void EndUndoAction() { cb.EndUndoAction(); }
|
||||
void AddUndoAction(int token, bool mayCoalesce) { cb.AddUndoAction(token, mayCoalesce); }
|
||||
void AddUndoAction(Sci::Position token, bool mayCoalesce) { cb.AddUndoAction(token, mayCoalesce); }
|
||||
void SetSavePoint();
|
||||
bool IsSavePoint() const { return cb.IsSavePoint(); }
|
||||
|
||||
|
@ -335,76 +339,75 @@ public:
|
|||
bool TentativeActive() const { return cb.TentativeActive(); }
|
||||
|
||||
const char * SCI_METHOD BufferPointer() { return cb.BufferPointer(); }
|
||||
const char *RangePointer(int position, int rangeLength) { return cb.RangePointer(position, rangeLength); }
|
||||
int GapPosition() const { return cb.GapPosition(); }
|
||||
const char *RangePointer(Sci::Position position, Sci::Position rangeLength) { return cb.RangePointer(position, rangeLength); }
|
||||
Sci::Position GapPosition() const { return cb.GapPosition(); }
|
||||
|
||||
int SCI_METHOD GetLineIndentation(Sci_Position line);
|
||||
int SetLineIndentation(int line, int indent);
|
||||
int GetLineIndentPosition(int line) const;
|
||||
int GetColumn(int position);
|
||||
int CountCharacters(int startPos, int endPos) const;
|
||||
int CountUTF16(int startPos, int endPos) const;
|
||||
int FindColumn(int line, int column);
|
||||
void Indent(bool forwards, int lineBottom, int lineTop);
|
||||
Sci::Position SetLineIndentation(Sci::Line line, Sci::Position indent);
|
||||
Sci::Position GetLineIndentPosition(Sci::Line line) const;
|
||||
Sci::Position GetColumn(Sci::Position pos);
|
||||
Sci::Position CountCharacters(Sci::Position startPos, Sci::Position endPos) const;
|
||||
Sci::Position CountUTF16(Sci::Position startPos, Sci::Position endPos) const;
|
||||
Sci::Position FindColumn(Sci::Line line, Sci::Position column);
|
||||
void Indent(bool forwards, Sci::Line lineBottom, Sci::Line lineTop);
|
||||
static std::string TransformLineEnds(const char *s, size_t len, int eolModeWanted);
|
||||
void ConvertLineEnds(int eolModeSet);
|
||||
void SetReadOnly(bool set) { cb.SetReadOnly(set); }
|
||||
bool IsReadOnly() const { return cb.IsReadOnly(); }
|
||||
|
||||
void DelChar(int pos);
|
||||
void DelCharBack(int pos);
|
||||
void DelChar(Sci::Position pos);
|
||||
void DelCharBack(Sci::Position pos);
|
||||
|
||||
char CharAt(int position) const { return cb.CharAt(position); }
|
||||
char CharAt(Sci::Position position) const { return cb.CharAt(position); }
|
||||
void SCI_METHOD GetCharRange(char *buffer, Sci_Position position, Sci_Position lengthRetrieve) const {
|
||||
cb.GetCharRange(buffer, position, lengthRetrieve);
|
||||
}
|
||||
char SCI_METHOD StyleAt(Sci_Position position) const { return cb.StyleAt(position); }
|
||||
int StyleIndexAt(Sci_Position position) const { return static_cast<unsigned char>(cb.StyleAt(position)); }
|
||||
void GetStyleRange(unsigned char *buffer, int position, int lengthRetrieve) const {
|
||||
void GetStyleRange(unsigned char *buffer, Sci::Position position, Sci::Position lengthRetrieve) const {
|
||||
cb.GetStyleRange(buffer, position, lengthRetrieve);
|
||||
}
|
||||
int GetMark(int line);
|
||||
int MarkerNext(int lineStart, int mask) const;
|
||||
int AddMark(int line, int markerNum);
|
||||
void AddMarkSet(int line, int valueSet);
|
||||
void DeleteMark(int line, int markerNum);
|
||||
int GetMark(Sci::Line line) const;
|
||||
Sci::Line MarkerNext(Sci::Line lineStart, int mask) const;
|
||||
int AddMark(Sci::Line line, int markerNum);
|
||||
void AddMarkSet(Sci::Line line, int valueSet);
|
||||
void DeleteMark(Sci::Line line, int markerNum);
|
||||
void DeleteMarkFromHandle(int markerHandle);
|
||||
void DeleteAllMarks(int markerNum);
|
||||
int LineFromHandle(int markerHandle);
|
||||
Sci::Line LineFromHandle(int markerHandle) const;
|
||||
Sci_Position SCI_METHOD LineStart(Sci_Position line) const;
|
||||
bool IsLineStartPosition(int position) const;
|
||||
bool IsLineStartPosition(Sci::Position position) const;
|
||||
Sci_Position SCI_METHOD LineEnd(Sci_Position line) const;
|
||||
int LineEndPosition(int position) const;
|
||||
bool IsLineEndPosition(int position) const;
|
||||
bool IsPositionInLineEnd(int position) const;
|
||||
int VCHomePosition(int position) const;
|
||||
Sci::Position LineEndPosition(Sci::Position position) const;
|
||||
bool IsLineEndPosition(Sci::Position position) const;
|
||||
bool IsPositionInLineEnd(Sci::Position position) const;
|
||||
Sci::Position VCHomePosition(Sci::Position position) const;
|
||||
|
||||
int SCI_METHOD SetLevel(Sci_Position line, int level);
|
||||
int SCI_METHOD GetLevel(Sci_Position line) const;
|
||||
void ClearLevels();
|
||||
int GetLastChild(int lineParent, int level=-1, int lastLine=-1);
|
||||
int GetFoldParent(int line) const;
|
||||
void GetHighlightDelimiters(HighlightDelimiter &hDelimiter, int line, int lastLine);
|
||||
Sci::Line GetLastChild(Sci::Line lineParent, int level=-1, Sci::Line lastLine=-1);
|
||||
Sci::Line GetFoldParent(Sci::Line line) const;
|
||||
void GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, Sci::Line line, Sci::Line lastLine);
|
||||
|
||||
void Indent(bool forwards);
|
||||
int ExtendWordSelect(int pos, int delta, bool onlyWordCharacters=false) const;
|
||||
int NextWordStart(int pos, int delta) const;
|
||||
int NextWordEnd(int pos, int delta) const;
|
||||
Sci::Position ExtendWordSelect(Sci::Position pos, int delta, bool onlyWordCharacters=false) const;
|
||||
Sci::Position NextWordStart(Sci::Position pos, int delta) const;
|
||||
Sci::Position NextWordEnd(Sci::Position pos, int delta) const;
|
||||
Sci_Position SCI_METHOD Length() const { return cb.Length(); }
|
||||
void Allocate(int newSize) { cb.Allocate(newSize); }
|
||||
void Allocate(Sci::Position newSize) { cb.Allocate(newSize); }
|
||||
|
||||
CharacterExtracted ExtractCharacter(int position) const;
|
||||
CharacterExtracted ExtractCharacter(Sci::Position position) const;
|
||||
|
||||
bool IsWordStartAt(int pos) const;
|
||||
bool IsWordEndAt(int pos) const;
|
||||
bool IsWordAt(int start, int end) const;
|
||||
bool IsWordStartAt(Sci::Position pos) const;
|
||||
bool IsWordEndAt(Sci::Position pos) const;
|
||||
bool IsWordAt(Sci::Position start, Sci::Position end) const;
|
||||
|
||||
bool MatchesWordOptions(bool word, bool wordStart, int pos, int length) const;
|
||||
bool MatchesWordOptions(bool word, bool wordStart, Sci::Position pos, Sci::Position length) const;
|
||||
bool HasCaseFolder() const;
|
||||
void SetCaseFolder(CaseFolder *pcf_);
|
||||
long FindText(int minPos, int maxPos, const char *search, int flags, int *length);
|
||||
const char *SubstituteByPosition(const char *text, int *length);
|
||||
int LinesTotal() const;
|
||||
long FindText(Sci::Position minPos, Sci::Position maxPos, const char *search, int flags, Sci::Position *length);
|
||||
const char *SubstituteByPosition(const char *text, Sci::Position *length);
|
||||
Sci::Line LinesTotal() const;
|
||||
|
||||
void SetDefaultCharClasses(bool includeWordClass);
|
||||
void SetCharClasses(const unsigned char *chars, CharClassify::cc newCharClass);
|
||||
|
@ -412,33 +415,33 @@ public:
|
|||
void SCI_METHOD StartStyling(Sci_Position position, char mask);
|
||||
bool SCI_METHOD SetStyleFor(Sci_Position length, char style);
|
||||
bool SCI_METHOD SetStyles(Sci_Position length, const char *styles);
|
||||
int GetEndStyled() const { return endStyled; }
|
||||
void EnsureStyledTo(int pos);
|
||||
void StyleToAdjustingLineDuration(int pos);
|
||||
Sci::Position GetEndStyled() const { return endStyled; }
|
||||
void EnsureStyledTo(Sci::Position pos);
|
||||
void StyleToAdjustingLineDuration(Sci::Position pos);
|
||||
void LexerChanged();
|
||||
int GetStyleClock() const { return styleClock; }
|
||||
void IncrementStyleClock();
|
||||
void SCI_METHOD DecorationSetCurrentIndicator(int indicator) {
|
||||
decorations.SetCurrentIndicator(indicator);
|
||||
}
|
||||
void SCI_METHOD DecorationSetCurrentIndicator(int indicator);
|
||||
void SCI_METHOD DecorationFillRange(Sci_Position position, int value, Sci_Position fillLength);
|
||||
LexInterface *GetLexInterface() const;
|
||||
void SetLexInterface(LexInterface *pLexInterface);
|
||||
|
||||
int SCI_METHOD SetLineState(Sci_Position line, int state);
|
||||
int SCI_METHOD GetLineState(Sci_Position line) const;
|
||||
int GetMaxLineState();
|
||||
Sci::Line GetMaxLineState() const;
|
||||
void SCI_METHOD ChangeLexerState(Sci_Position start, Sci_Position end);
|
||||
|
||||
StyledText MarginStyledText(int line) const;
|
||||
void MarginSetStyle(int line, int style);
|
||||
void MarginSetStyles(int line, const unsigned char *styles);
|
||||
void MarginSetText(int line, const char *text);
|
||||
StyledText MarginStyledText(Sci::Line line) const;
|
||||
void MarginSetStyle(Sci::Line line, int style);
|
||||
void MarginSetStyles(Sci::Line line, const unsigned char *styles);
|
||||
void MarginSetText(Sci::Line line, const char *text);
|
||||
void MarginClearAll();
|
||||
|
||||
StyledText AnnotationStyledText(int line) const;
|
||||
void AnnotationSetText(int line, const char *text);
|
||||
void AnnotationSetStyle(int line, int style);
|
||||
void AnnotationSetStyles(int line, const unsigned char *styles);
|
||||
int AnnotationLines(int line) const;
|
||||
StyledText AnnotationStyledText(Sci::Line line) const;
|
||||
void AnnotationSetText(Sci::Line line, const char *text);
|
||||
void AnnotationSetStyle(Sci::Line line, int style);
|
||||
void AnnotationSetStyles(Sci::Line line, const unsigned char *styles);
|
||||
int AnnotationLines(Sci::Line line) const;
|
||||
void AnnotationClearAll();
|
||||
|
||||
bool AddWatcher(DocWatcher *watcher, void *userData);
|
||||
|
@ -447,14 +450,14 @@ public:
|
|||
bool IsASCIIWordByte(unsigned char ch) const;
|
||||
CharClassify::cc WordCharacterClass(unsigned int ch) const;
|
||||
bool IsWordPartSeparator(unsigned int ch) const;
|
||||
int WordPartLeft(int pos) const;
|
||||
int WordPartRight(int pos) const;
|
||||
int ExtendStyleRange(int pos, int delta, bool singleLine = false);
|
||||
bool IsWhiteLine(int line) const;
|
||||
int ParaUp(int pos) const;
|
||||
int ParaDown(int pos) const;
|
||||
Sci::Position WordPartLeft(Sci::Position pos) const;
|
||||
Sci::Position WordPartRight(Sci::Position pos) const;
|
||||
Sci::Position ExtendStyleRange(Sci::Position pos, int delta, bool singleLine = false);
|
||||
bool IsWhiteLine(Sci::Line line) const;
|
||||
Sci::Position ParaUp(Sci::Position pos) const;
|
||||
Sci::Position ParaDown(Sci::Position pos) const;
|
||||
int IndentSize() const { return actualIndentInChars; }
|
||||
int BraceMatch(int position, int maxReStyle);
|
||||
Sci::Position BraceMatch(Sci::Position position, Sci::Position maxReStyle);
|
||||
|
||||
private:
|
||||
void NotifyModifyAttempt();
|
||||
|
@ -491,18 +494,18 @@ public:
|
|||
class DocModification {
|
||||
public:
|
||||
int modificationType;
|
||||
int position;
|
||||
int length;
|
||||
int linesAdded; /**< Negative if lines deleted. */
|
||||
Sci::Position position;
|
||||
Sci::Position length;
|
||||
Sci::Line linesAdded; /**< Negative if lines deleted. */
|
||||
const char *text; /**< Only valid for changes to text, not for changes to style. */
|
||||
int line;
|
||||
Sci::Line line;
|
||||
int foldLevelNow;
|
||||
int foldLevelPrev;
|
||||
int annotationLinesAdded;
|
||||
int token;
|
||||
Sci::Line annotationLinesAdded;
|
||||
Sci::Position token;
|
||||
|
||||
DocModification(int modificationType_, int position_=0, int length_=0,
|
||||
int linesAdded_=0, const char *text_=0, int line_=0) :
|
||||
DocModification(int modificationType_, Sci::Position position_=0, Sci::Position length_=0,
|
||||
Sci::Line linesAdded_=0, const char *text_=0, Sci::Line line_=0) :
|
||||
modificationType(modificationType_),
|
||||
position(position_),
|
||||
length(length_),
|
||||
|
@ -514,12 +517,12 @@ public:
|
|||
annotationLinesAdded(0),
|
||||
token(0) {}
|
||||
|
||||
DocModification(int modificationType_, const Action &act, int linesAdded_=0) :
|
||||
DocModification(int modificationType_, const Action &act, Sci::Line linesAdded_=0) :
|
||||
modificationType(modificationType_),
|
||||
position(act.position),
|
||||
length(act.lenData),
|
||||
linesAdded(linesAdded_),
|
||||
text(act.data),
|
||||
text(act.data.get()),
|
||||
line(0),
|
||||
foldLevelNow(0),
|
||||
foldLevelPrev(0),
|
||||
|
@ -539,7 +542,7 @@ public:
|
|||
virtual void NotifySavePoint(Document *doc, void *userData, bool atSavePoint) = 0;
|
||||
virtual void NotifyModified(Document *doc, DocModification mh, void *userData) = 0;
|
||||
virtual void NotifyDeleted(Document *doc, void *userData) = 0;
|
||||
virtual void NotifyStyleNeeded(Document *doc, void *userData, int endPos) = 0;
|
||||
virtual void NotifyStyleNeeded(Document *doc, void *userData, Sci::Position endPos) = 0;
|
||||
virtual void NotifyLexerChanged(Document *doc, void *userData) = 0;
|
||||
virtual void NotifyErrorOccurred(Document *doc, void *userData, int status) = 0;
|
||||
};
|
||||
|
|
|
@ -5,12 +5,11 @@
|
|||
// Copyright 1998-2014 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <cmath>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
@ -26,6 +25,7 @@
|
|||
|
||||
#include "StringCopy.h"
|
||||
#include "Position.h"
|
||||
#include "UniqueString.h"
|
||||
#include "SplitVector.h"
|
||||
#include "Partitioning.h"
|
||||
#include "RunStyles.h"
|
||||
|
@ -57,17 +57,17 @@ EditModel::EditModel() {
|
|||
inOverstrike = false;
|
||||
xOffset = 0;
|
||||
trackLineWidth = false;
|
||||
posDrag = SelectionPosition(invalidPosition);
|
||||
braces[0] = invalidPosition;
|
||||
braces[1] = invalidPosition;
|
||||
posDrag = SelectionPosition(Sci::invalidPosition);
|
||||
braces[0] = Sci::invalidPosition;
|
||||
braces[1] = Sci::invalidPosition;
|
||||
bracesMatchStyle = STYLE_BRACEBAD;
|
||||
highlightGuideColumn = 0;
|
||||
primarySelection = true;
|
||||
imeInteraction = imeWindowed;
|
||||
foldFlags = 0;
|
||||
foldDisplayTextStyle = SC_FOLDDISPLAYTEXT_HIDDEN;
|
||||
hotspot = Range(invalidPosition);
|
||||
hoverIndicatorPos = invalidPosition;
|
||||
hotspot = Range(Sci::invalidPosition);
|
||||
hoverIndicatorPos = Sci::invalidPosition;
|
||||
wrapWidth = LineLayout::wrapWidthInfinite;
|
||||
pdoc = new Document();
|
||||
pdoc->AddRef();
|
||||
|
|
|
@ -24,10 +24,6 @@ public:
|
|||
};
|
||||
|
||||
class EditModel {
|
||||
// Private so EditModel objects can not be copied
|
||||
explicit EditModel(const EditModel &);
|
||||
EditModel &operator=(const EditModel &);
|
||||
|
||||
public:
|
||||
bool inOverstrike;
|
||||
int xOffset; ///< Horizontal scrolled amount in pixels
|
||||
|
@ -36,7 +32,7 @@ public:
|
|||
SpecialRepresentations reprs;
|
||||
Caret caret;
|
||||
SelectionPosition posDrag;
|
||||
Position braces[2];
|
||||
Sci::Position braces[2];
|
||||
int bracesMatchStyle;
|
||||
int highlightGuideColumn;
|
||||
Selection sel;
|
||||
|
@ -49,7 +45,7 @@ public:
|
|||
ContractionState cs;
|
||||
// Hotspot support
|
||||
Range hotspot;
|
||||
int hoverIndicatorPos;
|
||||
Sci::Position hoverIndicatorPos;
|
||||
|
||||
// Wrapping support
|
||||
int wrapWidth;
|
||||
|
@ -57,10 +53,13 @@ public:
|
|||
Document *pdoc;
|
||||
|
||||
EditModel();
|
||||
// Deleted so EditModel objects can not be copied.
|
||||
explicit EditModel(const EditModel &) = delete;
|
||||
EditModel &operator=(const EditModel &) = delete;
|
||||
virtual ~EditModel();
|
||||
virtual int TopLineOfMain() const = 0;
|
||||
virtual Sci::Line TopLineOfMain() const = 0;
|
||||
virtual Point GetVisibleOriginInMain() const = 0;
|
||||
virtual int LinesOnScreen() const = 0;
|
||||
virtual Sci::Line LinesOnScreen() const = 0;
|
||||
virtual Range GetHotSpotRange() const = 0;
|
||||
};
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -50,7 +50,7 @@ typedef void (*DrawTabArrowFn)(Surface *surface, PRectangle rcTab, int ymid);
|
|||
class EditView {
|
||||
public:
|
||||
PrintParameters printParameters;
|
||||
PerLine *ldTabstops;
|
||||
std::unique_ptr<PerLine> ldTabstops;
|
||||
int tabWidthMinimumPixels;
|
||||
|
||||
bool hideSelection;
|
||||
|
@ -74,9 +74,9 @@ public:
|
|||
|
||||
bool imeCaretBlockOverride;
|
||||
|
||||
Surface *pixmapLine;
|
||||
Surface *pixmapIndentGuide;
|
||||
Surface *pixmapIndentGuideHighlight;
|
||||
std::unique_ptr<Surface> pixmapLine;
|
||||
std::unique_ptr<Surface> pixmapIndentGuide;
|
||||
std::unique_ptr<Surface> pixmapIndentGuideHighlight;
|
||||
|
||||
LineLayoutCache llc;
|
||||
PositionCache posCache;
|
||||
|
@ -90,6 +90,9 @@ public:
|
|||
DrawWrapMarkerFn customDrawWrapMarker;
|
||||
|
||||
EditView();
|
||||
// Deleted so EditView objects can not be copied.
|
||||
EditView(const EditView &) = delete;
|
||||
void operator=(const EditView &) = delete;
|
||||
virtual ~EditView();
|
||||
|
||||
bool SetTwoPhaseDraw(bool twoPhaseDraw);
|
||||
|
@ -97,53 +100,53 @@ public:
|
|||
bool LinesOverlap() const;
|
||||
|
||||
void ClearAllTabstops();
|
||||
XYPOSITION NextTabstopPos(int line, XYPOSITION x, XYPOSITION tabWidth) const;
|
||||
bool ClearTabstops(int line);
|
||||
bool AddTabstop(int line, int x);
|
||||
int GetNextTabstop(int line, int x) const;
|
||||
void LinesAddedOrRemoved(int lineOfPos, int linesAdded);
|
||||
XYPOSITION NextTabstopPos(Sci::Line line, XYPOSITION x, XYPOSITION tabWidth) const;
|
||||
bool ClearTabstops(Sci::Line line);
|
||||
bool AddTabstop(Sci::Line line, int x);
|
||||
int GetNextTabstop(Sci::Line line, int x) const;
|
||||
void LinesAddedOrRemoved(Sci::Line lineOfPos, Sci::Line linesAdded);
|
||||
|
||||
void DropGraphics(bool freeObjects);
|
||||
void AllocateGraphics(const ViewStyle &vsDraw);
|
||||
void RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const ViewStyle &vsDraw);
|
||||
|
||||
LineLayout *RetrieveLineLayout(int lineNumber, const EditModel &model);
|
||||
void LayoutLine(const EditModel &model, int line, Surface *surface, const ViewStyle &vstyle,
|
||||
LineLayout *RetrieveLineLayout(Sci::Line lineNumber, const EditModel &model);
|
||||
void LayoutLine(const EditModel &model, Sci::Line line, Surface *surface, const ViewStyle &vstyle,
|
||||
LineLayout *ll, int width = LineLayout::wrapWidthInfinite);
|
||||
|
||||
Point LocationFromPosition(Surface *surface, const EditModel &model, SelectionPosition pos, int topLine,
|
||||
Point LocationFromPosition(Surface *surface, const EditModel &model, SelectionPosition pos, Sci::Line topLine,
|
||||
const ViewStyle &vs, PointEnd pe);
|
||||
Range RangeDisplayLine(Surface *surface, const EditModel &model, int lineVisible, const ViewStyle &vs);
|
||||
Range RangeDisplayLine(Surface *surface, const EditModel &model, Sci::Line lineVisible, const ViewStyle &vs);
|
||||
SelectionPosition SPositionFromLocation(Surface *surface, const EditModel &model, PointDocument pt, bool canReturnInvalid,
|
||||
bool charPosition, bool virtualSpace, const ViewStyle &vs);
|
||||
SelectionPosition SPositionFromLineX(Surface *surface, const EditModel &model, int lineDoc, int x, const ViewStyle &vs);
|
||||
int DisplayFromPosition(Surface *surface, const EditModel &model, int pos, const ViewStyle &vs);
|
||||
int StartEndDisplayLine(Surface *surface, const EditModel &model, int pos, bool start, const ViewStyle &vs);
|
||||
SelectionPosition SPositionFromLineX(Surface *surface, const EditModel &model, Sci::Line lineDoc, int x, const ViewStyle &vs);
|
||||
Sci::Line DisplayFromPosition(Surface *surface, const EditModel &model, Sci::Position pos, const ViewStyle &vs);
|
||||
Sci::Position StartEndDisplayLine(Surface *surface, const EditModel &model, Sci::Position pos, bool start, const ViewStyle &vs);
|
||||
|
||||
void DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, int start, PRectangle rcSegment, bool highlight);
|
||||
void DrawIndentGuide(Surface *surface, Sci::Line lineVisible, int lineHeight, Sci::Position start, PRectangle rcSegment, bool highlight);
|
||||
void DrawEOL(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, PRectangle rcLine,
|
||||
int line, int lineEnd, int xStart, int subLine, XYACCUMULATOR subLineStart,
|
||||
Sci::Line line, Sci::Position lineEnd, int xStart, int subLine, XYACCUMULATOR subLineStart,
|
||||
ColourOptional background);
|
||||
void DrawFoldDisplayText(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
|
||||
int line, int xStart, PRectangle rcLine, int subLine, XYACCUMULATOR subLineStart, DrawPhase phase);
|
||||
Sci::Line line, int xStart, PRectangle rcLine, int subLine, XYACCUMULATOR subLineStart, DrawPhase phase);
|
||||
void DrawAnnotation(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
|
||||
int line, int xStart, PRectangle rcLine, int subLine, DrawPhase phase);
|
||||
void DrawCarets(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, int line,
|
||||
Sci::Line line, int xStart, PRectangle rcLine, int subLine, DrawPhase phase);
|
||||
void DrawCarets(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, Sci::Line lineDoc,
|
||||
int xStart, PRectangle rcLine, int subLine) const;
|
||||
void DrawBackground(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, PRectangle rcLine,
|
||||
Range lineRange, int posLineStart, int xStart,
|
||||
Range lineRange, Sci::Position posLineStart, int xStart,
|
||||
int subLine, ColourOptional background) const;
|
||||
void DrawForeground(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, int lineVisible,
|
||||
PRectangle rcLine, Range lineRange, int posLineStart, int xStart,
|
||||
void DrawForeground(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, Sci::Line lineVisible,
|
||||
PRectangle rcLine, Range lineRange, Sci::Position posLineStart, int xStart,
|
||||
int subLine, ColourOptional background);
|
||||
void DrawIndentGuidesOverEmpty(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
|
||||
int line, int lineVisible, PRectangle rcLine, int xStart, int subLine);
|
||||
void DrawLine(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, int line,
|
||||
int lineVisible, int xStart, PRectangle rcLine, int subLine, DrawPhase phase);
|
||||
Sci::Line line, Sci::Line lineVisible, PRectangle rcLine, int xStart, int subLine);
|
||||
void DrawLine(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll, Sci::Line line,
|
||||
Sci::Line lineVisible, int xStart, PRectangle rcLine, int subLine, DrawPhase phase);
|
||||
void PaintText(Surface *surfaceWindow, const EditModel &model, PRectangle rcArea, PRectangle rcClient,
|
||||
const ViewStyle &vsDraw);
|
||||
void FillLineRemainder(Surface *surface, const EditModel &model, const ViewStyle &vsDraw, const LineLayout *ll,
|
||||
int line, PRectangle rcArea, int subLine) const;
|
||||
Sci::Line line, PRectangle rcArea, int subLine) const;
|
||||
long FormatRange(bool draw, Sci_RangeToFormat *pfr, Surface *surface, Surface *surfaceMeasure,
|
||||
const EditModel &model, const ViewStyle &vs);
|
||||
};
|
||||
|
@ -154,9 +157,10 @@ public:
|
|||
class AutoLineLayout {
|
||||
LineLayoutCache &llc;
|
||||
LineLayout *ll;
|
||||
AutoLineLayout &operator=(const AutoLineLayout &);
|
||||
public:
|
||||
AutoLineLayout(LineLayoutCache &llc_, LineLayout *ll_) : llc(llc_), ll(ll_) {}
|
||||
explicit AutoLineLayout(const AutoLineLayout &) = delete;
|
||||
AutoLineLayout &operator=(const AutoLineLayout &) = delete;
|
||||
~AutoLineLayout() {
|
||||
llc.Dispose(ll);
|
||||
ll = 0;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -47,14 +47,14 @@ public:
|
|||
workUpdateUI=2
|
||||
};
|
||||
enum workItems items;
|
||||
Position upTo;
|
||||
Sci::Position upTo;
|
||||
|
||||
WorkNeeded() : items(workNone), upTo(0) {}
|
||||
void Reset() {
|
||||
items = workNone;
|
||||
upTo = 0;
|
||||
}
|
||||
void Need(workItems items_, Position pos) {
|
||||
void Need(workItems items_, Sci::Position pos) {
|
||||
if ((items_ & workStyle) && (upTo < pos))
|
||||
upTo = pos;
|
||||
items = static_cast<workItems>(items | items_);
|
||||
|
@ -115,8 +115,8 @@ private:
|
|||
struct WrapPending {
|
||||
// The range of lines that need to be wrapped
|
||||
enum { lineLarge = 0x7ffffff };
|
||||
int start; // When there are wraps pending, will be in document range
|
||||
int end; // May be lineLarge to indicate all of document after start
|
||||
Sci::Line start; // When there are wraps pending, will be in document range
|
||||
Sci::Line end; // May be lineLarge to indicate all of document after start
|
||||
WrapPending() {
|
||||
start = lineLarge;
|
||||
end = lineLarge;
|
||||
|
@ -125,14 +125,14 @@ struct WrapPending {
|
|||
start = lineLarge;
|
||||
end = lineLarge;
|
||||
}
|
||||
void Wrapped(int line) {
|
||||
void Wrapped(Sci::Line line) {
|
||||
if (start == line)
|
||||
start++;
|
||||
}
|
||||
bool NeedsWrap() const {
|
||||
return start < end;
|
||||
}
|
||||
bool AddRange(int lineStart, int lineEnd) {
|
||||
bool AddRange(Sci::Line lineStart, Sci::Line lineEnd) {
|
||||
const bool neededWrap = NeedsWrap();
|
||||
bool changed = false;
|
||||
if (start > lineStart) {
|
||||
|
@ -150,10 +150,6 @@ struct WrapPending {
|
|||
/**
|
||||
*/
|
||||
class Editor : public EditModel, public DocWatcher {
|
||||
// Private so Editor objects can not be copied
|
||||
explicit Editor(const Editor &);
|
||||
Editor &operator=(const Editor &);
|
||||
|
||||
protected: // ScintillaBase subclass needs access to much of Editor
|
||||
|
||||
/** On GTK+, Scintilla is a container widget holding two scroll bars
|
||||
|
@ -211,19 +207,19 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
|||
enum { ddNone, ddInitial, ddDragging } inDragDrop;
|
||||
bool dropWentOutside;
|
||||
SelectionPosition posDrop;
|
||||
int hotSpotClickPos;
|
||||
Sci::Position hotSpotClickPos;
|
||||
int lastXChosen;
|
||||
int lineAnchorPos;
|
||||
int originalAnchorPos;
|
||||
int wordSelectAnchorStartPos;
|
||||
int wordSelectAnchorEndPos;
|
||||
int wordSelectInitialCaretPos;
|
||||
int targetStart;
|
||||
int targetEnd;
|
||||
Sci::Position lineAnchorPos;
|
||||
Sci::Position originalAnchorPos;
|
||||
Sci::Position wordSelectAnchorStartPos;
|
||||
Sci::Position wordSelectAnchorEndPos;
|
||||
Sci::Position wordSelectInitialCaretPos;
|
||||
Sci::Position targetStart;
|
||||
Sci::Position targetEnd;
|
||||
int searchFlags;
|
||||
int topLine;
|
||||
int posTopLine;
|
||||
int lengthForEncode;
|
||||
Sci::Line topLine;
|
||||
Sci::Position posTopLine;
|
||||
Sci::Position lengthForEncode;
|
||||
|
||||
int needUpdateUI;
|
||||
|
||||
|
@ -249,7 +245,7 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
|||
int visiblePolicy;
|
||||
int visibleSlop;
|
||||
|
||||
int searchAnchor;
|
||||
Sci::Position searchAnchor;
|
||||
|
||||
bool recordingMacro;
|
||||
|
||||
|
@ -261,7 +257,10 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
|||
bool convertPastes;
|
||||
|
||||
Editor();
|
||||
virtual ~Editor();
|
||||
// Deleted so Editor objects can not be copied.
|
||||
explicit Editor(const Editor &) = delete;
|
||||
Editor &operator=(const Editor &) = delete;
|
||||
~Editor() override;
|
||||
virtual void Initialise() = 0;
|
||||
virtual void Finalise();
|
||||
|
||||
|
@ -274,40 +273,40 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
|||
|
||||
// The top left visible point in main window coordinates. Will be 0,0 except for
|
||||
// scroll views where it will be equivalent to the current scroll position.
|
||||
virtual Point GetVisibleOriginInMain() const;
|
||||
virtual Point GetVisibleOriginInMain() const override;
|
||||
PointDocument DocumentPointFromView(Point ptView) const; // Convert a point from view space to document
|
||||
int TopLineOfMain() const; // Return the line at Main's y coordinate 0
|
||||
Sci::Line TopLineOfMain() const override; // Return the line at Main's y coordinate 0
|
||||
virtual PRectangle GetClientRectangle() const;
|
||||
virtual PRectangle GetClientDrawingRectangle();
|
||||
PRectangle GetTextRectangle() const;
|
||||
|
||||
virtual int LinesOnScreen() const;
|
||||
int LinesToScroll() const;
|
||||
int MaxScrollPos() const;
|
||||
virtual Sci::Line LinesOnScreen() const override;
|
||||
Sci::Line LinesToScroll() const;
|
||||
Sci::Line MaxScrollPos() const;
|
||||
SelectionPosition ClampPositionIntoDocument(SelectionPosition sp) const;
|
||||
Point LocationFromPosition(SelectionPosition pos, PointEnd pe=peDefault);
|
||||
Point LocationFromPosition(int pos, PointEnd pe=peDefault);
|
||||
int XFromPosition(int pos);
|
||||
Point LocationFromPosition(Sci::Position pos, PointEnd pe=peDefault);
|
||||
int XFromPosition(Sci::Position pos);
|
||||
int XFromPosition(SelectionPosition sp);
|
||||
SelectionPosition SPositionFromLocation(Point pt, bool canReturnInvalid=false, bool charPosition=false, bool virtualSpace=true);
|
||||
int PositionFromLocation(Point pt, bool canReturnInvalid = false, bool charPosition = false);
|
||||
SelectionPosition SPositionFromLineX(int lineDoc, int x);
|
||||
int PositionFromLineX(int line, int x);
|
||||
int LineFromLocation(Point pt) const;
|
||||
void SetTopLine(int topLineNew);
|
||||
Sci::Position PositionFromLocation(Point pt, bool canReturnInvalid = false, bool charPosition = false);
|
||||
SelectionPosition SPositionFromLineX(Sci::Line lineDoc, int x);
|
||||
Sci::Position PositionFromLineX(Sci::Line lineDoc, int x);
|
||||
Sci::Line LineFromLocation(Point pt) const;
|
||||
void SetTopLine(Sci::Line topLineNew);
|
||||
|
||||
virtual bool AbandonPaint();
|
||||
virtual void RedrawRect(PRectangle rc);
|
||||
virtual void DiscardOverdraw();
|
||||
virtual void Redraw();
|
||||
void RedrawSelMargin(int line=-1, bool allAfter=false);
|
||||
void RedrawSelMargin(Sci::Line line=-1, bool allAfter=false);
|
||||
PRectangle RectangleFromRange(Range r, int overlap);
|
||||
void InvalidateRange(int start, int end);
|
||||
void InvalidateRange(Sci::Position start, Sci::Position end);
|
||||
|
||||
bool UserVirtualSpace() const {
|
||||
return ((virtualSpaceOptions & SCVS_USERACCESSIBLE) != 0);
|
||||
}
|
||||
int CurrentPosition() const;
|
||||
Sci::Position CurrentPosition() const;
|
||||
bool SelectionEmpty() const;
|
||||
SelectionPosition SelectionStart();
|
||||
SelectionPosition SelectionEnd();
|
||||
|
@ -316,39 +315,39 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
|||
void InvalidateSelection(SelectionRange newMain, bool invalidateWholeSelection=false);
|
||||
void InvalidateWholeSelection();
|
||||
void SetSelection(SelectionPosition currentPos_, SelectionPosition anchor_);
|
||||
void SetSelection(int currentPos_, int anchor_);
|
||||
void SetSelection(Sci::Position currentPos_, Sci::Position anchor_);
|
||||
void SetSelection(SelectionPosition currentPos_);
|
||||
void SetSelection(int currentPos_);
|
||||
void SetEmptySelection(SelectionPosition currentPos_);
|
||||
void SetEmptySelection(int currentPos_);
|
||||
void SetEmptySelection(Sci::Position currentPos_);
|
||||
enum AddNumber { addOne, addEach };
|
||||
void MultipleSelectAdd(AddNumber addNumber);
|
||||
bool RangeContainsProtected(int start, int end) const;
|
||||
bool RangeContainsProtected(Sci::Position start, Sci::Position end) const;
|
||||
bool SelectionContainsProtected();
|
||||
int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true) const;
|
||||
SelectionPosition MovePositionOutsideChar(SelectionPosition pos, int moveDir, bool checkLineEnd=true) const;
|
||||
Sci::Position MovePositionOutsideChar(Sci::Position pos, Sci::Position moveDir, bool checkLineEnd=true) const;
|
||||
SelectionPosition MovePositionOutsideChar(SelectionPosition pos, Sci::Position moveDir, bool checkLineEnd=true) const;
|
||||
void MovedCaret(SelectionPosition newPos, SelectionPosition previousPos, bool ensureVisible);
|
||||
void MovePositionTo(SelectionPosition newPos, Selection::selTypes selt=Selection::noSel, bool ensureVisible=true);
|
||||
void MovePositionTo(int newPos, Selection::selTypes selt=Selection::noSel, bool ensureVisible=true);
|
||||
void MovePositionTo(Sci::Position newPos, Selection::selTypes selt=Selection::noSel, bool ensureVisible=true);
|
||||
SelectionPosition MovePositionSoVisible(SelectionPosition pos, int moveDir);
|
||||
SelectionPosition MovePositionSoVisible(int pos, int moveDir);
|
||||
SelectionPosition MovePositionSoVisible(Sci::Position pos, int moveDir);
|
||||
Point PointMainCaret();
|
||||
void SetLastXChosen();
|
||||
|
||||
void ScrollTo(int line, bool moveThumb=true);
|
||||
virtual void ScrollText(int linesToMove);
|
||||
void ScrollTo(Sci::Line line, bool moveThumb=true);
|
||||
virtual void ScrollText(Sci::Line linesToMove);
|
||||
void HorizontalScrollTo(int xPos);
|
||||
void VerticalCentreCaret();
|
||||
void MoveSelectedLines(int lineDelta);
|
||||
void MoveSelectedLinesUp();
|
||||
void MoveSelectedLinesDown();
|
||||
void MoveCaretInsideView(bool ensureVisible=true);
|
||||
int DisplayFromPosition(int pos);
|
||||
Sci::Line DisplayFromPosition(Sci::Position pos);
|
||||
|
||||
struct XYScrollPosition {
|
||||
int xOffset;
|
||||
int topLine;
|
||||
XYScrollPosition(int xOffset_, int topLine_) : xOffset(xOffset_), topLine(topLine_) {}
|
||||
Sci::Line topLine;
|
||||
XYScrollPosition(int xOffset_, Sci::Line topLine_) : xOffset(xOffset_), topLine(topLine_) {}
|
||||
bool operator==(const XYScrollPosition &other) const {
|
||||
return (xOffset == other.xOffset) && (topLine == other.topLine);
|
||||
}
|
||||
|
@ -370,14 +369,14 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
|||
virtual void UpdateSystemCaret();
|
||||
|
||||
bool Wrapping() const;
|
||||
void NeedWrapping(int docLineStart=0, int docLineEnd=WrapPending::lineLarge);
|
||||
bool WrapOneLine(Surface *surface, int lineToWrap);
|
||||
enum wrapScope {wsAll, wsVisible, wsIdle};
|
||||
bool WrapLines(enum wrapScope ws);
|
||||
void NeedWrapping(Sci::Line docLineStart=0, Sci::Line docLineEnd=WrapPending::lineLarge);
|
||||
bool WrapOneLine(Surface *surface, Sci::Line lineToWrap);
|
||||
enum class WrapScope {wsAll, wsVisible, wsIdle};
|
||||
bool WrapLines(WrapScope ws);
|
||||
void LinesJoin();
|
||||
void LinesSplit(int pixelWidth);
|
||||
|
||||
void PaintSelMargin(Surface *surface, PRectangle &rc);
|
||||
void PaintSelMargin(Surface *surfaceWindow, PRectangle &rc);
|
||||
void RefreshPixMaps(Surface *surfaceWindow);
|
||||
void Paint(Surface *surfaceWindow, PRectangle rcArea);
|
||||
long FormatRange(bool draw, Sci_RangeToFormat *pfr);
|
||||
|
@ -385,13 +384,13 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
|||
|
||||
virtual void SetVerticalScrollPos() = 0;
|
||||
virtual void SetHorizontalScrollPos() = 0;
|
||||
virtual bool ModifyScrollBars(int nMax, int nPage) = 0;
|
||||
virtual bool ModifyScrollBars(Sci::Line nMax, Sci::Line nPage) = 0;
|
||||
virtual void ReconfigureScrollBars();
|
||||
void SetScrollBars();
|
||||
void ChangeSize();
|
||||
|
||||
void FilterSelections();
|
||||
int RealizeVirtualSpace(int position, unsigned int virtualSpace);
|
||||
Sci::Position RealizeVirtualSpace(Sci::Position position, Sci::Position virtualSpace);
|
||||
SelectionPosition RealizeVirtualSpace(const SelectionPosition &position);
|
||||
void AddChar(char ch);
|
||||
virtual void AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS=false);
|
||||
|
@ -402,16 +401,16 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
|||
void ClearSelection(bool retainMultipleSelections = false);
|
||||
void ClearAll();
|
||||
void ClearDocumentStyle();
|
||||
void Cut();
|
||||
void PasteRectangular(SelectionPosition pos, const char *ptr, int len);
|
||||
virtual void Cut();
|
||||
void PasteRectangular(SelectionPosition pos, const char *ptr, Sci::Position len);
|
||||
virtual void Copy() = 0;
|
||||
virtual void CopyAllowLine();
|
||||
virtual bool CanPaste();
|
||||
virtual void Paste() = 0;
|
||||
void Clear();
|
||||
void SelectAll();
|
||||
void Undo();
|
||||
void Redo();
|
||||
virtual void SelectAll();
|
||||
virtual void Undo();
|
||||
virtual void Redo();
|
||||
void DelCharBack(bool allowLineStartDeletion);
|
||||
virtual void ClaimSelection() = 0;
|
||||
|
||||
|
@ -421,37 +420,37 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
|||
virtual void SetCtrlID(int identifier);
|
||||
virtual int GetCtrlID() { return ctrlID; }
|
||||
virtual void NotifyParent(SCNotification scn) = 0;
|
||||
virtual void NotifyStyleToNeeded(int endStyleNeeded);
|
||||
virtual void NotifyStyleToNeeded(Sci::Position endStyleNeeded);
|
||||
void NotifyChar(int ch);
|
||||
void NotifySavePoint(bool isSavePoint);
|
||||
void NotifyModifyAttempt();
|
||||
virtual void NotifyDoubleClick(Point pt, int modifiers);
|
||||
virtual void NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt);
|
||||
void NotifyHotSpotClicked(int position, int modifiers);
|
||||
void NotifyHotSpotClicked(int position, bool shift, bool ctrl, bool alt);
|
||||
void NotifyHotSpotDoubleClicked(int position, int modifiers);
|
||||
void NotifyHotSpotDoubleClicked(int position, bool shift, bool ctrl, bool alt);
|
||||
void NotifyHotSpotReleaseClick(int position, int modifiers);
|
||||
void NotifyHotSpotReleaseClick(int position, bool shift, bool ctrl, bool alt);
|
||||
void NotifyHotSpotClicked(Sci::Position position, int modifiers);
|
||||
void NotifyHotSpotClicked(Sci::Position position, bool shift, bool ctrl, bool alt);
|
||||
void NotifyHotSpotDoubleClicked(Sci::Position position, int modifiers);
|
||||
void NotifyHotSpotDoubleClicked(Sci::Position position, bool shift, bool ctrl, bool alt);
|
||||
void NotifyHotSpotReleaseClick(Sci::Position position, int modifiers);
|
||||
void NotifyHotSpotReleaseClick(Sci::Position position, bool shift, bool ctrl, bool alt);
|
||||
bool NotifyUpdateUI();
|
||||
void NotifyPainted();
|
||||
void NotifyIndicatorClick(bool click, int position, int modifiers);
|
||||
void NotifyIndicatorClick(bool click, int position, bool shift, bool ctrl, bool alt);
|
||||
void NotifyIndicatorClick(bool click, Sci::Position position, int modifiers);
|
||||
void NotifyIndicatorClick(bool click, Sci::Position position, bool shift, bool ctrl, bool alt);
|
||||
bool NotifyMarginClick(Point pt, int modifiers);
|
||||
bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt);
|
||||
bool NotifyMarginRightClick(Point pt, int modifiers);
|
||||
void NotifyNeedShown(int pos, int len);
|
||||
void NotifyNeedShown(Sci::Position pos, Sci::Position len);
|
||||
void NotifyDwelling(Point pt, bool state);
|
||||
void NotifyZoom();
|
||||
|
||||
void NotifyModifyAttempt(Document *document, void *userData);
|
||||
void NotifySavePoint(Document *document, void *userData, bool atSavePoint);
|
||||
void NotifyModifyAttempt(Document *document, void *userData) override;
|
||||
void NotifySavePoint(Document *document, void *userData, bool atSavePoint) override;
|
||||
void CheckModificationForWrap(DocModification mh);
|
||||
void NotifyModified(Document *document, DocModification mh, void *userData);
|
||||
void NotifyDeleted(Document *document, void *userData);
|
||||
void NotifyStyleNeeded(Document *doc, void *userData, int endPos);
|
||||
void NotifyLexerChanged(Document *doc, void *userData);
|
||||
void NotifyErrorOccurred(Document *doc, void *userData, int status);
|
||||
void NotifyModified(Document *document, DocModification mh, void *userData) override;
|
||||
void NotifyDeleted(Document *document, void *userData) override;
|
||||
void NotifyStyleNeeded(Document *doc, void *userData, Sci::Position endStyleNeeded) override;
|
||||
void NotifyLexerChanged(Document *doc, void *userData) override;
|
||||
void NotifyErrorOccurred(Document *doc, void *userData, int status) override;
|
||||
void NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
|
||||
|
||||
void ContainerNeedsUpdate(int flags);
|
||||
|
@ -460,17 +459,18 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
|||
virtual std::string CaseMapString(const std::string &s, int caseMapping);
|
||||
void ChangeCaseOfSelection(int caseMapping);
|
||||
void LineTranspose();
|
||||
void LineReverse();
|
||||
void Duplicate(bool forLine);
|
||||
virtual void CancelModes();
|
||||
void NewLine();
|
||||
SelectionPosition PositionUpOrDown(SelectionPosition spStart, int direction, int lastX);
|
||||
void CursorUpOrDown(int direction, Selection::selTypes selt);
|
||||
void ParaUpOrDown(int direction, Selection::selTypes selt);
|
||||
Range RangeDisplayLine(int lineVisible);
|
||||
int StartEndDisplayLine(int pos, bool start);
|
||||
int VCHomeDisplayPosition(int position);
|
||||
int VCHomeWrapPosition(int position);
|
||||
int LineEndWrapPosition(int position);
|
||||
Range RangeDisplayLine(Sci::Line lineVisible);
|
||||
Sci::Position StartEndDisplayLine(Sci::Position pos, bool start);
|
||||
Sci::Position VCHomeDisplayPosition(Sci::Position position);
|
||||
Sci::Position VCHomeWrapPosition(Sci::Position position);
|
||||
Sci::Position LineEndWrapPosition(Sci::Position position);
|
||||
int HorizontalMove(unsigned int iMessage);
|
||||
int DelWordOrLine(unsigned int iMessage);
|
||||
virtual int KeyCommand(unsigned int iMessage);
|
||||
|
@ -484,13 +484,13 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
|||
long FindText(uptr_t wParam, sptr_t lParam);
|
||||
void SearchAnchor();
|
||||
long SearchText(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
|
||||
long SearchInTarget(const char *text, int length);
|
||||
void GoToLine(int lineNo);
|
||||
long SearchInTarget(const char *text, Sci::Position length);
|
||||
void GoToLine(Sci::Line lineNo);
|
||||
|
||||
virtual void CopyToClipboard(const SelectionText &selectedText) = 0;
|
||||
std::string RangeText(int start, int end) const;
|
||||
std::string RangeText(Sci::Position start, Sci::Position end) const;
|
||||
void CopySelectionRange(SelectionText *ss, bool allowLineCopy=false);
|
||||
void CopyRangeToClipboard(int start, int end);
|
||||
void CopyRangeToClipboard(Sci::Position start, Sci::Position end);
|
||||
void CopyText(int length, const char *text);
|
||||
void SetDragPosition(SelectionPosition newPos);
|
||||
virtual void DisplayCursor(Window::Cursor c);
|
||||
|
@ -499,13 +499,13 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
|||
void DropAt(SelectionPosition position, const char *value, size_t lengthValue, bool moving, bool rectangular);
|
||||
void DropAt(SelectionPosition position, const char *value, bool moving, bool rectangular);
|
||||
/** PositionInSelection returns true if position in selection. */
|
||||
bool PositionInSelection(int pos);
|
||||
bool PositionInSelection(Sci::Position pos);
|
||||
bool PointInSelection(Point pt);
|
||||
bool PointInSelMargin(Point pt) const;
|
||||
Window::Cursor GetMarginCursor(Point pt) const;
|
||||
void TrimAndSetSelection(int currentPos_, int anchor_);
|
||||
void LineSelection(int lineCurrentPos_, int lineAnchorPos_, bool wholeLine);
|
||||
void WordSelection(int pos);
|
||||
void TrimAndSetSelection(Sci::Position currentPos_, Sci::Position anchor_);
|
||||
void LineSelection(Sci::Position lineCurrentPos_, Sci::Position lineAnchorPos_, bool wholeLine);
|
||||
void WordSelection(Sci::Position pos);
|
||||
void DwellEnd(bool mouseMoved);
|
||||
void MouseLeave();
|
||||
virtual void ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers);
|
||||
|
@ -529,49 +529,49 @@ protected: // ScintillaBase subclass needs access to much of Editor
|
|||
virtual bool HaveMouseCapture() = 0;
|
||||
void SetFocusState(bool focusState);
|
||||
|
||||
int PositionAfterArea(PRectangle rcArea) const;
|
||||
void StyleToPositionInView(Position pos);
|
||||
int PositionAfterMaxStyling(int posMax, bool scrolling) const;
|
||||
Sci::Position PositionAfterArea(PRectangle rcArea) const;
|
||||
void StyleToPositionInView(Sci::Position pos);
|
||||
Sci::Position PositionAfterMaxStyling(Sci::Position posMax, bool scrolling) const;
|
||||
void StartIdleStyling(bool truncatedLastStyling);
|
||||
void StyleAreaBounded(PRectangle rcArea, bool scrolling);
|
||||
void IdleStyling();
|
||||
virtual void IdleWork();
|
||||
virtual void QueueIdleWork(WorkNeeded::workItems items, int upTo=0);
|
||||
virtual void QueueIdleWork(WorkNeeded::workItems items, Sci::Position upTo=0);
|
||||
|
||||
virtual bool PaintContains(PRectangle rc);
|
||||
bool PaintContainsMargin();
|
||||
void CheckForChangeOutsidePaint(Range r);
|
||||
void SetBraceHighlight(Position pos0, Position pos1, int matchStyle);
|
||||
void SetBraceHighlight(Sci::Position pos0, Sci::Position pos1, int matchStyle);
|
||||
|
||||
void SetAnnotationHeights(int start, int end);
|
||||
void SetAnnotationHeights(Sci::Line start, Sci::Line end);
|
||||
virtual void SetDocPointer(Document *document);
|
||||
|
||||
void SetAnnotationVisible(int visible);
|
||||
|
||||
int ExpandLine(int line);
|
||||
void SetFoldExpanded(int lineDoc, bool expanded);
|
||||
void FoldLine(int line, int action);
|
||||
void FoldExpand(int line, int action, int level);
|
||||
int ContractedFoldNext(int lineStart) const;
|
||||
void EnsureLineVisible(int lineDoc, bool enforcePolicy);
|
||||
void FoldChanged(int line, int levelNow, int levelPrev);
|
||||
void NeedShown(int pos, int len);
|
||||
Sci::Line ExpandLine(Sci::Line line);
|
||||
void SetFoldExpanded(Sci::Line lineDoc, bool expanded);
|
||||
void FoldLine(Sci::Line line, int action);
|
||||
void FoldExpand(Sci::Line line, int action, int level);
|
||||
Sci::Line ContractedFoldNext(Sci::Line lineStart) const;
|
||||
void EnsureLineVisible(Sci::Line lineDoc, bool enforcePolicy);
|
||||
void FoldChanged(Sci::Line line, int levelNow, int levelPrev);
|
||||
void NeedShown(Sci::Position pos, Sci::Position len);
|
||||
void FoldAll(int action);
|
||||
|
||||
int GetTag(char *tagValue, int tagNumber);
|
||||
int ReplaceTarget(bool replacePatterns, const char *text, int length=-1);
|
||||
Sci::Position GetTag(char *tagValue, int tagNumber);
|
||||
Sci::Position ReplaceTarget(bool replacePatterns, const char *text, Sci::Position length=-1);
|
||||
|
||||
bool PositionIsHotspot(int position) const;
|
||||
bool PositionIsHotspot(Sci::Position position) const;
|
||||
bool PointIsHotspot(Point pt);
|
||||
void SetHotSpotRange(Point *pt);
|
||||
Range GetHotSpotRange() const;
|
||||
void SetHoverIndicatorPosition(int position);
|
||||
Range GetHotSpotRange() const override;
|
||||
void SetHoverIndicatorPosition(Sci::Position position);
|
||||
void SetHoverIndicatorPoint(Point pt);
|
||||
|
||||
int CodePage() const;
|
||||
virtual bool ValidCodePage(int /* codePage */) const { return true; }
|
||||
int WrapCount(int line);
|
||||
void AddStyledText(char *buffer, int appendLength);
|
||||
void AddStyledText(char *buffer, Sci::Position appendLength);
|
||||
|
||||
virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0;
|
||||
bool ValidMargin(uptr_t wParam) const;
|
||||
|
@ -602,36 +602,34 @@ public:
|
|||
*/
|
||||
class AutoSurface {
|
||||
private:
|
||||
Surface *surf;
|
||||
std::unique_ptr<Surface> surf;
|
||||
public:
|
||||
AutoSurface(Editor *ed, int technology = -1) : surf(0) {
|
||||
AutoSurface(Editor *ed, int technology = -1) {
|
||||
if (ed->wMain.GetID()) {
|
||||
surf = Surface::Allocate(technology != -1 ? technology : ed->technology);
|
||||
if (surf) {
|
||||
surf->Init(ed->wMain.GetID());
|
||||
surf->SetUnicodeMode(SC_CP_UTF8 == ed->CodePage());
|
||||
surf->SetDBCSMode(ed->CodePage());
|
||||
}
|
||||
surf.reset(Surface::Allocate(technology != -1 ? technology : ed->technology));
|
||||
surf->Init(ed->wMain.GetID());
|
||||
surf->SetUnicodeMode(SC_CP_UTF8 == ed->CodePage());
|
||||
surf->SetDBCSMode(ed->CodePage());
|
||||
}
|
||||
}
|
||||
AutoSurface(SurfaceID sid, Editor *ed, int technology = -1) : surf(0) {
|
||||
AutoSurface(SurfaceID sid, Editor *ed, int technology = -1) {
|
||||
if (ed->wMain.GetID()) {
|
||||
surf = Surface::Allocate(technology != -1 ? technology : ed->technology);
|
||||
if (surf) {
|
||||
surf->Init(sid, ed->wMain.GetID());
|
||||
surf->SetUnicodeMode(SC_CP_UTF8 == ed->CodePage());
|
||||
surf->SetDBCSMode(ed->CodePage());
|
||||
}
|
||||
surf.reset(Surface::Allocate(technology != -1 ? technology : ed->technology));
|
||||
surf->Init(sid, ed->wMain.GetID());
|
||||
surf->SetUnicodeMode(SC_CP_UTF8 == ed->CodePage());
|
||||
surf->SetDBCSMode(ed->CodePage());
|
||||
}
|
||||
}
|
||||
// Deleted so AutoSurface objects can not be copied.
|
||||
AutoSurface(const AutoSurface &) = delete;
|
||||
void operator=(const AutoSurface &) = delete;
|
||||
~AutoSurface() {
|
||||
delete surf;
|
||||
}
|
||||
Surface *operator->() const {
|
||||
return surf;
|
||||
return surf.get();
|
||||
}
|
||||
operator Surface *() const {
|
||||
return surf;
|
||||
return surf.get();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -5,14 +5,14 @@
|
|||
// Copyright 2001 Simon Steele <ss@pnotepad.org>, portions copyright Neil Hodgson.
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
|||
using namespace Scintilla;
|
||||
#endif
|
||||
|
||||
LexerManager *LexerManager::theInstance = NULL;
|
||||
std::unique_ptr<LexerManager> LexerManager::theInstance;
|
||||
|
||||
//------------------------------------------
|
||||
//
|
||||
|
@ -47,46 +47,30 @@ void ExternalLexerModule::SetExternal(GetLexerFactoryFunction fFactory, int inde
|
|||
//
|
||||
//------------------------------------------
|
||||
|
||||
LexerLibrary::LexerLibrary(const char *ModuleName) {
|
||||
// Initialise some members...
|
||||
first = NULL;
|
||||
last = NULL;
|
||||
|
||||
LexerLibrary::LexerLibrary(const char *moduleName_) {
|
||||
// Load the DLL
|
||||
lib = DynamicLibrary::Load(ModuleName);
|
||||
lib.reset(DynamicLibrary::Load(moduleName_));
|
||||
if (lib->IsValid()) {
|
||||
m_sModuleName = ModuleName;
|
||||
moduleName = moduleName_;
|
||||
//Cannot use reinterpret_cast because: ANSI C++ forbids casting between pointers to functions and objects
|
||||
GetLexerCountFn GetLexerCount = (GetLexerCountFn)(sptr_t)lib->FindFunction("GetLexerCount");
|
||||
|
||||
if (GetLexerCount) {
|
||||
ExternalLexerModule *lex;
|
||||
LexerMinder *lm;
|
||||
|
||||
// Find functions in the DLL
|
||||
GetLexerNameFn GetLexerName = (GetLexerNameFn)(sptr_t)lib->FindFunction("GetLexerName");
|
||||
GetLexerFactoryFunction fnFactory = (GetLexerFactoryFunction)(sptr_t)lib->FindFunction("GetLexerFactory");
|
||||
|
||||
int nl = GetLexerCount();
|
||||
const int nl = GetLexerCount();
|
||||
|
||||
for (int i = 0; i < nl; i++) {
|
||||
// Assign a buffer for the lexer name.
|
||||
char lexname[100] = "";
|
||||
GetLexerName(i, lexname, sizeof(lexname));
|
||||
lex = new ExternalLexerModule(SCLEX_AUTOMATIC, NULL, lexname, NULL);
|
||||
ExternalLexerModule *lex = new ExternalLexerModule(SCLEX_AUTOMATIC, NULL, lexname, NULL);
|
||||
Catalogue::AddLexerModule(lex);
|
||||
|
||||
// Create a LexerMinder so we don't leak the ExternalLexerModule...
|
||||
lm = new LexerMinder;
|
||||
lm->self = lex;
|
||||
lm->next = NULL;
|
||||
if (first != NULL) {
|
||||
last->next = lm;
|
||||
last = lm;
|
||||
} else {
|
||||
first = lm;
|
||||
last = lm;
|
||||
}
|
||||
// Remember ExternalLexerModule so we don't leak it
|
||||
modules.push_back(std::unique_ptr<ExternalLexerModule>(lex));
|
||||
|
||||
// The external lexer needs to know how to call into its DLL to
|
||||
// do its lexing and folding, we tell it here.
|
||||
|
@ -94,27 +78,9 @@ LexerLibrary::LexerLibrary(const char *ModuleName) {
|
|||
}
|
||||
}
|
||||
}
|
||||
next = NULL;
|
||||
}
|
||||
|
||||
LexerLibrary::~LexerLibrary() {
|
||||
Release();
|
||||
delete lib;
|
||||
}
|
||||
|
||||
void LexerLibrary::Release() {
|
||||
LexerMinder *lm;
|
||||
LexerMinder *lmNext;
|
||||
lm = first;
|
||||
while (NULL != lm) {
|
||||
lmNext = lm->next;
|
||||
delete lm->self;
|
||||
delete lm;
|
||||
lm = lmNext;
|
||||
}
|
||||
|
||||
first = NULL;
|
||||
last = NULL;
|
||||
}
|
||||
|
||||
//------------------------------------------
|
||||
|
@ -126,20 +92,17 @@ void LexerLibrary::Release() {
|
|||
/// Return the single LexerManager instance...
|
||||
LexerManager *LexerManager::GetInstance() {
|
||||
if (!theInstance)
|
||||
theInstance = new LexerManager;
|
||||
return theInstance;
|
||||
theInstance.reset(new LexerManager);
|
||||
return theInstance.get();
|
||||
}
|
||||
|
||||
/// Delete any LexerManager instance...
|
||||
void LexerManager::DeleteInstance() {
|
||||
delete theInstance;
|
||||
theInstance = NULL;
|
||||
theInstance.reset();
|
||||
}
|
||||
|
||||
/// protected constructor - this is a singleton...
|
||||
LexerManager::LexerManager() {
|
||||
first = NULL;
|
||||
last = NULL;
|
||||
}
|
||||
|
||||
LexerManager::~LexerManager() {
|
||||
|
@ -147,41 +110,21 @@ LexerManager::~LexerManager() {
|
|||
}
|
||||
|
||||
void LexerManager::Load(const char *path) {
|
||||
LoadLexerLibrary(path);
|
||||
}
|
||||
|
||||
void LexerManager::LoadLexerLibrary(const char *module) {
|
||||
for (LexerLibrary *ll = first; ll; ll= ll->next) {
|
||||
if (strcmp(ll->m_sModuleName.c_str(), module) == 0)
|
||||
for (const std::unique_ptr<LexerLibrary> &ll : libraries) {
|
||||
if (ll->moduleName == path)
|
||||
return;
|
||||
}
|
||||
LexerLibrary *lib = new LexerLibrary(module);
|
||||
if (NULL != first) {
|
||||
last->next = lib;
|
||||
last = lib;
|
||||
} else {
|
||||
first = lib;
|
||||
last = lib;
|
||||
}
|
||||
LexerLibrary *lib = new LexerLibrary(path);
|
||||
libraries.push_back(std::unique_ptr<LexerLibrary>(lib));
|
||||
}
|
||||
|
||||
void LexerManager::Clear() {
|
||||
if (NULL != first) {
|
||||
LexerLibrary *cur = first;
|
||||
LexerLibrary *next;
|
||||
while (cur) {
|
||||
next = cur->next;
|
||||
delete cur;
|
||||
cur = next;
|
||||
}
|
||||
first = NULL;
|
||||
last = NULL;
|
||||
}
|
||||
libraries.clear();
|
||||
}
|
||||
|
||||
//------------------------------------------
|
||||
//
|
||||
// LexerManager
|
||||
// LMMinder -- trigger to clean up at exit.
|
||||
//
|
||||
//------------------------------------------
|
||||
|
||||
|
|
|
@ -38,26 +38,15 @@ public:
|
|||
virtual void SetExternal(GetLexerFactoryFunction fFactory, int index);
|
||||
};
|
||||
|
||||
/// LexerMinder points to an ExternalLexerModule - so we don't leak them.
|
||||
class LexerMinder {
|
||||
public:
|
||||
ExternalLexerModule *self;
|
||||
LexerMinder *next;
|
||||
};
|
||||
|
||||
/// LexerLibrary exists for every External Lexer DLL, contains LexerMinders.
|
||||
/// LexerLibrary exists for every External Lexer DLL, contains ExternalLexerModules.
|
||||
class LexerLibrary {
|
||||
DynamicLibrary *lib;
|
||||
LexerMinder *first;
|
||||
LexerMinder *last;
|
||||
|
||||
std::unique_ptr<DynamicLibrary> lib;
|
||||
std::vector<std::unique_ptr<ExternalLexerModule>> modules;
|
||||
public:
|
||||
explicit LexerLibrary(const char *ModuleName);
|
||||
explicit LexerLibrary(const char *moduleName_);
|
||||
~LexerLibrary();
|
||||
void Release();
|
||||
|
||||
LexerLibrary *next;
|
||||
std::string m_sModuleName;
|
||||
std::string moduleName;
|
||||
};
|
||||
|
||||
/// LexerManager manages external lexers, contains LexerLibrarys.
|
||||
|
@ -73,11 +62,8 @@ public:
|
|||
|
||||
private:
|
||||
LexerManager();
|
||||
static LexerManager *theInstance;
|
||||
|
||||
void LoadLexerLibrary(const char *module);
|
||||
LexerLibrary *first;
|
||||
LexerLibrary *last;
|
||||
static std::unique_ptr<LexerManager> theInstance;
|
||||
std::vector<std::unique_ptr<LexerLibrary>> libraries;
|
||||
};
|
||||
|
||||
class LMMinder {
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <stdexcept>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
|
@ -21,7 +22,8 @@ using namespace Scintilla;
|
|||
|
||||
static PRectangle PixelGridAlign(const PRectangle &rc) {
|
||||
// Move left and right side to nearest pixel to avoid blurry visuals
|
||||
return PRectangle::FromInts(int(rc.left + 0.5), int(rc.top), int(rc.right + 0.5), int(rc.bottom));
|
||||
return PRectangle::FromInts(static_cast<int>(rc.left + 0.5), static_cast<int>(rc.top),
|
||||
static_cast<int>(rc.right + 0.5), static_cast<int>(rc.bottom));
|
||||
}
|
||||
|
||||
void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine, const PRectangle &rcCharacter, DrawState drawState, int value) const {
|
||||
|
@ -35,8 +37,8 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r
|
|||
surface->PenColour(sacDraw.fore);
|
||||
int ymid = static_cast<int>(rc.bottom + rc.top) / 2;
|
||||
if (sacDraw.style == INDIC_SQUIGGLE) {
|
||||
int x = int(rc.left+0.5);
|
||||
int xLast = int(rc.right+0.5);
|
||||
int x = static_cast<int>(rc.left+0.5);
|
||||
const int xLast = static_cast<int>(rc.right+0.5);
|
||||
int y = 0;
|
||||
surface->MoveTo(x, static_cast<int>(rc.top) + y);
|
||||
while (x < xLast) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cstdlib>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
|
|
|
@ -5,12 +5,13 @@
|
|||
// Copyright 1998-2011 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <cstring>
|
||||
#include <cmath>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
|
@ -25,20 +26,17 @@ using namespace Scintilla;
|
|||
#endif
|
||||
|
||||
void LineMarker::SetXPM(const char *textForm) {
|
||||
delete pxpm;
|
||||
pxpm = new XPM(textForm);
|
||||
pxpm.reset(new XPM(textForm));
|
||||
markType = SC_MARK_PIXMAP;
|
||||
}
|
||||
|
||||
void LineMarker::SetXPM(const char *const *linesForm) {
|
||||
delete pxpm;
|
||||
pxpm = new XPM(linesForm);
|
||||
pxpm.reset(new XPM(linesForm));
|
||||
markType = SC_MARK_PIXMAP;
|
||||
}
|
||||
|
||||
void LineMarker::SetRGBAImage(Point sizeRGBAImage, float scale, const unsigned char *pixelsRGBAImage) {
|
||||
delete image;
|
||||
image = new RGBAImage(static_cast<int>(sizeRGBAImage.x), static_cast<int>(sizeRGBAImage.y), scale, pixelsRGBAImage);
|
||||
image.reset(new RGBAImage(static_cast<int>(sizeRGBAImage.x), static_cast<int>(sizeRGBAImage.y), scale, pixelsRGBAImage));
|
||||
markType = SC_MARK_RGBAIMAGE;
|
||||
}
|
||||
|
||||
|
@ -73,7 +71,7 @@ static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, C
|
|||
}
|
||||
|
||||
void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharacter, typeOfFold tFold, int marginStyle) const {
|
||||
if (customDraw != NULL) {
|
||||
if (customDraw) {
|
||||
customDraw(surface, rcWhole, fontForCharacter, tFold, marginStyle, this);
|
||||
return;
|
||||
}
|
||||
|
@ -122,11 +120,11 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
|
|||
int minDim = Platform::Minimum(static_cast<int>(rc.Width()), static_cast<int>(rc.Height()));
|
||||
minDim--; // Ensure does not go beyond edge
|
||||
int centreX = static_cast<int>(floor((rc.right + rc.left) / 2.0));
|
||||
int centreY = static_cast<int>(floor((rc.bottom + rc.top) / 2.0));
|
||||
int dimOn2 = minDim / 2;
|
||||
int dimOn4 = minDim / 4;
|
||||
const int centreY = static_cast<int>(floor((rc.bottom + rc.top) / 2.0));
|
||||
const int dimOn2 = minDim / 2;
|
||||
const int dimOn4 = minDim / 4;
|
||||
int blobSize = dimOn2-1;
|
||||
int armSize = dimOn2-2;
|
||||
const int armSize = dimOn2-2;
|
||||
if (marginStyle == SC_MARGIN_NUMBER || marginStyle == SC_MARGIN_TEXT || marginStyle == SC_MARGIN_RTEXT) {
|
||||
// On textual margins move marker to the left to try to avoid overlapping the text
|
||||
centreX = static_cast<int>(rc.left) + dimOn2 + 1;
|
||||
|
@ -384,7 +382,7 @@ void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharac
|
|||
rcLeft.right = rcLeft.left + 4;
|
||||
surface->FillRectangle(rcLeft, back);
|
||||
} else if (markType == SC_MARK_BOOKMARK) {
|
||||
int halfHeight = minDim / 3;
|
||||
const int halfHeight = minDim / 3;
|
||||
Point pts[] = {
|
||||
Point::FromInts(static_cast<int>(rc.left), centreY-halfHeight),
|
||||
Point::FromInts(static_cast<int>(rc.right) - 3, centreY - halfHeight),
|
||||
|
|
|
@ -25,8 +25,8 @@ public:
|
|||
ColourDesired back;
|
||||
ColourDesired backSelected;
|
||||
int alpha;
|
||||
XPM *pxpm;
|
||||
RGBAImage *image;
|
||||
std::unique_ptr<XPM> pxpm;
|
||||
std::unique_ptr<RGBAImage> image;
|
||||
/** Some platforms, notably PLAT_CURSES, do not support Scintilla's native
|
||||
* Draw function for drawing line markers. Allow those platforms to override
|
||||
* it instead of creating a new method(s) in the Surface class that existing
|
||||
|
@ -38,45 +38,39 @@ public:
|
|||
back = ColourDesired(0xff,0xff,0xff);
|
||||
backSelected = ColourDesired(0xff,0x00,0x00);
|
||||
alpha = SC_ALPHA_NOALPHA;
|
||||
pxpm = NULL;
|
||||
image = NULL;
|
||||
customDraw = NULL;
|
||||
customDraw = nullptr;
|
||||
}
|
||||
LineMarker(const LineMarker &) {
|
||||
// Defined to avoid pxpm being blindly copied, not as a complete copy constructor
|
||||
// Defined to avoid pxpm and image being blindly copied, not as a complete copy constructor.
|
||||
markType = SC_MARK_CIRCLE;
|
||||
fore = ColourDesired(0,0,0);
|
||||
back = ColourDesired(0xff,0xff,0xff);
|
||||
backSelected = ColourDesired(0xff,0x00,0x00);
|
||||
alpha = SC_ALPHA_NOALPHA;
|
||||
pxpm = NULL;
|
||||
image = NULL;
|
||||
customDraw = NULL;
|
||||
pxpm.reset();
|
||||
image.reset();
|
||||
customDraw = nullptr;
|
||||
}
|
||||
~LineMarker() {
|
||||
delete pxpm;
|
||||
delete image;
|
||||
}
|
||||
LineMarker &operator=(const LineMarker &other) {
|
||||
// Defined to avoid pxpm being blindly copied, not as a complete assignment operator
|
||||
// Defined to avoid pxpm and image being blindly copied, not as a complete assignment operator.
|
||||
if (this != &other) {
|
||||
markType = SC_MARK_CIRCLE;
|
||||
fore = ColourDesired(0,0,0);
|
||||
back = ColourDesired(0xff,0xff,0xff);
|
||||
backSelected = ColourDesired(0xff,0x00,0x00);
|
||||
alpha = SC_ALPHA_NOALPHA;
|
||||
delete pxpm;
|
||||
pxpm = NULL;
|
||||
delete image;
|
||||
image = NULL;
|
||||
customDraw = NULL;
|
||||
pxpm.reset();
|
||||
image.reset();
|
||||
customDraw = nullptr;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
void SetXPM(const char *textForm);
|
||||
void SetXPM(const char *const *linesForm);
|
||||
void SetRGBAImage(Point sizeRGBAImage, float scale, const unsigned char *pixelsRGBAImage);
|
||||
void Draw(Surface *surface, PRectangle &rc, Font &fontForCharacter, typeOfFold tFold, int marginStyle) const;
|
||||
void Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharacter, typeOfFold tFold, int marginStyle) const;
|
||||
};
|
||||
|
||||
#ifdef SCI_NAMESPACE
|
||||
|
|
|
@ -5,12 +5,13 @@
|
|||
// Copyright 1998-2014 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <cctype>
|
||||
#include <cstdio>
|
||||
#include <cmath>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
@ -26,6 +27,7 @@
|
|||
|
||||
#include "StringCopy.h"
|
||||
#include "Position.h"
|
||||
#include "UniqueString.h"
|
||||
#include "SplitVector.h"
|
||||
#include "Partitioning.h"
|
||||
#include "RunStyles.h"
|
||||
|
@ -63,10 +65,10 @@ void DrawWrapMarker(Surface *surface, PRectangle rcPlace,
|
|||
enum { xa = 1 }; // gap before start
|
||||
int w = static_cast<int>(rcPlace.right - rcPlace.left) - xa - 1;
|
||||
|
||||
bool xStraight = isEndMarker; // x-mirrored symbol for start marker
|
||||
const bool xStraight = isEndMarker; // x-mirrored symbol for start marker
|
||||
|
||||
int x0 = static_cast<int>(xStraight ? rcPlace.left : rcPlace.right - 1);
|
||||
int y0 = static_cast<int>(rcPlace.top);
|
||||
const int x0 = static_cast<int>(xStraight ? rcPlace.left : rcPlace.right - 1);
|
||||
const int y0 = static_cast<int>(rcPlace.top);
|
||||
|
||||
int dy = static_cast<int>(rcPlace.bottom - rcPlace.top) / 5;
|
||||
int y = static_cast<int>(rcPlace.bottom - rcPlace.top) / 2 + dy;
|
||||
|
@ -101,21 +103,15 @@ void DrawWrapMarker(Surface *surface, PRectangle rcPlace,
|
|||
}
|
||||
|
||||
MarginView::MarginView() {
|
||||
pixmapSelMargin = 0;
|
||||
pixmapSelPattern = 0;
|
||||
pixmapSelPatternOffset1 = 0;
|
||||
wrapMarkerPaddingRight = 3;
|
||||
customDrawWrapMarker = NULL;
|
||||
}
|
||||
|
||||
void MarginView::DropGraphics(bool freeObjects) {
|
||||
if (freeObjects) {
|
||||
delete pixmapSelMargin;
|
||||
pixmapSelMargin = 0;
|
||||
delete pixmapSelPattern;
|
||||
pixmapSelPattern = 0;
|
||||
delete pixmapSelPatternOffset1;
|
||||
pixmapSelPatternOffset1 = 0;
|
||||
pixmapSelMargin.reset();
|
||||
pixmapSelPattern.reset();
|
||||
pixmapSelPatternOffset1.reset();
|
||||
} else {
|
||||
if (pixmapSelMargin)
|
||||
pixmapSelMargin->Release();
|
||||
|
@ -128,11 +124,11 @@ void MarginView::DropGraphics(bool freeObjects) {
|
|||
|
||||
void MarginView::AllocateGraphics(const ViewStyle &vsDraw) {
|
||||
if (!pixmapSelMargin)
|
||||
pixmapSelMargin = Surface::Allocate(vsDraw.technology);
|
||||
pixmapSelMargin.reset(Surface::Allocate(vsDraw.technology));
|
||||
if (!pixmapSelPattern)
|
||||
pixmapSelPattern = Surface::Allocate(vsDraw.technology);
|
||||
pixmapSelPattern.reset(Surface::Allocate(vsDraw.technology));
|
||||
if (!pixmapSelPatternOffset1)
|
||||
pixmapSelPatternOffset1 = Surface::Allocate(vsDraw.technology);
|
||||
pixmapSelPatternOffset1.reset(Surface::Allocate(vsDraw.technology));
|
||||
}
|
||||
|
||||
void MarginView::RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const ViewStyle &vsDraw) {
|
||||
|
@ -183,7 +179,7 @@ static int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault, const Vie
|
|||
return markerCheck;
|
||||
}
|
||||
|
||||
void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRectangle rcMargin,
|
||||
void MarginView::PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc, PRectangle rcMargin,
|
||||
const EditModel &model, const ViewStyle &vs) {
|
||||
|
||||
PRectangle rcSelMargin = rcMargin;
|
||||
|
@ -204,7 +200,7 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect
|
|||
// Required because of special way brush is created for selection margin
|
||||
// Ensure patterns line up when scrolling with separate margin view
|
||||
// by choosing correctly aligned variant.
|
||||
bool invertPhase = static_cast<int>(ptOrigin.y) & 1;
|
||||
const bool invertPhase = static_cast<int>(ptOrigin.y) & 1;
|
||||
surface->FillRectangle(rcSelMargin,
|
||||
invertPhase ? *pixmapSelPattern : *pixmapSelPatternOffset1);
|
||||
} else {
|
||||
|
@ -230,16 +226,16 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect
|
|||
}
|
||||
|
||||
const int lineStartPaint = static_cast<int>(rcMargin.top + ptOrigin.y) / vs.lineHeight;
|
||||
int visibleLine = model.TopLineOfMain() + lineStartPaint;
|
||||
int yposScreen = lineStartPaint * vs.lineHeight - static_cast<int>(ptOrigin.y);
|
||||
Sci::Line visibleLine = model.TopLineOfMain() + lineStartPaint;
|
||||
Sci::Position yposScreen = lineStartPaint * vs.lineHeight - static_cast<Sci::Position>(ptOrigin.y);
|
||||
// Work out whether the top line is whitespace located after a
|
||||
// lessening of fold level which implies a 'fold tail' but which should not
|
||||
// be displayed until the last of a sequence of whitespace.
|
||||
bool needWhiteClosure = false;
|
||||
if (vs.ms[margin].mask & SC_MASK_FOLDERS) {
|
||||
int level = model.pdoc->GetLevel(model.cs.DocFromDisplay(visibleLine));
|
||||
const int level = model.pdoc->GetLevel(model.cs.DocFromDisplay(visibleLine));
|
||||
if (level & SC_FOLDLEVELWHITEFLAG) {
|
||||
int lineBack = model.cs.DocFromDisplay(visibleLine);
|
||||
Sci::Line lineBack = model.cs.DocFromDisplay(visibleLine);
|
||||
int levelPrev = level;
|
||||
while ((lineBack > 0) && (levelPrev & SC_FOLDLEVELWHITEFLAG)) {
|
||||
lineBack--;
|
||||
|
@ -251,7 +247,7 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect
|
|||
}
|
||||
}
|
||||
if (highlightDelimiter.isEnabled) {
|
||||
int lastLine = model.cs.DocFromDisplay(topLine + model.LinesOnScreen()) + 1;
|
||||
Sci::Line lastLine = model.cs.DocFromDisplay(topLine + model.LinesOnScreen()) + 1;
|
||||
model.pdoc->GetHighlightDelimiters(highlightDelimiter, model.pdoc->LineFromPosition(model.sel.MainCaret()), lastLine);
|
||||
}
|
||||
}
|
||||
|
@ -265,10 +261,10 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect
|
|||
while ((visibleLine < model.cs.LinesDisplayed()) && yposScreen < rc.bottom) {
|
||||
|
||||
PLATFORM_ASSERT(visibleLine < model.cs.LinesDisplayed());
|
||||
const int lineDoc = model.cs.DocFromDisplay(visibleLine);
|
||||
const Sci::Line lineDoc = model.cs.DocFromDisplay(visibleLine);
|
||||
PLATFORM_ASSERT(model.cs.GetVisible(lineDoc));
|
||||
const int firstVisibleLine = model.cs.DisplayFromDoc(lineDoc);
|
||||
const int lastVisibleLine = model.cs.DisplayLastFromDoc(lineDoc);
|
||||
const Sci::Line firstVisibleLine = model.cs.DisplayFromDoc(lineDoc);
|
||||
const Sci::Line lastVisibleLine = model.cs.DisplayLastFromDoc(lineDoc);
|
||||
const bool firstSubLine = visibleLine == firstVisibleLine;
|
||||
const bool lastSubLine = visibleLine == lastVisibleLine;
|
||||
|
||||
|
@ -313,7 +309,7 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect
|
|||
}
|
||||
}
|
||||
needWhiteClosure = false;
|
||||
const int firstFollowupLine = model.cs.DocFromDisplay(model.cs.DisplayFromDoc(lineDoc + 1));
|
||||
const Sci::Line firstFollowupLine = model.cs.DocFromDisplay(model.cs.DisplayFromDoc(lineDoc + 1));
|
||||
const int firstFollowupLineLevel = model.pdoc->GetLevel(firstFollowupLine);
|
||||
const int secondFollowupLineLevelNum = LevelNumber(model.pdoc->GetLevel(firstFollowupLine + 1));
|
||||
if (!model.cs.GetExpanded(lineDoc)) {
|
||||
|
@ -379,7 +375,7 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect
|
|||
sprintf(number, "%d", lineDoc + 1);
|
||||
if (model.foldFlags & (SC_FOLDFLAG_LEVELNUMBERS | SC_FOLDFLAG_LINESTATE)) {
|
||||
if (model.foldFlags & SC_FOLDFLAG_LEVELNUMBERS) {
|
||||
int lev = model.pdoc->GetLevel(lineDoc);
|
||||
const int lev = model.pdoc->GetLevel(lineDoc);
|
||||
sprintf(number, "%c%c %03X %03X",
|
||||
(lev & SC_FOLDLEVELHEADERFLAG) ? 'H' : '_',
|
||||
(lev & SC_FOLDLEVELWHITEFLAG) ? 'W' : '_',
|
||||
|
@ -387,7 +383,7 @@ void MarginView::PaintMargin(Surface *surface, int topLine, PRectangle rc, PRect
|
|||
lev >> 16
|
||||
);
|
||||
} else {
|
||||
int state = model.pdoc->GetLineState(lineDoc);
|
||||
const int state = model.pdoc->GetLineState(lineDoc);
|
||||
sprintf(number, "%0X", state);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,9 +21,9 @@ typedef void (*DrawWrapMarkerFn)(Surface *surface, PRectangle rcPlace, bool isEn
|
|||
*/
|
||||
class MarginView {
|
||||
public:
|
||||
Surface *pixmapSelMargin;
|
||||
Surface *pixmapSelPattern;
|
||||
Surface *pixmapSelPatternOffset1;
|
||||
std::unique_ptr<Surface> pixmapSelMargin;
|
||||
std::unique_ptr<Surface> pixmapSelPattern;
|
||||
std::unique_ptr<Surface> pixmapSelPatternOffset1;
|
||||
// Highlight current folding block
|
||||
HighlightDelimiter highlightDelimiter;
|
||||
|
||||
|
@ -39,7 +39,7 @@ public:
|
|||
void DropGraphics(bool freeObjects);
|
||||
void AllocateGraphics(const ViewStyle &vsDraw);
|
||||
void RefreshPixMaps(Surface *surfaceWindow, WindowID wid, const ViewStyle &vsDraw);
|
||||
void PaintMargin(Surface *surface, int topLine, PRectangle rc, PRectangle rcMargin,
|
||||
void PaintMargin(Surface *surface, Sci::Line topLine, PRectangle rc, PRectangle rcMargin,
|
||||
const EditModel &model, const ViewStyle &vs);
|
||||
};
|
||||
|
||||
|
|
|
@ -22,14 +22,17 @@ public:
|
|||
SetGrowSize(growSize_);
|
||||
ReAllocate(growSize_);
|
||||
}
|
||||
// Deleted so SplitVectorWithRangeAdd objects can not be copied.
|
||||
SplitVectorWithRangeAdd(const SplitVectorWithRangeAdd &) = delete;
|
||||
void operator=(const SplitVectorWithRangeAdd &) = delete;
|
||||
~SplitVectorWithRangeAdd() {
|
||||
}
|
||||
void RangeAddDelta(int start, int end, int delta) {
|
||||
// end is 1 past end, so end-start is number of elements to change
|
||||
int i = 0;
|
||||
int rangeLength = end - start;
|
||||
const int rangeLength = end - start;
|
||||
int range1Length = rangeLength;
|
||||
int part1Left = part1Length - start;
|
||||
const int part1Left = part1Length - start;
|
||||
if (range1Length > part1Left)
|
||||
range1Length = part1Left;
|
||||
while (i < range1Length) {
|
||||
|
@ -57,7 +60,7 @@ private:
|
|||
// there may be a step somewhere in the list.
|
||||
int stepPartition;
|
||||
int stepLength;
|
||||
SplitVectorWithRangeAdd *body;
|
||||
std::unique_ptr<SplitVectorWithRangeAdd> body;
|
||||
|
||||
// Move step forward
|
||||
void ApplyStep(int partitionUpTo) {
|
||||
|
@ -80,7 +83,7 @@ private:
|
|||
}
|
||||
|
||||
void Allocate(int growSize) {
|
||||
body = new SplitVectorWithRangeAdd(growSize);
|
||||
body.reset(new SplitVectorWithRangeAdd(growSize));
|
||||
stepPartition = 0;
|
||||
stepLength = 0;
|
||||
body->Insert(0, 0); // This value stays 0 for ever
|
||||
|
@ -92,9 +95,11 @@ public:
|
|||
Allocate(growSize);
|
||||
}
|
||||
|
||||
// Deleted so Partitioning objects can not be copied.
|
||||
Partitioning(const Partitioning &) = delete;
|
||||
void operator=(const Partitioning &) = delete;
|
||||
|
||||
~Partitioning() {
|
||||
delete body;
|
||||
body = 0;
|
||||
}
|
||||
|
||||
int Partitions() const {
|
||||
|
@ -170,7 +175,7 @@ public:
|
|||
int lower = 0;
|
||||
int upper = body->Length()-1;
|
||||
do {
|
||||
int middle = (upper + lower + 1) / 2; // Round high
|
||||
const int middle = (upper + lower + 1) / 2; // Round high
|
||||
int posMiddle = body->ValueAt(middle);
|
||||
if (middle > stepPartition)
|
||||
posMiddle += stepLength;
|
||||
|
@ -184,9 +189,7 @@ public:
|
|||
}
|
||||
|
||||
void DeleteAll() {
|
||||
int growSize = body->GetGrowSize();
|
||||
delete body;
|
||||
Allocate(growSize);
|
||||
Allocate(body->GetGrowSize());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -5,11 +5,15 @@
|
|||
// Copyright 1998-2009 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <string.h>
|
||||
#include <cstddef>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
#include <forward_list>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
|
@ -25,119 +29,73 @@ using namespace Scintilla;
|
|||
#endif
|
||||
|
||||
MarkerHandleSet::MarkerHandleSet() {
|
||||
root = 0;
|
||||
}
|
||||
|
||||
MarkerHandleSet::~MarkerHandleSet() {
|
||||
MarkerHandleNumber *mhn = root;
|
||||
while (mhn) {
|
||||
MarkerHandleNumber *mhnToFree = mhn;
|
||||
mhn = mhn->next;
|
||||
delete mhnToFree;
|
||||
}
|
||||
root = 0;
|
||||
mhList.clear();
|
||||
}
|
||||
|
||||
int MarkerHandleSet::Length() const {
|
||||
int c = 0;
|
||||
MarkerHandleNumber *mhn = root;
|
||||
while (mhn) {
|
||||
c++;
|
||||
mhn = mhn->next;
|
||||
}
|
||||
return c;
|
||||
bool MarkerHandleSet::Empty() const {
|
||||
return mhList.empty();
|
||||
}
|
||||
|
||||
int MarkerHandleSet::MarkValue() const {
|
||||
unsigned int m = 0;
|
||||
MarkerHandleNumber *mhn = root;
|
||||
while (mhn) {
|
||||
m |= (1 << mhn->number);
|
||||
mhn = mhn->next;
|
||||
for (const MarkerHandleNumber &mhn : mhList) {
|
||||
m |= (1 << mhn.number);
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
bool MarkerHandleSet::Contains(int handle) const {
|
||||
MarkerHandleNumber *mhn = root;
|
||||
while (mhn) {
|
||||
if (mhn->handle == handle) {
|
||||
for (const MarkerHandleNumber &mhn : mhList) {
|
||||
if (mhn.handle == handle) {
|
||||
return true;
|
||||
}
|
||||
mhn = mhn->next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MarkerHandleSet::InsertHandle(int handle, int markerNum) {
|
||||
MarkerHandleNumber *mhn = new MarkerHandleNumber;
|
||||
mhn->handle = handle;
|
||||
mhn->number = markerNum;
|
||||
mhn->next = root;
|
||||
root = mhn;
|
||||
mhList.push_front(MarkerHandleNumber(handle, markerNum));
|
||||
return true;
|
||||
}
|
||||
|
||||
void MarkerHandleSet::RemoveHandle(int handle) {
|
||||
MarkerHandleNumber **pmhn = &root;
|
||||
while (*pmhn) {
|
||||
MarkerHandleNumber *mhn = *pmhn;
|
||||
if (mhn->handle == handle) {
|
||||
*pmhn = mhn->next;
|
||||
delete mhn;
|
||||
return;
|
||||
}
|
||||
pmhn = &((*pmhn)->next);
|
||||
}
|
||||
mhList.remove_if([=](const MarkerHandleNumber &mhn) { return mhn.handle == handle; });
|
||||
}
|
||||
|
||||
bool MarkerHandleSet::RemoveNumber(int markerNum, bool all) {
|
||||
bool performedDeletion = false;
|
||||
MarkerHandleNumber **pmhn = &root;
|
||||
while (*pmhn) {
|
||||
MarkerHandleNumber *mhn = *pmhn;
|
||||
if (mhn->number == markerNum) {
|
||||
*pmhn = mhn->next;
|
||||
delete mhn;
|
||||
mhList.remove_if([&](const MarkerHandleNumber &mhn) {
|
||||
if ((all || !performedDeletion) && (mhn.number == markerNum)) {
|
||||
performedDeletion = true;
|
||||
if (!all)
|
||||
break;
|
||||
} else {
|
||||
pmhn = &((*pmhn)->next);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
return performedDeletion;
|
||||
}
|
||||
|
||||
void MarkerHandleSet::CombineWith(MarkerHandleSet *other) {
|
||||
MarkerHandleNumber **pmhn = &other->root;
|
||||
while (*pmhn) {
|
||||
pmhn = &((*pmhn)->next);
|
||||
}
|
||||
*pmhn = root;
|
||||
root = other->root;
|
||||
other->root = 0;
|
||||
mhList.splice_after(mhList.before_begin(), other->mhList);
|
||||
}
|
||||
|
||||
LineMarkers::~LineMarkers() {
|
||||
Init();
|
||||
}
|
||||
|
||||
void LineMarkers::Init() {
|
||||
for (int line = 0; line < markers.Length(); line++) {
|
||||
delete markers[line];
|
||||
markers[line] = 0;
|
||||
}
|
||||
markers.DeleteAll();
|
||||
}
|
||||
|
||||
void LineMarkers::InsertLine(int line) {
|
||||
void LineMarkers::Init() {
|
||||
markers.DeleteAll();
|
||||
}
|
||||
|
||||
void LineMarkers::InsertLine(Sci::Line line) {
|
||||
if (markers.Length()) {
|
||||
markers.Insert(line, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void LineMarkers::RemoveLine(int line) {
|
||||
void LineMarkers::RemoveLine(Sci::Line line) {
|
||||
// Retain the markers from the deleted line by oring them into the previous line
|
||||
if (markers.Length()) {
|
||||
if (line > 0) {
|
||||
|
@ -147,9 +105,9 @@ void LineMarkers::RemoveLine(int line) {
|
|||
}
|
||||
}
|
||||
|
||||
int LineMarkers::LineFromHandle(int markerHandle) {
|
||||
Sci::Line LineMarkers::LineFromHandle(int markerHandle) {
|
||||
if (markers.Length()) {
|
||||
for (int line = 0; line < markers.Length(); line++) {
|
||||
for (Sci::Line line = 0; line < markers.Length(); line++) {
|
||||
if (markers[line]) {
|
||||
if (markers[line]->Contains(markerHandle)) {
|
||||
return line;
|
||||
|
@ -160,66 +118,62 @@ int LineMarkers::LineFromHandle(int markerHandle) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
void LineMarkers::MergeMarkers(int pos) {
|
||||
if (markers[pos + 1] != NULL) {
|
||||
if (markers[pos] == NULL)
|
||||
markers[pos] = new MarkerHandleSet;
|
||||
markers[pos]->CombineWith(markers[pos + 1]);
|
||||
delete markers[pos + 1];
|
||||
markers[pos + 1] = NULL;
|
||||
void LineMarkers::MergeMarkers(Sci::Line line) {
|
||||
if (markers[line + 1]) {
|
||||
if (!markers[line])
|
||||
markers[line].reset(new MarkerHandleSet);
|
||||
markers[line]->CombineWith(markers[line + 1].get());
|
||||
markers[line + 1].reset();
|
||||
}
|
||||
}
|
||||
|
||||
int LineMarkers::MarkValue(int line) {
|
||||
int LineMarkers::MarkValue(Sci::Line line) {
|
||||
if (markers.Length() && (line >= 0) && (line < markers.Length()) && markers[line])
|
||||
return markers[line]->MarkValue();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LineMarkers::MarkerNext(int lineStart, int mask) const {
|
||||
Sci::Line LineMarkers::MarkerNext(Sci::Line lineStart, int mask) const {
|
||||
if (lineStart < 0)
|
||||
lineStart = 0;
|
||||
int length = markers.Length();
|
||||
for (int iLine = lineStart; iLine < length; iLine++) {
|
||||
MarkerHandleSet *onLine = markers[iLine];
|
||||
const Sci::Line length = markers.Length();
|
||||
for (Sci::Line iLine = lineStart; iLine < length; iLine++) {
|
||||
const MarkerHandleSet *onLine = markers[iLine].get();
|
||||
if (onLine && ((onLine->MarkValue() & mask) != 0))
|
||||
//if ((pdoc->GetMark(iLine) & lParam) != 0)
|
||||
return iLine;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int LineMarkers::AddMark(int line, int markerNum, int lines) {
|
||||
int LineMarkers::AddMark(Sci::Line line, int markerNum, Sci::Line lines) {
|
||||
handleCurrent++;
|
||||
if (!markers.Length()) {
|
||||
// No existing markers so allocate one element per line
|
||||
markers.InsertValue(0, lines, 0);
|
||||
markers.InsertEmpty(0, lines);
|
||||
}
|
||||
if (line >= markers.Length()) {
|
||||
return -1;
|
||||
}
|
||||
if (!markers[line]) {
|
||||
// Need new structure to hold marker handle
|
||||
markers[line] = new MarkerHandleSet();
|
||||
markers[line].reset(new MarkerHandleSet());
|
||||
}
|
||||
markers[line]->InsertHandle(handleCurrent, markerNum);
|
||||
|
||||
return handleCurrent;
|
||||
}
|
||||
|
||||
bool LineMarkers::DeleteMark(int line, int markerNum, bool all) {
|
||||
bool LineMarkers::DeleteMark(Sci::Line line, int markerNum, bool all) {
|
||||
bool someChanges = false;
|
||||
if (markers.Length() && (line >= 0) && (line < markers.Length()) && markers[line]) {
|
||||
if (markerNum == -1) {
|
||||
someChanges = true;
|
||||
delete markers[line];
|
||||
markers[line] = NULL;
|
||||
markers[line].reset();
|
||||
} else {
|
||||
someChanges = markers[line]->RemoveNumber(markerNum, all);
|
||||
if (markers[line]->Length() == 0) {
|
||||
delete markers[line];
|
||||
markers[line] = NULL;
|
||||
if (markers[line]->Empty()) {
|
||||
markers[line].reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -227,12 +181,11 @@ bool LineMarkers::DeleteMark(int line, int markerNum, bool all) {
|
|||
}
|
||||
|
||||
void LineMarkers::DeleteMarkFromHandle(int markerHandle) {
|
||||
int line = LineFromHandle(markerHandle);
|
||||
Sci::Line line = LineFromHandle(markerHandle);
|
||||
if (line >= 0) {
|
||||
markers[line]->RemoveHandle(markerHandle);
|
||||
if (markers[line]->Length() == 0) {
|
||||
delete markers[line];
|
||||
markers[line] = NULL;
|
||||
if (markers[line]->Empty()) {
|
||||
markers[line].reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -244,14 +197,14 @@ void LineLevels::Init() {
|
|||
levels.DeleteAll();
|
||||
}
|
||||
|
||||
void LineLevels::InsertLine(int line) {
|
||||
void LineLevels::InsertLine(Sci::Line line) {
|
||||
if (levels.Length()) {
|
||||
int level = (line < levels.Length()) ? levels[line] : SC_FOLDLEVELBASE;
|
||||
levels.InsertValue(line, 1, level);
|
||||
}
|
||||
}
|
||||
|
||||
void LineLevels::RemoveLine(int line) {
|
||||
void LineLevels::RemoveLine(Sci::Line line) {
|
||||
if (levels.Length()) {
|
||||
// Move up following lines but merge header flag from this line
|
||||
// to line before to avoid a temporary disappearence causing expansion.
|
||||
|
@ -264,7 +217,7 @@ void LineLevels::RemoveLine(int line) {
|
|||
}
|
||||
}
|
||||
|
||||
void LineLevels::ExpandLevels(int sizeNew) {
|
||||
void LineLevels::ExpandLevels(Sci::Line sizeNew) {
|
||||
levels.InsertValue(levels.Length(), sizeNew - levels.Length(), SC_FOLDLEVELBASE);
|
||||
}
|
||||
|
||||
|
@ -272,7 +225,7 @@ void LineLevels::ClearLevels() {
|
|||
levels.DeleteAll();
|
||||
}
|
||||
|
||||
int LineLevels::SetLevel(int line, int level, int lines) {
|
||||
int LineLevels::SetLevel(Sci::Line line, int level, Sci::Line lines) {
|
||||
int prev = 0;
|
||||
if ((line >= 0) && (line < lines)) {
|
||||
if (!levels.Length()) {
|
||||
|
@ -286,7 +239,7 @@ int LineLevels::SetLevel(int line, int level, int lines) {
|
|||
return prev;
|
||||
}
|
||||
|
||||
int LineLevels::GetLevel(int line) const {
|
||||
int LineLevels::GetLevel(Sci::Line line) const {
|
||||
if (levels.Length() && (line >= 0) && (line < levels.Length())) {
|
||||
return levels[line];
|
||||
} else {
|
||||
|
@ -301,7 +254,7 @@ void LineState::Init() {
|
|||
lineStates.DeleteAll();
|
||||
}
|
||||
|
||||
void LineState::InsertLine(int line) {
|
||||
void LineState::InsertLine(Sci::Line line) {
|
||||
if (lineStates.Length()) {
|
||||
lineStates.EnsureLength(line);
|
||||
int val = (line < lineStates.Length()) ? lineStates[line] : 0;
|
||||
|
@ -309,27 +262,27 @@ void LineState::InsertLine(int line) {
|
|||
}
|
||||
}
|
||||
|
||||
void LineState::RemoveLine(int line) {
|
||||
void LineState::RemoveLine(Sci::Line line) {
|
||||
if (lineStates.Length() > line) {
|
||||
lineStates.Delete(line);
|
||||
}
|
||||
}
|
||||
|
||||
int LineState::SetLineState(int line, int state) {
|
||||
int LineState::SetLineState(Sci::Line line, int state) {
|
||||
lineStates.EnsureLength(line + 1);
|
||||
int stateOld = lineStates[line];
|
||||
const int stateOld = lineStates[line];
|
||||
lineStates[line] = state;
|
||||
return stateOld;
|
||||
}
|
||||
|
||||
int LineState::GetLineState(int line) {
|
||||
int LineState::GetLineState(Sci::Line line) {
|
||||
if (line < 0)
|
||||
return 0;
|
||||
lineStates.EnsureLength(line + 1);
|
||||
return lineStates[line];
|
||||
}
|
||||
|
||||
int LineState::GetMaxLineState() const {
|
||||
Sci::Line LineState::GetMaxLineState() const {
|
||||
return lineStates.Length();
|
||||
}
|
||||
|
||||
|
@ -366,156 +319,146 @@ void LineAnnotation::Init() {
|
|||
ClearAll();
|
||||
}
|
||||
|
||||
void LineAnnotation::InsertLine(int line) {
|
||||
void LineAnnotation::InsertLine(Sci::Line line) {
|
||||
if (annotations.Length()) {
|
||||
annotations.EnsureLength(line);
|
||||
annotations.Insert(line, 0);
|
||||
annotations.Insert(line, std::unique_ptr<char []>());
|
||||
}
|
||||
}
|
||||
|
||||
void LineAnnotation::RemoveLine(int line) {
|
||||
void LineAnnotation::RemoveLine(Sci::Line line) {
|
||||
if (annotations.Length() && (line > 0) && (line <= annotations.Length())) {
|
||||
delete []annotations[line-1];
|
||||
annotations[line-1].reset();
|
||||
annotations.Delete(line-1);
|
||||
}
|
||||
}
|
||||
|
||||
bool LineAnnotation::MultipleStyles(int line) const {
|
||||
bool LineAnnotation::MultipleStyles(Sci::Line line) const {
|
||||
if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line])
|
||||
return reinterpret_cast<AnnotationHeader *>(annotations[line])->style == IndividualStyles;
|
||||
return reinterpret_cast<AnnotationHeader *>(annotations[line].get())->style == IndividualStyles;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
int LineAnnotation::Style(Sci::Line line) const {
|
||||
if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line])
|
||||
return reinterpret_cast<AnnotationHeader *>(annotations[line].get())->style;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LineAnnotation::Style(int line) const {
|
||||
const char *LineAnnotation::Text(Sci::Line line) const {
|
||||
if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line])
|
||||
return reinterpret_cast<AnnotationHeader *>(annotations[line])->style;
|
||||
return annotations[line].get()+sizeof(AnnotationHeader);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *LineAnnotation::Text(int line) const {
|
||||
if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line])
|
||||
return annotations[line]+sizeof(AnnotationHeader);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
const unsigned char *LineAnnotation::Styles(int line) const {
|
||||
const unsigned char *LineAnnotation::Styles(Sci::Line line) const {
|
||||
if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line] && MultipleStyles(line))
|
||||
return reinterpret_cast<unsigned char *>(annotations[line] + sizeof(AnnotationHeader) + Length(line));
|
||||
return reinterpret_cast<unsigned char *>(annotations[line].get() + sizeof(AnnotationHeader) + Length(line));
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char *AllocateAnnotation(int length, int style) {
|
||||
size_t len = sizeof(AnnotationHeader) + length + ((style == IndividualStyles) ? length : 0);
|
||||
const size_t len = sizeof(AnnotationHeader) + length + ((style == IndividualStyles) ? length : 0);
|
||||
char *ret = new char[len]();
|
||||
return ret;
|
||||
}
|
||||
|
||||
void LineAnnotation::SetText(int line, const char *text) {
|
||||
void LineAnnotation::SetText(Sci::Line line, const char *text) {
|
||||
if (text && (line >= 0)) {
|
||||
annotations.EnsureLength(line+1);
|
||||
int style = Style(line);
|
||||
if (annotations[line]) {
|
||||
delete []annotations[line];
|
||||
}
|
||||
annotations[line] = AllocateAnnotation(static_cast<int>(strlen(text)), style);
|
||||
AnnotationHeader *pah = reinterpret_cast<AnnotationHeader *>(annotations[line]);
|
||||
const int style = Style(line);
|
||||
annotations[line].reset(AllocateAnnotation(static_cast<int>(strlen(text)), style));
|
||||
char *pa = annotations[line].get();
|
||||
assert(pa);
|
||||
AnnotationHeader *pah = reinterpret_cast<AnnotationHeader *>(pa);
|
||||
pah->style = static_cast<short>(style);
|
||||
pah->length = static_cast<int>(strlen(text));
|
||||
pah->lines = static_cast<short>(NumberLines(text));
|
||||
memcpy(annotations[line]+sizeof(AnnotationHeader), text, pah->length);
|
||||
memcpy(pa+sizeof(AnnotationHeader), text, pah->length);
|
||||
} else {
|
||||
if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line]) {
|
||||
delete []annotations[line];
|
||||
annotations[line] = 0;
|
||||
annotations[line].reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LineAnnotation::ClearAll() {
|
||||
for (int line = 0; line < annotations.Length(); line++) {
|
||||
delete []annotations[line];
|
||||
annotations[line] = 0;
|
||||
}
|
||||
annotations.DeleteAll();
|
||||
}
|
||||
|
||||
void LineAnnotation::SetStyle(int line, int style) {
|
||||
void LineAnnotation::SetStyle(Sci::Line line, int style) {
|
||||
annotations.EnsureLength(line+1);
|
||||
if (!annotations[line]) {
|
||||
annotations[line] = AllocateAnnotation(0, style);
|
||||
annotations[line].reset(AllocateAnnotation(0, style));
|
||||
}
|
||||
reinterpret_cast<AnnotationHeader *>(annotations[line])->style = static_cast<short>(style);
|
||||
reinterpret_cast<AnnotationHeader *>(annotations[line].get())->style = static_cast<short>(style);
|
||||
}
|
||||
|
||||
void LineAnnotation::SetStyles(int line, const unsigned char *styles) {
|
||||
void LineAnnotation::SetStyles(Sci::Line line, const unsigned char *styles) {
|
||||
if (line >= 0) {
|
||||
annotations.EnsureLength(line+1);
|
||||
if (!annotations[line]) {
|
||||
annotations[line] = AllocateAnnotation(0, IndividualStyles);
|
||||
annotations[line].reset(AllocateAnnotation(0, IndividualStyles));
|
||||
} else {
|
||||
AnnotationHeader *pahSource = reinterpret_cast<AnnotationHeader *>(annotations[line]);
|
||||
AnnotationHeader *pahSource = reinterpret_cast<AnnotationHeader *>(annotations[line].get());
|
||||
if (pahSource->style != IndividualStyles) {
|
||||
char *allocation = AllocateAnnotation(pahSource->length, IndividualStyles);
|
||||
AnnotationHeader *pahAlloc = reinterpret_cast<AnnotationHeader *>(allocation);
|
||||
pahAlloc->length = pahSource->length;
|
||||
pahAlloc->lines = pahSource->lines;
|
||||
memcpy(allocation + sizeof(AnnotationHeader), annotations[line] + sizeof(AnnotationHeader), pahSource->length);
|
||||
delete []annotations[line];
|
||||
annotations[line] = allocation;
|
||||
memcpy(allocation + sizeof(AnnotationHeader), annotations[line].get() + sizeof(AnnotationHeader), pahSource->length);
|
||||
annotations[line].reset(allocation);
|
||||
}
|
||||
}
|
||||
AnnotationHeader *pah = reinterpret_cast<AnnotationHeader *>(annotations[line]);
|
||||
AnnotationHeader *pah = reinterpret_cast<AnnotationHeader *>(annotations[line].get());
|
||||
pah->style = IndividualStyles;
|
||||
memcpy(annotations[line] + sizeof(AnnotationHeader) + pah->length, styles, pah->length);
|
||||
memcpy(annotations[line].get() + sizeof(AnnotationHeader) + pah->length, styles, pah->length);
|
||||
}
|
||||
}
|
||||
|
||||
int LineAnnotation::Length(int line) const {
|
||||
int LineAnnotation::Length(Sci::Line line) const {
|
||||
if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line])
|
||||
return reinterpret_cast<AnnotationHeader *>(annotations[line])->length;
|
||||
return reinterpret_cast<AnnotationHeader *>(annotations[line].get())->length;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LineAnnotation::Lines(int line) const {
|
||||
int LineAnnotation::Lines(Sci::Line line) const {
|
||||
if (annotations.Length() && (line >= 0) && (line < annotations.Length()) && annotations[line])
|
||||
return reinterpret_cast<AnnotationHeader *>(annotations[line])->lines;
|
||||
return reinterpret_cast<AnnotationHeader *>(annotations[line].get())->lines;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
LineTabstops::~LineTabstops() {
|
||||
Init();
|
||||
}
|
||||
|
||||
void LineTabstops::Init() {
|
||||
for (int line = 0; line < tabstops.Length(); line++) {
|
||||
delete tabstops[line];
|
||||
}
|
||||
tabstops.DeleteAll();
|
||||
}
|
||||
|
||||
void LineTabstops::InsertLine(int line) {
|
||||
void LineTabstops::Init() {
|
||||
tabstops.DeleteAll();
|
||||
}
|
||||
|
||||
void LineTabstops::InsertLine(Sci::Line line) {
|
||||
if (tabstops.Length()) {
|
||||
tabstops.EnsureLength(line);
|
||||
tabstops.Insert(line, 0);
|
||||
tabstops.Insert(line, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void LineTabstops::RemoveLine(int line) {
|
||||
void LineTabstops::RemoveLine(Sci::Line line) {
|
||||
if (tabstops.Length() > line) {
|
||||
delete tabstops[line];
|
||||
tabstops[line].reset();
|
||||
tabstops.Delete(line);
|
||||
}
|
||||
}
|
||||
|
||||
bool LineTabstops::ClearTabstops(int line) {
|
||||
bool LineTabstops::ClearTabstops(Sci::Line line) {
|
||||
if (line < tabstops.Length()) {
|
||||
TabstopList *tl = tabstops[line];
|
||||
TabstopList *tl = tabstops[line].get();
|
||||
if (tl) {
|
||||
tl->clear();
|
||||
return true;
|
||||
|
@ -524,13 +467,13 @@ bool LineTabstops::ClearTabstops(int line) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool LineTabstops::AddTabstop(int line, int x) {
|
||||
bool LineTabstops::AddTabstop(Sci::Line line, int x) {
|
||||
tabstops.EnsureLength(line + 1);
|
||||
if (!tabstops[line]) {
|
||||
tabstops[line] = new TabstopList();
|
||||
tabstops[line].reset(new TabstopList());
|
||||
}
|
||||
|
||||
TabstopList *tl = tabstops[line];
|
||||
TabstopList *tl = tabstops[line].get();
|
||||
if (tl) {
|
||||
// tabstop positions are kept in order - insert in the right place
|
||||
std::vector<int>::iterator it = std::lower_bound(tl->begin(), tl->end(), x);
|
||||
|
@ -543,13 +486,13 @@ bool LineTabstops::AddTabstop(int line, int x) {
|
|||
return false;
|
||||
}
|
||||
|
||||
int LineTabstops::GetNextTabstop(int line, int x) const {
|
||||
int LineTabstops::GetNextTabstop(Sci::Line line, int x) const {
|
||||
if (line < tabstops.Length()) {
|
||||
TabstopList *tl = tabstops[line];
|
||||
TabstopList *tl = tabstops[line].get();
|
||||
if (tl) {
|
||||
for (size_t i = 0; i < tl->size(); i++) {
|
||||
if ((*tl)[i] > x) {
|
||||
return (*tl)[i];
|
||||
for (const int i : *tl) {
|
||||
if (i > x) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,19 +19,22 @@ namespace Scintilla {
|
|||
struct MarkerHandleNumber {
|
||||
int handle;
|
||||
int number;
|
||||
MarkerHandleNumber *next;
|
||||
MarkerHandleNumber(int handle_, int number_) : handle(handle_), number(number_) {}
|
||||
};
|
||||
|
||||
/**
|
||||
* A marker handle set contains any number of MarkerHandleNumbers.
|
||||
*/
|
||||
class MarkerHandleSet {
|
||||
MarkerHandleNumber *root;
|
||||
std::forward_list<MarkerHandleNumber> mhList;
|
||||
|
||||
public:
|
||||
MarkerHandleSet();
|
||||
// Deleted so MarkerHandleSet objects can not be copied.
|
||||
MarkerHandleSet(const MarkerHandleSet &) = delete;
|
||||
void operator=(const MarkerHandleSet &) = delete;
|
||||
~MarkerHandleSet();
|
||||
int Length() const;
|
||||
bool Empty() const;
|
||||
int MarkValue() const; ///< Bit set of marker numbers.
|
||||
bool Contains(int handle) const;
|
||||
bool InsertHandle(int handle, int markerNum);
|
||||
|
@ -41,38 +44,46 @@ public:
|
|||
};
|
||||
|
||||
class LineMarkers : public PerLine {
|
||||
SplitVector<MarkerHandleSet *> markers;
|
||||
SplitVector<std::unique_ptr<MarkerHandleSet>> markers;
|
||||
/// Handles are allocated sequentially and should never have to be reused as 32 bit ints are very big.
|
||||
int handleCurrent;
|
||||
public:
|
||||
LineMarkers() : handleCurrent(0) {
|
||||
}
|
||||
// Deleted so Worker objects can not be copied.
|
||||
LineMarkers(const LineMarkers &) = delete;
|
||||
void operator=(const LineMarkers &) = delete;
|
||||
virtual ~LineMarkers();
|
||||
virtual void Init();
|
||||
virtual void InsertLine(int line);
|
||||
virtual void RemoveLine(int line);
|
||||
void Init() override;
|
||||
void InsertLine(Sci::Line line) override;
|
||||
void RemoveLine(Sci::Line line) override;
|
||||
|
||||
int MarkValue(int line);
|
||||
int MarkerNext(int lineStart, int mask) const;
|
||||
int AddMark(int line, int marker, int lines);
|
||||
void MergeMarkers(int pos);
|
||||
bool DeleteMark(int line, int markerNum, bool all);
|
||||
int MarkValue(Sci::Line line);
|
||||
Sci::Line MarkerNext(Sci::Line lineStart, int mask) const;
|
||||
int AddMark(Sci::Line line, int markerNum, Sci::Line lines);
|
||||
void MergeMarkers(Sci::Line line);
|
||||
bool DeleteMark(Sci::Line line, int markerNum, bool all);
|
||||
void DeleteMarkFromHandle(int markerHandle);
|
||||
int LineFromHandle(int markerHandle);
|
||||
Sci::Line LineFromHandle(int markerHandle);
|
||||
};
|
||||
|
||||
class LineLevels : public PerLine {
|
||||
SplitVector<int> levels;
|
||||
public:
|
||||
LineLevels() {
|
||||
}
|
||||
// Deleted so Worker objects can not be copied.
|
||||
LineLevels(const LineLevels &) = delete;
|
||||
void operator=(const LineLevels &) = delete;
|
||||
virtual ~LineLevels();
|
||||
virtual void Init();
|
||||
virtual void InsertLine(int line);
|
||||
virtual void RemoveLine(int line);
|
||||
void Init() override;
|
||||
void InsertLine(Sci::Line line) override;
|
||||
void RemoveLine(Sci::Line line) override;
|
||||
|
||||
void ExpandLevels(int sizeNew=-1);
|
||||
void ExpandLevels(Sci::Line sizeNew=-1);
|
||||
void ClearLevels();
|
||||
int SetLevel(int line, int level, int lines);
|
||||
int GetLevel(int line) const;
|
||||
int SetLevel(Sci::Line line, int level, Sci::Line lines);
|
||||
int GetLevel(Sci::Line line) const;
|
||||
};
|
||||
|
||||
class LineState : public PerLine {
|
||||
|
@ -80,53 +91,62 @@ class LineState : public PerLine {
|
|||
public:
|
||||
LineState() {
|
||||
}
|
||||
// Deleted so Worker objects can not be copied.
|
||||
LineState(const LineState &) = delete;
|
||||
void operator=(const LineState &) = delete;
|
||||
virtual ~LineState();
|
||||
virtual void Init();
|
||||
virtual void InsertLine(int line);
|
||||
virtual void RemoveLine(int line);
|
||||
void Init() override;
|
||||
void InsertLine(Sci::Line line) override;
|
||||
void RemoveLine(Sci::Line line) override;
|
||||
|
||||
int SetLineState(int line, int state);
|
||||
int GetLineState(int line);
|
||||
int GetMaxLineState() const;
|
||||
int SetLineState(Sci::Line line, int state);
|
||||
int GetLineState(Sci::Line line);
|
||||
Sci::Line GetMaxLineState() const;
|
||||
};
|
||||
|
||||
class LineAnnotation : public PerLine {
|
||||
SplitVector<char *> annotations;
|
||||
SplitVector<std::unique_ptr<char []>> annotations;
|
||||
public:
|
||||
LineAnnotation() {
|
||||
}
|
||||
// Deleted so Worker objects can not be copied.
|
||||
LineAnnotation(const LineAnnotation &) = delete;
|
||||
void operator=(const LineAnnotation &) = delete;
|
||||
virtual ~LineAnnotation();
|
||||
virtual void Init();
|
||||
virtual void InsertLine(int line);
|
||||
virtual void RemoveLine(int line);
|
||||
void Init() override;
|
||||
void InsertLine(Sci::Line line) override;
|
||||
void RemoveLine(Sci::Line line) override;
|
||||
|
||||
bool MultipleStyles(int line) const;
|
||||
int Style(int line) const;
|
||||
const char *Text(int line) const;
|
||||
const unsigned char *Styles(int line) const;
|
||||
void SetText(int line, const char *text);
|
||||
bool MultipleStyles(Sci::Line line) const;
|
||||
int Style(Sci::Line line) const;
|
||||
const char *Text(Sci::Line line) const;
|
||||
const unsigned char *Styles(Sci::Line line) const;
|
||||
void SetText(Sci::Line line, const char *text);
|
||||
void ClearAll();
|
||||
void SetStyle(int line, int style);
|
||||
void SetStyles(int line, const unsigned char *styles);
|
||||
int Length(int line) const;
|
||||
int Lines(int line) const;
|
||||
void SetStyle(Sci::Line line, int style);
|
||||
void SetStyles(Sci::Line line, const unsigned char *styles);
|
||||
int Length(Sci::Line line) const;
|
||||
int Lines(Sci::Line line) const;
|
||||
};
|
||||
|
||||
typedef std::vector<int> TabstopList;
|
||||
|
||||
class LineTabstops : public PerLine {
|
||||
SplitVector<TabstopList *> tabstops;
|
||||
SplitVector<std::unique_ptr<TabstopList>> tabstops;
|
||||
public:
|
||||
LineTabstops() {
|
||||
}
|
||||
// Deleted so Worker objects can not be copied.
|
||||
LineTabstops(const LineTabstops &) = delete;
|
||||
void operator=(const LineTabstops &) = delete;
|
||||
virtual ~LineTabstops();
|
||||
virtual void Init();
|
||||
virtual void InsertLine(int line);
|
||||
virtual void RemoveLine(int line);
|
||||
void Init() override;
|
||||
void InsertLine(Sci::Line line) override;
|
||||
void RemoveLine(Sci::Line line) override;
|
||||
|
||||
bool ClearTabstops(int line);
|
||||
bool AddTabstop(int line, int x);
|
||||
int GetNextTabstop(int line, int x) const;
|
||||
bool ClearTabstops(Sci::Line line);
|
||||
bool AddTabstop(Sci::Line line, int x);
|
||||
int GetNextTabstop(Sci::Line line, int x) const;
|
||||
};
|
||||
|
||||
#ifdef SCI_NAMESPACE
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
namespace Sci {
|
||||
|
||||
typedef int Position;
|
||||
typedef int Line;
|
||||
|
||||
// A later version (4.x) of this file may:
|
||||
//#if defined(SCI_LARGE_FILE_SUPPORT)
|
||||
|
|
|
@ -5,16 +5,16 @@
|
|||
// Copyright 1998-2007 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
|||
#include "Scintilla.h"
|
||||
|
||||
#include "Position.h"
|
||||
#include "UniqueString.h"
|
||||
#include "SplitVector.h"
|
||||
#include "Partitioning.h"
|
||||
#include "RunStyles.h"
|
||||
|
@ -46,7 +47,6 @@ using namespace Scintilla;
|
|||
#endif
|
||||
|
||||
LineLayout::LineLayout(int maxLineLength_) :
|
||||
lineStarts(0),
|
||||
lenLineStarts(0),
|
||||
lineNumber(-1),
|
||||
inCache(false),
|
||||
|
@ -55,12 +55,9 @@ LineLayout::LineLayout(int maxLineLength_) :
|
|||
numCharsBeforeEOL(0),
|
||||
validity(llInvalid),
|
||||
xHighlightGuide(0),
|
||||
highlightColumn(0),
|
||||
highlightColumn(false),
|
||||
containsCaret(false),
|
||||
edgeColumn(0),
|
||||
chars(0),
|
||||
styles(0),
|
||||
positions(0),
|
||||
hotspot(0,0),
|
||||
widthLine(wrapWidthInfinite),
|
||||
lines(1),
|
||||
|
@ -77,24 +74,20 @@ LineLayout::~LineLayout() {
|
|||
void LineLayout::Resize(int maxLineLength_) {
|
||||
if (maxLineLength_ > maxLineLength) {
|
||||
Free();
|
||||
chars = new char[maxLineLength_ + 1];
|
||||
styles = new unsigned char[maxLineLength_ + 1];
|
||||
chars.reset(new char[maxLineLength_ + 1]);
|
||||
styles.reset(new unsigned char[maxLineLength_ + 1]);
|
||||
// Extra position allocated as sometimes the Windows
|
||||
// GetTextExtentExPoint API writes an extra element.
|
||||
positions = new XYPOSITION[maxLineLength_ + 1 + 1];
|
||||
positions.reset(new XYPOSITION[maxLineLength_ + 1 + 1]);
|
||||
maxLineLength = maxLineLength_;
|
||||
}
|
||||
}
|
||||
|
||||
void LineLayout::Free() {
|
||||
delete []chars;
|
||||
chars = 0;
|
||||
delete []styles;
|
||||
styles = 0;
|
||||
delete []positions;
|
||||
positions = 0;
|
||||
delete []lineStarts;
|
||||
lineStarts = 0;
|
||||
chars.reset();
|
||||
styles.reset();
|
||||
positions.reset();
|
||||
lineStarts.reset();
|
||||
}
|
||||
|
||||
void LineLayout::Invalidate(validLevel validity_) {
|
||||
|
@ -141,14 +134,13 @@ void LineLayout::SetLineStart(int line, int start) {
|
|||
else
|
||||
newLineStarts[i] = 0;
|
||||
}
|
||||
delete []lineStarts;
|
||||
lineStarts = newLineStarts;
|
||||
lineStarts.reset(newLineStarts);
|
||||
lenLineStarts = newMaxLines;
|
||||
}
|
||||
lineStarts[line] = start;
|
||||
}
|
||||
|
||||
void LineLayout::SetBracesHighlight(Range rangeLine, const Position braces[],
|
||||
void LineLayout::SetBracesHighlight(Range rangeLine, const Sci::Position braces[],
|
||||
char bracesMatchStyle, int xHighlight, bool ignoreStyle) {
|
||||
if (!ignoreStyle && rangeLine.ContainsCharacter(braces[0])) {
|
||||
int braceOffset = braces[0] - rangeLine.start;
|
||||
|
@ -170,7 +162,7 @@ void LineLayout::SetBracesHighlight(Range rangeLine, const Position braces[],
|
|||
}
|
||||
}
|
||||
|
||||
void LineLayout::RestoreBracesHighlight(Range rangeLine, const Position braces[], bool ignoreStyle) {
|
||||
void LineLayout::RestoreBracesHighlight(Range rangeLine, const Sci::Position braces[], bool ignoreStyle) {
|
||||
if (!ignoreStyle && rangeLine.ContainsCharacter(braces[0])) {
|
||||
int braceOffset = braces[0] - rangeLine.start;
|
||||
if (braceOffset < numCharsInLine) {
|
||||
|
@ -189,7 +181,7 @@ void LineLayout::RestoreBracesHighlight(Range rangeLine, const Position braces[]
|
|||
int LineLayout::FindBefore(XYPOSITION x, int lower, int upper) const {
|
||||
do {
|
||||
int middle = (upper + lower + 1) / 2; // Round high
|
||||
XYPOSITION posMiddle = positions[middle];
|
||||
const XYPOSITION posMiddle = positions[middle];
|
||||
if (x < posMiddle) {
|
||||
upper = middle - 1;
|
||||
} else {
|
||||
|
@ -266,7 +258,7 @@ void LineLayoutCache::Allocate(size_t length_) {
|
|||
cache.resize(length_);
|
||||
}
|
||||
|
||||
void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) {
|
||||
void LineLayoutCache::AllocateForLevel(Sci::Line linesOnScreen, Sci::Line linesInDoc) {
|
||||
PLATFORM_ASSERT(useCount == 0);
|
||||
size_t lengthForLevel = 0;
|
||||
if (level == llcCaret) {
|
||||
|
@ -282,8 +274,7 @@ void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) {
|
|||
} else {
|
||||
if (lengthForLevel < cache.size()) {
|
||||
for (size_t i = lengthForLevel; i < cache.size(); i++) {
|
||||
delete cache[i];
|
||||
cache[i] = 0;
|
||||
cache[i].reset();
|
||||
}
|
||||
}
|
||||
cache.resize(lengthForLevel);
|
||||
|
@ -293,16 +284,14 @@ void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) {
|
|||
|
||||
void LineLayoutCache::Deallocate() {
|
||||
PLATFORM_ASSERT(useCount == 0);
|
||||
for (size_t i = 0; i < cache.size(); i++)
|
||||
delete cache[i];
|
||||
cache.clear();
|
||||
}
|
||||
|
||||
void LineLayoutCache::Invalidate(LineLayout::validLevel validity_) {
|
||||
if (!cache.empty() && !allInvalidated) {
|
||||
for (size_t i = 0; i < cache.size(); i++) {
|
||||
if (cache[i]) {
|
||||
cache[i]->Invalidate(validity_);
|
||||
for (const std::unique_ptr<LineLayout> &ll : cache) {
|
||||
if (ll) {
|
||||
ll->Invalidate(validity_);
|
||||
}
|
||||
}
|
||||
if (validity_ == LineLayout::llInvalid) {
|
||||
|
@ -319,15 +308,15 @@ void LineLayoutCache::SetLevel(int level_) {
|
|||
}
|
||||
}
|
||||
|
||||
LineLayout *LineLayoutCache::Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_,
|
||||
int linesOnScreen, int linesInDoc) {
|
||||
LineLayout *LineLayoutCache::Retrieve(Sci::Line lineNumber, Sci::Line lineCaret, int maxChars, int styleClock_,
|
||||
Sci::Line linesOnScreen, Sci::Line linesInDoc) {
|
||||
AllocateForLevel(linesOnScreen, linesInDoc);
|
||||
if (styleClock != styleClock_) {
|
||||
Invalidate(LineLayout::llCheckTextAndStyle);
|
||||
styleClock = styleClock_;
|
||||
}
|
||||
allInvalidated = false;
|
||||
int pos = -1;
|
||||
Sci::Position pos = -1;
|
||||
LineLayout *ret = 0;
|
||||
if (level == llcCaret) {
|
||||
pos = 0;
|
||||
|
@ -346,16 +335,15 @@ LineLayout *LineLayoutCache::Retrieve(int lineNumber, int lineCaret, int maxChar
|
|||
if (cache[pos]) {
|
||||
if ((cache[pos]->lineNumber != lineNumber) ||
|
||||
(cache[pos]->maxLineLength < maxChars)) {
|
||||
delete cache[pos];
|
||||
cache[pos] = 0;
|
||||
cache[pos].reset();
|
||||
}
|
||||
}
|
||||
if (!cache[pos]) {
|
||||
cache[pos] = new LineLayout(maxChars);
|
||||
cache[pos].reset(new LineLayout(maxChars));
|
||||
}
|
||||
cache[pos]->lineNumber = lineNumber;
|
||||
cache[pos]->inCache = true;
|
||||
ret = cache[pos];
|
||||
ret = cache[pos].get();
|
||||
useCount++;
|
||||
}
|
||||
}
|
||||
|
@ -391,7 +379,7 @@ static inline int KeyFromString(const char *charBytes, size_t len) {
|
|||
}
|
||||
|
||||
SpecialRepresentations::SpecialRepresentations() {
|
||||
std::fill(startByteHasReprs, startByteHasReprs+0x100, 0);
|
||||
std::fill(startByteHasReprs, startByteHasReprs+0x100, static_cast<short>(0));
|
||||
}
|
||||
|
||||
void SpecialRepresentations::SetRepresentation(const char *charBytes, const char *value) {
|
||||
|
@ -432,7 +420,7 @@ bool SpecialRepresentations::Contains(const char *charBytes, size_t len) const {
|
|||
|
||||
void SpecialRepresentations::Clear() {
|
||||
mapReprs.clear();
|
||||
std::fill(startByteHasReprs, startByteHasReprs+0x100, 0);
|
||||
std::fill(startByteHasReprs, startByteHasReprs+0x100, static_cast<short>(0));
|
||||
}
|
||||
|
||||
void BreakFinder::Insert(int val) {
|
||||
|
@ -446,7 +434,7 @@ void BreakFinder::Insert(int val) {
|
|||
}
|
||||
}
|
||||
|
||||
BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lineRange_, int posLineStart_,
|
||||
BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lineRange_, Sci::Position posLineStart_,
|
||||
int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_, const ViewStyle *pvsDraw) :
|
||||
ll(ll_),
|
||||
lineRange(lineRange_),
|
||||
|
@ -469,11 +457,11 @@ BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lin
|
|||
}
|
||||
|
||||
if (breakForSelection) {
|
||||
SelectionPosition posStart(posLineStart);
|
||||
SelectionPosition posEnd(posLineStart + lineRange.end);
|
||||
SelectionSegment segmentLine(posStart, posEnd);
|
||||
const SelectionPosition posStart(posLineStart);
|
||||
const SelectionPosition posEnd(posLineStart + lineRange.end);
|
||||
const SelectionSegment segmentLine(posStart, posEnd);
|
||||
for (size_t r=0; r<psel->Count(); r++) {
|
||||
SelectionSegment portion = psel->Range(r).Intersect(segmentLine);
|
||||
const SelectionSegment portion = psel->Range(r).Intersect(segmentLine);
|
||||
if (!(portion.start == portion.end)) {
|
||||
if (portion.start.IsValid())
|
||||
Insert(portion.start.Position() - posLineStart);
|
||||
|
@ -482,10 +470,10 @@ BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lin
|
|||
}
|
||||
}
|
||||
}
|
||||
if (pvsDraw && pvsDraw->indicatorsSetFore > 0) {
|
||||
for (Decoration *deco = pdoc->decorations.root; deco; deco = deco->next) {
|
||||
if (pvsDraw->indicators[deco->indicator].OverridesTextFore()) {
|
||||
int startPos = deco->rs.EndRun(posLineStart);
|
||||
if (pvsDraw && pvsDraw->indicatorsSetFore) {
|
||||
for (const Decoration *deco : pdoc->decorations.View()) {
|
||||
if (pvsDraw->indicators[deco->Indicator()].OverridesTextFore()) {
|
||||
Sci::Position startPos = deco->rs.EndRun(posLineStart);
|
||||
while (startPos < (posLineStart + lineRange.end)) {
|
||||
Insert(startPos - posLineStart);
|
||||
startPos = deco->rs.EndRun(startPos);
|
||||
|
@ -507,10 +495,10 @@ TextSegment BreakFinder::Next() {
|
|||
while (nextBreak < lineRange.end) {
|
||||
int charWidth = 1;
|
||||
if (encodingFamily == efUnicode)
|
||||
charWidth = UTF8DrawBytes(reinterpret_cast<unsigned char *>(ll->chars) + nextBreak, lineRange.end - nextBreak);
|
||||
charWidth = UTF8DrawBytes(reinterpret_cast<unsigned char *>(&ll->chars[nextBreak]), lineRange.end - nextBreak);
|
||||
else if (encodingFamily == efDBCS)
|
||||
charWidth = pdoc->IsDBCSLeadByte(ll->chars[nextBreak]) ? 2 : 1;
|
||||
const Representation *repr = preprs->RepresentationFromCharacter(ll->chars + nextBreak, charWidth);
|
||||
const Representation *repr = preprs->RepresentationFromCharacter(&ll->chars[nextBreak], charWidth);
|
||||
if (((nextBreak > 0) && (ll->styles[nextBreak] != ll->styles[nextBreak - 1])) ||
|
||||
repr ||
|
||||
(nextBreak == saeNext)) {
|
||||
|
@ -546,7 +534,7 @@ TextSegment BreakFinder::Next() {
|
|||
subBreak = -1;
|
||||
return TextSegment(startSegment, nextBreak - startSegment);
|
||||
} else {
|
||||
subBreak += pdoc->SafeSegment(ll->chars + subBreak, nextBreak-subBreak, lengthEachSubdivision);
|
||||
subBreak += pdoc->SafeSegment(&ll->chars[subBreak], nextBreak-subBreak, lengthEachSubdivision);
|
||||
if (subBreak >= nextBreak) {
|
||||
subBreak = -1;
|
||||
return TextSegment(startSegment, nextBreak - startSegment);
|
||||
|
@ -561,7 +549,17 @@ bool BreakFinder::More() const {
|
|||
}
|
||||
|
||||
PositionCacheEntry::PositionCacheEntry() :
|
||||
styleNumber(0), len(0), clock(0), positions(0) {
|
||||
styleNumber(0), len(0), clock(0), positions(nullptr) {
|
||||
}
|
||||
|
||||
// Copy constructor not currently used, but needed for being element in std::vector.
|
||||
PositionCacheEntry::PositionCacheEntry(const PositionCacheEntry &other) :
|
||||
styleNumber(other.styleNumber), len(other.styleNumber), clock(other.styleNumber), positions(nullptr) {
|
||||
if (other.positions) {
|
||||
const size_t lenData = len + (len / sizeof(XYPOSITION)) + 1;
|
||||
positions.reset(new XYPOSITION[lenData]);
|
||||
memcpy(positions.get(), other.positions.get(), lenData * sizeof(XYPOSITION));
|
||||
}
|
||||
}
|
||||
|
||||
void PositionCacheEntry::Set(unsigned int styleNumber_, const char *s_,
|
||||
|
@ -571,11 +569,11 @@ void PositionCacheEntry::Set(unsigned int styleNumber_, const char *s_,
|
|||
len = len_;
|
||||
clock = clock_;
|
||||
if (s_ && positions_) {
|
||||
positions = new XYPOSITION[len + (len / 4) + 1];
|
||||
positions.reset(new XYPOSITION[len + (len / sizeof(XYPOSITION)) + 1]);
|
||||
for (unsigned int i=0; i<len; i++) {
|
||||
positions[i] = positions_[i];
|
||||
}
|
||||
memcpy(reinterpret_cast<char *>(reinterpret_cast<void *>(positions + len)), s_, len);
|
||||
memcpy(&positions[len], s_, len);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -584,8 +582,7 @@ PositionCacheEntry::~PositionCacheEntry() {
|
|||
}
|
||||
|
||||
void PositionCacheEntry::Clear() {
|
||||
delete []positions;
|
||||
positions = 0;
|
||||
positions.reset();
|
||||
styleNumber = 0;
|
||||
len = 0;
|
||||
clock = 0;
|
||||
|
@ -594,7 +591,7 @@ void PositionCacheEntry::Clear() {
|
|||
bool PositionCacheEntry::Retrieve(unsigned int styleNumber_, const char *s_,
|
||||
unsigned int len_, XYPOSITION *positions_) const {
|
||||
if ((styleNumber == styleNumber_) && (len == len_) &&
|
||||
(memcmp(reinterpret_cast<char *>(reinterpret_cast<void *>(positions + len)), s_, len)== 0)) {
|
||||
(memcmp(&positions[len], s_, len)== 0)) {
|
||||
for (unsigned int i=0; i<len; i++) {
|
||||
positions_[i] = positions[i];
|
||||
}
|
||||
|
@ -639,8 +636,8 @@ PositionCache::~PositionCache() {
|
|||
|
||||
void PositionCache::Clear() {
|
||||
if (!allClear) {
|
||||
for (size_t i=0; i<pces.size(); i++) {
|
||||
pces[i].Clear();
|
||||
for (PositionCacheEntry &pce : pces) {
|
||||
pce.Clear();
|
||||
}
|
||||
}
|
||||
clock = 1;
|
||||
|
@ -653,7 +650,7 @@ void PositionCache::SetSize(size_t size_) {
|
|||
}
|
||||
|
||||
void PositionCache::MeasureWidths(Surface *surface, const ViewStyle &vstyle, unsigned int styleNumber,
|
||||
const char *s, unsigned int len, XYPOSITION *positions, Document *pdoc) {
|
||||
const char *s, unsigned int len, XYPOSITION *positions, const Document *pdoc) {
|
||||
|
||||
allClear = false;
|
||||
size_t probe = pces.size(); // Out of bounds
|
||||
|
@ -700,8 +697,8 @@ void PositionCache::MeasureWidths(Surface *surface, const ViewStyle &vstyle, uns
|
|||
if (clock > 60000) {
|
||||
// Since there are only 16 bits for the clock, wrap it round and
|
||||
// reset all cache entries so none get stuck with a high clock.
|
||||
for (size_t i=0; i<pces.size(); i++) {
|
||||
pces[i].ResetClock();
|
||||
for (PositionCacheEntry &pce : pces) {
|
||||
pce.ResetClock();
|
||||
}
|
||||
clock = 2;
|
||||
}
|
||||
|
|
|
@ -47,10 +47,10 @@ enum PointEnd {
|
|||
class LineLayout {
|
||||
private:
|
||||
friend class LineLayoutCache;
|
||||
int *lineStarts;
|
||||
std::unique_ptr<int []>lineStarts;
|
||||
int lenLineStarts;
|
||||
/// Drawing is only performed for @a maxLineLength characters on each line.
|
||||
int lineNumber;
|
||||
Sci::Line lineNumber;
|
||||
bool inCache;
|
||||
public:
|
||||
enum { wrapWidthInfinite = 0x7ffffff };
|
||||
|
@ -63,9 +63,9 @@ public:
|
|||
bool highlightColumn;
|
||||
bool containsCaret;
|
||||
int edgeColumn;
|
||||
char *chars;
|
||||
unsigned char *styles;
|
||||
XYPOSITION *positions;
|
||||
std::unique_ptr<char[]> chars;
|
||||
std::unique_ptr<unsigned char[]> styles;
|
||||
std::unique_ptr<XYPOSITION[]> positions;
|
||||
char bracePreviousStyles[2];
|
||||
|
||||
// Hotspot support
|
||||
|
@ -77,18 +77,21 @@ public:
|
|||
XYPOSITION wrapIndent; // In pixels
|
||||
|
||||
explicit LineLayout(int maxLineLength_);
|
||||
// Deleted so LineLayout objects can not be copied.
|
||||
LineLayout(const LineLayout &) = delete;
|
||||
void operator=(const LineLayout &) = delete;
|
||||
virtual ~LineLayout();
|
||||
void Resize(int maxLineLength_);
|
||||
void Free();
|
||||
void Invalidate(validLevel validity_);
|
||||
int LineStart(int line) const;
|
||||
int LineLastVisible(int line) const;
|
||||
Range SubLineRange(int line) const;
|
||||
Range SubLineRange(int subLine) const;
|
||||
bool InLine(int offset, int line) const;
|
||||
void SetLineStart(int line, int start);
|
||||
void SetBracesHighlight(Range rangeLine, const Position braces[],
|
||||
void SetBracesHighlight(Range rangeLine, const Sci::Position braces[],
|
||||
char bracesMatchStyle, int xHighlight, bool ignoreStyle);
|
||||
void RestoreBracesHighlight(Range rangeLine, const Position braces[], bool ignoreStyle);
|
||||
void RestoreBracesHighlight(Range rangeLine, const Sci::Position braces[], bool ignoreStyle);
|
||||
int FindBefore(XYPOSITION x, int lower, int upper) const;
|
||||
int FindPositionFromX(XYPOSITION x, Range range, bool charPosition) const;
|
||||
Point PointFromPosition(int posInLine, int lineHeight, PointEnd pe) const;
|
||||
|
@ -99,14 +102,17 @@ public:
|
|||
*/
|
||||
class LineLayoutCache {
|
||||
int level;
|
||||
std::vector<LineLayout *>cache;
|
||||
std::vector<std::unique_ptr<LineLayout>>cache;
|
||||
bool allInvalidated;
|
||||
int styleClock;
|
||||
int useCount;
|
||||
void Allocate(size_t length_);
|
||||
void AllocateForLevel(int linesOnScreen, int linesInDoc);
|
||||
void AllocateForLevel(Sci::Line linesOnScreen, Sci::Line linesInDoc);
|
||||
public:
|
||||
LineLayoutCache();
|
||||
// Deleted so LineLayoutCache objects can not be copied.
|
||||
LineLayoutCache(const LineLayoutCache &) = delete;
|
||||
void operator=(const LineLayoutCache &) = delete;
|
||||
virtual ~LineLayoutCache();
|
||||
void Deallocate();
|
||||
enum {
|
||||
|
@ -118,8 +124,8 @@ public:
|
|||
void Invalidate(LineLayout::validLevel validity_);
|
||||
void SetLevel(int level_);
|
||||
int GetLevel() const { return level; }
|
||||
LineLayout *Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_,
|
||||
int linesOnScreen, int linesInDoc);
|
||||
LineLayout *Retrieve(Sci::Line lineNumber, Sci::Line lineCaret, int maxChars, int styleClock_,
|
||||
Sci::Line linesOnScreen, Sci::Line linesInDoc);
|
||||
void Dispose(LineLayout *ll);
|
||||
};
|
||||
|
||||
|
@ -127,14 +133,18 @@ class PositionCacheEntry {
|
|||
unsigned int styleNumber:8;
|
||||
unsigned int len:8;
|
||||
unsigned int clock:16;
|
||||
XYPOSITION *positions;
|
||||
std::unique_ptr<XYPOSITION []> positions;
|
||||
public:
|
||||
PositionCacheEntry();
|
||||
// Copy constructor not currently used, but needed for being element in std::vector.
|
||||
PositionCacheEntry(const PositionCacheEntry &);
|
||||
// Deleted so PositionCacheEntry objects can not be assigned.
|
||||
void operator=(const PositionCacheEntry &) = delete;
|
||||
~PositionCacheEntry();
|
||||
void Set(unsigned int styleNumber_, const char *s_, unsigned int len_, XYPOSITION *positions_, unsigned int clock_);
|
||||
void Clear();
|
||||
bool Retrieve(unsigned int styleNumber_, const char *s_, unsigned int len_, XYPOSITION *positions_) const;
|
||||
static unsigned int Hash(unsigned int styleNumber_, const char *s, unsigned int len);
|
||||
static unsigned int Hash(unsigned int styleNumber_, const char *s, unsigned int len_);
|
||||
bool NewerThan(const PositionCacheEntry &other) const;
|
||||
void ResetClock();
|
||||
};
|
||||
|
@ -176,7 +186,7 @@ struct TextSegment {
|
|||
class BreakFinder {
|
||||
const LineLayout *ll;
|
||||
Range lineRange;
|
||||
int posLineStart;
|
||||
Sci::Position posLineStart;
|
||||
int nextBreak;
|
||||
std::vector<int> selAndEdge;
|
||||
unsigned int saeCurrentPos;
|
||||
|
@ -186,16 +196,17 @@ class BreakFinder {
|
|||
EncodingFamily encodingFamily;
|
||||
const SpecialRepresentations *preprs;
|
||||
void Insert(int val);
|
||||
// Private so BreakFinder objects can not be copied
|
||||
BreakFinder(const BreakFinder &);
|
||||
public:
|
||||
// If a whole run is longer than lengthStartSubdivision then subdivide
|
||||
// into smaller runs at spaces or punctuation.
|
||||
enum { lengthStartSubdivision = 300 };
|
||||
// Try to make each subdivided run lengthEachSubdivision or shorter.
|
||||
enum { lengthEachSubdivision = 100 };
|
||||
BreakFinder(const LineLayout *ll_, const Selection *psel, Range rangeLine_, int posLineStart_,
|
||||
BreakFinder(const LineLayout *ll_, const Selection *psel, Range lineRange_, Sci::Position posLineStart_,
|
||||
int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_, const ViewStyle *pvsDraw);
|
||||
// Deleted so BreakFinder objects can not be copied.
|
||||
BreakFinder(const BreakFinder &) = delete;
|
||||
void operator=(const BreakFinder &) = delete;
|
||||
~BreakFinder();
|
||||
TextSegment Next();
|
||||
bool More() const;
|
||||
|
@ -205,16 +216,17 @@ class PositionCache {
|
|||
std::vector<PositionCacheEntry> pces;
|
||||
unsigned int clock;
|
||||
bool allClear;
|
||||
// Private so PositionCache objects can not be copied
|
||||
PositionCache(const PositionCache &);
|
||||
public:
|
||||
PositionCache();
|
||||
// Deleted so PositionCache objects can not be copied.
|
||||
PositionCache(const PositionCache &) = delete;
|
||||
void operator=(const PositionCache &) = delete;
|
||||
~PositionCache();
|
||||
void Clear();
|
||||
void SetSize(size_t size_);
|
||||
size_t GetSize() const { return pces.size(); }
|
||||
void MeasureWidths(Surface *surface, const ViewStyle &vstyle, unsigned int styleNumber,
|
||||
const char *s, unsigned int len, XYPOSITION *positions, Document *pdoc);
|
||||
const char *s, unsigned int len, XYPOSITION *positions, const Document *pdoc);
|
||||
};
|
||||
|
||||
inline bool IsSpaceOrTab(int ch) {
|
||||
|
|
|
@ -200,7 +200,7 @@
|
|||
* matches: foo-foo fo-fo fob-fob foobar-foobar ...
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cstdlib>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
@ -256,9 +256,9 @@ RESearch::RESearch(CharClassify *charClassTable) {
|
|||
charClass = charClassTable;
|
||||
sta = NOP; /* status of lastpat */
|
||||
bol = 0;
|
||||
std::fill(bittab, bittab + BITBLK, 0);
|
||||
std::fill(bittab, bittab + BITBLK, static_cast<unsigned char>(0));
|
||||
std::fill(tagstk, tagstk + MAXTAG, 0);
|
||||
std::fill(nfa, nfa + MAXNFA, 0);
|
||||
std::fill(nfa, nfa + MAXNFA, '\0');
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
@ -277,9 +277,9 @@ void RESearch::Clear() {
|
|||
void RESearch::GrabMatches(CharacterIndexer &ci) {
|
||||
for (unsigned int i = 0; i < MAXTAG; i++) {
|
||||
if ((bopat[i] != NOTFOUND) && (eopat[i] != NOTFOUND)) {
|
||||
unsigned int len = eopat[i] - bopat[i];
|
||||
Sci::Position len = eopat[i] - bopat[i];
|
||||
pat[i].resize(len);
|
||||
for (unsigned int j = 0; j < len; j++)
|
||||
for (Sci::Position j = 0; j < len; j++)
|
||||
pat[i][j] = ci.CharAt(bopat[i] + j);
|
||||
}
|
||||
}
|
||||
|
@ -358,7 +358,7 @@ int RESearch::GetBackslashExpression(
|
|||
incr = 0; // Most of the time, will skip the char "naturally".
|
||||
int c;
|
||||
int result = -1;
|
||||
unsigned char bsc = *pattern;
|
||||
const unsigned char bsc = *pattern;
|
||||
if (!bsc) {
|
||||
// Avoid overrun
|
||||
result = '\\'; // \ at end of pattern, take it literally
|
||||
|
@ -376,9 +376,9 @@ int RESearch::GetBackslashExpression(
|
|||
result = escapeValue(bsc);
|
||||
break;
|
||||
case 'x': {
|
||||
unsigned char hd1 = *(pattern + 1);
|
||||
unsigned char hd2 = *(pattern + 2);
|
||||
int hexValue = GetHexaChar(hd1, hd2);
|
||||
const unsigned char hd1 = *(pattern + 1);
|
||||
const unsigned char hd2 = *(pattern + 2);
|
||||
const int hexValue = GetHexaChar(hd1, hd2);
|
||||
if (hexValue >= 0) {
|
||||
result = hexValue;
|
||||
incr = 2; // Must skip the digits
|
||||
|
@ -434,7 +434,7 @@ int RESearch::GetBackslashExpression(
|
|||
return result;
|
||||
}
|
||||
|
||||
const char *RESearch::Compile(const char *pattern, int length, bool caseSensitive, bool posix) {
|
||||
const char *RESearch::Compile(const char *pattern, Sci::Position length, bool caseSensitive, bool posix) {
|
||||
char *mp=nfa; /* nfa pointer */
|
||||
char *lp; /* saved pointer */
|
||||
char *sp=nfa; /* another one */
|
||||
|
@ -755,9 +755,9 @@ const char *RESearch::Compile(const char *pattern, int length, bool caseSensitiv
|
|||
* respectively.
|
||||
*
|
||||
*/
|
||||
int RESearch::Execute(CharacterIndexer &ci, int lp, int endp) {
|
||||
int RESearch::Execute(CharacterIndexer &ci, Sci::Position lp, Sci::Position endp) {
|
||||
unsigned char c;
|
||||
int ep = NOTFOUND;
|
||||
Sci::Position ep = NOTFOUND;
|
||||
char *ap = nfa;
|
||||
|
||||
bol = lp;
|
||||
|
@ -844,13 +844,13 @@ extern void re_fail(char *,char);
|
|||
#define CHRSKIP 3 /* [CLO] CHR chr END */
|
||||
#define CCLSKIP 34 /* [CLO] CCL 32 bytes END */
|
||||
|
||||
int RESearch::PMatch(CharacterIndexer &ci, int lp, int endp, char *ap) {
|
||||
Sci::Position RESearch::PMatch(CharacterIndexer &ci, Sci::Position lp, Sci::Position endp, char *ap) {
|
||||
int op, c, n;
|
||||
int e; /* extra pointer for CLO */
|
||||
int bp; /* beginning of subpat... */
|
||||
int ep; /* ending of subpat... */
|
||||
int are; /* to save the line ptr. */
|
||||
int llp; /* lazy lp for LCLO */
|
||||
Sci::Position e; /* extra pointer for CLO */
|
||||
Sci::Position bp; /* beginning of subpat... */
|
||||
Sci::Position ep; /* ending of subpat... */
|
||||
Sci::Position are; /* to save the line ptr. */
|
||||
Sci::Position llp; /* lazy lp for LCLO */
|
||||
|
||||
while ((op = *ap++) != END)
|
||||
switch (op) {
|
||||
|
@ -940,7 +940,7 @@ int RESearch::PMatch(CharacterIndexer &ci, int lp, int endp, char *ap) {
|
|||
llp = lp;
|
||||
e = NOTFOUND;
|
||||
while (llp >= are) {
|
||||
int q;
|
||||
Sci::Position q;
|
||||
if ((q = PMatch(ci, llp, endp, ap)) != NOTFOUND) {
|
||||
e = q;
|
||||
lp = llp;
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace Scintilla {
|
|||
|
||||
class CharacterIndexer {
|
||||
public:
|
||||
virtual char CharAt(int index)=0;
|
||||
virtual char CharAt(Sci::Position index)=0;
|
||||
virtual ~CharacterIndexer() {
|
||||
}
|
||||
};
|
||||
|
@ -32,18 +32,19 @@ class RESearch {
|
|||
|
||||
public:
|
||||
explicit RESearch(CharClassify *charClassTable);
|
||||
// No dynamic allocation so default copy constructor and assignment operator are OK.
|
||||
~RESearch();
|
||||
void Clear();
|
||||
void GrabMatches(CharacterIndexer &ci);
|
||||
const char *Compile(const char *pattern, int length, bool caseSensitive, bool posix);
|
||||
int Execute(CharacterIndexer &ci, int lp, int endp);
|
||||
const char *Compile(const char *pattern, Sci::Position length, bool caseSensitive, bool posix);
|
||||
int Execute(CharacterIndexer &ci, Sci::Position lp, Sci::Position endp);
|
||||
|
||||
enum { MAXTAG=10 };
|
||||
enum { MAXNFA=4096 };
|
||||
enum { NOTFOUND=-1 };
|
||||
|
||||
int bopat[MAXTAG];
|
||||
int eopat[MAXTAG];
|
||||
Sci::Position bopat[MAXTAG];
|
||||
Sci::Position eopat[MAXTAG];
|
||||
std::string pat[MAXTAG];
|
||||
|
||||
private:
|
||||
|
@ -51,10 +52,10 @@ private:
|
|||
void ChSetWithCase(unsigned char c, bool caseSensitive);
|
||||
int GetBackslashExpression(const char *pattern, int &incr);
|
||||
|
||||
int PMatch(CharacterIndexer &ci, int lp, int endp, char *ap);
|
||||
Sci::Position PMatch(CharacterIndexer &ci, Sci::Position lp, Sci::Position endp, char *ap);
|
||||
|
||||
int bol;
|
||||
int tagstk[MAXTAG]; /* subpat tag stack */
|
||||
Sci::Position bol;
|
||||
Sci::Position tagstk[MAXTAG]; /* subpat tag stack */
|
||||
char nfa[MAXNFA]; /* automaton */
|
||||
int sta;
|
||||
unsigned char bittab[BITBLK]; /* bit table for CCL pre-set bits */
|
||||
|
|
|
@ -4,13 +4,16 @@
|
|||
// Copyright 1998-2007 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <cstdarg>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
|
@ -37,7 +40,7 @@ int RunStyles::RunFromPosition(int position) const {
|
|||
// If there is no run boundary at position, insert one continuing style.
|
||||
int RunStyles::SplitRun(int position) {
|
||||
int run = RunFromPosition(position);
|
||||
int posRun = starts->PositionFromPartition(run);
|
||||
const int posRun = starts->PositionFromPartition(run);
|
||||
if (posRun < position) {
|
||||
int runStyle = ValueAt(position);
|
||||
run++;
|
||||
|
@ -69,16 +72,12 @@ void RunStyles::RemoveRunIfSameAsPrevious(int run) {
|
|||
}
|
||||
|
||||
RunStyles::RunStyles() {
|
||||
starts = new Partitioning(8);
|
||||
styles = new SplitVector<int>();
|
||||
starts.reset(new Partitioning(8));
|
||||
styles.reset(new SplitVector<int>());
|
||||
styles->InsertValue(0, 2, 0);
|
||||
}
|
||||
|
||||
RunStyles::~RunStyles() {
|
||||
delete starts;
|
||||
starts = NULL;
|
||||
delete styles;
|
||||
styles = NULL;
|
||||
}
|
||||
|
||||
int RunStyles::Length() const {
|
||||
|
@ -90,12 +89,12 @@ int RunStyles::ValueAt(int position) const {
|
|||
}
|
||||
|
||||
int RunStyles::FindNextChange(int position, int end) const {
|
||||
int run = starts->PartitionFromPosition(position);
|
||||
const int run = starts->PartitionFromPosition(position);
|
||||
if (run < starts->Partitions()) {
|
||||
int runChange = starts->PositionFromPartition(run);
|
||||
const int runChange = starts->PositionFromPartition(run);
|
||||
if (runChange > position)
|
||||
return runChange;
|
||||
int nextChange = starts->PositionFromPartition(run + 1);
|
||||
const int nextChange = starts->PositionFromPartition(run + 1);
|
||||
if (nextChange > position) {
|
||||
return nextChange;
|
||||
} else if (position < end) {
|
||||
|
@ -199,12 +198,8 @@ void RunStyles::InsertSpace(int position, int insertLength) {
|
|||
}
|
||||
|
||||
void RunStyles::DeleteAll() {
|
||||
delete starts;
|
||||
starts = NULL;
|
||||
delete styles;
|
||||
styles = NULL;
|
||||
starts = new Partitioning(8);
|
||||
styles = new SplitVector<int>();
|
||||
starts.reset(new Partitioning(8));
|
||||
styles.reset(new SplitVector<int>());
|
||||
styles->InsertValue(0, 2, 0);
|
||||
}
|
||||
|
||||
|
@ -272,7 +267,7 @@ void RunStyles::Check() const {
|
|||
}
|
||||
int start=0;
|
||||
while (start < Length()) {
|
||||
int end = EndRun(start);
|
||||
const int end = EndRun(start);
|
||||
if (start >= end) {
|
||||
throw std::runtime_error("RunStyles: Partition is 0 length.");
|
||||
}
|
||||
|
|
|
@ -16,17 +16,18 @@ namespace Scintilla {
|
|||
|
||||
class RunStyles {
|
||||
private:
|
||||
Partitioning *starts;
|
||||
SplitVector<int> *styles;
|
||||
std::unique_ptr<Partitioning> starts;
|
||||
std::unique_ptr<SplitVector<int>> styles;
|
||||
int RunFromPosition(int position) const;
|
||||
int SplitRun(int position);
|
||||
void RemoveRun(int run);
|
||||
void RemoveRunIfEmpty(int run);
|
||||
void RemoveRunIfSameAsPrevious(int run);
|
||||
// Private so RunStyles objects can not be copied
|
||||
RunStyles(const RunStyles &);
|
||||
public:
|
||||
RunStyles();
|
||||
// Deleted so RunStyles objects can not be copied.
|
||||
RunStyles(const RunStyles &) = delete;
|
||||
void operator=(const RunStyles &) = delete;
|
||||
~RunStyles();
|
||||
int Length() const;
|
||||
int ValueAt(int position) const;
|
||||
|
|
|
@ -5,17 +5,17 @@
|
|||
// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
|
@ -34,6 +34,7 @@
|
|||
#endif
|
||||
|
||||
#include "Position.h"
|
||||
#include "UniqueString.h"
|
||||
#include "SplitVector.h"
|
||||
#include "Partitioning.h"
|
||||
#include "RunStyles.h"
|
||||
|
@ -79,7 +80,7 @@ void ScintillaBase::Finalise() {
|
|||
}
|
||||
|
||||
void ScintillaBase::AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS) {
|
||||
bool isFillUp = ac.Active() && ac.IsFillUpChar(*s);
|
||||
const bool isFillUp = ac.Active() && ac.IsFillUpChar(*s);
|
||||
if (!isFillUp) {
|
||||
Editor::AddCharUTF(s, len, treatAsDBCS);
|
||||
}
|
||||
|
@ -206,24 +207,24 @@ void ScintillaBase::AutoCompleteDoubleClick(void *p) {
|
|||
sci->AutoCompleteCompleted(0, SC_AC_DOUBLECLICK);
|
||||
}
|
||||
|
||||
void ScintillaBase::AutoCompleteInsert(Position startPos, int removeLen, const char *text, int textLen) {
|
||||
void ScintillaBase::AutoCompleteInsert(Sci::Position startPos, int removeLen, const char *text, int textLen) {
|
||||
UndoGroup ug(pdoc);
|
||||
if (multiAutoCMode == SC_MULTIAUTOC_ONCE) {
|
||||
pdoc->DeleteChars(startPos, removeLen);
|
||||
const int lengthInserted = pdoc->InsertString(startPos, text, textLen);
|
||||
const Sci::Position lengthInserted = pdoc->InsertString(startPos, text, textLen);
|
||||
SetEmptySelection(startPos + lengthInserted);
|
||||
} else {
|
||||
// SC_MULTIAUTOC_EACH
|
||||
for (size_t r=0; r<sel.Count(); r++) {
|
||||
if (!RangeContainsProtected(sel.Range(r).Start().Position(),
|
||||
sel.Range(r).End().Position())) {
|
||||
int positionInsert = sel.Range(r).Start().Position();
|
||||
Sci::Position positionInsert = sel.Range(r).Start().Position();
|
||||
positionInsert = RealizeVirtualSpace(positionInsert, sel.Range(r).caret.VirtualSpace());
|
||||
if (positionInsert - removeLen >= 0) {
|
||||
positionInsert -= removeLen;
|
||||
pdoc->DeleteChars(positionInsert, removeLen);
|
||||
}
|
||||
const int lengthInserted = pdoc->InsertString(positionInsert, text, textLen);
|
||||
const Sci::Position lengthInserted = pdoc->InsertString(positionInsert, text, textLen);
|
||||
if (lengthInserted > 0) {
|
||||
sel.Range(r).caret.SetPosition(positionInsert + lengthInserted);
|
||||
sel.Range(r).anchor.SetPosition(positionInsert + lengthInserted);
|
||||
|
@ -287,7 +288,7 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
|
|||
rcac.top = pt.y + vs.lineHeight;
|
||||
}
|
||||
rcac.right = rcac.left + widthLB;
|
||||
rcac.bottom = static_cast<XYPOSITION>(Platform::Minimum(static_cast<int>(rcac.top) + heightLB, static_cast<int>(rcPopupBounds.bottom)));
|
||||
rcac.bottom = static_cast<XYPOSITION>(std::min(static_cast<int>(rcac.top) + heightLB, static_cast<int>(rcPopupBounds.bottom)));
|
||||
ac.lb->SetPositionRelative(rcac, wMain);
|
||||
ac.lb->SetFont(vs.styles[STYLE_DEFAULT].font);
|
||||
unsigned int aveCharWidth = static_cast<unsigned int>(vs.styles[STYLE_DEFAULT].aveCharWidth);
|
||||
|
@ -299,9 +300,9 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) {
|
|||
// Fiddle the position of the list so it is right next to the target and wide enough for all its strings
|
||||
PRectangle rcList = ac.lb->GetDesiredRect();
|
||||
int heightAlloced = static_cast<int>(rcList.bottom - rcList.top);
|
||||
widthLB = Platform::Maximum(widthLB, static_cast<int>(rcList.right - rcList.left));
|
||||
widthLB = std::max(widthLB, static_cast<int>(rcList.right - rcList.left));
|
||||
if (maxListWidth != 0)
|
||||
widthLB = Platform::Minimum(widthLB, aveCharWidth*maxListWidth);
|
||||
widthLB = std::min(widthLB, static_cast<int>(aveCharWidth)*maxListWidth);
|
||||
// Make an allowance for large strings in list
|
||||
rcList.left = pt.x - ac.lb->CaretFromEdge();
|
||||
rcList.right = rcList.left + widthLB;
|
||||
|
@ -365,7 +366,7 @@ void ScintillaBase::AutoCompleteCharacterDeleted() {
|
|||
}
|
||||
|
||||
void ScintillaBase::AutoCompleteCompleted(char ch, unsigned int completionMethod) {
|
||||
int item = ac.GetSelection();
|
||||
const int item = ac.GetSelection();
|
||||
if (item == -1) {
|
||||
AutoCompleteCancel();
|
||||
return;
|
||||
|
@ -381,7 +382,7 @@ void ScintillaBase::AutoCompleteCompleted(char ch, unsigned int completionMethod
|
|||
scn.listCompletionMethod = completionMethod;
|
||||
scn.wParam = listType;
|
||||
scn.listType = listType;
|
||||
Position firstPos = ac.posStart - ac.startLen;
|
||||
Sci::Position firstPos = ac.posStart - ac.startLen;
|
||||
scn.position = firstPos;
|
||||
scn.lParam = firstPos;
|
||||
scn.text = selected.c_str();
|
||||
|
@ -394,7 +395,7 @@ void ScintillaBase::AutoCompleteCompleted(char ch, unsigned int completionMethod
|
|||
if (listType > 0)
|
||||
return;
|
||||
|
||||
Position endPos = sel.MainCaret();
|
||||
Sci::Position endPos = sel.MainCaret();
|
||||
if (ac.dropRestOfWord)
|
||||
endPos = pdoc->ExtendWordSelect(endPos, 1, true);
|
||||
if (endPos < firstPos)
|
||||
|
@ -415,7 +416,7 @@ int ScintillaBase::AutoCompleteGetCurrent() const {
|
|||
|
||||
int ScintillaBase::AutoCompleteGetCurrentText(char *buffer) const {
|
||||
if (ac.Active()) {
|
||||
int item = ac.GetSelection();
|
||||
const int item = ac.GetSelection();
|
||||
if (item != -1) {
|
||||
const std::string selected = ac.GetValue(item);
|
||||
if (buffer != NULL)
|
||||
|
@ -453,7 +454,7 @@ void ScintillaBase::CallTipShow(Point pt, const char *defn) {
|
|||
wMain);
|
||||
// If the call-tip window would be out of the client
|
||||
// space
|
||||
PRectangle rcClient = GetClientRectangle();
|
||||
const PRectangle rcClient = GetClientRectangle();
|
||||
int offset = vs.lineHeight + static_cast<int>(rc.Height());
|
||||
// adjust so it displays above the text.
|
||||
if (rc.bottom > rcClient.bottom && rc.Height() < rcClient.Height()) {
|
||||
|
@ -485,7 +486,7 @@ bool ScintillaBase::ShouldDisplayPopup(Point ptInWindowCoordinates) const {
|
|||
|
||||
void ScintillaBase::ContextMenu(Point pt) {
|
||||
if (displayPopupMenu) {
|
||||
bool writable = !WndProc(SCI_GETREADONLY, 0, 0);
|
||||
const bool writable = !WndProc(SCI_GETREADONLY, 0, 0);
|
||||
popup.CreatePopUp();
|
||||
AddToPopUp("Undo", idcmdUndo, writable && pdoc->CanUndo());
|
||||
AddToPopUp("Redo", idcmdRedo, writable && pdoc->CanRedo());
|
||||
|
@ -535,7 +536,7 @@ public:
|
|||
int lexLanguage;
|
||||
|
||||
explicit LexState(Document *pdoc_);
|
||||
virtual ~LexState();
|
||||
~LexState() override;
|
||||
void SetLexer(uptr_t wParam);
|
||||
void SetLexerLanguage(const char *languageName);
|
||||
const char *DescribeWordListSets();
|
||||
|
@ -581,10 +582,10 @@ LexState::~LexState() {
|
|||
}
|
||||
|
||||
LexState *ScintillaBase::DocumentLexState() {
|
||||
if (!pdoc->pli) {
|
||||
pdoc->pli = new LexState(pdoc);
|
||||
if (!pdoc->GetLexInterface()) {
|
||||
pdoc->SetLexInterface(new LexState(pdoc));
|
||||
}
|
||||
return static_cast<LexState *>(pdoc->pli);
|
||||
return static_cast<LexState *>(pdoc->GetLexInterface());
|
||||
}
|
||||
|
||||
void LexState::SetLexerModule(const LexerModule *lex) {
|
||||
|
@ -770,11 +771,11 @@ const char *LexState::GetSubStyleBases() {
|
|||
|
||||
#endif
|
||||
|
||||
void ScintillaBase::NotifyStyleToNeeded(int endStyleNeeded) {
|
||||
void ScintillaBase::NotifyStyleToNeeded(Sci::Position endStyleNeeded) {
|
||||
#ifdef SCI_LEXER
|
||||
if (DocumentLexState()->lexLanguage != SCLEX_CONTAINER) {
|
||||
int lineEndStyled = pdoc->LineFromPosition(pdoc->GetEndStyled());
|
||||
int endStyled = pdoc->LineStart(lineEndStyled);
|
||||
Sci::Line lineEndStyled = pdoc->LineFromPosition(pdoc->GetEndStyled());
|
||||
Sci::Position endStyled = pdoc->LineStart(lineEndStyled);
|
||||
DocumentLexState()->Colourise(endStyled, endStyleNeeded);
|
||||
return;
|
||||
}
|
||||
|
@ -993,10 +994,10 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara
|
|||
|
||||
case SCI_COLOURISE:
|
||||
if (DocumentLexState()->lexLanguage == SCLEX_CONTAINER) {
|
||||
pdoc->ModifiedAt(static_cast<int>(wParam));
|
||||
NotifyStyleToNeeded((lParam == -1) ? pdoc->Length() : static_cast<int>(lParam));
|
||||
pdoc->ModifiedAt(static_cast<Sci::Position>(wParam));
|
||||
NotifyStyleToNeeded((lParam == -1) ? pdoc->Length() : static_cast<Sci::Position>(lParam));
|
||||
} else {
|
||||
DocumentLexState()->Colourise(static_cast<int>(wParam), static_cast<int>(lParam));
|
||||
DocumentLexState()->Colourise(static_cast<Sci::Position>(wParam), static_cast<Sci::Position>(lParam));
|
||||
}
|
||||
Redraw();
|
||||
break;
|
||||
|
|
|
@ -19,10 +19,6 @@ class LexState;
|
|||
/**
|
||||
*/
|
||||
class ScintillaBase : public Editor {
|
||||
// Private so ScintillaBase objects can not be copied
|
||||
explicit ScintillaBase(const ScintillaBase &);
|
||||
ScintillaBase &operator=(const ScintillaBase &);
|
||||
|
||||
protected:
|
||||
/** Enumeration of commands and child windows. */
|
||||
enum {
|
||||
|
@ -58,16 +54,19 @@ protected:
|
|||
#endif
|
||||
|
||||
ScintillaBase();
|
||||
// Deleted so ScintillaBase objects can not be copied.
|
||||
explicit ScintillaBase(const ScintillaBase &) = delete;
|
||||
ScintillaBase &operator=(const ScintillaBase &) = delete;
|
||||
virtual ~ScintillaBase();
|
||||
virtual void Initialise() = 0;
|
||||
virtual void Finalise();
|
||||
void Initialise() override {}
|
||||
void Finalise() override;
|
||||
|
||||
virtual void AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS=false);
|
||||
void AddCharUTF(const char *s, unsigned int len, bool treatAsDBCS=false) override;
|
||||
void Command(int cmdId);
|
||||
virtual void CancelModes();
|
||||
virtual int KeyCommand(unsigned int iMessage);
|
||||
void CancelModes() override;
|
||||
int KeyCommand(unsigned int iMessage) override;
|
||||
|
||||
void AutoCompleteInsert(Position startPos, int removeLen, const char *text, int textLen);
|
||||
void AutoCompleteInsert(Sci::Position startPos, int removeLen, const char *text, int textLen);
|
||||
void AutoCompleteStart(int lenEntered, const char *list);
|
||||
void AutoCompleteCancel();
|
||||
void AutoCompleteMove(int delta);
|
||||
|
@ -87,16 +86,16 @@ protected:
|
|||
bool ShouldDisplayPopup(Point ptInWindowCoordinates) const;
|
||||
void ContextMenu(Point pt);
|
||||
|
||||
virtual void ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers);
|
||||
virtual void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt);
|
||||
virtual void RightButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers);
|
||||
void ButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers) override;
|
||||
void ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) override;
|
||||
void RightButtonDownWithModifiers(Point pt, unsigned int curTime, int modifiers) override;
|
||||
|
||||
void NotifyStyleToNeeded(int endStyleNeeded);
|
||||
void NotifyLexerChanged(Document *doc, void *userData);
|
||||
void NotifyStyleToNeeded(Sci::Position endStyleNeeded) override;
|
||||
void NotifyLexerChanged(Document *doc, void *userData) override;
|
||||
|
||||
public:
|
||||
// Public so scintilla_send_message can use it
|
||||
virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
|
||||
sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override;
|
||||
};
|
||||
|
||||
#ifdef SCI_NAMESPACE
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// Copyright 2009 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cstdlib>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
|
@ -22,10 +22,10 @@
|
|||
using namespace Scintilla;
|
||||
#endif
|
||||
|
||||
void SelectionPosition::MoveForInsertDelete(bool insertion, int startChange, int length) {
|
||||
void SelectionPosition::MoveForInsertDelete(bool insertion, Sci::Position startChange, Sci::Position length) {
|
||||
if (insertion) {
|
||||
if (position == startChange) {
|
||||
int virtualLengthRemove = std::min(length, virtualSpace);
|
||||
Sci::Position virtualLengthRemove = std::min(length, virtualSpace);
|
||||
virtualSpace -= virtualLengthRemove;
|
||||
position += virtualLengthRemove;
|
||||
} else if (position > startChange) {
|
||||
|
@ -36,7 +36,7 @@ void SelectionPosition::MoveForInsertDelete(bool insertion, int startChange, int
|
|||
virtualSpace = 0;
|
||||
}
|
||||
if (position > startChange) {
|
||||
int endDeletion = startChange + length;
|
||||
const Sci::Position endDeletion = startChange + length;
|
||||
if (position > endDeletion) {
|
||||
position -= length;
|
||||
} else {
|
||||
|
@ -75,7 +75,7 @@ bool SelectionPosition::operator >=(const SelectionPosition &other) const {
|
|||
return *this > other;
|
||||
}
|
||||
|
||||
int SelectionRange::Length() const {
|
||||
Sci::Position SelectionRange::Length() const {
|
||||
if (anchor > caret) {
|
||||
return anchor.Position() - caret.Position();
|
||||
} else {
|
||||
|
@ -83,12 +83,12 @@ int SelectionRange::Length() const {
|
|||
}
|
||||
}
|
||||
|
||||
void SelectionRange::MoveForInsertDelete(bool insertion, int startChange, int length) {
|
||||
void SelectionRange::MoveForInsertDelete(bool insertion, Sci::Position startChange, Sci::Position length) {
|
||||
caret.MoveForInsertDelete(insertion, startChange, length);
|
||||
anchor.MoveForInsertDelete(insertion, startChange, length);
|
||||
}
|
||||
|
||||
bool SelectionRange::Contains(int pos) const {
|
||||
bool SelectionRange::Contains(Sci::Position pos) const {
|
||||
if (anchor > caret)
|
||||
return (pos >= caret.Position()) && (pos <= anchor.Position());
|
||||
else
|
||||
|
@ -102,7 +102,7 @@ bool SelectionRange::Contains(SelectionPosition sp) const {
|
|||
return (sp >= anchor) && (sp <= caret);
|
||||
}
|
||||
|
||||
bool SelectionRange::ContainsCharacter(int posCharacter) const {
|
||||
bool SelectionRange::ContainsCharacter(Sci::Position posCharacter) const {
|
||||
if (anchor > caret)
|
||||
return (posCharacter >= caret.Position()) && (posCharacter < anchor.Position());
|
||||
else
|
||||
|
@ -131,8 +131,8 @@ void SelectionRange::Swap() {
|
|||
}
|
||||
|
||||
bool SelectionRange::Trim(SelectionRange range) {
|
||||
SelectionPosition startRange = range.Start();
|
||||
SelectionPosition endRange = range.End();
|
||||
const SelectionPosition startRange = range.Start();
|
||||
const SelectionPosition endRange = range.End();
|
||||
SelectionPosition start = Start();
|
||||
SelectionPosition end = End();
|
||||
PLATFORM_ASSERT(start <= end);
|
||||
|
@ -168,7 +168,7 @@ bool SelectionRange::Trim(SelectionRange range) {
|
|||
// If range is all virtual collapse to start of virtual space
|
||||
void SelectionRange::MinimizeVirtualSpace() {
|
||||
if (caret.Position() == anchor.Position()) {
|
||||
int virtualSpace = caret.VirtualSpace();
|
||||
Sci::Position virtualSpace = caret.VirtualSpace();
|
||||
if (virtualSpace > anchor.VirtualSpace())
|
||||
virtualSpace = anchor.VirtualSpace();
|
||||
caret.SetVirtualSpace(virtualSpace);
|
||||
|
@ -187,11 +187,11 @@ bool Selection::IsRectangular() const {
|
|||
return (selType == selRectangle) || (selType == selThin);
|
||||
}
|
||||
|
||||
int Selection::MainCaret() const {
|
||||
Sci::Position Selection::MainCaret() const {
|
||||
return ranges[mainRange].caret.Position();
|
||||
}
|
||||
|
||||
int Selection::MainAnchor() const {
|
||||
Sci::Position Selection::MainAnchor() const {
|
||||
return ranges[mainRange].anchor.Position();
|
||||
}
|
||||
|
||||
|
@ -266,8 +266,8 @@ void Selection::SetMoveExtends(bool moveExtends_) {
|
|||
}
|
||||
|
||||
bool Selection::Empty() const {
|
||||
for (size_t i=0; i<ranges.size(); i++) {
|
||||
if (!ranges[i].Empty())
|
||||
for (const SelectionRange &range : ranges) {
|
||||
if (!range.Empty())
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -275,26 +275,26 @@ bool Selection::Empty() const {
|
|||
|
||||
SelectionPosition Selection::Last() const {
|
||||
SelectionPosition lastPosition;
|
||||
for (size_t i=0; i<ranges.size(); i++) {
|
||||
if (lastPosition < ranges[i].caret)
|
||||
lastPosition = ranges[i].caret;
|
||||
if (lastPosition < ranges[i].anchor)
|
||||
lastPosition = ranges[i].anchor;
|
||||
for (const SelectionRange &range : ranges) {
|
||||
if (lastPosition < range.caret)
|
||||
lastPosition = range.caret;
|
||||
if (lastPosition < range.anchor)
|
||||
lastPosition = range.anchor;
|
||||
}
|
||||
return lastPosition;
|
||||
}
|
||||
|
||||
int Selection::Length() const {
|
||||
int len = 0;
|
||||
for (size_t i=0; i<ranges.size(); i++) {
|
||||
len += ranges[i].Length();
|
||||
Sci::Position Selection::Length() const {
|
||||
Sci::Position len = 0;
|
||||
for (const SelectionRange &range : ranges) {
|
||||
len += range.Length();
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
void Selection::MovePositions(bool insertion, int startChange, int length) {
|
||||
for (size_t i=0; i<ranges.size(); i++) {
|
||||
ranges[i].MoveForInsertDelete(insertion, startChange, length);
|
||||
void Selection::MovePositions(bool insertion, Sci::Position startChange, Sci::Position length) {
|
||||
for (SelectionRange &range : ranges) {
|
||||
range.MoveForInsertDelete(insertion, startChange, length);
|
||||
}
|
||||
if (selType == selRectangle) {
|
||||
rangeRectangular.MoveForInsertDelete(insertion, startChange, length);
|
||||
|
@ -376,7 +376,7 @@ void Selection::CommitTentative() {
|
|||
tentativeMain = false;
|
||||
}
|
||||
|
||||
int Selection::CharacterInSelection(int posCharacter) const {
|
||||
int Selection::CharacterInSelection(Sci::Position posCharacter) const {
|
||||
for (size_t i=0; i<ranges.size(); i++) {
|
||||
if (ranges[i].ContainsCharacter(posCharacter))
|
||||
return i == mainRange ? 1 : 2;
|
||||
|
@ -384,7 +384,7 @@ int Selection::CharacterInSelection(int posCharacter) const {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int Selection::InSelectionForEOL(int pos) const {
|
||||
int Selection::InSelectionForEOL(Sci::Position pos) const {
|
||||
for (size_t i=0; i<ranges.size(); i++) {
|
||||
if (!ranges[i].Empty() && (pos > ranges[i].Start().Position()) && (pos <= ranges[i].End().Position()))
|
||||
return i == mainRange ? 1 : 2;
|
||||
|
@ -392,13 +392,13 @@ int Selection::InSelectionForEOL(int pos) const {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int Selection::VirtualSpaceFor(int pos) const {
|
||||
int virtualSpace = 0;
|
||||
for (size_t i=0; i<ranges.size(); i++) {
|
||||
if ((ranges[i].caret.Position() == pos) && (virtualSpace < ranges[i].caret.VirtualSpace()))
|
||||
virtualSpace = ranges[i].caret.VirtualSpace();
|
||||
if ((ranges[i].anchor.Position() == pos) && (virtualSpace < ranges[i].anchor.VirtualSpace()))
|
||||
virtualSpace = ranges[i].anchor.VirtualSpace();
|
||||
Sci::Position Selection::VirtualSpaceFor(Sci::Position pos) const {
|
||||
Sci::Position virtualSpace = 0;
|
||||
for (const SelectionRange &range : ranges) {
|
||||
if ((range.caret.Position() == pos) && (virtualSpace < range.caret.VirtualSpace()))
|
||||
virtualSpace = range.caret.VirtualSpace();
|
||||
if ((range.anchor.Position() == pos) && (virtualSpace < range.anchor.VirtualSpace()))
|
||||
virtualSpace = range.anchor.VirtualSpace();
|
||||
}
|
||||
return virtualSpace;
|
||||
}
|
||||
|
|
|
@ -13,10 +13,10 @@ namespace Scintilla {
|
|||
#endif
|
||||
|
||||
class SelectionPosition {
|
||||
int position;
|
||||
int virtualSpace;
|
||||
Sci::Position position;
|
||||
Sci::Position virtualSpace;
|
||||
public:
|
||||
explicit SelectionPosition(int position_=INVALID_POSITION, int virtualSpace_=0) : position(position_), virtualSpace(virtualSpace_) {
|
||||
explicit SelectionPosition(Sci::Position position_=INVALID_POSITION, Sci::Position virtualSpace_=0) : position(position_), virtualSpace(virtualSpace_) {
|
||||
PLATFORM_ASSERT(virtualSpace < 800000);
|
||||
if (virtualSpace < 0)
|
||||
virtualSpace = 0;
|
||||
|
@ -25,7 +25,7 @@ public:
|
|||
position = 0;
|
||||
virtualSpace = 0;
|
||||
}
|
||||
void MoveForInsertDelete(bool insertion, int startChange, int length);
|
||||
void MoveForInsertDelete(bool insertion, Sci::Position startChange, Sci::Position length);
|
||||
bool operator ==(const SelectionPosition &other) const {
|
||||
return position == other.position && virtualSpace == other.virtualSpace;
|
||||
}
|
||||
|
@ -33,22 +33,22 @@ public:
|
|||
bool operator >(const SelectionPosition &other) const;
|
||||
bool operator <=(const SelectionPosition &other) const;
|
||||
bool operator >=(const SelectionPosition &other) const;
|
||||
int Position() const {
|
||||
Sci::Position Position() const {
|
||||
return position;
|
||||
}
|
||||
void SetPosition(int position_) {
|
||||
void SetPosition(Sci::Position position_) {
|
||||
position = position_;
|
||||
virtualSpace = 0;
|
||||
}
|
||||
int VirtualSpace() const {
|
||||
Sci::Position VirtualSpace() const {
|
||||
return virtualSpace;
|
||||
}
|
||||
void SetVirtualSpace(int virtualSpace_) {
|
||||
void SetVirtualSpace(Sci::Position virtualSpace_) {
|
||||
PLATFORM_ASSERT(virtualSpace_ < 800000);
|
||||
if (virtualSpace_ >= 0)
|
||||
virtualSpace = virtualSpace_;
|
||||
}
|
||||
void Add(int increment) {
|
||||
void Add(Sci::Position increment) {
|
||||
position = position + increment;
|
||||
}
|
||||
bool IsValid() const {
|
||||
|
@ -90,17 +90,17 @@ struct SelectionRange {
|
|||
}
|
||||
explicit SelectionRange(SelectionPosition single) : caret(single), anchor(single) {
|
||||
}
|
||||
explicit SelectionRange(int single) : caret(single), anchor(single) {
|
||||
explicit SelectionRange(Sci::Position single) : caret(single), anchor(single) {
|
||||
}
|
||||
SelectionRange(SelectionPosition caret_, SelectionPosition anchor_) : caret(caret_), anchor(anchor_) {
|
||||
}
|
||||
SelectionRange(int caret_, int anchor_) : caret(caret_), anchor(anchor_) {
|
||||
SelectionRange(Sci::Position caret_, Sci::Position anchor_) : caret(caret_), anchor(anchor_) {
|
||||
}
|
||||
bool Empty() const {
|
||||
return anchor == caret;
|
||||
}
|
||||
int Length() const;
|
||||
// int Width() const; // Like Length but takes virtual space into account
|
||||
Sci::Position Length() const;
|
||||
// Sci::Position Width() const; // Like Length but takes virtual space into account
|
||||
bool operator ==(const SelectionRange &other) const {
|
||||
return caret == other.caret && anchor == other.anchor;
|
||||
}
|
||||
|
@ -115,10 +115,10 @@ struct SelectionRange {
|
|||
anchor.SetVirtualSpace(0);
|
||||
caret.SetVirtualSpace(0);
|
||||
}
|
||||
void MoveForInsertDelete(bool insertion, int startChange, int length);
|
||||
bool Contains(int pos) const;
|
||||
void MoveForInsertDelete(bool insertion, Sci::Position startChange, Sci::Position length);
|
||||
bool Contains(Sci::Position pos) const;
|
||||
bool Contains(SelectionPosition sp) const;
|
||||
bool ContainsCharacter(int posCharacter) const;
|
||||
bool ContainsCharacter(Sci::Position posCharacter) const;
|
||||
SelectionSegment Intersect(SelectionSegment check) const;
|
||||
SelectionPosition Start() const {
|
||||
return (anchor < caret) ? anchor : caret;
|
||||
|
@ -146,8 +146,8 @@ public:
|
|||
Selection();
|
||||
~Selection();
|
||||
bool IsRectangular() const;
|
||||
int MainCaret() const;
|
||||
int MainAnchor() const;
|
||||
Sci::Position MainCaret() const;
|
||||
Sci::Position MainAnchor() const;
|
||||
SelectionRange &Rectangular();
|
||||
SelectionSegment Limits() const;
|
||||
// This is for when you want to move the caret in response to a
|
||||
|
@ -166,8 +166,8 @@ public:
|
|||
void SetMoveExtends(bool moveExtends_);
|
||||
bool Empty() const;
|
||||
SelectionPosition Last() const;
|
||||
int Length() const;
|
||||
void MovePositions(bool insertion, int startChange, int length);
|
||||
Sci::Position Length() const;
|
||||
void MovePositions(bool insertion, Sci::Position startChange, Sci::Position length);
|
||||
void TrimSelection(SelectionRange range);
|
||||
void TrimOtherSelections(size_t r, SelectionRange range);
|
||||
void SetSelection(SelectionRange range);
|
||||
|
@ -177,9 +177,9 @@ public:
|
|||
void DropAdditionalRanges();
|
||||
void TentativeSelection(SelectionRange range);
|
||||
void CommitTentative();
|
||||
int CharacterInSelection(int posCharacter) const;
|
||||
int InSelectionForEOL(int pos) const;
|
||||
int VirtualSpaceFor(int pos) const;
|
||||
int CharacterInSelection(Sci::Position posCharacter) const;
|
||||
int InSelectionForEOL(Sci::Position pos) const;
|
||||
Sci::Position VirtualSpaceFor(Sci::Position pos) const;
|
||||
void Clear();
|
||||
void RemoveDuplicates();
|
||||
void RotateMain();
|
||||
|
|
|
@ -17,15 +17,50 @@ namespace Scintilla {
|
|||
template <typename T>
|
||||
class SparseVector {
|
||||
private:
|
||||
Partitioning *starts;
|
||||
SplitVector<T> *values;
|
||||
// Private so SparseVector objects can not be copied
|
||||
SparseVector(const SparseVector &);
|
||||
std::unique_ptr<Partitioning> starts;
|
||||
std::unique_ptr<SplitVector<T>> values;
|
||||
T empty;
|
||||
// Deleted so SparseVector objects can not be copied.
|
||||
SparseVector(const SparseVector &) = delete;
|
||||
void operator=(const SparseVector &) = delete;
|
||||
void ClearValue(int partition) {
|
||||
values->SetValueAt(partition, T());
|
||||
}
|
||||
void CommonSetValueAt(int position, T value) {
|
||||
// Do the work of setting the value to allow for specialization of SetValueAt.
|
||||
public:
|
||||
SparseVector() : empty() {
|
||||
starts.reset(new Partitioning(8));
|
||||
values.reset(new SplitVector<T>());
|
||||
values->InsertEmpty(0, 2);
|
||||
}
|
||||
~SparseVector() {
|
||||
starts.reset();
|
||||
// starts dead here but not used by ClearValue.
|
||||
for (int part = 0; part < values->Length(); part++) {
|
||||
ClearValue(part);
|
||||
}
|
||||
values.reset();
|
||||
}
|
||||
int Length() const {
|
||||
return starts->PositionFromPartition(starts->Partitions());
|
||||
}
|
||||
int Elements() const {
|
||||
return starts->Partitions();
|
||||
}
|
||||
int PositionOfElement(int element) const {
|
||||
return starts->PositionFromPartition(element);
|
||||
}
|
||||
const T& ValueAt(int position) const {
|
||||
assert(position < Length());
|
||||
const int partition = starts->PartitionFromPosition(position);
|
||||
const int startPartition = starts->PositionFromPartition(partition);
|
||||
if (startPartition == position) {
|
||||
return values->ValueAt(partition);
|
||||
} else {
|
||||
return empty;
|
||||
}
|
||||
}
|
||||
template <typename ParamType>
|
||||
void SetValueAt(int position, ParamType &&value) {
|
||||
assert(position < Length());
|
||||
const int partition = starts->PartitionFromPosition(position);
|
||||
const int startPartition = starts->PositionFromPartition(partition);
|
||||
|
@ -44,71 +79,30 @@ private:
|
|||
if (position == startPartition) {
|
||||
// Already a value at this position, so replace
|
||||
ClearValue(partition);
|
||||
values->SetValueAt(partition, value);
|
||||
values->SetValueAt(partition, std::move(value));
|
||||
} else {
|
||||
// Insert a new element
|
||||
starts->InsertPartition(partition + 1, position);
|
||||
values->InsertValue(partition + 1, 1, value);
|
||||
values->Insert(partition + 1, std::move(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
public:
|
||||
SparseVector() {
|
||||
starts = new Partitioning(8);
|
||||
values = new SplitVector<T>();
|
||||
values->InsertValue(0, 2, T());
|
||||
}
|
||||
~SparseVector() {
|
||||
delete starts;
|
||||
starts = NULL;
|
||||
// starts dead here but not used by ClearValue.
|
||||
for (int part = 0; part < values->Length(); part++) {
|
||||
ClearValue(part);
|
||||
}
|
||||
delete values;
|
||||
values = NULL;
|
||||
}
|
||||
int Length() const {
|
||||
return starts->PositionFromPartition(starts->Partitions());
|
||||
}
|
||||
int Elements() const {
|
||||
return starts->Partitions();
|
||||
}
|
||||
int PositionOfElement(int element) const {
|
||||
return starts->PositionFromPartition(element);
|
||||
}
|
||||
T ValueAt(int position) const {
|
||||
assert(position < Length());
|
||||
const int partition = starts->PartitionFromPosition(position);
|
||||
const int startPartition = starts->PositionFromPartition(partition);
|
||||
if (startPartition == position) {
|
||||
return values->ValueAt(partition);
|
||||
} else {
|
||||
return T();
|
||||
}
|
||||
}
|
||||
void SetValueAt(int position, T value) {
|
||||
CommonSetValueAt(position, value);
|
||||
}
|
||||
void InsertSpace(int position, int insertLength) {
|
||||
assert(position <= Length()); // Only operation that works at end.
|
||||
const int partition = starts->PartitionFromPosition(position);
|
||||
const int startPartition = starts->PositionFromPartition(partition);
|
||||
if (startPartition == position) {
|
||||
T valueCurrent = values->ValueAt(partition);
|
||||
const bool positionOccupied = values->ValueAt(partition) != T();
|
||||
// Inserting at start of run so make previous longer
|
||||
if (partition == 0) {
|
||||
// Inserting at start of document so ensure 0
|
||||
if (valueCurrent != T()) {
|
||||
ClearValue(0);
|
||||
// Inserting at start of document so ensure start empty
|
||||
if (positionOccupied) {
|
||||
starts->InsertPartition(1, 0);
|
||||
values->InsertValue(1, 1, valueCurrent);
|
||||
starts->InsertText(0, insertLength);
|
||||
} else {
|
||||
starts->InsertText(partition, insertLength);
|
||||
values->InsertEmpty(0, 1);
|
||||
}
|
||||
starts->InsertText(partition, insertLength);
|
||||
} else {
|
||||
if (valueCurrent != T()) {
|
||||
if (positionOccupied) {
|
||||
starts->InsertText(partition - 1, insertLength);
|
||||
} else {
|
||||
// Insert at end of run so do not extend style
|
||||
|
@ -157,28 +151,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
// The specialization for const char * makes copies and deletes them as needed.
|
||||
|
||||
template<>
|
||||
inline void SparseVector<const char *>::ClearValue(int partition) {
|
||||
const char *value = values->ValueAt(partition);
|
||||
delete []value;
|
||||
values->SetValueAt(partition, NULL);
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void SparseVector<const char *>::SetValueAt(int position, const char *value) {
|
||||
// Make a copy of the string
|
||||
if (value) {
|
||||
const size_t len = strlen(value);
|
||||
char *valueCopy = new char[len + 1]();
|
||||
std::copy(value, value + len, valueCopy);
|
||||
CommonSetValueAt(position, valueCopy);
|
||||
} else {
|
||||
CommonSetValueAt(position, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SCI_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -16,11 +16,11 @@ namespace Scintilla {
|
|||
template <typename T>
|
||||
class SplitVector {
|
||||
protected:
|
||||
T *body;
|
||||
int size;
|
||||
std::vector<T> body;
|
||||
T empty; /// Returned as the result of out-of-bounds access.
|
||||
int lengthBody;
|
||||
int part1Length;
|
||||
int gapLength; /// invariant: gapLength == size - lengthBody
|
||||
int gapLength; /// invariant: gapLength == body.size() - lengthBody
|
||||
int growSize;
|
||||
|
||||
/// Move the gap to a particular position so that insertion and
|
||||
|
@ -30,16 +30,16 @@ protected:
|
|||
if (position != part1Length) {
|
||||
if (position < part1Length) {
|
||||
// Moving the gap towards start so moving elements towards end
|
||||
std::copy_backward(
|
||||
body + position,
|
||||
body + part1Length,
|
||||
body + gapLength + part1Length);
|
||||
std::move_backward(
|
||||
body.data() + position,
|
||||
body.data() + part1Length,
|
||||
body.data() + gapLength + part1Length);
|
||||
} else { // position > part1Length
|
||||
// Moving the gap towards end so moving elements towards start
|
||||
std::copy(
|
||||
body + part1Length + gapLength,
|
||||
body + gapLength + position,
|
||||
body + part1Length);
|
||||
std::move(
|
||||
body.data() + part1Length + gapLength,
|
||||
body.data() + gapLength + position,
|
||||
body.data() + part1Length);
|
||||
}
|
||||
part1Length = position;
|
||||
}
|
||||
|
@ -49,16 +49,16 @@ protected:
|
|||
/// reallocating if more space needed.
|
||||
void RoomFor(int insertionLength) {
|
||||
if (gapLength <= insertionLength) {
|
||||
while (growSize < size / 6)
|
||||
while (growSize < static_cast<int>(body.size() / 6))
|
||||
growSize *= 2;
|
||||
ReAllocate(size + insertionLength + growSize);
|
||||
ReAllocate(static_cast<int>(body.size()) + insertionLength + growSize);
|
||||
}
|
||||
}
|
||||
|
||||
void Init() {
|
||||
body = NULL;
|
||||
body.clear();
|
||||
body.shrink_to_fit();
|
||||
growSize = 8;
|
||||
size = 0;
|
||||
lengthBody = 0;
|
||||
part1Length = 0;
|
||||
gapLength = 0;
|
||||
|
@ -66,13 +66,15 @@ protected:
|
|||
|
||||
public:
|
||||
/// Construct a split buffer.
|
||||
SplitVector() {
|
||||
SplitVector() : empty() {
|
||||
Init();
|
||||
}
|
||||
|
||||
// Deleted so SplitVector objects can not be copied.
|
||||
SplitVector(const SplitVector &) = delete;
|
||||
void operator=(const SplitVector &) = delete;
|
||||
|
||||
~SplitVector() {
|
||||
delete []body;
|
||||
body = 0;
|
||||
}
|
||||
|
||||
int GetGrowSize() const {
|
||||
|
@ -90,61 +92,73 @@ public:
|
|||
if (newSize < 0)
|
||||
throw std::runtime_error("SplitVector::ReAllocate: negative size.");
|
||||
|
||||
if (newSize > size) {
|
||||
if (newSize > static_cast<int>(body.size())) {
|
||||
// Move the gap to the end
|
||||
GapTo(lengthBody);
|
||||
T *newBody = new T[newSize];
|
||||
if ((size != 0) && (body != 0)) {
|
||||
std::copy(body, body + lengthBody, newBody);
|
||||
delete []body;
|
||||
}
|
||||
body = newBody;
|
||||
gapLength += newSize - size;
|
||||
size = newSize;
|
||||
gapLength += newSize - static_cast<int>(body.size());
|
||||
// RoomFor implements a growth strategy but so does vector::resize so
|
||||
// ensure vector::resize allocates exactly the amount wanted by
|
||||
// calling reserve first.
|
||||
body.reserve(newSize);
|
||||
body.resize(newSize);
|
||||
}
|
||||
}
|
||||
|
||||
/// Retrieve the character at a particular position.
|
||||
/// Retrieving positions outside the range of the buffer returns 0.
|
||||
/// The assertions here are disabled since calling code can be
|
||||
/// simpler if out of range access works and returns 0.
|
||||
T ValueAt(int position) const {
|
||||
/// Retrieve the element at a particular position.
|
||||
/// Retrieving positions outside the range of the buffer returns empty or 0.
|
||||
const T& ValueAt(int position) const {
|
||||
if (position < part1Length) {
|
||||
//PLATFORM_ASSERT(position >= 0);
|
||||
if (position < 0) {
|
||||
return 0;
|
||||
return empty;
|
||||
} else {
|
||||
return body[position];
|
||||
}
|
||||
} else {
|
||||
//PLATFORM_ASSERT(position < lengthBody);
|
||||
if (position >= lengthBody) {
|
||||
return 0;
|
||||
return empty;
|
||||
} else {
|
||||
return body[gapLength + position];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetValueAt(int position, T v) {
|
||||
/// Set the element at a particular position.
|
||||
/// Setting positions outside the range of the buffer performs no assignment
|
||||
/// but asserts in debug builds.
|
||||
template <typename ParamType>
|
||||
void SetValueAt(int position, ParamType&& v) {
|
||||
if (position < part1Length) {
|
||||
PLATFORM_ASSERT(position >= 0);
|
||||
if (position < 0) {
|
||||
;
|
||||
} else {
|
||||
body[position] = v;
|
||||
body[position] = std::move(v);
|
||||
}
|
||||
} else {
|
||||
PLATFORM_ASSERT(position < lengthBody);
|
||||
if (position >= lengthBody) {
|
||||
;
|
||||
} else {
|
||||
body[gapLength + position] = v;
|
||||
body[gapLength + position] = std::move(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
T &operator[](int position) const {
|
||||
/// Retrieve the element at a particular position.
|
||||
/// The position must be within bounds or an assertion is triggered.
|
||||
const T &operator[](int position) const {
|
||||
PLATFORM_ASSERT(position >= 0 && position < lengthBody);
|
||||
if (position < part1Length) {
|
||||
return body[position];
|
||||
} else {
|
||||
return body[gapLength + position];
|
||||
}
|
||||
}
|
||||
|
||||
/// Retrieve reference to the element at a particular position.
|
||||
/// This, instead of the const variant, can be used to mutate in-place.
|
||||
/// The position must be within bounds or an assertion is triggered.
|
||||
T &operator[](int position) {
|
||||
PLATFORM_ASSERT(position >= 0 && position < lengthBody);
|
||||
if (position < part1Length) {
|
||||
return body[position];
|
||||
|
@ -167,7 +181,7 @@ public:
|
|||
}
|
||||
RoomFor(1);
|
||||
GapTo(position);
|
||||
body[part1Length] = v;
|
||||
body[part1Length] = std::move(v);
|
||||
lengthBody++;
|
||||
part1Length++;
|
||||
gapLength--;
|
||||
|
@ -183,7 +197,28 @@ public:
|
|||
}
|
||||
RoomFor(insertLength);
|
||||
GapTo(position);
|
||||
std::fill(&body[part1Length], &body[part1Length + insertLength], v);
|
||||
std::fill(body.data() + part1Length, body.data() + part1Length + insertLength, v);
|
||||
lengthBody += insertLength;
|
||||
part1Length += insertLength;
|
||||
gapLength -= insertLength;
|
||||
}
|
||||
}
|
||||
|
||||
/// Add some new empty elements.
|
||||
/// InsertValue is good for value objects but not for unique_ptr objects
|
||||
/// since they can only be moved from once.
|
||||
void InsertEmpty(int position, int insertLength) {
|
||||
PLATFORM_ASSERT((position >= 0) && (position <= lengthBody));
|
||||
if (insertLength > 0) {
|
||||
if ((position < 0) || (position > lengthBody)) {
|
||||
return;
|
||||
}
|
||||
RoomFor(insertLength);
|
||||
GapTo(position);
|
||||
for (int elem = part1Length; elem < part1Length + insertLength; elem++) {
|
||||
T emptyOne = {};
|
||||
body[elem] = std::move(emptyOne);
|
||||
}
|
||||
lengthBody += insertLength;
|
||||
part1Length += insertLength;
|
||||
gapLength -= insertLength;
|
||||
|
@ -194,7 +229,7 @@ public:
|
|||
/// appending zero valued elements if needed.
|
||||
void EnsureLength(int wantedLength) {
|
||||
if (Length() < wantedLength) {
|
||||
InsertValue(Length(), wantedLength - Length(), 0);
|
||||
InsertEmpty(Length(), wantedLength - Length());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -207,7 +242,7 @@ public:
|
|||
}
|
||||
RoomFor(insertLength);
|
||||
GapTo(positionToInsert);
|
||||
std::copy(s + positionFrom, s + positionFrom + insertLength, body + part1Length);
|
||||
std::copy(s + positionFrom, s + positionFrom + insertLength, body.data() + part1Length);
|
||||
lengthBody += insertLength;
|
||||
part1Length += insertLength;
|
||||
gapLength -= insertLength;
|
||||
|
@ -232,7 +267,8 @@ public:
|
|||
}
|
||||
if ((position == 0) && (deleteLength == lengthBody)) {
|
||||
// Full deallocation returns storage and is faster
|
||||
delete []body;
|
||||
body.clear();
|
||||
body.shrink_to_fit();
|
||||
Init();
|
||||
} else if (deleteLength > 0) {
|
||||
GapTo(position);
|
||||
|
@ -243,47 +279,52 @@ public:
|
|||
|
||||
/// Delete all the buffer contents.
|
||||
void DeleteAll() {
|
||||
DeleteRange(0, lengthBody);
|
||||
DeleteRange(0, static_cast<int>(lengthBody));
|
||||
}
|
||||
|
||||
// Retrieve a range of elements into an array
|
||||
/// Retrieve a range of elements into an array
|
||||
void GetRange(T *buffer, int position, int retrieveLength) const {
|
||||
// Split into up to 2 ranges, before and after the split then use memcpy on each.
|
||||
int range1Length = 0;
|
||||
if (position < part1Length) {
|
||||
int part1AfterPosition = part1Length - position;
|
||||
const int part1AfterPosition = part1Length - position;
|
||||
range1Length = retrieveLength;
|
||||
if (range1Length > part1AfterPosition)
|
||||
range1Length = part1AfterPosition;
|
||||
}
|
||||
std::copy(body + position, body + position + range1Length, buffer);
|
||||
std::copy(body.data() + position, body.data() + position + range1Length, buffer);
|
||||
buffer += range1Length;
|
||||
position = position + range1Length + gapLength;
|
||||
position = static_cast<int>(position + range1Length + gapLength);
|
||||
int range2Length = retrieveLength - range1Length;
|
||||
std::copy(body + position, body + position + range2Length, buffer);
|
||||
std::copy(body.data() + position, body.data() + position + range2Length, buffer);
|
||||
}
|
||||
|
||||
/// Compact the buffer and return a pointer to the first element.
|
||||
T *BufferPointer() {
|
||||
RoomFor(1);
|
||||
GapTo(lengthBody);
|
||||
body[lengthBody] = 0;
|
||||
return body;
|
||||
T emptyOne = {};
|
||||
body[lengthBody] = std::move(emptyOne);
|
||||
return body.data();
|
||||
}
|
||||
|
||||
/// Return a pointer to a range of elements, first rearranging the buffer if
|
||||
/// needed to make that range contiguous.
|
||||
T *RangePointer(int position, int rangeLength) {
|
||||
if (position < part1Length) {
|
||||
if ((position + rangeLength) > part1Length) {
|
||||
// Range overlaps gap, so move gap to start of range.
|
||||
GapTo(position);
|
||||
return body + position + gapLength;
|
||||
return body.data() + position + gapLength;
|
||||
} else {
|
||||
return body + position;
|
||||
return body.data() + position;
|
||||
}
|
||||
} else {
|
||||
return body + position + gapLength;
|
||||
return body.data() + position + gapLength;
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the position of the gap within the buffer.
|
||||
int GapPosition() const {
|
||||
return part1Length;
|
||||
}
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "Platform.h"
|
||||
|
@ -70,6 +68,7 @@ FontMeasurements::FontMeasurements() {
|
|||
void FontMeasurements::Clear() {
|
||||
ascent = 1;
|
||||
descent = 1;
|
||||
capitalHeight = 1;
|
||||
aveCharWidth = 1;
|
||||
spaceWidth = 1;
|
||||
sizeZoomed = 2;
|
||||
|
|
|
@ -33,10 +33,10 @@ struct FontSpecification {
|
|||
|
||||
// Just like Font but only has a copy of the FontID so should not delete it
|
||||
class FontAlias : public Font {
|
||||
// Private so FontAlias objects can not be assigned except for intiialization
|
||||
FontAlias &operator=(const FontAlias &);
|
||||
public:
|
||||
FontAlias();
|
||||
// FontAlias objects can not be assigned except for initialization
|
||||
FontAlias &operator=(const FontAlias &) = delete;
|
||||
FontAlias(const FontAlias &);
|
||||
virtual ~FontAlias();
|
||||
void MakeAlias(Font &fontOrigin);
|
||||
|
@ -46,6 +46,7 @@ public:
|
|||
struct FontMeasurements {
|
||||
unsigned int ascent;
|
||||
unsigned int descent;
|
||||
XYPOSITION capitalHeight; // Top of capital letter to baseline: ascent - internal leading
|
||||
XYPOSITION aveCharWidth;
|
||||
XYPOSITION spaceWidth;
|
||||
int sizeZoomed;
|
||||
|
|
|
@ -5,9 +5,10 @@
|
|||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||
// The License.txt file describes the conditions under which this software may be distributed.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cstdlib>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include "UniConversion.h"
|
||||
|
||||
|
@ -19,10 +20,10 @@ using namespace Scintilla;
|
|||
namespace Scintilla {
|
||||
#endif
|
||||
|
||||
unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen) {
|
||||
unsigned int len = 0;
|
||||
for (unsigned int i = 0; i < tlen && uptr[i];) {
|
||||
unsigned int uch = uptr[i];
|
||||
size_t UTF8Length(const wchar_t *uptr, size_t tlen) {
|
||||
size_t len = 0;
|
||||
for (size_t i = 0; i < tlen && uptr[i];) {
|
||||
const unsigned int uch = uptr[i];
|
||||
if (uch < 0x80) {
|
||||
len++;
|
||||
} else if (uch < 0x800) {
|
||||
|
@ -39,10 +40,10 @@ unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen) {
|
|||
return len;
|
||||
}
|
||||
|
||||
void UTF8FromUTF16(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len) {
|
||||
unsigned int k = 0;
|
||||
for (unsigned int i = 0; i < tlen && uptr[i];) {
|
||||
unsigned int uch = uptr[i];
|
||||
void UTF8FromUTF16(const wchar_t *uptr, size_t tlen, char *putf, size_t len) {
|
||||
size_t k = 0;
|
||||
for (size_t i = 0; i < tlen && uptr[i];) {
|
||||
const unsigned int uch = uptr[i];
|
||||
if (uch < 0x80) {
|
||||
putf[k++] = static_cast<char>(uch);
|
||||
} else if (uch < 0x800) {
|
||||
|
@ -52,7 +53,7 @@ void UTF8FromUTF16(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned
|
|||
(uch <= SURROGATE_TRAIL_LAST)) {
|
||||
// Half a surrogate pair
|
||||
i++;
|
||||
unsigned int xch = 0x10000 + ((uch & 0x3ff) << 10) + (uptr[i] & 0x3ff);
|
||||
const unsigned int xch = 0x10000 + ((uch & 0x3ff) << 10) + (uptr[i] & 0x3ff);
|
||||
putf[k++] = static_cast<char>(0xF0 | (xch >> 18));
|
||||
putf[k++] = static_cast<char>(0x80 | ((xch >> 12) & 0x3f));
|
||||
putf[k++] = static_cast<char>(0x80 | ((xch >> 6) & 0x3f));
|
||||
|
@ -84,7 +85,7 @@ size_t UTF16Length(const char *s, size_t len) {
|
|||
size_t ulen = 0;
|
||||
size_t charLen;
|
||||
for (size_t i = 0; i<len;) {
|
||||
unsigned char ch = static_cast<unsigned char>(s[i]);
|
||||
const unsigned char ch = static_cast<unsigned char>(s[i]);
|
||||
if (ch < 0x80) {
|
||||
charLen = 1;
|
||||
} else if (ch < 0x80 + 0x40 + 0x20) {
|
||||
|
@ -137,10 +138,10 @@ size_t UTF16FromUTF8(const char *s, size_t len, wchar_t *tbuf, size_t tlen) {
|
|||
return ui;
|
||||
}
|
||||
|
||||
unsigned int UTF32FromUTF8(const char *s, unsigned int len, unsigned int *tbuf, unsigned int tlen) {
|
||||
unsigned int ui=0;
|
||||
size_t UTF32FromUTF8(const char *s, size_t len, unsigned int *tbuf, size_t tlen) {
|
||||
size_t ui=0;
|
||||
const unsigned char *us = reinterpret_cast<const unsigned char *>(s);
|
||||
unsigned int i=0;
|
||||
size_t i=0;
|
||||
while ((i<len) && (ui<tlen)) {
|
||||
unsigned char ch = us[i++];
|
||||
unsigned int value = 0;
|
||||
|
@ -300,10 +301,32 @@ int UTF8Classify(const unsigned char *us, int len) {
|
|||
}
|
||||
|
||||
int UTF8DrawBytes(const unsigned char *us, int len) {
|
||||
int utf8StatusNext = UTF8Classify(us, len);
|
||||
const int utf8StatusNext = UTF8Classify(us, len);
|
||||
return (utf8StatusNext & UTF8MaskInvalid) ? 1 : (utf8StatusNext & UTF8MaskWidth);
|
||||
}
|
||||
|
||||
// Replace invalid bytes in UTF-8 with the replacement character
|
||||
std::string FixInvalidUTF8(const std::string &text) {
|
||||
std::string result;
|
||||
const unsigned char *us = reinterpret_cast<const unsigned char *>(text.c_str());
|
||||
size_t remaining = text.size();
|
||||
while (remaining > 0) {
|
||||
const int utf8Status = UTF8Classify(us, static_cast<int>(remaining));
|
||||
if (utf8Status & UTF8MaskInvalid) {
|
||||
// Replacement character 0xFFFD = UTF8:"efbfbd".
|
||||
result.append("\xef\xbf\xbd");
|
||||
us++;
|
||||
remaining--;
|
||||
} else {
|
||||
const int len = utf8Status&UTF8MaskWidth;
|
||||
result.append(reinterpret_cast<const char *>(us), len);
|
||||
us += len;
|
||||
remaining -= len;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef SCI_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -16,13 +16,14 @@ const int UTF8MaxBytes = 4;
|
|||
|
||||
const int unicodeReplacementChar = 0xFFFD;
|
||||
|
||||
unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen);
|
||||
void UTF8FromUTF16(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len);
|
||||
size_t UTF8Length(const wchar_t *uptr, size_t tlen);
|
||||
void UTF8FromUTF16(const wchar_t *uptr, size_t tlen, char *putf, size_t len);
|
||||
unsigned int UTF8CharLength(unsigned char ch);
|
||||
size_t UTF16Length(const char *s, size_t len);
|
||||
size_t UTF16FromUTF8(const char *s, size_t len, wchar_t *tbuf, size_t tlen);
|
||||
unsigned int UTF32FromUTF8(const char *s, unsigned int len, unsigned int *tbuf, unsigned int tlen);
|
||||
size_t UTF32FromUTF8(const char *s, size_t len, unsigned int *tbuf, size_t tlen);
|
||||
unsigned int UTF16FromUTF32Character(unsigned int val, wchar_t *tbuf);
|
||||
std::string FixInvalidUTF8(const std::string &text);
|
||||
|
||||
extern int UTF8BytesOfLead[256];
|
||||
void UTF8BytesOfLeadInitialise();
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue