Merge pull request #1914 from b4n/scintilla/update-3-10-0
Update Scintilla to version 3.10.0 Fixes #1421.
This commit is contained in:
commit
0b75601ac8
@ -9,6 +9,14 @@ position=number
|
|||||||
deleted=line_removed
|
deleted=line_removed
|
||||||
added=line_added
|
added=line_added
|
||||||
changed=line_changed
|
changed=line_changed
|
||||||
|
# '++' lines
|
||||||
|
patch_add=line_added
|
||||||
|
# '+-' lines
|
||||||
|
patch_delete=line_added
|
||||||
|
# '-+' lines
|
||||||
|
removed_patch_add=line_removed
|
||||||
|
# '--' lines
|
||||||
|
removed_patch_delete=line_removed
|
||||||
|
|
||||||
|
|
||||||
[settings]
|
[settings]
|
||||||
|
@ -374,10 +374,9 @@ static void write_latex_file(GeanyDocument *doc, const gchar *filename,
|
|||||||
GString *body;
|
GString *body;
|
||||||
GString *cmds;
|
GString *cmds;
|
||||||
GString *latex;
|
GString *latex;
|
||||||
gint style_max = pow(2, scintilla_send_message(sci, SCI_GETSTYLEBITS, 0, 0));
|
|
||||||
|
|
||||||
/* first read all styles from Scintilla */
|
/* first read all styles from Scintilla */
|
||||||
for (i = 0; i < style_max; i++)
|
for (i = 0; i < STYLE_MAX; i++)
|
||||||
{
|
{
|
||||||
styles[i][FORE] = scintilla_send_message(sci, SCI_STYLEGETFORE, i, 0);
|
styles[i][FORE] = scintilla_send_message(sci, SCI_STYLEGETFORE, i, 0);
|
||||||
styles[i][BACK] = scintilla_send_message(sci, SCI_STYLEGETBACK, i, 0);
|
styles[i][BACK] = scintilla_send_message(sci, SCI_STYLEGETBACK, i, 0);
|
||||||
@ -517,7 +516,7 @@ static void write_latex_file(GeanyDocument *doc, const gchar *filename,
|
|||||||
|
|
||||||
/* write used styles in the header */
|
/* write used styles in the header */
|
||||||
cmds = g_string_new("");
|
cmds = g_string_new("");
|
||||||
for (i = 0; i < style_max; i++)
|
for (i = 0; i < STYLE_MAX; i++)
|
||||||
{
|
{
|
||||||
if (styles[i][USED])
|
if (styles[i][USED])
|
||||||
{
|
{
|
||||||
@ -578,10 +577,9 @@ static void write_html_file(GeanyDocument *doc, const gchar *filename,
|
|||||||
GString *body;
|
GString *body;
|
||||||
GString *css;
|
GString *css;
|
||||||
GString *html;
|
GString *html;
|
||||||
gint style_max = pow(2, scintilla_send_message(sci, SCI_GETSTYLEBITS, 0, 0));
|
|
||||||
|
|
||||||
/* first read all styles from Scintilla */
|
/* first read all styles from Scintilla */
|
||||||
for (i = 0; i < style_max; i++)
|
for (i = 0; i < STYLE_MAX; i++)
|
||||||
{
|
{
|
||||||
styles[i][FORE] = ROTATE_RGB(scintilla_send_message(sci, SCI_STYLEGETFORE, i, 0));
|
styles[i][FORE] = ROTATE_RGB(scintilla_send_message(sci, SCI_STYLEGETFORE, i, 0));
|
||||||
styles[i][BACK] = ROTATE_RGB(scintilla_send_message(sci, SCI_STYLEGETBACK, i, 0));
|
styles[i][BACK] = ROTATE_RGB(scintilla_send_message(sci, SCI_STYLEGETBACK, i, 0));
|
||||||
@ -707,7 +705,7 @@ static void write_html_file(GeanyDocument *doc, const gchar *filename,
|
|||||||
"\tbody\n\t{\n\t\tfont-family: %s, monospace;\n\t\tfont-size: %dpt;\n\t}\n",
|
"\tbody\n\t{\n\t\tfont-family: %s, monospace;\n\t\tfont-size: %dpt;\n\t}\n",
|
||||||
font_name, font_size);
|
font_name, font_size);
|
||||||
|
|
||||||
for (i = 0; i < style_max; i++)
|
for (i = 0; i < STYLE_MAX; i++)
|
||||||
{
|
{
|
||||||
if (styles[i][USED])
|
if (styles[i][USED])
|
||||||
{
|
{
|
||||||
|
@ -64,6 +64,8 @@ lexlib/CharacterCategory.cxx \
|
|||||||
lexlib/CharacterCategory.h \
|
lexlib/CharacterCategory.h \
|
||||||
lexlib/CharacterSet.cxx \
|
lexlib/CharacterSet.cxx \
|
||||||
lexlib/CharacterSet.h \
|
lexlib/CharacterSet.h \
|
||||||
|
lexlib/DefaultLexer.cxx \
|
||||||
|
lexlib/DefaultLexer.h \
|
||||||
lexlib/LexAccessor.h \
|
lexlib/LexAccessor.h \
|
||||||
lexlib/LexerBase.cxx \
|
lexlib/LexerBase.cxx \
|
||||||
lexlib/LexerBase.h \
|
lexlib/LexerBase.h \
|
||||||
@ -99,6 +101,8 @@ src/CharClassify.cxx \
|
|||||||
src/CharClassify.h \
|
src/CharClassify.h \
|
||||||
src/ContractionState.cxx \
|
src/ContractionState.cxx \
|
||||||
src/ContractionState.h \
|
src/ContractionState.h \
|
||||||
|
src/DBCS.cxx \
|
||||||
|
src/DBCS.h \
|
||||||
src/Decoration.cxx \
|
src/Decoration.cxx \
|
||||||
src/Decoration.h \
|
src/Decoration.h \
|
||||||
src/Document.cxx \
|
src/Document.cxx \
|
||||||
@ -109,11 +113,13 @@ src/EditModel.cxx \
|
|||||||
src/EditModel.h \
|
src/EditModel.h \
|
||||||
src/EditView.cxx \
|
src/EditView.cxx \
|
||||||
src/EditView.h \
|
src/EditView.h \
|
||||||
|
src/ElapsedPeriod.h \
|
||||||
src/ExternalLexer.cxx \
|
src/ExternalLexer.cxx \
|
||||||
src/ExternalLexer.h \
|
src/ExternalLexer.h \
|
||||||
src/FontQuality.h \
|
src/FontQuality.h \
|
||||||
src/Indicator.cxx \
|
src/Indicator.cxx \
|
||||||
src/Indicator.h \
|
src/Indicator.h \
|
||||||
|
src/IntegerRectangle.h \
|
||||||
src/KeyMap.cxx \
|
src/KeyMap.cxx \
|
||||||
src/KeyMap.h \
|
src/KeyMap.h \
|
||||||
src/LineMarker.cxx \
|
src/LineMarker.cxx \
|
||||||
|
@ -6,9 +6,7 @@
|
|||||||
#ifndef CONVERTER_H
|
#ifndef CONVERTER_H
|
||||||
#define CONVERTER_H
|
#define CONVERTER_H
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
const GIConv iconvhBad = (GIConv)(-1);
|
const GIConv iconvhBad = (GIConv)(-1);
|
||||||
const gsize sizeFailure = static_cast<gsize>(-1);
|
const gsize sizeFailure = static_cast<gsize>(-1);
|
||||||
@ -67,8 +65,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -45,21 +45,7 @@ static double doubleFromPangoUnits(int pu) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static cairo_surface_t *CreateSimilarSurface(GdkWindow *window, cairo_content_t content, int width, int height) {
|
static cairo_surface_t *CreateSimilarSurface(GdkWindow *window, cairo_content_t content, int width, int height) {
|
||||||
#if GTK_CHECK_VERSION(2,22,0)
|
|
||||||
return gdk_window_create_similar_surface(window, content, width, height);
|
return gdk_window_create_similar_surface(window, content, width, height);
|
||||||
#else
|
|
||||||
cairo_surface_t *window_surface, *surface;
|
|
||||||
|
|
||||||
g_return_val_if_fail(GDK_IS_WINDOW(window), NULL);
|
|
||||||
|
|
||||||
window_surface = GDK_DRAWABLE_GET_CLASS(window)->ref_cairo_surface(window);
|
|
||||||
|
|
||||||
surface = cairo_surface_create_similar(window_surface, content, width, height);
|
|
||||||
|
|
||||||
cairo_surface_destroy(window_surface);
|
|
||||||
|
|
||||||
return surface;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GdkWindow *WindowFromWidget(GtkWidget *w) {
|
static GdkWindow *WindowFromWidget(GtkWidget *w) {
|
||||||
@ -71,9 +57,7 @@ static GdkWindow *WindowFromWidget(GtkWidget *w) {
|
|||||||
#pragma warning(disable: 4505)
|
#pragma warning(disable: 4505)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
enum encodingType { singleByte, UTF8, dbcs};
|
enum encodingType { singleByte, UTF8, dbcs};
|
||||||
|
|
||||||
@ -121,13 +105,7 @@ static GtkWidget *PWidget(WindowID wid) {
|
|||||||
return static_cast<GtkWidget *>(wid);
|
return static_cast<GtkWidget *>(wid);
|
||||||
}
|
}
|
||||||
|
|
||||||
Point Point::FromLong(long lpoint) {
|
Font::Font() noexcept : fid(0) {}
|
||||||
return Point(
|
|
||||||
Platform::LowShortFromLong(lpoint),
|
|
||||||
Platform::HighShortFromLong(lpoint));
|
|
||||||
}
|
|
||||||
|
|
||||||
Font::Font() : fid(0) {}
|
|
||||||
|
|
||||||
Font::~Font() {}
|
Font::~Font() {}
|
||||||
|
|
||||||
@ -143,9 +121,7 @@ void Font::Release() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Required on OS X
|
// Required on OS X
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
// SurfaceID is a cairo_t*
|
// SurfaceID is a cairo_t*
|
||||||
class SurfaceImpl : public Surface {
|
class SurfaceImpl : public Surface {
|
||||||
@ -177,13 +153,14 @@ public:
|
|||||||
int DeviceHeightFont(int points) override;
|
int DeviceHeightFont(int points) override;
|
||||||
void MoveTo(int x_, int y_) override;
|
void MoveTo(int x_, int y_) override;
|
||||||
void LineTo(int x_, int y_) override;
|
void LineTo(int x_, int y_) override;
|
||||||
void Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired back) override;
|
void Polygon(Point *pts, size_t npts, ColourDesired fore, ColourDesired back) override;
|
||||||
void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) override;
|
void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) override;
|
||||||
void FillRectangle(PRectangle rc, ColourDesired back) override;
|
void FillRectangle(PRectangle rc, ColourDesired back) override;
|
||||||
void FillRectangle(PRectangle rc, Surface &surfacePattern) override;
|
void FillRectangle(PRectangle rc, Surface &surfacePattern) override;
|
||||||
void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back) override;
|
void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back) override;
|
||||||
void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill,
|
void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill,
|
||||||
ColourDesired outline, int alphaOutline, int flags) override;
|
ColourDesired outline, int alphaOutline, int flags) override;
|
||||||
|
void GradientRectangle(PRectangle rc, const std::vector<ColourStop> &stops, GradientOptions options) override;
|
||||||
void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) override;
|
void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) override;
|
||||||
void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) override;
|
void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) override;
|
||||||
void Copy(PRectangle rc, Point from, Surface &surfaceSource) override;
|
void Copy(PRectangle rc, Point from, Surface &surfaceSource) override;
|
||||||
@ -194,11 +171,9 @@ public:
|
|||||||
void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore) 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;
|
void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions) override;
|
||||||
XYPOSITION WidthText(Font &font_, const char *s, int len) override;
|
XYPOSITION WidthText(Font &font_, const char *s, int len) override;
|
||||||
XYPOSITION WidthChar(Font &font_, char ch) override;
|
|
||||||
XYPOSITION Ascent(Font &font_) override;
|
XYPOSITION Ascent(Font &font_) override;
|
||||||
XYPOSITION Descent(Font &font_) override;
|
XYPOSITION Descent(Font &font_) override;
|
||||||
XYPOSITION InternalLeading(Font &font_) override;
|
XYPOSITION InternalLeading(Font &font_) override;
|
||||||
XYPOSITION ExternalLeading(Font &font_) override;
|
|
||||||
XYPOSITION Height(Font &font_) override;
|
XYPOSITION Height(Font &font_) override;
|
||||||
XYPOSITION AverageCharWidth(Font &font_) override;
|
XYPOSITION AverageCharWidth(Font &font_) override;
|
||||||
|
|
||||||
@ -208,9 +183,7 @@ public:
|
|||||||
void SetUnicodeMode(bool unicodeMode_) override;
|
void SetUnicodeMode(bool unicodeMode_) override;
|
||||||
void SetDBCSMode(int codePage) override;
|
void SetDBCSMode(int codePage) override;
|
||||||
};
|
};
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
const char *CharacterSetID(int characterSet) {
|
const char *CharacterSetID(int characterSet) {
|
||||||
switch (characterSet) {
|
switch (characterSet) {
|
||||||
@ -310,7 +283,6 @@ void SurfaceImpl::Release() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool SurfaceImpl::Initialised() {
|
bool SurfaceImpl::Initialised() {
|
||||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 8, 0)
|
|
||||||
if (inited && context) {
|
if (inited && context) {
|
||||||
if (cairo_status(context) == CAIRO_STATUS_SUCCESS) {
|
if (cairo_status(context) == CAIRO_STATUS_SUCCESS) {
|
||||||
// Even when status is success, the target surface may have been
|
// Even when status is success, the target surface may have been
|
||||||
@ -327,7 +299,6 @@ bool SurfaceImpl::Initialised() {
|
|||||||
}
|
}
|
||||||
return cairo_status(context) == CAIRO_STATUS_SUCCESS;
|
return cairo_status(context) == CAIRO_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return inited;
|
return inited;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,7 +361,7 @@ void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_, WindowID
|
|||||||
|
|
||||||
void SurfaceImpl::PenColour(ColourDesired fore) {
|
void SurfaceImpl::PenColour(ColourDesired fore) {
|
||||||
if (context) {
|
if (context) {
|
||||||
ColourDesired cdFore(fore.AsLong());
|
ColourDesired cdFore(fore.AsInteger());
|
||||||
cairo_set_source_rgb(context,
|
cairo_set_source_rgb(context,
|
||||||
cdFore.GetRed() / 255.0,
|
cdFore.GetRed() / 255.0,
|
||||||
cdFore.GetGreen() / 255.0,
|
cdFore.GetGreen() / 255.0,
|
||||||
@ -432,10 +403,10 @@ void SurfaceImpl::LineTo(int x_, int y_) {
|
|||||||
if ((xDiff == 0) || (yDiff == 0)) {
|
if ((xDiff == 0) || (yDiff == 0)) {
|
||||||
// Horizontal or vertical lines can be more precisely drawn as a filled rectangle
|
// Horizontal or vertical lines can be more precisely drawn as a filled rectangle
|
||||||
int xEnd = x_ - xDelta;
|
int xEnd = x_ - xDelta;
|
||||||
int left = Platform::Minimum(x, xEnd);
|
int left = std::min(x, xEnd);
|
||||||
int width = abs(x - xEnd) + 1;
|
int width = abs(x - xEnd) + 1;
|
||||||
int yEnd = y_ - yDelta;
|
int yEnd = y_ - yDelta;
|
||||||
int top = Platform::Minimum(y, yEnd);
|
int top = std::min(y, yEnd);
|
||||||
int height = abs(y - yEnd) + 1;
|
int height = abs(y - yEnd) + 1;
|
||||||
cairo_rectangle(context, left, top, width, height);
|
cairo_rectangle(context, left, top, width, height);
|
||||||
cairo_fill(context);
|
cairo_fill(context);
|
||||||
@ -454,12 +425,12 @@ void SurfaceImpl::LineTo(int x_, int y_) {
|
|||||||
y = y_;
|
y = y_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurfaceImpl::Polygon(Point *pts, int npts, ColourDesired fore,
|
void SurfaceImpl::Polygon(Point *pts, size_t npts, ColourDesired fore,
|
||||||
ColourDesired back) {
|
ColourDesired back) {
|
||||||
PLATFORM_ASSERT(context);
|
PLATFORM_ASSERT(context);
|
||||||
PenColour(back);
|
PenColour(back);
|
||||||
cairo_move_to(context, pts[0].x + 0.5, pts[0].y + 0.5);
|
cairo_move_to(context, pts[0].x + 0.5, pts[0].y + 0.5);
|
||||||
for (int i = 1; i < npts; i++) {
|
for (size_t i = 1; i < npts; i++) {
|
||||||
cairo_line_to(context, pts[i].x + 0.5, pts[i].y + 0.5);
|
cairo_line_to(context, pts[i].x + 0.5, pts[i].y + 0.5);
|
||||||
}
|
}
|
||||||
cairo_close_path(context);
|
cairo_close_path(context);
|
||||||
@ -537,12 +508,7 @@ void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesi
|
|||||||
static void PathRoundRectangle(cairo_t *context, double left, double top, double width, double height, int radius) {
|
static void PathRoundRectangle(cairo_t *context, double left, double top, double width, double height, int radius) {
|
||||||
double degrees = kPi / 180.0;
|
double degrees = kPi / 180.0;
|
||||||
|
|
||||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
|
|
||||||
cairo_new_sub_path(context);
|
cairo_new_sub_path(context);
|
||||||
#else
|
|
||||||
// First arc is in the top-right corner and starts from a point on the top line
|
|
||||||
cairo_move_to(context, left + width - radius, top);
|
|
||||||
#endif
|
|
||||||
cairo_arc(context, left + width - radius, top + radius, radius, -90 * degrees, 0 * degrees);
|
cairo_arc(context, left + width - radius, top + radius, radius, -90 * degrees, 0 * degrees);
|
||||||
cairo_arc(context, left + width - radius, top + height - radius, radius, 0 * degrees, 90 * degrees);
|
cairo_arc(context, left + width - radius, top + height - radius, radius, 0 * degrees, 90 * degrees);
|
||||||
cairo_arc(context, left + radius, top + height - radius, radius, 90 * degrees, 180 * degrees);
|
cairo_arc(context, left + radius, top + height - radius, radius, 90 * degrees, 180 * degrees);
|
||||||
@ -553,7 +519,7 @@ static void PathRoundRectangle(cairo_t *context, double left, double top, double
|
|||||||
void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill,
|
void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill,
|
||||||
ColourDesired outline, int alphaOutline, int /*flags*/) {
|
ColourDesired outline, int alphaOutline, int /*flags*/) {
|
||||||
if (context && rc.Width() > 0) {
|
if (context && rc.Width() > 0) {
|
||||||
ColourDesired cdFill(fill.AsLong());
|
ColourDesired cdFill(fill.AsInteger());
|
||||||
cairo_set_source_rgba(context,
|
cairo_set_source_rgba(context,
|
||||||
cdFill.GetRed() / 255.0,
|
cdFill.GetRed() / 255.0,
|
||||||
cdFill.GetGreen() / 255.0,
|
cdFill.GetGreen() / 255.0,
|
||||||
@ -565,7 +531,7 @@ void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fi
|
|||||||
cairo_rectangle(context, rc.left + 1.0, rc.top + 1.0, rc.right - rc.left - 2.0, rc.bottom - rc.top - 2.0);
|
cairo_rectangle(context, rc.left + 1.0, rc.top + 1.0, rc.right - rc.left - 2.0, rc.bottom - rc.top - 2.0);
|
||||||
cairo_fill(context);
|
cairo_fill(context);
|
||||||
|
|
||||||
ColourDesired cdOutline(outline.AsLong());
|
ColourDesired cdOutline(outline.AsInteger());
|
||||||
cairo_set_source_rgba(context,
|
cairo_set_source_rgba(context,
|
||||||
cdOutline.GetRed() / 255.0,
|
cdOutline.GetRed() / 255.0,
|
||||||
cdOutline.GetGreen() / 255.0,
|
cdOutline.GetGreen() / 255.0,
|
||||||
@ -579,6 +545,32 @@ void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SurfaceImpl::GradientRectangle(PRectangle rc, const std::vector<ColourStop> &stops, GradientOptions options) {
|
||||||
|
if (context) {
|
||||||
|
cairo_pattern_t *pattern;
|
||||||
|
switch (options) {
|
||||||
|
case GradientOptions::leftToRight:
|
||||||
|
pattern = cairo_pattern_create_linear(rc.left, rc.top, rc.right, rc.top);
|
||||||
|
break;
|
||||||
|
case GradientOptions::topToBottom:
|
||||||
|
default:
|
||||||
|
pattern = cairo_pattern_create_linear(rc.left, rc.top, rc.left, rc.bottom);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for (const ColourStop &stop : stops) {
|
||||||
|
cairo_pattern_add_color_stop_rgba(pattern, stop.position,
|
||||||
|
stop.colour.GetRedComponent(),
|
||||||
|
stop.colour.GetGreenComponent(),
|
||||||
|
stop.colour.GetBlueComponent(),
|
||||||
|
stop.colour.GetAlphaComponent());
|
||||||
|
}
|
||||||
|
cairo_rectangle(context, rc.left, rc.top, rc.Width(), rc.Height());
|
||||||
|
cairo_set_source(context, pattern);
|
||||||
|
cairo_fill(context);
|
||||||
|
cairo_pattern_destroy(pattern);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) {
|
void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) {
|
||||||
PLATFORM_ASSERT(context);
|
PLATFORM_ASSERT(context);
|
||||||
if (rc.Width() > width)
|
if (rc.Width() > width)
|
||||||
@ -588,11 +580,7 @@ void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsi
|
|||||||
rc.top += (rc.Height() - height) / 2;
|
rc.top += (rc.Height() - height) / 2;
|
||||||
rc.bottom = rc.top + height;
|
rc.bottom = rc.top + height;
|
||||||
|
|
||||||
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1,6,0)
|
|
||||||
int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width);
|
int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width);
|
||||||
#else
|
|
||||||
int stride = width * 4;
|
|
||||||
#endif
|
|
||||||
int ucs = stride * height;
|
int ucs = stride * height;
|
||||||
std::vector<unsigned char> image(ucs);
|
std::vector<unsigned char> image(ucs);
|
||||||
for (int iy=0; iy<height; iy++) {
|
for (int iy=0; iy<height; iy++) {
|
||||||
@ -618,7 +606,7 @@ void SurfaceImpl::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back)
|
|||||||
PLATFORM_ASSERT(context);
|
PLATFORM_ASSERT(context);
|
||||||
PenColour(back);
|
PenColour(back);
|
||||||
cairo_arc(context, (rc.left + rc.right) / 2, (rc.top + rc.bottom) / 2,
|
cairo_arc(context, (rc.left + rc.right) / 2, (rc.top + rc.bottom) / 2,
|
||||||
Platform::Minimum(rc.Width(), rc.Height()) / 2, 0, 2*kPi);
|
std::min(rc.Width(), rc.Height()) / 2, 0, 2*kPi);
|
||||||
cairo_fill_preserve(context);
|
cairo_fill_preserve(context);
|
||||||
PenColour(fore);
|
PenColour(fore);
|
||||||
cairo_stroke(context);
|
cairo_stroke(context);
|
||||||
@ -706,11 +694,7 @@ void SurfaceImpl::DrawTextBase(PRectangle rc, Font &font_, XYPOSITION ybase, con
|
|||||||
}
|
}
|
||||||
pango_layout_set_font_description(layout, PFont(font_)->pfd);
|
pango_layout_set_font_description(layout, PFont(font_)->pfd);
|
||||||
pango_cairo_update_layout(context, layout);
|
pango_cairo_update_layout(context, layout);
|
||||||
#ifdef PANGO_VERSION
|
|
||||||
PangoLayoutLine *pll = pango_layout_get_line_readonly(layout,0);
|
PangoLayoutLine *pll = pango_layout_get_line_readonly(layout,0);
|
||||||
#else
|
|
||||||
PangoLayoutLine *pll = pango_layout_get_line(layout,0);
|
|
||||||
#endif
|
|
||||||
cairo_move_to(context, xText, ybase);
|
cairo_move_to(context, xText, ybase);
|
||||||
pango_cairo_show_layout_line(context, pll);
|
pango_cairo_show_layout_line(context, pll);
|
||||||
}
|
}
|
||||||
@ -823,7 +807,7 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION
|
|||||||
positions[i++] = iti.position - (places - place) * iti.distance / places;
|
positions[i++] = iti.position - (places - place) * iti.distance / places;
|
||||||
positionsCalculated++;
|
positionsCalculated++;
|
||||||
}
|
}
|
||||||
clusterStart += UTF8CharLength(static_cast<unsigned char>(utfForm.c_str()[clusterStart]));
|
clusterStart += UTF8BytesOfLead[static_cast<unsigned char>(utfForm.c_str()[clusterStart])];
|
||||||
place++;
|
place++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -897,11 +881,7 @@ XYPOSITION SurfaceImpl::WidthText(Font &font_, const char *s, int len) {
|
|||||||
}
|
}
|
||||||
pango_layout_set_text(layout, utfForm.c_str(), utfForm.length());
|
pango_layout_set_text(layout, utfForm.c_str(), utfForm.length());
|
||||||
}
|
}
|
||||||
#ifdef PANGO_VERSION
|
|
||||||
PangoLayoutLine *pangoLine = pango_layout_get_line_readonly(layout,0);
|
PangoLayoutLine *pangoLine = pango_layout_get_line_readonly(layout,0);
|
||||||
#else
|
|
||||||
PangoLayoutLine *pangoLine = pango_layout_get_line(layout,0);
|
|
||||||
#endif
|
|
||||||
pango_layout_line_get_extents(pangoLine, NULL, &pos);
|
pango_layout_line_get_extents(pangoLine, NULL, &pos);
|
||||||
return doubleFromPangoUnits(pos.width);
|
return doubleFromPangoUnits(pos.width);
|
||||||
}
|
}
|
||||||
@ -911,17 +891,6 @@ XYPOSITION SurfaceImpl::WidthText(Font &font_, const char *s, int len) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XYPOSITION SurfaceImpl::WidthChar(Font &font_, char ch) {
|
|
||||||
if (font_.GetID()) {
|
|
||||||
if (PFont(font_)->pfd) {
|
|
||||||
return WidthText(font_, &ch, 1);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ascent and descent determined by Pango font metrics.
|
// Ascent and descent determined by Pango font metrics.
|
||||||
|
|
||||||
XYPOSITION SurfaceImpl::Ascent(Font &font_) {
|
XYPOSITION SurfaceImpl::Ascent(Font &font_) {
|
||||||
@ -958,16 +927,12 @@ XYPOSITION SurfaceImpl::InternalLeading(Font &) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
XYPOSITION SurfaceImpl::ExternalLeading(Font &) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
XYPOSITION SurfaceImpl::Height(Font &font_) {
|
XYPOSITION SurfaceImpl::Height(Font &font_) {
|
||||||
return Ascent(font_) + Descent(font_);
|
return Ascent(font_) + Descent(font_);
|
||||||
}
|
}
|
||||||
|
|
||||||
XYPOSITION SurfaceImpl::AverageCharWidth(Font &font_) {
|
XYPOSITION SurfaceImpl::AverageCharWidth(Font &font_) {
|
||||||
return WidthChar(font_, 'n');
|
return WidthText(font_, "n", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SurfaceImpl::SetClip(PRectangle rc) {
|
void SurfaceImpl::SetClip(PRectangle rc) {
|
||||||
@ -1011,11 +976,7 @@ void Window::Destroy() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Window::HasFocus() {
|
PRectangle Window::GetPosition() const {
|
||||||
return gtk_widget_has_focus(GTK_WIDGET(wid));
|
|
||||||
}
|
|
||||||
|
|
||||||
PRectangle Window::GetPosition() {
|
|
||||||
// Before any size allocated pretend its 1000 wide so not scrolled
|
// Before any size allocated pretend its 1000 wide so not scrolled
|
||||||
PRectangle rc(0, 0, 1000, 1000);
|
PRectangle rc(0, 0, 1000, 1000);
|
||||||
if (wid) {
|
if (wid) {
|
||||||
@ -1059,15 +1020,15 @@ GdkRectangle MonitorRectangleForWidget(GtkWidget *wid) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::SetPositionRelative(PRectangle rc, Window relativeTo) {
|
void Window::SetPositionRelative(PRectangle rc, const Window *relativeTo) {
|
||||||
int ox = 0;
|
int ox = 0;
|
||||||
int oy = 0;
|
int oy = 0;
|
||||||
GdkWindow *wndRelativeTo = WindowFromWidget(PWidget(relativeTo.wid));
|
GdkWindow *wndRelativeTo = WindowFromWidget(PWidget(relativeTo->wid));
|
||||||
gdk_window_get_origin(wndRelativeTo, &ox, &oy);
|
gdk_window_get_origin(wndRelativeTo, &ox, &oy);
|
||||||
ox += rc.left;
|
ox += rc.left;
|
||||||
oy += rc.top;
|
oy += rc.top;
|
||||||
|
|
||||||
GdkRectangle rcMonitor = MonitorRectangleForWidget(PWidget(relativeTo.wid));
|
GdkRectangle rcMonitor = MonitorRectangleForWidget(PWidget(relativeTo->wid));
|
||||||
|
|
||||||
/* do some corrections to fit into screen */
|
/* do some corrections to fit into screen */
|
||||||
int sizex = rc.right - rc.left;
|
int sizex = rc.right - rc.left;
|
||||||
@ -1086,7 +1047,7 @@ void Window::SetPositionRelative(PRectangle rc, Window relativeTo) {
|
|||||||
gtk_window_resize(GTK_WINDOW(wid), sizex, sizey);
|
gtk_window_resize(GTK_WINDOW(wid), sizex, sizey);
|
||||||
}
|
}
|
||||||
|
|
||||||
PRectangle Window::GetClientPosition() {
|
PRectangle Window::GetClientPosition() const {
|
||||||
// On GTK+, the client position is the window position
|
// On GTK+, the client position is the window position
|
||||||
return GetPosition();
|
return GetPosition();
|
||||||
}
|
}
|
||||||
@ -1158,10 +1119,6 @@ void Window::SetCursor(Cursor curs) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::SetTitle(const char *s) {
|
|
||||||
gtk_window_set_title(GTK_WINDOW(wid), s);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Returns rectangle of monitor pt is on, both rect and pt are in Window's
|
/* Returns rectangle of monitor pt is on, both rect and pt are in Window's
|
||||||
gdk window coordinates */
|
gdk window coordinates */
|
||||||
PRectangle Window::GetMonitorRect(Point pt) {
|
PRectangle Window::GetMonitorRect(Point pt) {
|
||||||
@ -1201,7 +1158,7 @@ static void list_image_free(gpointer, gpointer value, gpointer) {
|
|||||||
g_free(list_image);
|
g_free(list_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
ListBox::ListBox() {
|
ListBox::ListBox() noexcept {
|
||||||
}
|
}
|
||||||
|
|
||||||
ListBox::~ListBox() {
|
ListBox::~ListBox() {
|
||||||
@ -1229,8 +1186,7 @@ class ListBoxX : public ListBox {
|
|||||||
GtkCssProvider *cssProvider;
|
GtkCssProvider *cssProvider;
|
||||||
#endif
|
#endif
|
||||||
public:
|
public:
|
||||||
CallBackAction doubleClickAction;
|
IListBoxDelegate *delegate;
|
||||||
void *doubleClickActionData;
|
|
||||||
|
|
||||||
ListBoxX() : widCached(0), frame(0), list(0), scroller(0), pixhash(NULL), pixbuf_renderer(0),
|
ListBoxX() : widCached(0), frame(0), list(0), scroller(0), pixhash(NULL), pixbuf_renderer(0),
|
||||||
renderer(0),
|
renderer(0),
|
||||||
@ -1239,7 +1195,7 @@ public:
|
|||||||
#if GTK_CHECK_VERSION(3,0,0)
|
#if GTK_CHECK_VERSION(3,0,0)
|
||||||
cssProvider(NULL),
|
cssProvider(NULL),
|
||||||
#endif
|
#endif
|
||||||
doubleClickAction(NULL), doubleClickActionData(NULL) {
|
delegate(nullptr) {
|
||||||
}
|
}
|
||||||
~ListBoxX() override {
|
~ListBoxX() override {
|
||||||
if (pixhash) {
|
if (pixhash) {
|
||||||
@ -1276,10 +1232,7 @@ public:
|
|||||||
void RegisterImage(int type, const char *xpm_data) override;
|
void RegisterImage(int type, const char *xpm_data) override;
|
||||||
void RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage) override;
|
void RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage) override;
|
||||||
void ClearRegisteredImages() override;
|
void ClearRegisteredImages() override;
|
||||||
void SetDoubleClickAction(CallBackAction action, void *data) override {
|
void SetDelegate(IListBoxDelegate *lbDelegate) override;
|
||||||
doubleClickAction = action;
|
|
||||||
doubleClickActionData = data;
|
|
||||||
}
|
|
||||||
void SetList(const char *listText, char separator, char typesep) override;
|
void SetList(const char *listText, char separator, char typesep) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1307,7 +1260,7 @@ static int treeViewGetRowHeight(GtkTreeView *view) {
|
|||||||
"vertical-separator", &vertical_separator,
|
"vertical-separator", &vertical_separator,
|
||||||
"expander-size", &expander_size, NULL);
|
"expander-size", &expander_size, NULL);
|
||||||
row_height += vertical_separator;
|
row_height += vertical_separator;
|
||||||
row_height = Platform::Maximum(row_height, expander_size);
|
row_height = std::max(row_height, expander_size);
|
||||||
return row_height;
|
return row_height;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -1370,8 +1323,9 @@ static void small_scroller_init(SmallScroller *){}
|
|||||||
static gboolean ButtonPress(GtkWidget *, GdkEventButton* ev, gpointer p) {
|
static gboolean ButtonPress(GtkWidget *, GdkEventButton* ev, gpointer p) {
|
||||||
try {
|
try {
|
||||||
ListBoxX* lb = static_cast<ListBoxX*>(p);
|
ListBoxX* lb = static_cast<ListBoxX*>(p);
|
||||||
if (ev->type == GDK_2BUTTON_PRESS && lb->doubleClickAction != NULL) {
|
if (ev->type == GDK_2BUTTON_PRESS && lb->delegate) {
|
||||||
lb->doubleClickAction(lb->doubleClickActionData);
|
ListBoxEvent event(ListBoxEvent::EventType::doubleClick);
|
||||||
|
lb->delegate->ListNotify(&event);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1381,6 +1335,20 @@ static gboolean ButtonPress(GtkWidget *, GdkEventButton* ev, gpointer p) {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean ButtonRelease(GtkWidget *, GdkEventButton* ev, gpointer p) {
|
||||||
|
try {
|
||||||
|
ListBoxX* lb = static_cast<ListBoxX*>(p);
|
||||||
|
if (ev->type != GDK_2BUTTON_PRESS && lb->delegate) {
|
||||||
|
ListBoxEvent event(ListBoxEvent::EventType::selectionChange);
|
||||||
|
lb->delegate->ListNotify(&event);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
} catch (...) {
|
||||||
|
// No pointer back to Scintilla to save status
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Change the active color to the selected color so the listbox uses the color
|
/* Change the active color to the selected color so the listbox uses the color
|
||||||
scheme that it would use if it had the focus. */
|
scheme that it would use if it had the focus. */
|
||||||
static void StyleSet(GtkWidget *w, GtkStyle*, void*) {
|
static void StyleSet(GtkWidget *w, GtkStyle*, void*) {
|
||||||
@ -1505,6 +1473,8 @@ void ListBoxX::Create(Window &parent, int, Point, int, bool, int) {
|
|||||||
gtk_widget_show(widget);
|
gtk_widget_show(widget);
|
||||||
g_signal_connect(G_OBJECT(widget), "button_press_event",
|
g_signal_connect(G_OBJECT(widget), "button_press_event",
|
||||||
G_CALLBACK(ButtonPress), this);
|
G_CALLBACK(ButtonPress), this);
|
||||||
|
g_signal_connect(G_OBJECT(widget), "button_release_event",
|
||||||
|
G_CALLBACK(ButtonRelease), this);
|
||||||
|
|
||||||
GtkWidget *top = gtk_widget_get_toplevel(static_cast<GtkWidget *>(parent.GetID()));
|
GtkWidget *top = gtk_widget_get_toplevel(static_cast<GtkWidget *>(parent.GetID()));
|
||||||
gtk_window_set_transient_for(GTK_WINDOW(static_cast<GtkWidget *>(wid)),
|
gtk_window_set_transient_for(GTK_WINDOW(static_cast<GtkWidget *>(wid)),
|
||||||
@ -1780,6 +1750,11 @@ void ListBoxX::Select(int n) {
|
|||||||
} else {
|
} else {
|
||||||
gtk_tree_selection_unselect_all(selection);
|
gtk_tree_selection_unselect_all(selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (delegate) {
|
||||||
|
ListBoxEvent event(ListBoxEvent::EventType::selectionChange);
|
||||||
|
delegate->ListNotify(&event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ListBoxX::GetSelection() {
|
int ListBoxX::GetSelection() {
|
||||||
@ -1876,6 +1851,10 @@ void ListBoxX::ClearRegisteredImages() {
|
|||||||
images.Clear();
|
images.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ListBoxX::SetDelegate(IListBoxDelegate *lbDelegate) {
|
||||||
|
delegate = lbDelegate;
|
||||||
|
}
|
||||||
|
|
||||||
void ListBoxX::SetList(const char *listText, char separator, char typesep) {
|
void ListBoxX::SetList(const char *listText, char separator, char typesep) {
|
||||||
Clear();
|
Clear();
|
||||||
int count = strlen(listText) + 1;
|
int count = strlen(listText) + 1;
|
||||||
@ -1902,7 +1881,7 @@ void ListBoxX::SetList(const char *listText, char separator, char typesep) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu::Menu() : mid(0) {}
|
Menu::Menu() noexcept : mid(0) {}
|
||||||
|
|
||||||
void Menu::CreatePopUp() {
|
void Menu::CreatePopUp() {
|
||||||
Destroy();
|
Destroy();
|
||||||
@ -1950,13 +1929,6 @@ void Menu::Show(Point pt, Window &w) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ElapsedTime::ElapsedTime() {
|
|
||||||
GTimeVal curTime;
|
|
||||||
g_get_current_time(&curTime);
|
|
||||||
bigBit = curTime.tv_sec;
|
|
||||||
littleBit = curTime.tv_usec;
|
|
||||||
}
|
|
||||||
|
|
||||||
class DynamicLibraryImpl : public DynamicLibrary {
|
class DynamicLibraryImpl : public DynamicLibrary {
|
||||||
protected:
|
protected:
|
||||||
GModule* m;
|
GModule* m;
|
||||||
@ -1993,21 +1965,6 @@ DynamicLibrary *DynamicLibrary::Load(const char *modulePath) {
|
|||||||
return static_cast<DynamicLibrary *>( new DynamicLibraryImpl(modulePath) );
|
return static_cast<DynamicLibrary *>( new DynamicLibraryImpl(modulePath) );
|
||||||
}
|
}
|
||||||
|
|
||||||
double ElapsedTime::Duration(bool reset) {
|
|
||||||
GTimeVal curTime;
|
|
||||||
g_get_current_time(&curTime);
|
|
||||||
long endBigBit = curTime.tv_sec;
|
|
||||||
long endLittleBit = curTime.tv_usec;
|
|
||||||
double result = 1000000.0 * (endBigBit - bigBit);
|
|
||||||
result += endLittleBit - littleBit;
|
|
||||||
result /= 1000000.0;
|
|
||||||
if (reset) {
|
|
||||||
bigBit = endBigBit;
|
|
||||||
littleBit = endLittleBit;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ColourDesired Platform::Chrome() {
|
ColourDesired Platform::Chrome() {
|
||||||
return ColourDesired(0xe0, 0xe0, 0xe0);
|
return ColourDesired(0xe0, 0xe0, 0xe0);
|
||||||
}
|
}
|
||||||
@ -2036,83 +1993,10 @@ unsigned int Platform::DoubleClickTime() {
|
|||||||
return 500; // Half a second
|
return 500; // Half a second
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Platform::MouseButtonBounce() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Platform::DebugDisplay(const char *s) {
|
void Platform::DebugDisplay(const char *s) {
|
||||||
fprintf(stderr, "%s", s);
|
fprintf(stderr, "%s", s);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Platform::IsKeyDown(int) {
|
|
||||||
// TODO: discover state of keys in GTK+/X
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
long Platform::SendScintilla(
|
|
||||||
WindowID w, unsigned int msg, unsigned long wParam, long lParam) {
|
|
||||||
return scintilla_send_message(SCINTILLA(w), msg, wParam, lParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
long Platform::SendScintillaPointer(
|
|
||||||
WindowID w, unsigned int msg, unsigned long wParam, void *lParam) {
|
|
||||||
return scintilla_send_message(SCINTILLA(w), msg, wParam,
|
|
||||||
reinterpret_cast<sptr_t>(lParam));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Platform::IsDBCSLeadByte(int codePage, char ch) {
|
|
||||||
// Byte ranges found in Wikipedia articles with relevant search strings in each case
|
|
||||||
unsigned char uch = static_cast<unsigned char>(ch);
|
|
||||||
switch (codePage) {
|
|
||||||
case 932:
|
|
||||||
// Shift_jis
|
|
||||||
return ((uch >= 0x81) && (uch <= 0x9F)) ||
|
|
||||||
((uch >= 0xE0) && (uch <= 0xFC));
|
|
||||||
// Lead bytes F0 to FC may be a Microsoft addition.
|
|
||||||
case 936:
|
|
||||||
// GBK
|
|
||||||
return (uch >= 0x81) && (uch <= 0xFE);
|
|
||||||
case 950:
|
|
||||||
// Big5
|
|
||||||
return (uch >= 0x81) && (uch <= 0xFE);
|
|
||||||
// Korean EUC-KR may be code page 949.
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Platform::DBCSCharLength(int codePage, const char *s) {
|
|
||||||
if (codePage == 932 || codePage == 936 || codePage == 950) {
|
|
||||||
return IsDBCSLeadByte(codePage, s[0]) ? 2 : 1;
|
|
||||||
} else {
|
|
||||||
int bytes = mblen(s, MB_CUR_MAX);
|
|
||||||
if (bytes >= 1)
|
|
||||||
return bytes;
|
|
||||||
else
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int Platform::DBCSCharMaxLength() {
|
|
||||||
return MB_CUR_MAX;
|
|
||||||
//return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
// These are utility functions not really tied to a platform
|
|
||||||
|
|
||||||
int Platform::Minimum(int a, int b) {
|
|
||||||
if (a < b)
|
|
||||||
return a;
|
|
||||||
else
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Platform::Maximum(int a, int b) {
|
|
||||||
if (a > b)
|
|
||||||
return a;
|
|
||||||
else
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
//#define TRACE
|
//#define TRACE
|
||||||
|
|
||||||
#ifdef TRACE
|
#ifdef TRACE
|
||||||
@ -2145,14 +2029,6 @@ void Platform::Assert(const char *c, const char *file, int line) {
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
int Platform::Clamp(int val, int minVal, int maxVal) {
|
|
||||||
if (val > maxVal)
|
|
||||||
val = maxVal;
|
|
||||||
if (val < minVal)
|
|
||||||
val = minVal;
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Platform_Initialise() {
|
void Platform_Initialise() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
|
||||||
|
#include "ILoader.h"
|
||||||
#include "ILexer.h"
|
#include "ILexer.h"
|
||||||
#include "Scintilla.h"
|
#include "Scintilla.h"
|
||||||
#include "ScintillaWidget.h"
|
#include "ScintillaWidget.h"
|
||||||
@ -55,7 +56,6 @@
|
|||||||
#include "CallTip.h"
|
#include "CallTip.h"
|
||||||
#include "KeyMap.h"
|
#include "KeyMap.h"
|
||||||
#include "Indicator.h"
|
#include "Indicator.h"
|
||||||
#include "XPM.h"
|
|
||||||
#include "LineMarker.h"
|
#include "LineMarker.h"
|
||||||
#include "Style.h"
|
#include "Style.h"
|
||||||
#include "ViewStyle.h"
|
#include "ViewStyle.h"
|
||||||
@ -65,7 +65,6 @@
|
|||||||
#include "Document.h"
|
#include "Document.h"
|
||||||
#include "CaseConvert.h"
|
#include "CaseConvert.h"
|
||||||
#include "UniConversion.h"
|
#include "UniConversion.h"
|
||||||
#include "UnicodeFromUTF8.h"
|
|
||||||
#include "Selection.h"
|
#include "Selection.h"
|
||||||
#include "PositionCache.h"
|
#include "PositionCache.h"
|
||||||
#include "EditModel.h"
|
#include "EditModel.h"
|
||||||
@ -85,13 +84,8 @@
|
|||||||
|
|
||||||
#include "Converter.h"
|
#include "Converter.h"
|
||||||
|
|
||||||
#if GTK_CHECK_VERSION(2,20,0)
|
|
||||||
#define IS_WIDGET_REALIZED(w) (gtk_widget_get_realized(GTK_WIDGET(w)))
|
#define IS_WIDGET_REALIZED(w) (gtk_widget_get_realized(GTK_WIDGET(w)))
|
||||||
#define IS_WIDGET_MAPPED(w) (gtk_widget_get_mapped(GTK_WIDGET(w)))
|
#define IS_WIDGET_MAPPED(w) (gtk_widget_get_mapped(GTK_WIDGET(w)))
|
||||||
#else
|
|
||||||
#define IS_WIDGET_REALIZED(w) (GTK_WIDGET_REALIZED(w))
|
|
||||||
#define IS_WIDGET_MAPPED(w) (GTK_WIDGET_MAPPED(w))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SC_INDICATOR_INPUT INDIC_IME
|
#define SC_INDICATOR_INPUT INDIC_IME
|
||||||
#define SC_INDICATOR_TARGET INDIC_IME+1
|
#define SC_INDICATOR_TARGET INDIC_IME+1
|
||||||
@ -109,9 +103,7 @@ static GdkWindow *WindowFromWidget(GtkWidget *w) {
|
|||||||
#pragma warning(disable: 4505)
|
#pragma warning(disable: 4505)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
static GdkWindow *PWindow(const Window &w) {
|
static GdkWindow *PWindow(const Window &w) {
|
||||||
GtkWidget *widget = static_cast<GtkWidget *>(w.GetID());
|
GtkWidget *widget = static_cast<GtkWidget *>(w.GetID());
|
||||||
@ -155,6 +147,8 @@ static const GtkTargetEntry clipboardPasteTargets[] = {
|
|||||||
};
|
};
|
||||||
static const gint nClipboardPasteTargets = ELEMENTS(clipboardPasteTargets);
|
static const gint nClipboardPasteTargets = ELEMENTS(clipboardPasteTargets);
|
||||||
|
|
||||||
|
static const GdkDragAction actionCopyOrMove = static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||||
|
|
||||||
static GtkWidget *PWidget(Window &w) {
|
static GtkWidget *PWidget(Window &w) {
|
||||||
return static_cast<GtkWidget *>(w.GetID());
|
return static_cast<GtkWidget *>(w.GetID());
|
||||||
}
|
}
|
||||||
@ -167,7 +161,7 @@ ScintillaGTK *ScintillaGTK::FromWidget(GtkWidget *widget) {
|
|||||||
ScintillaGTK::ScintillaGTK(_ScintillaObject *sci_) :
|
ScintillaGTK::ScintillaGTK(_ScintillaObject *sci_) :
|
||||||
adjustmentv(0), adjustmenth(0),
|
adjustmentv(0), adjustmenth(0),
|
||||||
verticalScrollBarWidth(30), horizontalScrollBarHeight(30),
|
verticalScrollBarWidth(30), horizontalScrollBarHeight(30),
|
||||||
evbtn(0), capturedMouse(false), dragWasDropped(false),
|
evbtn(nullptr), capturedMouse(false), dragWasDropped(false),
|
||||||
lastKey(0), rectangularSelectionModifier(SCMOD_CTRL), parentClass(0),
|
lastKey(0), rectangularSelectionModifier(SCMOD_CTRL), parentClass(0),
|
||||||
im_context(NULL), lastNonCommonScript(PANGO_SCRIPT_INVALID_CODE),
|
im_context(NULL), lastNonCommonScript(PANGO_SCRIPT_INVALID_CODE),
|
||||||
lastWheelMouseDirection(0),
|
lastWheelMouseDirection(0),
|
||||||
@ -182,11 +176,7 @@ ScintillaGTK::ScintillaGTK(_ScintillaObject *sci_) :
|
|||||||
sci = sci_;
|
sci = sci_;
|
||||||
wMain = GTK_WIDGET(sci);
|
wMain = GTK_WIDGET(sci);
|
||||||
|
|
||||||
#if PLAT_GTK_WIN32
|
|
||||||
rectangularSelectionModifier = SCMOD_ALT;
|
rectangularSelectionModifier = SCMOD_ALT;
|
||||||
#else
|
|
||||||
rectangularSelectionModifier = SCMOD_CTRL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if PLAT_GTK_WIN32
|
#if PLAT_GTK_WIN32
|
||||||
// There does not seem to be a real standard for indicating that the clipboard
|
// There does not seem to be a real standard for indicating that the clipboard
|
||||||
@ -215,8 +205,8 @@ ScintillaGTK::~ScintillaGTK() {
|
|||||||
styleIdleID = 0;
|
styleIdleID = 0;
|
||||||
}
|
}
|
||||||
if (evbtn) {
|
if (evbtn) {
|
||||||
gdk_event_free(reinterpret_cast<GdkEvent *>(evbtn));
|
gdk_event_free(evbtn);
|
||||||
evbtn = 0;
|
evbtn = nullptr;
|
||||||
}
|
}
|
||||||
wPreedit.Destroy();
|
wPreedit.Destroy();
|
||||||
}
|
}
|
||||||
@ -231,11 +221,7 @@ static void UnRefCursor(GdkCursor *cursor) {
|
|||||||
|
|
||||||
void ScintillaGTK::RealizeThis(GtkWidget *widget) {
|
void ScintillaGTK::RealizeThis(GtkWidget *widget) {
|
||||||
//Platform::DebugPrintf("ScintillaGTK::realize this\n");
|
//Platform::DebugPrintf("ScintillaGTK::realize this\n");
|
||||||
#if GTK_CHECK_VERSION(2,20,0)
|
|
||||||
gtk_widget_set_realized(widget, TRUE);
|
gtk_widget_set_realized(widget, TRUE);
|
||||||
#else
|
|
||||||
GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
|
|
||||||
#endif
|
|
||||||
GdkWindowAttr attrs;
|
GdkWindowAttr attrs;
|
||||||
attrs.window_type = GDK_WINDOW_CHILD;
|
attrs.window_type = GDK_WINDOW_CHILD;
|
||||||
GtkAllocation allocation;
|
GtkAllocation allocation;
|
||||||
@ -306,7 +292,10 @@ void ScintillaGTK::RealizeThis(GtkWidget *widget) {
|
|||||||
gdk_window_set_cursor(PWindow(scrollbarh), cursor);
|
gdk_window_set_cursor(PWindow(scrollbarh), cursor);
|
||||||
UnRefCursor(cursor);
|
UnRefCursor(cursor);
|
||||||
|
|
||||||
gtk_selection_add_targets(widget, GDK_SELECTION_PRIMARY,
|
wSelection = gtk_invisible_new();
|
||||||
|
g_signal_connect(PWidget(wSelection), "selection_get", G_CALLBACK(PrimarySelection), (gpointer) this);
|
||||||
|
g_signal_connect(PWidget(wSelection), "selection_clear_event", G_CALLBACK(PrimaryClear), (gpointer) this);
|
||||||
|
gtk_selection_add_targets(PWidget(wSelection), GDK_SELECTION_PRIMARY,
|
||||||
clipboardCopyTargets, nClipboardCopyTargets);
|
clipboardCopyTargets, nClipboardCopyTargets);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,16 +306,13 @@ void ScintillaGTK::Realize(GtkWidget *widget) {
|
|||||||
|
|
||||||
void ScintillaGTK::UnRealizeThis(GtkWidget *widget) {
|
void ScintillaGTK::UnRealizeThis(GtkWidget *widget) {
|
||||||
try {
|
try {
|
||||||
gtk_selection_clear_targets(widget, GDK_SELECTION_PRIMARY);
|
gtk_selection_clear_targets(PWidget(wSelection), GDK_SELECTION_PRIMARY);
|
||||||
|
wSelection.Destroy();
|
||||||
|
|
||||||
if (IS_WIDGET_MAPPED(widget)) {
|
if (IS_WIDGET_MAPPED(widget)) {
|
||||||
gtk_widget_unmap(widget);
|
gtk_widget_unmap(widget);
|
||||||
}
|
}
|
||||||
#if GTK_CHECK_VERSION(2,20,0)
|
|
||||||
gtk_widget_set_realized(widget, FALSE);
|
gtk_widget_set_realized(widget, FALSE);
|
||||||
#else
|
|
||||||
GTK_WIDGET_UNSET_FLAGS(widget, GTK_REALIZED);
|
|
||||||
#endif
|
|
||||||
gtk_widget_unrealize(PWidget(wText));
|
gtk_widget_unrealize(PWidget(wText));
|
||||||
if (PWidget(scrollbarv))
|
if (PWidget(scrollbarv))
|
||||||
gtk_widget_unrealize(PWidget(scrollbarv));
|
gtk_widget_unrealize(PWidget(scrollbarv));
|
||||||
@ -361,11 +347,7 @@ static void MapWidget(GtkWidget *widget) {
|
|||||||
void ScintillaGTK::MapThis() {
|
void ScintillaGTK::MapThis() {
|
||||||
try {
|
try {
|
||||||
//Platform::DebugPrintf("ScintillaGTK::map this\n");
|
//Platform::DebugPrintf("ScintillaGTK::map this\n");
|
||||||
#if GTK_CHECK_VERSION(2,20,0)
|
|
||||||
gtk_widget_set_mapped(PWidget(wMain), TRUE);
|
gtk_widget_set_mapped(PWidget(wMain), TRUE);
|
||||||
#else
|
|
||||||
GTK_WIDGET_SET_FLAGS(PWidget(wMain), GTK_MAPPED);
|
|
||||||
#endif
|
|
||||||
MapWidget(PWidget(wText));
|
MapWidget(PWidget(wText));
|
||||||
MapWidget(PWidget(scrollbarh));
|
MapWidget(PWidget(scrollbarh));
|
||||||
MapWidget(PWidget(scrollbarv));
|
MapWidget(PWidget(scrollbarv));
|
||||||
@ -387,11 +369,7 @@ void ScintillaGTK::Map(GtkWidget *widget) {
|
|||||||
void ScintillaGTK::UnMapThis() {
|
void ScintillaGTK::UnMapThis() {
|
||||||
try {
|
try {
|
||||||
//Platform::DebugPrintf("ScintillaGTK::unmap this\n");
|
//Platform::DebugPrintf("ScintillaGTK::unmap this\n");
|
||||||
#if GTK_CHECK_VERSION(2,20,0)
|
|
||||||
gtk_widget_set_mapped(PWidget(wMain), FALSE);
|
gtk_widget_set_mapped(PWidget(wMain), FALSE);
|
||||||
#else
|
|
||||||
GTK_WIDGET_UNSET_FLAGS(PWidget(wMain), GTK_MAPPED);
|
|
||||||
#endif
|
|
||||||
DropGraphics(false);
|
DropGraphics(false);
|
||||||
gdk_window_hide(PWindow(wMain));
|
gdk_window_hide(PWindow(wMain));
|
||||||
gtk_widget_unmap(PWidget(wText));
|
gtk_widget_unmap(PWidget(wText));
|
||||||
@ -631,7 +609,7 @@ void ScintillaGTK::Init() {
|
|||||||
|
|
||||||
gtk_drag_dest_set(GTK_WIDGET(PWidget(wMain)),
|
gtk_drag_dest_set(GTK_WIDGET(PWidget(wMain)),
|
||||||
GTK_DEST_DEFAULT_ALL, clipboardPasteTargets, nClipboardPasteTargets,
|
GTK_DEST_DEFAULT_ALL, clipboardPasteTargets, nClipboardPasteTargets,
|
||||||
static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE));
|
actionCopyOrMove);
|
||||||
|
|
||||||
/* create pre-edit window */
|
/* create pre-edit window */
|
||||||
wPreedit = gtk_window_new(GTK_WINDOW_POPUP);
|
wPreedit = gtk_window_new(GTK_WINDOW_POPUP);
|
||||||
@ -708,29 +686,27 @@ bool ScintillaGTK::DragThreshold(Point ptStart, Point ptNow) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ScintillaGTK::StartDrag() {
|
void ScintillaGTK::StartDrag() {
|
||||||
PLATFORM_ASSERT(evbtn != 0);
|
PLATFORM_ASSERT(evbtn);
|
||||||
dragWasDropped = false;
|
dragWasDropped = false;
|
||||||
inDragDrop = ddDragging;
|
inDragDrop = ddDragging;
|
||||||
GtkTargetList *tl = gtk_target_list_new(clipboardCopyTargets, nClipboardCopyTargets);
|
GtkTargetList *tl = gtk_target_list_new(clipboardCopyTargets, nClipboardCopyTargets);
|
||||||
#if GTK_CHECK_VERSION(3,10,0)
|
#if GTK_CHECK_VERSION(3,10,0)
|
||||||
gtk_drag_begin_with_coordinates(GTK_WIDGET(PWidget(wMain)),
|
gtk_drag_begin_with_coordinates(GTK_WIDGET(PWidget(wMain)),
|
||||||
tl,
|
tl,
|
||||||
static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE),
|
actionCopyOrMove,
|
||||||
evbtn->button,
|
buttonMouse,
|
||||||
reinterpret_cast<GdkEvent *>(evbtn),
|
evbtn,
|
||||||
-1, -1);
|
-1, -1);
|
||||||
#else
|
#else
|
||||||
gtk_drag_begin(GTK_WIDGET(PWidget(wMain)),
|
gtk_drag_begin(GTK_WIDGET(PWidget(wMain)),
|
||||||
tl,
|
tl,
|
||||||
static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE),
|
actionCopyOrMove,
|
||||||
evbtn->button,
|
buttonMouse,
|
||||||
reinterpret_cast<GdkEvent *>(evbtn));
|
evbtn);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
std::string ConvertText(const char *s, size_t len, const char *charSetDest,
|
std::string ConvertText(const char *s, size_t len, const char *charSetDest,
|
||||||
const char *charSetSource, bool transliterations, bool silent) {
|
const char *charSetSource, bool transliterations, bool silent) {
|
||||||
// s is not const because of different versions of iconv disagreeing about const
|
// s is not const because of different versions of iconv disagreeing about const
|
||||||
@ -763,14 +739,12 @@ std::string ConvertText(const char *s, size_t len, const char *charSetDest,
|
|||||||
}
|
}
|
||||||
return destForm;
|
return destForm;
|
||||||
}
|
}
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// Returns the target converted to UTF8.
|
// Returns the target converted to UTF8.
|
||||||
// Return the length in bytes.
|
// Return the length in bytes.
|
||||||
int ScintillaGTK::TargetAsUTF8(char *text) {
|
Sci::Position ScintillaGTK::TargetAsUTF8(char *text) const {
|
||||||
int targetLength = targetEnd - targetStart;
|
Sci::Position targetLength = targetEnd - targetStart;
|
||||||
if (IsUnicodeMode()) {
|
if (IsUnicodeMode()) {
|
||||||
if (text) {
|
if (text) {
|
||||||
pdoc->GetCharRange(text, targetStart, targetLength);
|
pdoc->GetCharRange(text, targetStart, targetLength);
|
||||||
@ -796,8 +770,8 @@ int ScintillaGTK::TargetAsUTF8(char *text) {
|
|||||||
|
|
||||||
// Translates a nul terminated UTF8 string into the document encoding.
|
// Translates a nul terminated UTF8 string into the document encoding.
|
||||||
// Return the length of the result in bytes.
|
// Return the length of the result in bytes.
|
||||||
int ScintillaGTK::EncodedFromUTF8(char *utf8, char *encoded) const {
|
Sci::Position ScintillaGTK::EncodedFromUTF8(const char *utf8, char *encoded) const {
|
||||||
int inputLength = (lengthForEncode >= 0) ? lengthForEncode : strlen(utf8);
|
Sci::Position inputLength = (lengthForEncode >= 0) ? lengthForEncode : strlen(utf8);
|
||||||
if (IsUnicodeMode()) {
|
if (IsUnicodeMode()) {
|
||||||
if (encoded) {
|
if (encoded) {
|
||||||
memcpy(encoded, utf8, inputLength);
|
memcpy(encoded, utf8, inputLength);
|
||||||
@ -849,15 +823,15 @@ sptr_t ScintillaGTK::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
|
|||||||
|
|
||||||
#ifdef SCI_LEXER
|
#ifdef SCI_LEXER
|
||||||
case SCI_LOADLEXERLIBRARY:
|
case SCI_LOADLEXERLIBRARY:
|
||||||
LexerManager::GetInstance()->Load(reinterpret_cast<const char*>(lParam));
|
LexerManager::GetInstance()->Load(ConstCharPtrFromSPtr(lParam));
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case SCI_TARGETASUTF8:
|
case SCI_TARGETASUTF8:
|
||||||
return TargetAsUTF8(reinterpret_cast<char*>(lParam));
|
return TargetAsUTF8(CharPtrFromSPtr(lParam));
|
||||||
|
|
||||||
case SCI_ENCODEDFROMUTF8:
|
case SCI_ENCODEDFROMUTF8:
|
||||||
return EncodedFromUTF8(reinterpret_cast<char*>(wParam),
|
return EncodedFromUTF8(ConstCharPtrFromUPtr(wParam),
|
||||||
reinterpret_cast<char*>(lParam));
|
CharPtrFromSPtr(lParam));
|
||||||
|
|
||||||
case SCI_SETRECTANGULARSELECTIONMODIFIER:
|
case SCI_SETRECTANGULARSELECTIONMODIFIER:
|
||||||
rectangularSelectionModifier = wParam;
|
rectangularSelectionModifier = wParam;
|
||||||
@ -898,20 +872,13 @@ sptr_t ScintillaGTK::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam
|
|||||||
} catch (...) {
|
} catch (...) {
|
||||||
errorStatus = SC_STATUS_FAILURE;
|
errorStatus = SC_STATUS_FAILURE;
|
||||||
}
|
}
|
||||||
return 0l;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
sptr_t ScintillaGTK::DefWndProc(unsigned int, uptr_t, sptr_t) {
|
sptr_t ScintillaGTK::DefWndProc(unsigned int, uptr_t, sptr_t) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Report that this Editor subclass has a working implementation of FineTickerStart.
|
|
||||||
*/
|
|
||||||
bool ScintillaGTK::FineTickerAvailable() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ScintillaGTK::FineTickerRunning(TickReason reason) {
|
bool ScintillaGTK::FineTickerRunning(TickReason reason) {
|
||||||
return timers[reason].timer != 0;
|
return timers[reason].timer != 0;
|
||||||
}
|
}
|
||||||
@ -933,7 +900,7 @@ bool ScintillaGTK::SetIdle(bool on) {
|
|||||||
// Start idler, if it's not running.
|
// Start idler, if it's not running.
|
||||||
if (!idler.state) {
|
if (!idler.state) {
|
||||||
idler.state = true;
|
idler.state = true;
|
||||||
idler.idlerID = reinterpret_cast<IdlerID>(
|
idler.idlerID = GUINT_TO_POINTER(
|
||||||
gdk_threads_add_idle_full(G_PRIORITY_DEFAULT_IDLE, IdleCallback, this, NULL));
|
gdk_threads_add_idle_full(G_PRIORITY_DEFAULT_IDLE, IdleCallback, this, NULL));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1012,8 +979,7 @@ void ScintillaGTK::FullPaint() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PRectangle ScintillaGTK::GetClientRectangle() const {
|
PRectangle ScintillaGTK::GetClientRectangle() const {
|
||||||
Window win = wMain;
|
PRectangle rc = wMain.GetClientPosition();
|
||||||
PRectangle rc = win.GetClientPosition();
|
|
||||||
if (verticalScrollBarVisible)
|
if (verticalScrollBarVisible)
|
||||||
rc.right -= verticalScrollBarWidth;
|
rc.right -= verticalScrollBarWidth;
|
||||||
if (horizontalScrollBarVisible && !Wrapping())
|
if (horizontalScrollBarVisible && !Wrapping())
|
||||||
@ -1332,7 +1298,7 @@ void ScintillaGTK::CreateCallTipWindow(PRectangle rc) {
|
|||||||
G_CALLBACK(ScintillaGTK::ExposeCT), &ct);
|
G_CALLBACK(ScintillaGTK::ExposeCT), &ct);
|
||||||
#endif
|
#endif
|
||||||
g_signal_connect(G_OBJECT(widcdrw), "button_press_event",
|
g_signal_connect(G_OBJECT(widcdrw), "button_press_event",
|
||||||
G_CALLBACK(ScintillaGTK::PressCT), static_cast<void *>(this));
|
G_CALLBACK(ScintillaGTK::PressCT), this);
|
||||||
gtk_widget_set_events(widcdrw,
|
gtk_widget_set_events(widcdrw,
|
||||||
GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK);
|
GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK);
|
||||||
GtkWidget *top = gtk_widget_get_toplevel(static_cast<GtkWidget *>(wMain.GetID()));
|
GtkWidget *top = gtk_widget_get_toplevel(static_cast<GtkWidget *>(wMain.GetID()));
|
||||||
@ -1363,17 +1329,17 @@ void ScintillaGTK::AddToPopUp(const char *label, int cmd, bool enabled) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ScintillaGTK::OwnPrimarySelection() {
|
bool ScintillaGTK::OwnPrimarySelection() {
|
||||||
return ((gdk_selection_owner_get(GDK_SELECTION_PRIMARY)
|
return (wSelection.Created() &&
|
||||||
== PWindow(wMain)) &&
|
(gdk_selection_owner_get(GDK_SELECTION_PRIMARY) == PWindow(wSelection)) &&
|
||||||
(PWindow(wMain) != NULL));
|
(PWindow(wSelection) != NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScintillaGTK::ClaimSelection() {
|
void ScintillaGTK::ClaimSelection() {
|
||||||
// X Windows has a 'primary selection' as well as the clipboard.
|
// X Windows has a 'primary selection' as well as the clipboard.
|
||||||
// Whenever the user selects some text, we become the primary selection
|
// Whenever the user selects some text, we become the primary selection
|
||||||
if (!sel.Empty() && IS_WIDGET_REALIZED(GTK_WIDGET(PWidget(wMain)))) {
|
if (!sel.Empty() && wSelection.Created() && IS_WIDGET_REALIZED(GTK_WIDGET(PWidget(wSelection)))) {
|
||||||
primarySelection = true;
|
primarySelection = true;
|
||||||
gtk_selection_owner_set(GTK_WIDGET(PWidget(wMain)),
|
gtk_selection_owner_set(GTK_WIDGET(PWidget(wSelection)),
|
||||||
GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME);
|
GDK_SELECTION_PRIMARY, GDK_CURRENT_TIME);
|
||||||
primary.Clear();
|
primary.Clear();
|
||||||
} else if (OwnPrimarySelection()) {
|
} else if (OwnPrimarySelection()) {
|
||||||
@ -1541,7 +1507,7 @@ void ScintillaGTK::GetSelection(GtkSelectionData *selection_data, guint info, Se
|
|||||||
} else {
|
} else {
|
||||||
gtk_selection_data_set(selection_data,
|
gtk_selection_data_set(selection_data,
|
||||||
static_cast<GdkAtom>(GDK_SELECTION_TYPE_STRING),
|
static_cast<GdkAtom>(GDK_SELECTION_TYPE_STRING),
|
||||||
8, reinterpret_cast<const unsigned char *>(textData), len);
|
8, reinterpret_cast<const guchar *>(textData), len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1582,6 +1548,27 @@ void ScintillaGTK::UnclaimSelection(GdkEventSelection *selection_event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScintillaGTK::PrimarySelection(GtkWidget *, GtkSelectionData *selection_data, guint info, guint, ScintillaGTK *sciThis) {
|
||||||
|
try {
|
||||||
|
if (SelectionOfGSD(selection_data) == GDK_SELECTION_PRIMARY) {
|
||||||
|
if (sciThis->primary.Empty()) {
|
||||||
|
sciThis->CopySelectionRange(&sciThis->primary);
|
||||||
|
}
|
||||||
|
sciThis->GetSelection(selection_data, info, &sciThis->primary);
|
||||||
|
}
|
||||||
|
} catch (...) {
|
||||||
|
sciThis->errorStatus = SC_STATUS_FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean ScintillaGTK::PrimaryClear(GtkWidget *widget, GdkEventSelection *event, ScintillaGTK *sciThis) {
|
||||||
|
sciThis->UnclaimSelection(event);
|
||||||
|
if (GTK_WIDGET_CLASS(sciThis->parentClass)->selection_clear_event) {
|
||||||
|
return GTK_WIDGET_CLASS(sciThis->parentClass)->selection_clear_event(widget, event);
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
void ScintillaGTK::Resize(int width, int height) {
|
void ScintillaGTK::Resize(int width, int height) {
|
||||||
//Platform::DebugPrintf("Resize %d %d\n", width, height);
|
//Platform::DebugPrintf("Resize %d %d\n", width, height);
|
||||||
//printf("Resize %d %d\n", width, height);
|
//printf("Resize %d %d\n", width, height);
|
||||||
@ -1614,7 +1601,7 @@ void ScintillaGTK::Resize(int width, int height) {
|
|||||||
gtk_widget_show(GTK_WIDGET(PWidget(scrollbarh)));
|
gtk_widget_show(GTK_WIDGET(PWidget(scrollbarh)));
|
||||||
alloc.x = 0;
|
alloc.x = 0;
|
||||||
alloc.y = height - horizontalScrollBarHeight;
|
alloc.y = height - horizontalScrollBarHeight;
|
||||||
alloc.width = Platform::Maximum(minHScrollBarWidth, width - verticalScrollBarWidth);
|
alloc.width = std::max(minHScrollBarWidth, width - verticalScrollBarWidth);
|
||||||
alloc.height = horizontalScrollBarHeight;
|
alloc.height = horizontalScrollBarHeight;
|
||||||
gtk_widget_size_allocate(GTK_WIDGET(PWidget(scrollbarh)), &alloc);
|
gtk_widget_size_allocate(GTK_WIDGET(PWidget(scrollbarh)), &alloc);
|
||||||
} else {
|
} else {
|
||||||
@ -1627,7 +1614,7 @@ void ScintillaGTK::Resize(int width, int height) {
|
|||||||
alloc.x = width - verticalScrollBarWidth;
|
alloc.x = width - verticalScrollBarWidth;
|
||||||
alloc.y = 0;
|
alloc.y = 0;
|
||||||
alloc.width = verticalScrollBarWidth;
|
alloc.width = verticalScrollBarWidth;
|
||||||
alloc.height = Platform::Maximum(minVScrollBarHeight, height - horizontalScrollBarHeight);
|
alloc.height = std::max(minVScrollBarHeight, height - horizontalScrollBarHeight);
|
||||||
gtk_widget_size_allocate(GTK_WIDGET(PWidget(scrollbarv)), &alloc);
|
gtk_widget_size_allocate(GTK_WIDGET(PWidget(scrollbarv)), &alloc);
|
||||||
} else {
|
} else {
|
||||||
gtk_widget_hide(GTK_WIDGET(PWidget(scrollbarv)));
|
gtk_widget_hide(GTK_WIDGET(PWidget(scrollbarv)));
|
||||||
@ -1648,8 +1635,8 @@ void ScintillaGTK::Resize(int width, int height) {
|
|||||||
alloc.width = requisition.width;
|
alloc.width = requisition.width;
|
||||||
alloc.height = requisition.height;
|
alloc.height = requisition.height;
|
||||||
#endif
|
#endif
|
||||||
alloc.width = Platform::Maximum(alloc.width, width - verticalScrollBarWidth);
|
alloc.width = std::max(alloc.width, width - verticalScrollBarWidth);
|
||||||
alloc.height = Platform::Maximum(alloc.height, height - horizontalScrollBarHeight);
|
alloc.height = std::max(alloc.height, height - horizontalScrollBarHeight);
|
||||||
gtk_widget_size_allocate(GTK_WIDGET(PWidget(wText)), &alloc);
|
gtk_widget_size_allocate(GTK_WIDGET(PWidget(wText)), &alloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1688,13 +1675,13 @@ gint ScintillaGTK::PressThis(GdkEventButton *event) {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (evbtn) {
|
if (evbtn) {
|
||||||
gdk_event_free(reinterpret_cast<GdkEvent *>(evbtn));
|
gdk_event_free(evbtn);
|
||||||
evbtn = 0;
|
|
||||||
}
|
}
|
||||||
evbtn = reinterpret_cast<GdkEventButton *>(gdk_event_copy(reinterpret_cast<GdkEvent *>(event)));
|
evbtn = gdk_event_copy(reinterpret_cast<GdkEvent *>(event));
|
||||||
|
buttonMouse = event->button;
|
||||||
Point pt;
|
Point pt;
|
||||||
pt.x = int(event->x);
|
pt.x = floor(event->x);
|
||||||
pt.y = int(event->y);
|
pt.y = floor(event->y);
|
||||||
PRectangle rcClient = GetClientRectangle();
|
PRectangle rcClient = GetClientRectangle();
|
||||||
//Platform::DebugPrintf("Press %0d,%0d in %0d,%0d %0d,%0d\n",
|
//Platform::DebugPrintf("Press %0d,%0d in %0d,%0d %0d,%0d\n",
|
||||||
// pt.x, pt.y, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
|
// pt.x, pt.y, rcClient.left, rcClient.top, rcClient.right, rcClient.bottom);
|
||||||
@ -1796,7 +1783,11 @@ gint ScintillaGTK::MouseRelease(GtkWidget *widget, GdkEventButton *event) {
|
|||||||
// If mouse released on scroll bar then the position is relative to the
|
// If mouse released on scroll bar then the position is relative to the
|
||||||
// scrollbar, not the drawing window so just repeat the most recent point.
|
// scrollbar, not the drawing window so just repeat the most recent point.
|
||||||
pt = sciThis->ptMouseLast;
|
pt = sciThis->ptMouseLast;
|
||||||
sciThis->ButtonUp(pt, event->time, (event->state & GDK_CONTROL_MASK) != 0);
|
const int modifiers = ModifierFlags(
|
||||||
|
(event->state & GDK_SHIFT_MASK) != 0,
|
||||||
|
(event->state & GDK_CONTROL_MASK) != 0,
|
||||||
|
(event->state & modifierTranslated(sciThis->rectangularSelectionModifier)) != 0);
|
||||||
|
sciThis->ButtonUpWithModifiers(pt, event->time, modifiers);
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
sciThis->errorStatus = SC_STATUS_FAILURE;
|
sciThis->errorStatus = SC_STATUS_FAILURE;
|
||||||
@ -1933,10 +1924,11 @@ gint ScintillaGTK::Motion(GtkWidget *widget, GdkEventMotion *event) {
|
|||||||
//Platform::DebugPrintf("Move %x %x %d %c %d %d\n",
|
//Platform::DebugPrintf("Move %x %x %d %c %d %d\n",
|
||||||
// sciThis,event->window,event->time,event->is_hint? 'h' :'.', x, y);
|
// sciThis,event->window,event->time,event->is_hint? 'h' :'.', x, y);
|
||||||
Point pt(x, y);
|
Point pt(x, y);
|
||||||
int modifiers = ((event->state & GDK_SHIFT_MASK) != 0 ? SCI_SHIFT : 0) |
|
const int modifiers = ModifierFlags(
|
||||||
((event->state & GDK_CONTROL_MASK) != 0 ? SCI_CTRL : 0) |
|
(event->state & GDK_SHIFT_MASK) != 0,
|
||||||
((event->state & modifierTranslated(sciThis->rectangularSelectionModifier)) != 0 ? SCI_ALT : 0);
|
(event->state & GDK_CONTROL_MASK) != 0,
|
||||||
sciThis->ButtonMoveWithModifiers(pt, modifiers);
|
(event->state & modifierTranslated(sciThis->rectangularSelectionModifier)) != 0);
|
||||||
|
sciThis->ButtonMoveWithModifiers(pt, event->time, modifiers);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
sciThis->errorStatus = SC_STATUS_FAILURE;
|
sciThis->errorStatus = SC_STATUS_FAILURE;
|
||||||
}
|
}
|
||||||
@ -2465,8 +2457,8 @@ static GObjectClass *scintilla_class_parent_class;
|
|||||||
|
|
||||||
void ScintillaGTK::Dispose(GObject *object) {
|
void ScintillaGTK::Dispose(GObject *object) {
|
||||||
try {
|
try {
|
||||||
ScintillaObject *scio = reinterpret_cast<ScintillaObject *>(object);
|
ScintillaObject *scio = SCINTILLA(object);
|
||||||
ScintillaGTK *sciThis = reinterpret_cast<ScintillaGTK *>(scio->pscin);
|
ScintillaGTK *sciThis = static_cast<ScintillaGTK *>(scio->pscin);
|
||||||
|
|
||||||
if (PWidget(sciThis->scrollbarv)) {
|
if (PWidget(sciThis->scrollbarv)) {
|
||||||
gtk_widget_unparent(PWidget(sciThis->scrollbarv));
|
gtk_widget_unparent(PWidget(sciThis->scrollbarv));
|
||||||
@ -2622,11 +2614,12 @@ gboolean ScintillaGTK::ExposeTextThis(GtkWidget * /*widget*/, GdkEventExpose *os
|
|||||||
Paint(surfaceWindow.get(), rcPaint);
|
Paint(surfaceWindow.get(), rcPaint);
|
||||||
surfaceWindow->Release();
|
surfaceWindow->Release();
|
||||||
cairo_destroy(cr);
|
cairo_destroy(cr);
|
||||||
if (paintState == paintAbandoned) {
|
if ((paintState == paintAbandoned) || repaintFullWindow) {
|
||||||
// Painting area was insufficient to cover new styling or brace highlight positions
|
// Painting area was insufficient to cover new styling or brace highlight positions
|
||||||
FullPaint();
|
FullPaint();
|
||||||
}
|
}
|
||||||
paintState = notPainting;
|
paintState = notPainting;
|
||||||
|
repaintFullWindow = false;
|
||||||
|
|
||||||
if (rgnUpdate) {
|
if (rgnUpdate) {
|
||||||
gdk_region_destroy(rgnUpdate);
|
gdk_region_destroy(rgnUpdate);
|
||||||
@ -2723,20 +2716,14 @@ gboolean ScintillaGTK::DragMotionThis(GdkDragContext *context,
|
|||||||
try {
|
try {
|
||||||
Point npt(x, y);
|
Point npt(x, y);
|
||||||
SetDragPosition(SPositionFromLocation(npt, false, false, UserVirtualSpace()));
|
SetDragPosition(SPositionFromLocation(npt, false, false, UserVirtualSpace()));
|
||||||
#if GTK_CHECK_VERSION(2,22,0)
|
|
||||||
GdkDragAction preferredAction = gdk_drag_context_get_suggested_action(context);
|
GdkDragAction preferredAction = gdk_drag_context_get_suggested_action(context);
|
||||||
GdkDragAction actions = gdk_drag_context_get_actions(context);
|
GdkDragAction actions = gdk_drag_context_get_actions(context);
|
||||||
#else
|
|
||||||
GdkDragAction preferredAction = context->suggested_action;
|
|
||||||
GdkDragAction actions = context->actions;
|
|
||||||
#endif
|
|
||||||
SelectionPosition pos = SPositionFromLocation(npt);
|
SelectionPosition pos = SPositionFromLocation(npt);
|
||||||
if ((inDragDrop == ddDragging) && (PositionInSelection(pos.Position()))) {
|
if ((inDragDrop == ddDragging) && (PositionInSelection(pos.Position()))) {
|
||||||
// Avoid dragging selection onto itself as that produces a move
|
// Avoid dragging selection onto itself as that produces a move
|
||||||
// with no real effect but which creates undo actions.
|
// with no real effect but which creates undo actions.
|
||||||
preferredAction = static_cast<GdkDragAction>(0);
|
preferredAction = static_cast<GdkDragAction>(0);
|
||||||
} else if (actions == static_cast<GdkDragAction>
|
} else if (actions == actionCopyOrMove) {
|
||||||
(GDK_ACTION_COPY | GDK_ACTION_MOVE)) {
|
|
||||||
preferredAction = GDK_ACTION_MOVE;
|
preferredAction = GDK_ACTION_MOVE;
|
||||||
}
|
}
|
||||||
gdk_drag_status(context, preferredAction, dragtime);
|
gdk_drag_status(context, preferredAction, dragtime);
|
||||||
@ -2807,11 +2794,7 @@ void ScintillaGTK::DragDataGet(GtkWidget *widget, GdkDragContext *context,
|
|||||||
if (!sciThis->sel.Empty()) {
|
if (!sciThis->sel.Empty()) {
|
||||||
sciThis->GetSelection(selection_data, info, &sciThis->drag);
|
sciThis->GetSelection(selection_data, info, &sciThis->drag);
|
||||||
}
|
}
|
||||||
#if GTK_CHECK_VERSION(2,22,0)
|
|
||||||
GdkDragAction action = gdk_drag_context_get_selected_action(context);
|
GdkDragAction action = gdk_drag_context_get_selected_action(context);
|
||||||
#else
|
|
||||||
GdkDragAction action = context->action;
|
|
||||||
#endif
|
|
||||||
if (action == GDK_ACTION_MOVE) {
|
if (action == GDK_ACTION_MOVE) {
|
||||||
for (size_t r=0; r<sciThis->sel.Count(); r++) {
|
for (size_t r=0; r<sciThis->sel.Count(); r++) {
|
||||||
if (sciThis->posDrop >= sciThis->sel.Range(r).Start()) {
|
if (sciThis->posDrop >= sciThis->sel.Range(r).Start()) {
|
||||||
|
@ -6,9 +6,7 @@
|
|||||||
#ifndef SCINTILLAGTK_H
|
#ifndef SCINTILLAGTK_H
|
||||||
#define SCINTILLAGTK_H
|
#define SCINTILLAGTK_H
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
class ScintillaGTKAccessible;
|
class ScintillaGTKAccessible;
|
||||||
|
|
||||||
@ -23,12 +21,14 @@ class ScintillaGTK : public ScintillaBase {
|
|||||||
Window scrollbarh;
|
Window scrollbarh;
|
||||||
GtkAdjustment *adjustmentv;
|
GtkAdjustment *adjustmentv;
|
||||||
GtkAdjustment *adjustmenth;
|
GtkAdjustment *adjustmenth;
|
||||||
|
Window wSelection;
|
||||||
int verticalScrollBarWidth;
|
int verticalScrollBarWidth;
|
||||||
int horizontalScrollBarHeight;
|
int horizontalScrollBarHeight;
|
||||||
|
|
||||||
SelectionText primary;
|
SelectionText primary;
|
||||||
|
|
||||||
GdkEventButton *evbtn;
|
GdkEvent *evbtn;
|
||||||
|
guint buttonMouse;
|
||||||
bool capturedMouse;
|
bool capturedMouse;
|
||||||
bool dragWasDropped;
|
bool dragWasDropped;
|
||||||
int lastKey;
|
int lastKey;
|
||||||
@ -75,7 +75,9 @@ public:
|
|||||||
explicit ScintillaGTK(_ScintillaObject *sci_);
|
explicit ScintillaGTK(_ScintillaObject *sci_);
|
||||||
// Deleted so ScintillaGTK objects can not be copied.
|
// Deleted so ScintillaGTK objects can not be copied.
|
||||||
ScintillaGTK(const ScintillaGTK &) = delete;
|
ScintillaGTK(const ScintillaGTK &) = delete;
|
||||||
|
ScintillaGTK(ScintillaGTK &&) = delete;
|
||||||
ScintillaGTK &operator=(const ScintillaGTK &) = delete;
|
ScintillaGTK &operator=(const ScintillaGTK &) = delete;
|
||||||
|
ScintillaGTK &operator=(ScintillaGTK &&) = delete;
|
||||||
virtual ~ScintillaGTK();
|
virtual ~ScintillaGTK();
|
||||||
static ScintillaGTK *FromWidget(GtkWidget *widget);
|
static ScintillaGTK *FromWidget(GtkWidget *widget);
|
||||||
static void ClassInit(OBJECT_CLASS* object_class, GtkWidgetClass *widget_class, GtkContainerClass *container_class);
|
static void ClassInit(OBJECT_CLASS* object_class, GtkWidgetClass *widget_class, GtkContainerClass *container_class);
|
||||||
@ -86,8 +88,8 @@ private:
|
|||||||
void DisplayCursor(Window::Cursor c) override;
|
void DisplayCursor(Window::Cursor c) override;
|
||||||
bool DragThreshold(Point ptStart, Point ptNow) override;
|
bool DragThreshold(Point ptStart, Point ptNow) override;
|
||||||
void StartDrag() override;
|
void StartDrag() override;
|
||||||
int TargetAsUTF8(char *text);
|
Sci::Position TargetAsUTF8(char *text) const;
|
||||||
int EncodedFromUTF8(char *utf8, char *encoded) const;
|
Sci::Position EncodedFromUTF8(const char *utf8, char *encoded) const;
|
||||||
bool ValidCodePage(int codePage) const override;
|
bool ValidCodePage(int codePage) const override;
|
||||||
public: // Public for scintilla_send_message
|
public: // Public for scintilla_send_message
|
||||||
sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override;
|
sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) override;
|
||||||
@ -100,7 +102,6 @@ private:
|
|||||||
TimeThunk() : reason(tickCaret), scintilla(NULL), timer(0) {}
|
TimeThunk() : reason(tickCaret), scintilla(NULL), timer(0) {}
|
||||||
};
|
};
|
||||||
TimeThunk timers[tickDwell+1];
|
TimeThunk timers[tickDwell+1];
|
||||||
bool FineTickerAvailable() override;
|
|
||||||
bool FineTickerRunning(TickReason reason) override;
|
bool FineTickerRunning(TickReason reason) override;
|
||||||
void FineTickerStart(TickReason reason, int millis, int tolerance) override;
|
void FineTickerStart(TickReason reason, int millis, int tolerance) override;
|
||||||
void FineTickerCancel(TickReason reason) override;
|
void FineTickerCancel(TickReason reason) override;
|
||||||
@ -140,6 +141,8 @@ private:
|
|||||||
static void ClipboardClearSelection(GtkClipboard* clip, void *data);
|
static void ClipboardClearSelection(GtkClipboard* clip, void *data);
|
||||||
|
|
||||||
void UnclaimSelection(GdkEventSelection *selection_event);
|
void UnclaimSelection(GdkEventSelection *selection_event);
|
||||||
|
static void PrimarySelection(GtkWidget *widget, GtkSelectionData *selection_data, guint info, guint time_stamp, ScintillaGTK *sciThis);
|
||||||
|
static gboolean PrimaryClear(GtkWidget *widget, GdkEventSelection *event, ScintillaGTK *sciThis);
|
||||||
void Resize(int width, int height);
|
void Resize(int width, int height);
|
||||||
|
|
||||||
// Callback functions
|
// Callback functions
|
||||||
@ -282,8 +285,6 @@ public:
|
|||||||
std::string ConvertText(const char *s, size_t len, const char *charSetDest,
|
std::string ConvertText(const char *s, size_t len, const char *charSetDest,
|
||||||
const char *charSetSource, bool transliterations, bool silent=false);
|
const char *charSetSource, bool transliterations, bool silent=false);
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -84,6 +84,7 @@
|
|||||||
// ScintillaGTK.h and stuff it needs
|
// ScintillaGTK.h and stuff it needs
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
|
||||||
|
#include "ILoader.h"
|
||||||
#include "ILexer.h"
|
#include "ILexer.h"
|
||||||
#include "Scintilla.h"
|
#include "Scintilla.h"
|
||||||
#include "ScintillaWidget.h"
|
#include "ScintillaWidget.h"
|
||||||
@ -104,7 +105,6 @@
|
|||||||
#include "CallTip.h"
|
#include "CallTip.h"
|
||||||
#include "KeyMap.h"
|
#include "KeyMap.h"
|
||||||
#include "Indicator.h"
|
#include "Indicator.h"
|
||||||
#include "XPM.h"
|
|
||||||
#include "LineMarker.h"
|
#include "LineMarker.h"
|
||||||
#include "Style.h"
|
#include "Style.h"
|
||||||
#include "ViewStyle.h"
|
#include "ViewStyle.h"
|
||||||
@ -114,7 +114,6 @@
|
|||||||
#include "Document.h"
|
#include "Document.h"
|
||||||
#include "CaseConvert.h"
|
#include "CaseConvert.h"
|
||||||
#include "UniConversion.h"
|
#include "UniConversion.h"
|
||||||
#include "UnicodeFromUTF8.h"
|
|
||||||
#include "Selection.h"
|
#include "Selection.h"
|
||||||
#include "PositionCache.h"
|
#include "PositionCache.h"
|
||||||
#include "EditModel.h"
|
#include "EditModel.h"
|
||||||
@ -127,9 +126,7 @@
|
|||||||
#include "ScintillaGTK.h"
|
#include "ScintillaGTK.h"
|
||||||
#include "ScintillaGTKAccessible.h"
|
#include "ScintillaGTKAccessible.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
struct ScintillaObjectAccessiblePrivate {
|
struct ScintillaObjectAccessiblePrivate {
|
||||||
ScintillaGTKAccessible *pscin;
|
ScintillaGTKAccessible *pscin;
|
||||||
@ -764,7 +761,7 @@ void ScintillaGTKAccessible::PasteText(int charPosition) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void TextReceivedCallback(GtkClipboard *clipboard, const gchar *text, gpointer data) {
|
static void TextReceivedCallback(GtkClipboard *clipboard, const gchar *text, gpointer data) {
|
||||||
Helper *helper = reinterpret_cast<Helper*>(data);
|
Helper *helper = static_cast<Helper*>(data);
|
||||||
try {
|
try {
|
||||||
if (helper->scia != 0) {
|
if (helper->scia != 0) {
|
||||||
helper->TextReceived(clipboard, text);
|
helper->TextReceived(clipboard, text);
|
||||||
|
@ -6,9 +6,7 @@
|
|||||||
#ifndef SCINTILLAGTKACCESSIBLE_H
|
#ifndef SCINTILLAGTKACCESSIBLE_H
|
||||||
#define SCINTILLAGTKACCESSIBLE_H
|
#define SCINTILLAGTKACCESSIBLE_H
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ATK_CHECK_VERSION
|
#ifndef ATK_CHECK_VERSION
|
||||||
# define ATK_CHECK_VERSION(x, y, z) 0
|
# define ATK_CHECK_VERSION(x, y, z) 0
|
||||||
@ -34,7 +32,7 @@ private:
|
|||||||
void Notify(GtkWidget *widget, gint code, SCNotification *nt);
|
void Notify(GtkWidget *widget, gint code, SCNotification *nt);
|
||||||
static void SciNotify(GtkWidget *widget, gint code, SCNotification *nt, gpointer data) {
|
static void SciNotify(GtkWidget *widget, gint code, SCNotification *nt, gpointer data) {
|
||||||
try {
|
try {
|
||||||
reinterpret_cast<ScintillaGTKAccessible*>(data)->Notify(widget, code, nt);
|
static_cast<ScintillaGTKAccessible*>(data)->Notify(widget, code, nt);
|
||||||
} catch (...) {}
|
} catch (...) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,9 +186,7 @@ public:
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* SCINTILLAGTKACCESSIBLE_H */
|
#endif /* SCINTILLAGTKACCESSIBLE_H */
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
|
#include <glib-object.h>
|
||||||
#include <glib-object.h>
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef G_ENABLE_DEBUG
|
#ifdef G_ENABLE_DEBUG
|
||||||
#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
|
#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v)
|
||||||
@ -48,8 +46,7 @@
|
|||||||
#define g_marshal_value_peek_variant(v) (v)->data[0].v_pointer
|
#define g_marshal_value_peek_variant(v) (v)->data[0].v_pointer
|
||||||
#endif /* !G_ENABLE_DEBUG */
|
#endif /* !G_ENABLE_DEBUG */
|
||||||
|
|
||||||
|
/* VOID:INT,OBJECT (scintilla-marshal.list:1) */
|
||||||
/* NONE:INT,OBJECT (scintilla-marshal.list:1) */
|
|
||||||
void
|
void
|
||||||
scintilla_marshal_VOID__INT_OBJECT (GClosure *closure,
|
scintilla_marshal_VOID__INT_OBJECT (GClosure *closure,
|
||||||
GValue *return_value G_GNUC_UNUSED,
|
GValue *return_value G_GNUC_UNUSED,
|
||||||
@ -58,13 +55,13 @@ scintilla_marshal_VOID__INT_OBJECT (GClosure *closure,
|
|||||||
gpointer invocation_hint G_GNUC_UNUSED,
|
gpointer invocation_hint G_GNUC_UNUSED,
|
||||||
gpointer marshal_data)
|
gpointer marshal_data)
|
||||||
{
|
{
|
||||||
typedef void (*GMarshalFunc_VOID__INT_OBJECT) (gpointer data1,
|
typedef void (*GMarshalFunc_VOID__INT_OBJECT) (gpointer data1,
|
||||||
gint arg_1,
|
gint arg1,
|
||||||
gpointer arg_2,
|
gpointer arg2,
|
||||||
gpointer data2);
|
gpointer data2);
|
||||||
GMarshalFunc_VOID__INT_OBJECT callback;
|
GCClosure *cc = (GCClosure *) closure;
|
||||||
GCClosure *cc = (GCClosure*) closure;
|
|
||||||
gpointer data1, data2;
|
gpointer data1, data2;
|
||||||
|
GMarshalFunc_VOID__INT_OBJECT callback;
|
||||||
|
|
||||||
g_return_if_fail (n_param_values == 3);
|
g_return_if_fail (n_param_values == 3);
|
||||||
|
|
||||||
@ -86,7 +83,7 @@ scintilla_marshal_VOID__INT_OBJECT (GClosure *closure,
|
|||||||
data2);
|
data2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* NONE:INT,BOXED (scintilla-marshal.list:2) */
|
/* VOID:INT,BOXED (scintilla-marshal.list:2) */
|
||||||
void
|
void
|
||||||
scintilla_marshal_VOID__INT_BOXED (GClosure *closure,
|
scintilla_marshal_VOID__INT_BOXED (GClosure *closure,
|
||||||
GValue *return_value G_GNUC_UNUSED,
|
GValue *return_value G_GNUC_UNUSED,
|
||||||
@ -95,13 +92,13 @@ scintilla_marshal_VOID__INT_BOXED (GClosure *closure,
|
|||||||
gpointer invocation_hint G_GNUC_UNUSED,
|
gpointer invocation_hint G_GNUC_UNUSED,
|
||||||
gpointer marshal_data)
|
gpointer marshal_data)
|
||||||
{
|
{
|
||||||
typedef void (*GMarshalFunc_VOID__INT_BOXED) (gpointer data1,
|
typedef void (*GMarshalFunc_VOID__INT_BOXED) (gpointer data1,
|
||||||
gint arg_1,
|
gint arg1,
|
||||||
gpointer arg_2,
|
gpointer arg2,
|
||||||
gpointer data2);
|
gpointer data2);
|
||||||
GMarshalFunc_VOID__INT_BOXED callback;
|
GCClosure *cc = (GCClosure *) closure;
|
||||||
GCClosure *cc = (GCClosure*) closure;
|
|
||||||
gpointer data1, data2;
|
gpointer data1, data2;
|
||||||
|
GMarshalFunc_VOID__INT_BOXED callback;
|
||||||
|
|
||||||
g_return_if_fail (n_param_values == 3);
|
g_return_if_fail (n_param_values == 3);
|
||||||
|
|
||||||
|
@ -1,30 +1,30 @@
|
|||||||
|
/* This file is generated, all changes will be lost */
|
||||||
|
#ifndef __SCINTILLA_MARSHAL_MARSHAL_H__
|
||||||
|
#define __SCINTILLA_MARSHAL_MARSHAL_H__
|
||||||
|
|
||||||
#ifndef __scintilla_marshal_MARSHAL_H__
|
#include <glib-object.h>
|
||||||
#define __scintilla_marshal_MARSHAL_H__
|
|
||||||
|
|
||||||
#include <glib-object.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
/* NONE:INT,OBJECT (scintilla-marshal.list:1) */
|
/* VOID:INT,OBJECT (scintilla-marshal.list:1) */
|
||||||
extern void scintilla_marshal_VOID__INT_OBJECT (GClosure *closure,
|
extern
|
||||||
GValue *return_value,
|
void scintilla_marshal_VOID__INT_OBJECT (GClosure *closure,
|
||||||
guint n_param_values,
|
GValue *return_value,
|
||||||
const GValue *param_values,
|
guint n_param_values,
|
||||||
gpointer invocation_hint,
|
const GValue *param_values,
|
||||||
gpointer marshal_data);
|
gpointer invocation_hint,
|
||||||
#define scintilla_marshal_NONE__INT_OBJECT scintilla_marshal_VOID__INT_OBJECT
|
gpointer marshal_data);
|
||||||
|
|
||||||
|
/* VOID:INT,BOXED (scintilla-marshal.list:2) */
|
||||||
|
extern
|
||||||
|
void scintilla_marshal_VOID__INT_BOXED (GClosure *closure,
|
||||||
|
GValue *return_value,
|
||||||
|
guint n_param_values,
|
||||||
|
const GValue *param_values,
|
||||||
|
gpointer invocation_hint,
|
||||||
|
gpointer marshal_data);
|
||||||
|
|
||||||
/* NONE:INT,BOXED (scintilla-marshal.list:2) */
|
|
||||||
extern void scintilla_marshal_VOID__INT_BOXED (GClosure *closure,
|
|
||||||
GValue *return_value,
|
|
||||||
guint n_param_values,
|
|
||||||
const GValue *param_values,
|
|
||||||
gpointer invocation_hint,
|
|
||||||
gpointer marshal_data);
|
|
||||||
#define scintilla_marshal_NONE__INT_BOXED scintilla_marshal_VOID__INT_BOXED
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __scintilla_marshal_MARSHAL_H__ */
|
#endif /* __SCINTILLA_MARSHAL_MARSHAL_H__ */
|
||||||
|
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
NONE:INT,OBJECT
|
VOID:INT,OBJECT
|
||||||
NONE:INT,BOXED
|
VOID:INT,BOXED
|
||||||
|
@ -10,15 +10,7 @@
|
|||||||
|
|
||||||
#include "Sci_Position.h"
|
#include "Sci_Position.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define SCI_METHOD __stdcall
|
|
||||||
#else
|
|
||||||
#define SCI_METHOD
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enum { dvOriginal=0, dvLineEnd=1 };
|
enum { dvOriginal=0, dvLineEnd=1 };
|
||||||
|
|
||||||
@ -54,7 +46,7 @@ public:
|
|||||||
virtual int SCI_METHOD GetCharacterAndWidth(Sci_Position position, Sci_Position *pWidth) const = 0;
|
virtual int SCI_METHOD GetCharacterAndWidth(Sci_Position position, Sci_Position *pWidth) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum { lvOriginal=0, lvSubStyles=1 };
|
enum { lvOriginal=0, lvSubStyles=1, lvMetaData=2 };
|
||||||
|
|
||||||
class ILexer {
|
class ILexer {
|
||||||
public:
|
public:
|
||||||
@ -85,16 +77,14 @@ public:
|
|||||||
virtual const char * SCI_METHOD GetSubStyleBases() = 0;
|
virtual const char * SCI_METHOD GetSubStyleBases() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ILoader {
|
class ILexerWithMetaData : public ILexerWithSubStyles {
|
||||||
public:
|
public:
|
||||||
virtual int SCI_METHOD Release() = 0;
|
virtual int SCI_METHOD NamedStyles() = 0;
|
||||||
// Returns a status code from SC_STATUS_*
|
virtual const char * SCI_METHOD NameOfStyle(int style) = 0;
|
||||||
virtual int SCI_METHOD AddData(char *data, Sci_Position length) = 0;
|
virtual const char * SCI_METHOD TagsOfStyle(int style) = 0;
|
||||||
virtual void * SCI_METHOD ConvertToDocument() = 0;
|
virtual const char * SCI_METHOD DescriptionOfStyle(int style) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
21
scintilla/include/ILoader.h
Normal file
21
scintilla/include/ILoader.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// Scintilla source code edit control
|
||||||
|
/** @file ILoader.h
|
||||||
|
** Interface for loading into a Scintilla document from a background thread.
|
||||||
|
**/
|
||||||
|
// Copyright 1998-2017 by Neil Hodgson <neilh@scintilla.org>
|
||||||
|
// The License.txt file describes the conditions under which this software may be distributed.
|
||||||
|
|
||||||
|
#ifndef ILOADER_H
|
||||||
|
#define ILOADER_H
|
||||||
|
|
||||||
|
#include "Sci_Position.h"
|
||||||
|
|
||||||
|
class ILoader {
|
||||||
|
public:
|
||||||
|
virtual int SCI_METHOD Release() = 0;
|
||||||
|
// Returns a status code from SC_STATUS_*
|
||||||
|
virtual int SCI_METHOD AddData(const char *data, Sci_Position length) = 0;
|
||||||
|
virtual void * SCI_METHOD ConvertToDocument() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -71,15 +71,10 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef float XYPOSITION;
|
typedef float XYPOSITION;
|
||||||
typedef double XYACCUMULATOR;
|
typedef double XYACCUMULATOR;
|
||||||
inline int RoundXYPosition(XYPOSITION xyPos) {
|
|
||||||
return static_cast<int>(xyPos + 0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Underlying the implementation of the platform classes are platform specific types.
|
// Underlying the implementation of the platform classes are platform specific types.
|
||||||
// Sometimes these need to be passed around by client code so they are defined here
|
// Sometimes these need to be passed around by client code so they are defined here
|
||||||
@ -101,21 +96,19 @@ public:
|
|||||||
XYPOSITION x;
|
XYPOSITION x;
|
||||||
XYPOSITION y;
|
XYPOSITION y;
|
||||||
|
|
||||||
explicit Point(XYPOSITION x_=0, XYPOSITION y_=0) : x(x_), y(y_) {
|
constexpr explicit Point(XYPOSITION x_=0, XYPOSITION y_=0) noexcept : x(x_), y(y_) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static Point FromInts(int x_, int y_) {
|
static Point FromInts(int x_, int y_) noexcept {
|
||||||
return Point(static_cast<XYPOSITION>(x_), static_cast<XYPOSITION>(y_));
|
return Point(static_cast<XYPOSITION>(x_), static_cast<XYPOSITION>(y_));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Other automatically defined methods (assignment, copy constructor, destructor) are fine
|
// Other automatically defined methods (assignment, copy constructor, destructor) are fine
|
||||||
|
|
||||||
static Point FromLong(long lpoint);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A geometric rectangle class.
|
* A geometric rectangle class.
|
||||||
* PRectangle is similar to the Win32 RECT.
|
* PRectangle is similar to Win32 RECT.
|
||||||
* PRectangles contain their top and left sides, but not their right and bottom sides.
|
* PRectangles contain their top and left sides, but not their right and bottom sides.
|
||||||
*/
|
*/
|
||||||
class PRectangle {
|
class PRectangle {
|
||||||
@ -125,113 +118,147 @@ public:
|
|||||||
XYPOSITION right;
|
XYPOSITION right;
|
||||||
XYPOSITION bottom;
|
XYPOSITION bottom;
|
||||||
|
|
||||||
explicit PRectangle(XYPOSITION left_=0, XYPOSITION top_=0, XYPOSITION right_=0, XYPOSITION bottom_ = 0) :
|
constexpr explicit PRectangle(XYPOSITION left_=0, XYPOSITION top_=0, XYPOSITION right_=0, XYPOSITION bottom_ = 0) noexcept :
|
||||||
left(left_), top(top_), right(right_), bottom(bottom_) {
|
left(left_), top(top_), right(right_), bottom(bottom_) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static PRectangle FromInts(int left_, int top_, int right_, int bottom_) {
|
static PRectangle FromInts(int left_, int top_, int right_, int bottom_) noexcept {
|
||||||
return PRectangle(static_cast<XYPOSITION>(left_), static_cast<XYPOSITION>(top_),
|
return PRectangle(static_cast<XYPOSITION>(left_), static_cast<XYPOSITION>(top_),
|
||||||
static_cast<XYPOSITION>(right_), static_cast<XYPOSITION>(bottom_));
|
static_cast<XYPOSITION>(right_), static_cast<XYPOSITION>(bottom_));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Other automatically defined methods (assignment, copy constructor, destructor) are fine
|
// Other automatically defined methods (assignment, copy constructor, destructor) are fine
|
||||||
|
|
||||||
bool operator==(const PRectangle &rc) const {
|
bool operator==(const PRectangle &rc) const noexcept {
|
||||||
return (rc.left == left) && (rc.right == right) &&
|
return (rc.left == left) && (rc.right == right) &&
|
||||||
(rc.top == top) && (rc.bottom == bottom);
|
(rc.top == top) && (rc.bottom == bottom);
|
||||||
}
|
}
|
||||||
bool Contains(Point pt) const {
|
bool Contains(Point pt) const noexcept {
|
||||||
return (pt.x >= left) && (pt.x <= right) &&
|
return (pt.x >= left) && (pt.x <= right) &&
|
||||||
(pt.y >= top) && (pt.y <= bottom);
|
(pt.y >= top) && (pt.y <= bottom);
|
||||||
}
|
}
|
||||||
bool ContainsWholePixel(Point pt) const {
|
bool ContainsWholePixel(Point pt) const noexcept {
|
||||||
// Does the rectangle contain all of the pixel to left/below the point
|
// Does the rectangle contain all of the pixel to left/below the point
|
||||||
return (pt.x >= left) && ((pt.x+1) <= right) &&
|
return (pt.x >= left) && ((pt.x+1) <= right) &&
|
||||||
(pt.y >= top) && ((pt.y+1) <= bottom);
|
(pt.y >= top) && ((pt.y+1) <= bottom);
|
||||||
}
|
}
|
||||||
bool Contains(PRectangle rc) const {
|
bool Contains(PRectangle rc) const noexcept {
|
||||||
return (rc.left >= left) && (rc.right <= right) &&
|
return (rc.left >= left) && (rc.right <= right) &&
|
||||||
(rc.top >= top) && (rc.bottom <= bottom);
|
(rc.top >= top) && (rc.bottom <= bottom);
|
||||||
}
|
}
|
||||||
bool Intersects(PRectangle other) const {
|
bool Intersects(PRectangle other) const noexcept {
|
||||||
return (right > other.left) && (left < other.right) &&
|
return (right > other.left) && (left < other.right) &&
|
||||||
(bottom > other.top) && (top < other.bottom);
|
(bottom > other.top) && (top < other.bottom);
|
||||||
}
|
}
|
||||||
void Move(XYPOSITION xDelta, XYPOSITION yDelta) {
|
void Move(XYPOSITION xDelta, XYPOSITION yDelta) noexcept {
|
||||||
left += xDelta;
|
left += xDelta;
|
||||||
top += yDelta;
|
top += yDelta;
|
||||||
right += xDelta;
|
right += xDelta;
|
||||||
bottom += yDelta;
|
bottom += yDelta;
|
||||||
}
|
}
|
||||||
XYPOSITION Width() const { return right - left; }
|
XYPOSITION Width() const noexcept { return right - left; }
|
||||||
XYPOSITION Height() const { return bottom - top; }
|
XYPOSITION Height() const noexcept { return bottom - top; }
|
||||||
bool Empty() const {
|
bool Empty() const noexcept {
|
||||||
return (Height() <= 0) || (Width() <= 0);
|
return (Height() <= 0) || (Width() <= 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds a desired RGB colour.
|
* Holds an RGB colour with 8 bits for each component.
|
||||||
*/
|
*/
|
||||||
|
constexpr const float componentMaximum = 255.0f;
|
||||||
class ColourDesired {
|
class ColourDesired {
|
||||||
long co;
|
int co;
|
||||||
public:
|
public:
|
||||||
ColourDesired(long lcol=0) {
|
explicit ColourDesired(int co_=0) noexcept : co(co_) {
|
||||||
co = lcol;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ColourDesired(unsigned int red, unsigned int green, unsigned int blue) {
|
ColourDesired(unsigned int red, unsigned int green, unsigned int blue) noexcept :
|
||||||
Set(red, green, blue);
|
co(red | (green << 8) | (blue << 16)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const ColourDesired &other) const {
|
bool operator==(const ColourDesired &other) const noexcept {
|
||||||
return co == other.co;
|
return co == other.co;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Set(long lcol) {
|
int AsInteger() const noexcept {
|
||||||
co = lcol;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Set(unsigned int red, unsigned int green, unsigned int blue) {
|
|
||||||
co = red | (green << 8) | (blue << 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline unsigned int ValueOfHex(const char ch) {
|
|
||||||
if (ch >= '0' && ch <= '9')
|
|
||||||
return ch - '0';
|
|
||||||
else if (ch >= 'A' && ch <= 'F')
|
|
||||||
return ch - 'A' + 10;
|
|
||||||
else if (ch >= 'a' && ch <= 'f')
|
|
||||||
return ch - 'a' + 10;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Set(const char *val) {
|
|
||||||
if (*val == '#') {
|
|
||||||
val++;
|
|
||||||
}
|
|
||||||
unsigned int r = ValueOfHex(val[0]) * 16 + ValueOfHex(val[1]);
|
|
||||||
unsigned int g = ValueOfHex(val[2]) * 16 + ValueOfHex(val[3]);
|
|
||||||
unsigned int b = ValueOfHex(val[4]) * 16 + ValueOfHex(val[5]);
|
|
||||||
Set(r, g, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
long AsLong() const {
|
|
||||||
return co;
|
return co;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int GetRed() const {
|
// Red, green and blue values as bytes 0..255
|
||||||
|
unsigned char GetRed() const noexcept {
|
||||||
return co & 0xff;
|
return co & 0xff;
|
||||||
}
|
}
|
||||||
|
unsigned char GetGreen() const noexcept {
|
||||||
unsigned int GetGreen() const {
|
|
||||||
return (co >> 8) & 0xff;
|
return (co >> 8) & 0xff;
|
||||||
}
|
}
|
||||||
|
unsigned char GetBlue() const noexcept {
|
||||||
unsigned int GetBlue() const {
|
|
||||||
return (co >> 16) & 0xff;
|
return (co >> 16) & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Red, green and blue values as float 0..1.0
|
||||||
|
float GetRedComponent() const noexcept {
|
||||||
|
return GetRed() / componentMaximum;
|
||||||
|
}
|
||||||
|
float GetGreenComponent() const noexcept {
|
||||||
|
return GetGreen() / componentMaximum;
|
||||||
|
}
|
||||||
|
float GetBlueComponent() const noexcept {
|
||||||
|
return GetBlue() / componentMaximum;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holds an RGBA colour.
|
||||||
|
*/
|
||||||
|
class ColourAlpha : public ColourDesired {
|
||||||
|
public:
|
||||||
|
explicit ColourAlpha(int co_ = 0) noexcept : ColourDesired(co_) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ColourAlpha(unsigned int red, unsigned int green, unsigned int blue) noexcept :
|
||||||
|
ColourDesired(red | (green << 8) | (blue << 16)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ColourAlpha(unsigned int red, unsigned int green, unsigned int blue, unsigned int alpha) noexcept :
|
||||||
|
ColourDesired(red | (green << 8) | (blue << 16) | (alpha << 24)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ColourAlpha(ColourDesired cd, unsigned int alpha) noexcept :
|
||||||
|
ColourDesired(cd.AsInteger() | (alpha << 24)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ColourDesired GetColour() const noexcept {
|
||||||
|
return ColourDesired(AsInteger() & 0xffffff);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char GetAlpha() const noexcept {
|
||||||
|
return (AsInteger() >> 24) & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
float GetAlphaComponent() const noexcept {
|
||||||
|
return GetAlpha() / componentMaximum;
|
||||||
|
}
|
||||||
|
|
||||||
|
ColourAlpha MixedWith(ColourAlpha other) const noexcept {
|
||||||
|
const unsigned int red = (GetRed() + other.GetRed()) / 2;
|
||||||
|
const unsigned int green = (GetGreen() + other.GetGreen()) / 2;
|
||||||
|
const unsigned int blue = (GetBlue() + other.GetBlue()) / 2;
|
||||||
|
const unsigned int alpha = (GetAlpha() + other.GetAlpha()) / 2;
|
||||||
|
return ColourAlpha(red, green, blue, alpha);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Holds an element of a gradient with an RGBA colour and a relative position.
|
||||||
|
*/
|
||||||
|
class ColourStop {
|
||||||
|
public:
|
||||||
|
float position;
|
||||||
|
ColourAlpha colour;
|
||||||
|
ColourStop(float position_, ColourAlpha colour_) noexcept :
|
||||||
|
position(position_), colour(colour_) {
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -254,7 +281,7 @@ struct FontParameters {
|
|||||||
bool italic_=false,
|
bool italic_=false,
|
||||||
int extraFontFlag_=0,
|
int extraFontFlag_=0,
|
||||||
int technology_=0,
|
int technology_=0,
|
||||||
int characterSet_=0) :
|
int characterSet_=0) noexcept :
|
||||||
|
|
||||||
faceName(faceName_),
|
faceName(faceName_),
|
||||||
size(size_),
|
size(size_),
|
||||||
@ -271,19 +298,21 @@ struct FontParameters {
|
|||||||
class Font {
|
class Font {
|
||||||
protected:
|
protected:
|
||||||
FontID fid;
|
FontID fid;
|
||||||
// Private so Font objects can not be copied
|
|
||||||
Font(const Font &);
|
|
||||||
Font &operator=(const Font &);
|
|
||||||
public:
|
public:
|
||||||
Font();
|
Font() noexcept;
|
||||||
|
// Deleted so Font objects can not be copied
|
||||||
|
Font(const Font &) = delete;
|
||||||
|
Font(Font &&) = delete;
|
||||||
|
Font &operator=(const Font &) = delete;
|
||||||
|
Font &operator=(Font &&) = delete;
|
||||||
virtual ~Font();
|
virtual ~Font();
|
||||||
|
|
||||||
virtual void Create(const FontParameters &fp);
|
virtual void Create(const FontParameters &fp);
|
||||||
virtual void Release();
|
virtual void Release();
|
||||||
|
|
||||||
FontID GetID() { return fid; }
|
FontID GetID() const noexcept { return fid; }
|
||||||
// Alias another font - caller guarantees not to Release
|
// Alias another font - caller guarantees not to Release
|
||||||
void SetID(FontID fid_) { fid = fid_; }
|
void SetID(FontID fid_) noexcept { fid = fid_; }
|
||||||
friend class Surface;
|
friend class Surface;
|
||||||
friend class SurfaceImpl;
|
friend class SurfaceImpl;
|
||||||
};
|
};
|
||||||
@ -292,12 +321,12 @@ public:
|
|||||||
* A surface abstracts a place to draw.
|
* A surface abstracts a place to draw.
|
||||||
*/
|
*/
|
||||||
class Surface {
|
class Surface {
|
||||||
private:
|
|
||||||
// Private so Surface objects can not be copied
|
|
||||||
Surface(const Surface &) {}
|
|
||||||
Surface &operator=(const Surface &) { return *this; }
|
|
||||||
public:
|
public:
|
||||||
Surface() {}
|
Surface() noexcept = default;
|
||||||
|
Surface(const Surface &) = delete;
|
||||||
|
Surface(Surface &&) = delete;
|
||||||
|
Surface &operator=(const Surface &) = delete;
|
||||||
|
Surface &operator=(Surface &&) = delete;
|
||||||
virtual ~Surface() {}
|
virtual ~Surface() {}
|
||||||
static Surface *Allocate(int technology);
|
static Surface *Allocate(int technology);
|
||||||
|
|
||||||
@ -312,13 +341,15 @@ public:
|
|||||||
virtual int DeviceHeightFont(int points)=0;
|
virtual int DeviceHeightFont(int points)=0;
|
||||||
virtual void MoveTo(int x_, int y_)=0;
|
virtual void MoveTo(int x_, int y_)=0;
|
||||||
virtual void LineTo(int x_, int y_)=0;
|
virtual void LineTo(int x_, int y_)=0;
|
||||||
virtual void Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired back)=0;
|
virtual void Polygon(Point *pts, size_t npts, ColourDesired fore, ColourDesired back)=0;
|
||||||
virtual void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back)=0;
|
virtual void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back)=0;
|
||||||
virtual void FillRectangle(PRectangle rc, ColourDesired back)=0;
|
virtual void FillRectangle(PRectangle rc, ColourDesired back)=0;
|
||||||
virtual void FillRectangle(PRectangle rc, Surface &surfacePattern)=0;
|
virtual void FillRectangle(PRectangle rc, Surface &surfacePattern)=0;
|
||||||
virtual void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back)=0;
|
virtual void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back)=0;
|
||||||
virtual void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill,
|
virtual void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill,
|
||||||
ColourDesired outline, int alphaOutline, int flags)=0;
|
ColourDesired outline, int alphaOutline, int flags)=0;
|
||||||
|
enum class GradientOptions { leftToRight, topToBottom };
|
||||||
|
virtual void GradientRectangle(PRectangle rc, const std::vector<ColourStop> &stops, GradientOptions options)=0;
|
||||||
virtual void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) = 0;
|
virtual void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) = 0;
|
||||||
virtual void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back)=0;
|
virtual void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back)=0;
|
||||||
virtual void Copy(PRectangle rc, Point from, Surface &surfaceSource)=0;
|
virtual void Copy(PRectangle rc, Point from, Surface &surfaceSource)=0;
|
||||||
@ -328,11 +359,9 @@ public:
|
|||||||
virtual void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore)=0;
|
virtual void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore)=0;
|
||||||
virtual void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions)=0;
|
virtual void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions)=0;
|
||||||
virtual XYPOSITION WidthText(Font &font_, const char *s, int len)=0;
|
virtual XYPOSITION WidthText(Font &font_, const char *s, int len)=0;
|
||||||
virtual XYPOSITION WidthChar(Font &font_, char ch)=0;
|
|
||||||
virtual XYPOSITION Ascent(Font &font_)=0;
|
virtual XYPOSITION Ascent(Font &font_)=0;
|
||||||
virtual XYPOSITION Descent(Font &font_)=0;
|
virtual XYPOSITION Descent(Font &font_)=0;
|
||||||
virtual XYPOSITION InternalLeading(Font &font_)=0;
|
virtual XYPOSITION InternalLeading(Font &font_)=0;
|
||||||
virtual XYPOSITION ExternalLeading(Font &font_)=0;
|
|
||||||
virtual XYPOSITION Height(Font &font_)=0;
|
virtual XYPOSITION Height(Font &font_)=0;
|
||||||
virtual XYPOSITION AverageCharWidth(Font &font_)=0;
|
virtual XYPOSITION AverageCharWidth(Font &font_)=0;
|
||||||
|
|
||||||
@ -343,11 +372,6 @@ public:
|
|||||||
virtual void SetDBCSMode(int codePage)=0;
|
virtual void SetDBCSMode(int codePage)=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* A simple callback action passing one piece of untyped user data.
|
|
||||||
*/
|
|
||||||
typedef void (*CallBackAction)(void*);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to hide the details of window manipulation.
|
* Class to hide the details of window manipulation.
|
||||||
* Does not own the window which will normally have a longer life than this object.
|
* Does not own the window which will normally have a longer life than this object.
|
||||||
@ -356,38 +380,31 @@ class Window {
|
|||||||
protected:
|
protected:
|
||||||
WindowID wid;
|
WindowID wid;
|
||||||
public:
|
public:
|
||||||
Window() : wid(0), cursorLast(cursorInvalid) {
|
Window() noexcept : wid(nullptr), cursorLast(cursorInvalid) {
|
||||||
}
|
}
|
||||||
Window(const Window &source) : wid(source.wid), cursorLast(cursorInvalid) {
|
Window(const Window &source) = delete;
|
||||||
}
|
Window(Window &&) = delete;
|
||||||
virtual ~Window();
|
Window &operator=(WindowID wid_) noexcept {
|
||||||
Window &operator=(WindowID wid_) {
|
|
||||||
wid = wid_;
|
wid = wid_;
|
||||||
cursorLast = cursorInvalid;
|
cursorLast = cursorInvalid;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
Window &operator=(const Window &other) {
|
Window &operator=(const Window &) = delete;
|
||||||
if (this != &other) {
|
Window &operator=(Window &&) = delete;
|
||||||
wid = other.wid;
|
virtual ~Window();
|
||||||
cursorLast = other.cursorLast;
|
WindowID GetID() const noexcept { return wid; }
|
||||||
}
|
bool Created() const noexcept { return wid != nullptr; }
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
WindowID GetID() const { return wid; }
|
|
||||||
bool Created() const { return wid != 0; }
|
|
||||||
void Destroy();
|
void Destroy();
|
||||||
bool HasFocus();
|
PRectangle GetPosition() const;
|
||||||
PRectangle GetPosition();
|
|
||||||
void SetPosition(PRectangle rc);
|
void SetPosition(PRectangle rc);
|
||||||
void SetPositionRelative(PRectangle rc, Window relativeTo);
|
void SetPositionRelative(PRectangle rc, const Window *relativeTo);
|
||||||
PRectangle GetClientPosition();
|
PRectangle GetClientPosition() const;
|
||||||
void Show(bool show=true);
|
void Show(bool show=true);
|
||||||
void InvalidateAll();
|
void InvalidateAll();
|
||||||
void InvalidateRectangle(PRectangle rc);
|
void InvalidateRectangle(PRectangle rc);
|
||||||
virtual void SetFont(Font &font);
|
virtual void SetFont(Font &font);
|
||||||
enum Cursor { cursorInvalid, cursorText, cursorArrow, cursorUp, cursorWait, cursorHoriz, cursorVert, cursorReverseArrow, cursorHand };
|
enum Cursor { cursorInvalid, cursorText, cursorArrow, cursorUp, cursorWait, cursorHoriz, cursorVert, cursorReverseArrow, cursorHand };
|
||||||
void SetCursor(Cursor curs);
|
void SetCursor(Cursor curs);
|
||||||
void SetTitle(const char *s);
|
|
||||||
PRectangle GetMonitorRect(Point pt);
|
PRectangle GetMonitorRect(Point pt);
|
||||||
private:
|
private:
|
||||||
Cursor cursorLast;
|
Cursor cursorLast;
|
||||||
@ -397,13 +414,26 @@ private:
|
|||||||
* Listbox management.
|
* Listbox management.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// ScintillaBase implements IListBoxDelegate to receive ListBoxEvents from a ListBox
|
||||||
|
|
||||||
|
struct ListBoxEvent {
|
||||||
|
enum class EventType { selectionChange, doubleClick } event;
|
||||||
|
ListBoxEvent(EventType event_) noexcept : event(event_) {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class IListBoxDelegate {
|
||||||
|
public:
|
||||||
|
virtual void ListNotify(ListBoxEvent *plbe)=0;
|
||||||
|
};
|
||||||
|
|
||||||
class ListBox : public Window {
|
class ListBox : public Window {
|
||||||
public:
|
public:
|
||||||
ListBox();
|
ListBox() noexcept;
|
||||||
virtual ~ListBox();
|
~ListBox() override;
|
||||||
static ListBox *Allocate();
|
static ListBox *Allocate();
|
||||||
|
|
||||||
virtual void SetFont(Font &font)=0;
|
void SetFont(Font &font) override =0;
|
||||||
virtual void Create(Window &parent, int ctrlID, Point location, int lineHeight_, bool unicodeMode_, int technology_)=0;
|
virtual void Create(Window &parent, int ctrlID, Point location, int lineHeight_, bool unicodeMode_, int technology_)=0;
|
||||||
virtual void SetAverageCharWidth(int width)=0;
|
virtual void SetAverageCharWidth(int width)=0;
|
||||||
virtual void SetVisibleRows(int rows)=0;
|
virtual void SetVisibleRows(int rows)=0;
|
||||||
@ -420,7 +450,7 @@ public:
|
|||||||
virtual void RegisterImage(int type, const char *xpm_data)=0;
|
virtual void RegisterImage(int type, const char *xpm_data)=0;
|
||||||
virtual void RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage) = 0;
|
virtual void RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage) = 0;
|
||||||
virtual void ClearRegisteredImages()=0;
|
virtual void ClearRegisteredImages()=0;
|
||||||
virtual void SetDoubleClickAction(CallBackAction, void *)=0;
|
virtual void SetDelegate(IListBoxDelegate *lbDelegate)=0;
|
||||||
virtual void SetList(const char* list, char separator, char typesep)=0;
|
virtual void SetList(const char* list, char separator, char typesep)=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -430,27 +460,19 @@ public:
|
|||||||
class Menu {
|
class Menu {
|
||||||
MenuID mid;
|
MenuID mid;
|
||||||
public:
|
public:
|
||||||
Menu();
|
Menu() noexcept;
|
||||||
MenuID GetID() { return mid; }
|
MenuID GetID() const noexcept { return mid; }
|
||||||
void CreatePopUp();
|
void CreatePopUp();
|
||||||
void Destroy();
|
void Destroy();
|
||||||
void Show(Point pt, Window &w);
|
void Show(Point pt, Window &w);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ElapsedTime {
|
|
||||||
long bigBit;
|
|
||||||
long littleBit;
|
|
||||||
public:
|
|
||||||
ElapsedTime();
|
|
||||||
double Duration(bool reset=false);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dynamic Library (DLL/SO/...) loading
|
* Dynamic Library (DLL/SO/...) loading
|
||||||
*/
|
*/
|
||||||
class DynamicLibrary {
|
class DynamicLibrary {
|
||||||
public:
|
public:
|
||||||
virtual ~DynamicLibrary() {}
|
virtual ~DynamicLibrary() = default;
|
||||||
|
|
||||||
/// @return Pointer to function "name", or NULL on failure.
|
/// @return Pointer to function "name", or NULL on failure.
|
||||||
virtual Function FindFunction(const char *name) = 0;
|
virtual Function FindFunction(const char *name) = 0;
|
||||||
@ -477,61 +499,34 @@ public:
|
|||||||
* and chrome colour. Not a creatable object, more of a module with several functions.
|
* and chrome colour. Not a creatable object, more of a module with several functions.
|
||||||
*/
|
*/
|
||||||
class Platform {
|
class Platform {
|
||||||
// Private so Platform objects can not be copied
|
|
||||||
Platform(const Platform &) {}
|
|
||||||
Platform &operator=(const Platform &) { return *this; }
|
|
||||||
public:
|
public:
|
||||||
// Should be private because no new Platforms are ever created
|
Platform() = default;
|
||||||
// but gcc warns about this
|
Platform(const Platform &) = delete;
|
||||||
Platform() {}
|
Platform(Platform &&) = delete;
|
||||||
~Platform() {}
|
Platform &operator=(const Platform &) = delete;
|
||||||
|
Platform &operator=(Platform &&) = delete;
|
||||||
|
~Platform() = default;
|
||||||
static ColourDesired Chrome();
|
static ColourDesired Chrome();
|
||||||
static ColourDesired ChromeHighlight();
|
static ColourDesired ChromeHighlight();
|
||||||
static const char *DefaultFont();
|
static const char *DefaultFont();
|
||||||
static int DefaultFontSize();
|
static int DefaultFontSize();
|
||||||
static unsigned int DoubleClickTime();
|
static unsigned int DoubleClickTime();
|
||||||
static bool MouseButtonBounce();
|
|
||||||
static void DebugDisplay(const char *s);
|
static void DebugDisplay(const char *s);
|
||||||
static bool IsKeyDown(int key);
|
static constexpr long LongFromTwoShorts(short a,short b) noexcept {
|
||||||
static long SendScintilla(
|
|
||||||
WindowID w, unsigned int msg, unsigned long wParam=0, long lParam=0);
|
|
||||||
static long SendScintillaPointer(
|
|
||||||
WindowID w, unsigned int msg, unsigned long wParam=0, void *lParam=0);
|
|
||||||
static bool IsDBCSLeadByte(int codePage, char ch);
|
|
||||||
static int DBCSCharLength(int codePage, const char *s);
|
|
||||||
static int DBCSCharMaxLength();
|
|
||||||
|
|
||||||
// These are utility functions not really tied to a platform
|
|
||||||
static int Minimum(int a, int b);
|
|
||||||
static int Maximum(int a, int b);
|
|
||||||
// Next three assume 16 bit shorts and 32 bit longs
|
|
||||||
static long LongFromTwoShorts(short a,short b) {
|
|
||||||
return (a) | ((b) << 16);
|
return (a) | ((b) << 16);
|
||||||
}
|
}
|
||||||
static short HighShortFromLong(long x) {
|
|
||||||
return static_cast<short>(x >> 16);
|
|
||||||
}
|
|
||||||
static short LowShortFromLong(long x) {
|
|
||||||
return static_cast<short>(x & 0xffff);
|
|
||||||
}
|
|
||||||
static void DebugPrintf(const char *format, ...);
|
static void DebugPrintf(const char *format, ...);
|
||||||
static bool ShowAssertionPopUps(bool assertionPopUps_);
|
static bool ShowAssertionPopUps(bool assertionPopUps_);
|
||||||
static void Assert(const char *c, const char *file, int line) CLANG_ANALYZER_NORETURN;
|
static void Assert(const char *c, const char *file, int line) CLANG_ANALYZER_NORETURN;
|
||||||
static int Clamp(int val, int minVal, int maxVal);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
#define PLATFORM_ASSERT(c) ((void)0)
|
#define PLATFORM_ASSERT(c) ((void)0)
|
||||||
#else
|
#else
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
#define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Scintilla::Platform::Assert(#c, __FILE__, __LINE__))
|
#define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Scintilla::Platform::Assert(#c, __FILE__, __LINE__))
|
||||||
#else
|
|
||||||
#define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Platform::Assert(#c, __FILE__, __LINE__))
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -135,6 +135,8 @@
|
|||||||
#define SCLEX_JSON 120
|
#define SCLEX_JSON 120
|
||||||
#define SCLEX_EDIFACT 121
|
#define SCLEX_EDIFACT 121
|
||||||
#define SCLEX_INDENT 122
|
#define SCLEX_INDENT 122
|
||||||
|
#define SCLEX_MAXIMA 123
|
||||||
|
#define SCLEX_LPEG 999
|
||||||
#define SCLEX_AUTOMATIC 1000
|
#define SCLEX_AUTOMATIC 1000
|
||||||
#define SCE_P_DEFAULT 0
|
#define SCE_P_DEFAULT 0
|
||||||
#define SCE_P_COMMENTLINE 1
|
#define SCE_P_COMMENTLINE 1
|
||||||
@ -557,6 +559,10 @@
|
|||||||
#define SCE_DIFF_DELETED 5
|
#define SCE_DIFF_DELETED 5
|
||||||
#define SCE_DIFF_ADDED 6
|
#define SCE_DIFF_ADDED 6
|
||||||
#define SCE_DIFF_CHANGED 7
|
#define SCE_DIFF_CHANGED 7
|
||||||
|
#define SCE_DIFF_PATCH_ADD 8
|
||||||
|
#define SCE_DIFF_PATCH_DELETE 9
|
||||||
|
#define SCE_DIFF_REMOVED_PATCH_ADD 10
|
||||||
|
#define SCE_DIFF_REMOVED_PATCH_DELETE 11
|
||||||
#define SCE_CONF_DEFAULT 0
|
#define SCE_CONF_DEFAULT 0
|
||||||
#define SCE_CONF_COMMENT 1
|
#define SCE_CONF_COMMENT 1
|
||||||
#define SCE_CONF_NUMBER 2
|
#define SCE_CONF_NUMBER 2
|
||||||
@ -672,6 +678,14 @@
|
|||||||
#define SCE_MATLAB_OPERATOR 6
|
#define SCE_MATLAB_OPERATOR 6
|
||||||
#define SCE_MATLAB_IDENTIFIER 7
|
#define SCE_MATLAB_IDENTIFIER 7
|
||||||
#define SCE_MATLAB_DOUBLEQUOTESTRING 8
|
#define SCE_MATLAB_DOUBLEQUOTESTRING 8
|
||||||
|
#define SCE_MAXIMA_OPERATOR 0
|
||||||
|
#define SCE_MAXIMA_COMMANDENDING 1
|
||||||
|
#define SCE_MAXIMA_COMMENT 2
|
||||||
|
#define SCE_MAXIMA_NUMBER 3
|
||||||
|
#define SCE_MAXIMA_STRING 4
|
||||||
|
#define SCE_MAXIMA_COMMAND 5
|
||||||
|
#define SCE_MAXIMA_VARIABLE 6
|
||||||
|
#define SCE_MAXIMA_UNKNOWN 7
|
||||||
#define SCE_SCRIPTOL_DEFAULT 0
|
#define SCE_SCRIPTOL_DEFAULT 0
|
||||||
#define SCE_SCRIPTOL_WHITE 1
|
#define SCE_SCRIPTOL_WHITE 1
|
||||||
#define SCE_SCRIPTOL_COMMENTLINE 2
|
#define SCE_SCRIPTOL_COMMENTLINE 2
|
||||||
|
@ -9,13 +9,21 @@
|
|||||||
#ifndef SCI_POSITION_H
|
#ifndef SCI_POSITION_H
|
||||||
#define SCI_POSITION_H
|
#define SCI_POSITION_H
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
// Basic signed type used throughout interface
|
// Basic signed type used throughout interface
|
||||||
typedef int Sci_Position;
|
typedef ptrdiff_t Sci_Position;
|
||||||
|
|
||||||
// Unsigned variant used for ILexer::Lex and ILexer::Fold
|
// Unsigned variant used for ILexer::Lex and ILexer::Fold
|
||||||
typedef unsigned int Sci_PositionU;
|
typedef size_t Sci_PositionU;
|
||||||
|
|
||||||
// For Sci_CharacterRange which is defined as long to be compatible with Win32 CHARRANGE
|
// For Sci_CharacterRange which is defined as long to be compatible with Win32 CHARRANGE
|
||||||
typedef long Sci_PositionCR;
|
typedef long Sci_PositionCR;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define SCI_METHOD __stdcall
|
||||||
|
#else
|
||||||
|
#define SCI_METHOD
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -27,12 +27,7 @@ int Scintilla_LinkLexers(void);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Include header that defines basic numeric types.
|
// Include header that defines basic numeric types.
|
||||||
#if defined(_MSC_VER)
|
|
||||||
// Older releases of MSVC did not have stdint.h.
|
|
||||||
#include <stddef.h>
|
|
||||||
#else
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
// Define uptr_t, an unsigned integer type large enough to hold a pointer.
|
// Define uptr_t, an unsigned integer type large enough to hold a pointer.
|
||||||
typedef uintptr_t uptr_t;
|
typedef uintptr_t uptr_t;
|
||||||
@ -293,6 +288,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
|||||||
#define INDIC_TEXTFORE 17
|
#define INDIC_TEXTFORE 17
|
||||||
#define INDIC_POINT 18
|
#define INDIC_POINT 18
|
||||||
#define INDIC_POINTCHARACTER 19
|
#define INDIC_POINTCHARACTER 19
|
||||||
|
#define INDIC_GRADIENT 20
|
||||||
|
#define INDIC_GRADIENTCENTRE 21
|
||||||
#define INDIC_IME 32
|
#define INDIC_IME 32
|
||||||
#define INDIC_IME_MAX 35
|
#define INDIC_IME_MAX 35
|
||||||
#define INDIC_MAX 35
|
#define INDIC_MAX 35
|
||||||
@ -320,8 +317,6 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
|||||||
#define SCI_SETWHITESPACEBACK 2085
|
#define SCI_SETWHITESPACEBACK 2085
|
||||||
#define SCI_SETWHITESPACESIZE 2086
|
#define SCI_SETWHITESPACESIZE 2086
|
||||||
#define SCI_GETWHITESPACESIZE 2087
|
#define SCI_GETWHITESPACESIZE 2087
|
||||||
#define SCI_SETSTYLEBITS 2090
|
|
||||||
#define SCI_GETSTYLEBITS 2091
|
|
||||||
#define SCI_SETLINESTATE 2092
|
#define SCI_SETLINESTATE 2092
|
||||||
#define SCI_GETLINESTATE 2093
|
#define SCI_GETLINESTATE 2093
|
||||||
#define SCI_GETMAXLINESTATE 2094
|
#define SCI_GETMAXLINESTATE 2094
|
||||||
@ -397,6 +392,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
|||||||
#define SC_PRINT_BLACKONWHITE 2
|
#define SC_PRINT_BLACKONWHITE 2
|
||||||
#define SC_PRINT_COLOURONWHITE 3
|
#define SC_PRINT_COLOURONWHITE 3
|
||||||
#define SC_PRINT_COLOURONWHITEDEFAULTBG 4
|
#define SC_PRINT_COLOURONWHITEDEFAULTBG 4
|
||||||
|
#define SC_PRINT_SCREENCOLOURS 5
|
||||||
#define SCI_SETPRINTCOLOURMODE 2148
|
#define SCI_SETPRINTCOLOURMODE 2148
|
||||||
#define SCI_GETPRINTCOLOURMODE 2149
|
#define SCI_GETPRINTCOLOURMODE 2149
|
||||||
#define SCFIND_WHOLEWORD 0x2
|
#define SCFIND_WHOLEWORD 0x2
|
||||||
@ -552,6 +548,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
|||||||
#define SC_WRAPINDENT_FIXED 0
|
#define SC_WRAPINDENT_FIXED 0
|
||||||
#define SC_WRAPINDENT_SAME 1
|
#define SC_WRAPINDENT_SAME 1
|
||||||
#define SC_WRAPINDENT_INDENT 2
|
#define SC_WRAPINDENT_INDENT 2
|
||||||
|
#define SC_WRAPINDENT_DEEPINDENT 3
|
||||||
#define SCI_SETWRAPINDENTMODE 2472
|
#define SCI_SETWRAPINDENTMODE 2472
|
||||||
#define SCI_GETWRAPINDENTMODE 2473
|
#define SCI_GETWRAPINDENTMODE 2473
|
||||||
#define SC_CACHE_NONE 0
|
#define SC_CACHE_NONE 0
|
||||||
@ -693,9 +690,13 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
|||||||
#define SCI_SELECTIONISRECTANGLE 2372
|
#define SCI_SELECTIONISRECTANGLE 2372
|
||||||
#define SCI_SETZOOM 2373
|
#define SCI_SETZOOM 2373
|
||||||
#define SCI_GETZOOM 2374
|
#define SCI_GETZOOM 2374
|
||||||
|
#define SC_DOCUMENTOPTION_DEFAULT 0
|
||||||
|
#define SC_DOCUMENTOPTION_STYLES_NONE 0x1
|
||||||
|
#define SC_DOCUMENTOPTION_TEXT_LARGE 0x100
|
||||||
#define SCI_CREATEDOCUMENT 2375
|
#define SCI_CREATEDOCUMENT 2375
|
||||||
#define SCI_ADDREFDOCUMENT 2376
|
#define SCI_ADDREFDOCUMENT 2376
|
||||||
#define SCI_RELEASEDOCUMENT 2377
|
#define SCI_RELEASEDOCUMENT 2377
|
||||||
|
#define SCI_GETDOCUMENTOPTIONS 2379
|
||||||
#define SCI_GETMODEVENTMASK 2378
|
#define SCI_GETMODEVENTMASK 2378
|
||||||
#define SCI_SETFOCUS 2380
|
#define SCI_SETFOCUS 2380
|
||||||
#define SCI_GETFOCUS 2381
|
#define SCI_GETFOCUS 2381
|
||||||
@ -762,6 +763,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
|||||||
#define SC_SEL_THIN 3
|
#define SC_SEL_THIN 3
|
||||||
#define SCI_SETSELECTIONMODE 2422
|
#define SCI_SETSELECTIONMODE 2422
|
||||||
#define SCI_GETSELECTIONMODE 2423
|
#define SCI_GETSELECTIONMODE 2423
|
||||||
|
#define SCI_GETMOVEEXTENDSSELECTION 2706
|
||||||
#define SCI_GETLINESELSTARTPOSITION 2424
|
#define SCI_GETLINESELSTARTPOSITION 2424
|
||||||
#define SCI_GETLINESELENDPOSITION 2425
|
#define SCI_GETLINESELENDPOSITION 2425
|
||||||
#define SCI_LINEDOWNRECTEXTEND 2426
|
#define SCI_LINEDOWNRECTEXTEND 2426
|
||||||
@ -990,7 +992,6 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
|||||||
#define SCI_GETPROPERTY 4008
|
#define SCI_GETPROPERTY 4008
|
||||||
#define SCI_GETPROPERTYEXPANDED 4009
|
#define SCI_GETPROPERTYEXPANDED 4009
|
||||||
#define SCI_GETPROPERTYINT 4010
|
#define SCI_GETPROPERTYINT 4010
|
||||||
#define SCI_GETSTYLEBITSNEEDED 4011
|
|
||||||
#define SCI_GETLEXERLANGUAGE 4012
|
#define SCI_GETLEXERLANGUAGE 4012
|
||||||
#define SCI_PRIVATELEXERCALL 4013
|
#define SCI_PRIVATELEXERCALL 4013
|
||||||
#define SCI_PROPERTYNAMES 4014
|
#define SCI_PROPERTYNAMES 4014
|
||||||
@ -1010,6 +1011,10 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
|||||||
#define SCI_SETIDENTIFIERS 4024
|
#define SCI_SETIDENTIFIERS 4024
|
||||||
#define SCI_DISTANCETOSECONDARYSTYLES 4025
|
#define SCI_DISTANCETOSECONDARYSTYLES 4025
|
||||||
#define SCI_GETSUBSTYLEBASES 4026
|
#define SCI_GETSUBSTYLEBASES 4026
|
||||||
|
#define SCI_GETNAMEDSTYLES 4029
|
||||||
|
#define SCI_NAMEOFSTYLE 4030
|
||||||
|
#define SCI_TAGSOFSTYLE 4031
|
||||||
|
#define SCI_DESCRIPTIONOFSTYLE 4032
|
||||||
#define SC_MOD_INSERTTEXT 0x1
|
#define SC_MOD_INSERTTEXT 0x1
|
||||||
#define SC_MOD_DELETETEXT 0x2
|
#define SC_MOD_DELETETEXT 0x2
|
||||||
#define SC_MOD_CHANGESTYLE 0x4
|
#define SC_MOD_CHANGESTYLE 0x4
|
||||||
@ -1102,6 +1107,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam,
|
|||||||
#define SCN_FOCUSOUT 2029
|
#define SCN_FOCUSOUT 2029
|
||||||
#define SCN_AUTOCCOMPLETED 2030
|
#define SCN_AUTOCCOMPLETED 2030
|
||||||
#define SCN_MARGINRIGHTCLICK 2031
|
#define SCN_MARGINRIGHTCLICK 2031
|
||||||
|
#define SCN_AUTOCSELECTIONCHANGE 2032
|
||||||
/* --Autogenerated -- end of section automatically generated from Scintilla.iface */
|
/* --Autogenerated -- end of section automatically generated from Scintilla.iface */
|
||||||
|
|
||||||
/* These structures are defined to be exactly the same shape as the Win32
|
/* These structures are defined to be exactly the same shape as the Win32
|
||||||
@ -1210,6 +1216,10 @@ struct SCNotification {
|
|||||||
#define RangeToFormat Sci_RangeToFormat
|
#define RangeToFormat Sci_RangeToFormat
|
||||||
#define NotifyHeader Sci_NotifyHeader
|
#define NotifyHeader Sci_NotifyHeader
|
||||||
|
|
||||||
|
#define SCI_SETSTYLEBITS 2090
|
||||||
|
#define SCI_GETSTYLEBITS 2091
|
||||||
|
#define SCI_GETSTYLEBITSNEEDED 4011
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -639,6 +639,8 @@ val INDIC_FULLBOX=16
|
|||||||
val INDIC_TEXTFORE=17
|
val INDIC_TEXTFORE=17
|
||||||
val INDIC_POINT=18
|
val INDIC_POINT=18
|
||||||
val INDIC_POINTCHARACTER=19
|
val INDIC_POINTCHARACTER=19
|
||||||
|
val INDIC_GRADIENT=20
|
||||||
|
val INDIC_GRADIENTCENTRE=21
|
||||||
val INDIC_IME=32
|
val INDIC_IME=32
|
||||||
val INDIC_IME_MAX=35
|
val INDIC_IME_MAX=35
|
||||||
val INDIC_MAX=35
|
val INDIC_MAX=35
|
||||||
@ -702,14 +704,6 @@ set void SetWhitespaceSize=2086(int size,)
|
|||||||
# Get the size of the dots used to mark space characters.
|
# Get the size of the dots used to mark space characters.
|
||||||
get int GetWhitespaceSize=2087(,)
|
get int GetWhitespaceSize=2087(,)
|
||||||
|
|
||||||
# Divide each styling byte into lexical class bits (default: 5) and indicator
|
|
||||||
# bits (default: 3). If a lexer requires more than 32 lexical states, then this
|
|
||||||
# is used to expand the possible states.
|
|
||||||
set void SetStyleBits=2090(int bits,)
|
|
||||||
|
|
||||||
# Retrieve number of bits in style bytes used to hold the lexical state.
|
|
||||||
get int GetStyleBits=2091(,)
|
|
||||||
|
|
||||||
# Used to hold extra styling information for each line.
|
# Used to hold extra styling information for each line.
|
||||||
set void SetLineState=2092(int line, int state)
|
set void SetLineState=2092(int line, int state)
|
||||||
|
|
||||||
@ -930,6 +924,7 @@ get int GetPrintMagnification=2147(,)
|
|||||||
|
|
||||||
enu PrintOption=SC_PRINT_
|
enu PrintOption=SC_PRINT_
|
||||||
# PrintColourMode - use same colours as screen.
|
# PrintColourMode - use same colours as screen.
|
||||||
|
# with the exception of line number margins, which use a white background
|
||||||
val SC_PRINT_NORMAL=0
|
val SC_PRINT_NORMAL=0
|
||||||
# PrintColourMode - invert the light value of each style for printing.
|
# PrintColourMode - invert the light value of each style for printing.
|
||||||
val SC_PRINT_INVERTLIGHT=1
|
val SC_PRINT_INVERTLIGHT=1
|
||||||
@ -939,6 +934,8 @@ val SC_PRINT_BLACKONWHITE=2
|
|||||||
val SC_PRINT_COLOURONWHITE=3
|
val SC_PRINT_COLOURONWHITE=3
|
||||||
# PrintColourMode - only the default-background is forced to be white for printing.
|
# PrintColourMode - only the default-background is forced to be white for printing.
|
||||||
val SC_PRINT_COLOURONWHITEDEFAULTBG=4
|
val SC_PRINT_COLOURONWHITEDEFAULTBG=4
|
||||||
|
# PrintColourMode - use same colours as screen, including line number margins.
|
||||||
|
val SC_PRINT_SCREENCOLOURS=5
|
||||||
|
|
||||||
# Modify colours when printing for clearer printed text.
|
# Modify colours when printing for clearer printed text.
|
||||||
set void SetPrintColourMode=2148(int mode,)
|
set void SetPrintColourMode=2148(int mode,)
|
||||||
@ -997,7 +994,7 @@ fun int GetSelText=2161(, stringresult text)
|
|||||||
# Return the length of the text.
|
# Return the length of the text.
|
||||||
fun int GetTextRange=2162(, textrange tr)
|
fun int GetTextRange=2162(, textrange tr)
|
||||||
|
|
||||||
# Draw the selection in normal style or with selection highlighted.
|
# Draw the selection either highlighted or in normal (non-highlighted) style.
|
||||||
fun void HideSelection=2163(bool hide,)
|
fun void HideSelection=2163(bool hide,)
|
||||||
|
|
||||||
# Retrieve the x value of the point in the window where a position is displayed.
|
# Retrieve the x value of the point in the window where a position is displayed.
|
||||||
@ -1362,6 +1359,7 @@ enu WrapIndentMode=SC_WRAPINDENT_
|
|||||||
val SC_WRAPINDENT_FIXED=0
|
val SC_WRAPINDENT_FIXED=0
|
||||||
val SC_WRAPINDENT_SAME=1
|
val SC_WRAPINDENT_SAME=1
|
||||||
val SC_WRAPINDENT_INDENT=2
|
val SC_WRAPINDENT_INDENT=2
|
||||||
|
val SC_WRAPINDENT_DEEPINDENT=3
|
||||||
|
|
||||||
# Sets how wrapped sublines are placed. Default is fixed.
|
# Sets how wrapped sublines are placed. Default is fixed.
|
||||||
set void SetWrapIndentMode=2472(int wrapIndentMode,)
|
set void SetWrapIndentMode=2472(int wrapIndentMode,)
|
||||||
@ -1786,14 +1784,22 @@ set void SetZoom=2373(int zoomInPoints,)
|
|||||||
# Retrieve the zoom level.
|
# Retrieve the zoom level.
|
||||||
get int GetZoom=2374(,)
|
get int GetZoom=2374(,)
|
||||||
|
|
||||||
|
enu DocumentOption=SC_DOCUMENTOPTION_
|
||||||
|
val SC_DOCUMENTOPTION_DEFAULT=0
|
||||||
|
val SC_DOCUMENTOPTION_STYLES_NONE=0x1
|
||||||
|
val SC_DOCUMENTOPTION_TEXT_LARGE=0x100
|
||||||
|
|
||||||
# Create a new document object.
|
# Create a new document object.
|
||||||
# Starts with reference count of 1 and not selected into editor.
|
# Starts with reference count of 1 and not selected into editor.
|
||||||
fun int CreateDocument=2375(,)
|
fun int CreateDocument=2375(int bytes, int documentOptions)
|
||||||
# Extend life of document.
|
# Extend life of document.
|
||||||
fun void AddRefDocument=2376(, int doc)
|
fun void AddRefDocument=2376(, int doc)
|
||||||
# Release a reference to the document, deleting document if it fades to black.
|
# Release a reference to the document, deleting document if it fades to black.
|
||||||
fun void ReleaseDocument=2377(, int doc)
|
fun void ReleaseDocument=2377(, int doc)
|
||||||
|
|
||||||
|
# Get which document options are set.
|
||||||
|
get int GetDocumentOptions=2379(,)
|
||||||
|
|
||||||
# Get which document modification events are sent to the container.
|
# Get which document modification events are sent to the container.
|
||||||
get int GetModEventMask=2378(,)
|
get int GetModEventMask=2378(,)
|
||||||
|
|
||||||
@ -1979,6 +1985,9 @@ set void SetSelectionMode=2422(int selectionMode,)
|
|||||||
# Get the mode of the current selection.
|
# Get the mode of the current selection.
|
||||||
get int GetSelectionMode=2423(,)
|
get int GetSelectionMode=2423(,)
|
||||||
|
|
||||||
|
# Get whether or not regular caret moves will extend or reduce the selection.
|
||||||
|
get bool GetMoveExtendsSelection=2706(,)
|
||||||
|
|
||||||
# Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line).
|
# Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line).
|
||||||
fun position GetLineSelStartPosition=2424(int line,)
|
fun position GetLineSelStartPosition=2424(int line,)
|
||||||
|
|
||||||
@ -2552,7 +2561,7 @@ set void SetTechnology=2630(int technology,)
|
|||||||
get int GetTechnology=2631(,)
|
get int GetTechnology=2631(,)
|
||||||
|
|
||||||
# Create an ILoader*.
|
# Create an ILoader*.
|
||||||
fun int CreateLoader=2632(int bytes,)
|
fun int CreateLoader=2632(int bytes, int documentOptions)
|
||||||
|
|
||||||
# On OS X, show a find indicator.
|
# On OS X, show a find indicator.
|
||||||
fun void FindIndicatorShow=2640(position start, position end)
|
fun void FindIndicatorShow=2640(position start, position end)
|
||||||
@ -2645,9 +2654,6 @@ get int GetPropertyExpanded=4009(string key, stringresult value)
|
|||||||
# interpreted as an int AFTER any "$()" variable replacement.
|
# interpreted as an int AFTER any "$()" variable replacement.
|
||||||
get int GetPropertyInt=4010(string key, int defaultValue)
|
get int GetPropertyInt=4010(string key, int defaultValue)
|
||||||
|
|
||||||
# Retrieve the number of bits the current lexer needs for styling.
|
|
||||||
get int GetStyleBitsNeeded=4011(,)
|
|
||||||
|
|
||||||
# Retrieve the name of the lexer.
|
# Retrieve the name of the lexer.
|
||||||
# Return the length of the text.
|
# Return the length of the text.
|
||||||
# Result is NUL-terminated.
|
# Result is NUL-terminated.
|
||||||
@ -2709,6 +2715,21 @@ get int DistanceToSecondaryStyles=4025(,)
|
|||||||
# Result is NUL-terminated.
|
# Result is NUL-terminated.
|
||||||
get int GetSubStyleBases=4026(, stringresult styles)
|
get int GetSubStyleBases=4026(, stringresult styles)
|
||||||
|
|
||||||
|
# Retrieve the number of named styles for the lexer.
|
||||||
|
get int GetNamedStyles=4029(,)
|
||||||
|
|
||||||
|
# Retrieve the name of a style.
|
||||||
|
# Result is NUL-terminated.
|
||||||
|
fun int NameOfStyle=4030(int style, stringresult name)
|
||||||
|
|
||||||
|
# Retrieve a ' ' separated list of style tags like "literal quoted string".
|
||||||
|
# Result is NUL-terminated.
|
||||||
|
fun int TagsOfStyle=4031(int style, stringresult tags)
|
||||||
|
|
||||||
|
# Retrieve a description of a style.
|
||||||
|
# Result is NUL-terminated.
|
||||||
|
fun int DescriptionOfStyle=4032(int style, stringresult description)
|
||||||
|
|
||||||
# Notifications
|
# Notifications
|
||||||
# Type of modification and the action which caused the modification.
|
# Type of modification and the action which caused the modification.
|
||||||
# These are defined as a bit mask to make it easy to specify which notifications are wanted.
|
# These are defined as a bit mask to make it easy to specify which notifications are wanted.
|
||||||
@ -2917,6 +2938,8 @@ val SCLEX_TEHEX=119
|
|||||||
val SCLEX_JSON=120
|
val SCLEX_JSON=120
|
||||||
val SCLEX_EDIFACT=121
|
val SCLEX_EDIFACT=121
|
||||||
val SCLEX_INDENT=122
|
val SCLEX_INDENT=122
|
||||||
|
val SCLEX_MAXIMA=123
|
||||||
|
val SCLEX_LPEG=999
|
||||||
|
|
||||||
# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
|
# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
|
||||||
# value assigned in sequence from SCLEX_AUTOMATIC+1.
|
# value assigned in sequence from SCLEX_AUTOMATIC+1.
|
||||||
@ -2944,7 +2967,11 @@ val SCE_P_FSTRING=16
|
|||||||
val SCE_P_FCHARACTER=17
|
val SCE_P_FCHARACTER=17
|
||||||
val SCE_P_FTRIPLE=18
|
val SCE_P_FTRIPLE=18
|
||||||
val SCE_P_FTRIPLEDOUBLE=19
|
val SCE_P_FTRIPLEDOUBLE=19
|
||||||
# Lexical states for SCLEX_CPP, SCLEX_BULLANT, SCLEX_COBOL, SCLEX_TACL, SCLEX_TAL
|
# Lexical states for SCLEX_CPP
|
||||||
|
# Lexical states for SCLEX_BULLANT
|
||||||
|
# Lexical states for SCLEX_COBOL
|
||||||
|
# Lexical states for SCLEX_TACL
|
||||||
|
# Lexical states for SCLEX_TAL
|
||||||
lex Cpp=SCLEX_CPP SCE_C_
|
lex Cpp=SCLEX_CPP SCE_C_
|
||||||
lex BullAnt=SCLEX_BULLANT SCE_C_
|
lex BullAnt=SCLEX_BULLANT SCE_C_
|
||||||
lex COBOL=SCLEX_COBOL SCE_C_
|
lex COBOL=SCLEX_COBOL SCE_C_
|
||||||
@ -3397,6 +3424,10 @@ val SCE_DIFF_POSITION=4
|
|||||||
val SCE_DIFF_DELETED=5
|
val SCE_DIFF_DELETED=5
|
||||||
val SCE_DIFF_ADDED=6
|
val SCE_DIFF_ADDED=6
|
||||||
val SCE_DIFF_CHANGED=7
|
val SCE_DIFF_CHANGED=7
|
||||||
|
val SCE_DIFF_PATCH_ADD=8
|
||||||
|
val SCE_DIFF_PATCH_DELETE=9
|
||||||
|
val SCE_DIFF_REMOVED_PATCH_ADD=10
|
||||||
|
val SCE_DIFF_REMOVED_PATCH_DELETE=11
|
||||||
# Lexical states for SCLEX_CONF (Apache Configuration Files Lexer)
|
# Lexical states for SCLEX_CONF (Apache Configuration Files Lexer)
|
||||||
lex Conf=SCLEX_CONF SCE_CONF_
|
lex Conf=SCLEX_CONF SCE_CONF_
|
||||||
val SCE_CONF_DEFAULT=0
|
val SCE_CONF_DEFAULT=0
|
||||||
@ -3532,6 +3563,16 @@ val SCE_MATLAB_STRING=5
|
|||||||
val SCE_MATLAB_OPERATOR=6
|
val SCE_MATLAB_OPERATOR=6
|
||||||
val SCE_MATLAB_IDENTIFIER=7
|
val SCE_MATLAB_IDENTIFIER=7
|
||||||
val SCE_MATLAB_DOUBLEQUOTESTRING=8
|
val SCE_MATLAB_DOUBLEQUOTESTRING=8
|
||||||
|
# Lexical states for SCLEX_MAXIMA
|
||||||
|
lex Maxima=SCLEX_MAXIMA SCE_MAXIMA_
|
||||||
|
val SCE_MAXIMA_OPERATOR=0
|
||||||
|
val SCE_MAXIMA_COMMANDENDING=1
|
||||||
|
val SCE_MAXIMA_COMMENT=2
|
||||||
|
val SCE_MAXIMA_NUMBER=3
|
||||||
|
val SCE_MAXIMA_STRING=4
|
||||||
|
val SCE_MAXIMA_COMMAND=5
|
||||||
|
val SCE_MAXIMA_VARIABLE=6
|
||||||
|
val SCE_MAXIMA_UNKNOWN=7
|
||||||
# Lexical states for SCLEX_SCRIPTOL
|
# Lexical states for SCLEX_SCRIPTOL
|
||||||
lex Sol=SCLEX_SCRIPTOL SCE_SCRIPTOL_
|
lex Sol=SCLEX_SCRIPTOL SCE_SCRIPTOL_
|
||||||
val SCE_SCRIPTOL_DEFAULT=0
|
val SCE_SCRIPTOL_DEFAULT=0
|
||||||
@ -4855,13 +4896,25 @@ evt void FocusIn=2028(void)
|
|||||||
evt void FocusOut=2029(void)
|
evt void FocusOut=2029(void)
|
||||||
evt void AutoCCompleted=2030(string text, int position, int ch, CompletionMethods listCompletionMethod)
|
evt void AutoCCompleted=2030(string text, int position, int ch, CompletionMethods listCompletionMethod)
|
||||||
evt void MarginRightClick=2031(int modifiers, int position, int margin)
|
evt void MarginRightClick=2031(int modifiers, int position, int margin)
|
||||||
|
evt void AutoCSelectionChange=2032(int listType, string text, int position)
|
||||||
|
|
||||||
# There are no provisional APIs currently, but some arguments to SCI_SETTECHNOLOGY are provisional.
|
# There are no provisional APIs currently.
|
||||||
|
|
||||||
cat Provisional
|
cat Provisional
|
||||||
|
|
||||||
cat Deprecated
|
cat Deprecated
|
||||||
|
|
||||||
|
# Divide each styling byte into lexical class bits (default: 5) and indicator
|
||||||
|
# bits (default: 3). If a lexer requires more than 32 lexical states, then this
|
||||||
|
# is used to expand the possible states.
|
||||||
|
set void SetStyleBits=2090(int bits,)
|
||||||
|
|
||||||
|
# Retrieve number of bits in style bytes used to hold the lexical state.
|
||||||
|
get int GetStyleBits=2091(,)
|
||||||
|
|
||||||
|
# Retrieve the number of bits the current lexer needs for styling.
|
||||||
|
get int GetStyleBitsNeeded=4011(,)
|
||||||
|
|
||||||
# Deprecated in 3.5.5
|
# Deprecated in 3.5.5
|
||||||
|
|
||||||
# Always interpret keyboard input as Unicode
|
# Always interpret keyboard input as Unicode
|
||||||
|
@ -26,9 +26,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline bool IsAKeywordChar(const int ch) {
|
static inline bool IsAKeywordChar(const int ch) {
|
||||||
return (ch < 0x80 && (isalnum(ch) || (ch == '_') || (ch == ' ')));
|
return (ch < 0x80 && (isalnum(ch) || (ch == '_') || (ch == ' ')));
|
||||||
|
@ -25,9 +25,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Interface
|
* Interface
|
||||||
|
@ -30,10 +30,9 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
#include "OptionSet.h"
|
#include "OptionSet.h"
|
||||||
|
#include "DefaultLexer.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline bool IsAWordChar(const int ch) {
|
static inline bool IsAWordChar(const int ch) {
|
||||||
return (ch < 0x80) && (isalnum(ch) || ch == '.' ||
|
return (ch < 0x80) && (isalnum(ch) || ch == '.' ||
|
||||||
@ -139,7 +138,7 @@ struct OptionSetAsm : public OptionSet<OptionsAsm> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class LexerAsm : public ILexer {
|
class LexerAsm : public DefaultLexer {
|
||||||
WordList cpuInstruction;
|
WordList cpuInstruction;
|
||||||
WordList mathInstruction;
|
WordList mathInstruction;
|
||||||
WordList registers;
|
WordList registers;
|
||||||
|
@ -23,9 +23,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
#define HERE_DELIM_MAX 256
|
#define HERE_DELIM_MAX 256
|
||||||
|
|
||||||
|
@ -37,10 +37,9 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
#include "OptionSet.h"
|
#include "OptionSet.h"
|
||||||
|
#include "DefaultLexer.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Bits:
|
/* Bits:
|
||||||
* 1 - whitespace
|
* 1 - whitespace
|
||||||
@ -226,7 +225,7 @@ struct OptionSetBasic : public OptionSet<OptionsBasic> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class LexerBasic : public ILexer {
|
class LexerBasic : public DefaultLexer {
|
||||||
char comment_char;
|
char comment_char;
|
||||||
int (*CheckFoldPoint)(char const *, int &);
|
int (*CheckFoldPoint)(char const *, int &);
|
||||||
WordList keywordlists[4];
|
WordList keywordlists[4];
|
||||||
|
@ -23,9 +23,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
static bool Is0To9(char ch) {
|
static bool Is0To9(char ch) {
|
||||||
return (ch >= '0') && (ch <= '9');
|
return (ch >= '0') && (ch <= '9');
|
||||||
|
@ -26,9 +26,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
#define IN_DIVISION 0x01
|
#define IN_DIVISION 0x01
|
||||||
#define IN_DECLARATIVES 0x02
|
#define IN_DECLARATIVES 0x02
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include <utility>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
@ -22,6 +23,7 @@
|
|||||||
#include "Scintilla.h"
|
#include "Scintilla.h"
|
||||||
#include "SciLexer.h"
|
#include "SciLexer.h"
|
||||||
|
|
||||||
|
#include "StringCopy.h"
|
||||||
#include "WordList.h"
|
#include "WordList.h"
|
||||||
#include "LexAccessor.h"
|
#include "LexAccessor.h"
|
||||||
#include "Accessor.h"
|
#include "Accessor.h"
|
||||||
@ -32,14 +34,12 @@
|
|||||||
#include "SparseState.h"
|
#include "SparseState.h"
|
||||||
#include "SubStyles.h"
|
#include "SubStyles.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace {
|
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
|
||||||
|
|
||||||
bool IsSpaceEquiv(int state) {
|
bool IsSpaceEquiv(int state) noexcept {
|
||||||
return (state <= SCE_C_COMMENTDOC) ||
|
return (state <= SCE_C_COMMENTDOC) ||
|
||||||
// including SCE_C_DEFAULT, SCE_C_COMMENT, SCE_C_COMMENTLINE
|
// including SCE_C_DEFAULT, SCE_C_COMMENT, SCE_C_COMMENTLINE
|
||||||
(state == SCE_C_COMMENTLINEDOC) || (state == SCE_C_COMMENTDOCKEYWORD) ||
|
(state == SCE_C_COMMENTLINEDOC) || (state == SCE_C_COMMENTDOCKEYWORD) ||
|
||||||
@ -53,8 +53,8 @@ bool IsSpaceEquiv(int state) {
|
|||||||
// a = b+++/ptn/...
|
// a = b+++/ptn/...
|
||||||
// Putting a space between the '++' post-inc operator and the '+' binary op
|
// Putting a space between the '++' post-inc operator and the '+' binary op
|
||||||
// fixes this, and is highly recommended for readability anyway.
|
// fixes this, and is highly recommended for readability anyway.
|
||||||
bool FollowsPostfixOperator(StyleContext &sc, LexAccessor &styler) {
|
bool FollowsPostfixOperator(const StyleContext &sc, LexAccessor &styler) {
|
||||||
Sci_Position pos = static_cast<Sci_Position>(sc.currentPos);
|
Sci_Position pos = sc.currentPos;
|
||||||
while (--pos > 0) {
|
while (--pos > 0) {
|
||||||
const char ch = styler[pos];
|
const char ch = styler[pos];
|
||||||
if (ch == '+' || ch == '-') {
|
if (ch == '+' || ch == '-') {
|
||||||
@ -64,10 +64,10 @@ bool FollowsPostfixOperator(StyleContext &sc, LexAccessor &styler) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool followsReturnKeyword(StyleContext &sc, LexAccessor &styler) {
|
bool followsReturnKeyword(const StyleContext &sc, LexAccessor &styler) {
|
||||||
// Don't look at styles, so no need to flush.
|
// Don't look at styles, so no need to flush.
|
||||||
Sci_Position pos = static_cast<Sci_Position>(sc.currentPos);
|
Sci_Position pos = sc.currentPos;
|
||||||
Sci_Position currentLine = styler.GetLine(pos);
|
const Sci_Position currentLine = styler.GetLine(pos);
|
||||||
const Sci_Position lineStartPos = styler.LineStart(currentLine);
|
const Sci_Position lineStartPos = styler.LineStart(currentLine);
|
||||||
while (--pos > lineStartPos) {
|
while (--pos > lineStartPos) {
|
||||||
const char ch = styler.SafeGetCharAt(pos);
|
const char ch = styler.SafeGetCharAt(pos);
|
||||||
@ -86,11 +86,11 @@ bool followsReturnKeyword(StyleContext &sc, LexAccessor &styler) {
|
|||||||
return !*s;
|
return !*s;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsSpaceOrTab(int ch) {
|
bool IsSpaceOrTab(int ch) noexcept {
|
||||||
return ch == ' ' || ch == '\t';
|
return ch == ' ' || ch == '\t';
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OnlySpaceOrTab(const std::string &s) {
|
bool OnlySpaceOrTab(const std::string &s) noexcept {
|
||||||
for (const char ch : s) {
|
for (const char ch : s) {
|
||||||
if (!IsSpaceOrTab(ch))
|
if (!IsSpaceOrTab(ch))
|
||||||
return false;
|
return false;
|
||||||
@ -102,7 +102,7 @@ std::vector<std::string> StringSplit(const std::string &text, int separator) {
|
|||||||
std::vector<std::string> vs(text.empty() ? 0 : 1);
|
std::vector<std::string> vs(text.empty() ? 0 : 1);
|
||||||
for (const char ch : text) {
|
for (const char ch : text) {
|
||||||
if (ch == separator) {
|
if (ch == separator) {
|
||||||
vs.push_back(std::string());
|
vs.emplace_back();
|
||||||
} else {
|
} else {
|
||||||
vs.back() += ch;
|
vs.back() += ch;
|
||||||
}
|
}
|
||||||
@ -144,8 +144,8 @@ void highlightTaskMarker(StyleContext &sc, LexAccessor &styler,
|
|||||||
int activity, const WordList &markerList, bool caseSensitive){
|
int activity, const WordList &markerList, bool caseSensitive){
|
||||||
if ((isoperator(sc.chPrev) || IsASpace(sc.chPrev)) && markerList.Length()) {
|
if ((isoperator(sc.chPrev) || IsASpace(sc.chPrev)) && markerList.Length()) {
|
||||||
const int lengthMarker = 50;
|
const int lengthMarker = 50;
|
||||||
char marker[lengthMarker+1];
|
char marker[lengthMarker+1] = "";
|
||||||
Sci_Position currPos = static_cast<Sci_Position>(sc.currentPos);
|
const Sci_Position currPos = static_cast<Sci_Position>(sc.currentPos);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < lengthMarker) {
|
while (i < lengthMarker) {
|
||||||
const char ch = styler.SafeGetCharAt(currPos + i);
|
const char ch = styler.SafeGetCharAt(currPos + i);
|
||||||
@ -155,7 +155,7 @@ void highlightTaskMarker(StyleContext &sc, LexAccessor &styler,
|
|||||||
if (caseSensitive)
|
if (caseSensitive)
|
||||||
marker[i] = ch;
|
marker[i] = ch;
|
||||||
else
|
else
|
||||||
marker[i] = static_cast<char>(tolower(ch));
|
marker[i] = MakeLowerCase(ch);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
marker[i] = '\0';
|
marker[i] = '\0';
|
||||||
@ -216,7 +216,7 @@ std::string GetRestOfLine(LexAccessor &styler, Sci_Position start, bool allowSpa
|
|||||||
return restOfLine;
|
return restOfLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsStreamCommentStyle(int style) {
|
bool IsStreamCommentStyle(int style) noexcept {
|
||||||
return style == SCE_C_COMMENT ||
|
return style == SCE_C_COMMENT ||
|
||||||
style == SCE_C_COMMENTDOC ||
|
style == SCE_C_COMMENTDOC ||
|
||||||
style == SCE_C_COMMENTDOCKEYWORD ||
|
style == SCE_C_COMMENTDOCKEYWORD ||
|
||||||
@ -238,22 +238,22 @@ class LinePPState {
|
|||||||
int state;
|
int state;
|
||||||
int ifTaken;
|
int ifTaken;
|
||||||
int level;
|
int level;
|
||||||
bool ValidLevel() const {
|
bool ValidLevel() const noexcept {
|
||||||
return level >= 0 && level < 32;
|
return level >= 0 && level < 32;
|
||||||
}
|
}
|
||||||
int maskLevel() const {
|
int maskLevel() const noexcept {
|
||||||
return 1 << level;
|
return 1 << level;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
LinePPState() : state(0), ifTaken(0), level(-1) {
|
LinePPState() : state(0), ifTaken(0), level(-1) {
|
||||||
}
|
}
|
||||||
bool IsInactive() const {
|
bool IsInactive() const noexcept {
|
||||||
return state != 0;
|
return state != 0;
|
||||||
}
|
}
|
||||||
bool CurrentIfTaken() const {
|
bool CurrentIfTaken() const noexcept {
|
||||||
return (ifTaken & maskLevel()) != 0;
|
return (ifTaken & maskLevel()) != 0;
|
||||||
}
|
}
|
||||||
void StartSection(bool on) {
|
void StartSection(bool on) noexcept {
|
||||||
level++;
|
level++;
|
||||||
if (ValidLevel()) {
|
if (ValidLevel()) {
|
||||||
if (on) {
|
if (on) {
|
||||||
@ -265,14 +265,14 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void EndSection() {
|
void EndSection() noexcept {
|
||||||
if (ValidLevel()) {
|
if (ValidLevel()) {
|
||||||
state &= ~maskLevel();
|
state &= ~maskLevel();
|
||||||
ifTaken &= ~maskLevel();
|
ifTaken &= ~maskLevel();
|
||||||
}
|
}
|
||||||
level--;
|
level--;
|
||||||
}
|
}
|
||||||
void InvertCurrentLevel() {
|
void InvertCurrentLevel() noexcept {
|
||||||
if (ValidLevel()) {
|
if (ValidLevel()) {
|
||||||
state ^= maskLevel();
|
state ^= maskLevel();
|
||||||
ifTaken |= maskLevel();
|
ifTaken |= maskLevel();
|
||||||
@ -432,9 +432,41 @@ struct OptionSetCPP : public OptionSet<OptionsCPP> {
|
|||||||
|
|
||||||
const char styleSubable[] = {SCE_C_IDENTIFIER, SCE_C_COMMENTDOCKEYWORD, 0};
|
const char styleSubable[] = {SCE_C_IDENTIFIER, SCE_C_COMMENTDOCKEYWORD, 0};
|
||||||
|
|
||||||
|
LexicalClass lexicalClasses[] = {
|
||||||
|
// Lexer Cpp SCLEX_CPP SCE_C_:
|
||||||
|
0, "SCE_C_DEFAULT", "default", "White space",
|
||||||
|
1, "SCE_C_COMMENT", "comment", "Comment: /* */.",
|
||||||
|
2, "SCE_C_COMMENTLINE", "comment line", "Line Comment: //.",
|
||||||
|
3, "SCE_C_COMMENTDOC", "comment documentation", "Doc comment: block comments beginning with /** or /*!",
|
||||||
|
4, "SCE_C_NUMBER", "literal numeric", "Number",
|
||||||
|
5, "SCE_C_WORD", "keyword", "Keyword",
|
||||||
|
6, "SCE_C_STRING", "literal string", "Double quoted string",
|
||||||
|
7, "SCE_C_CHARACTER", "literal string character", "Single quoted string",
|
||||||
|
8, "SCE_C_UUID", "literal uuid", "UUIDs (only in IDL)",
|
||||||
|
9, "SCE_C_PREPROCESSOR", "preprocessor", "Preprocessor",
|
||||||
|
10, "SCE_C_OPERATOR", "operator", "Operators",
|
||||||
|
11, "SCE_C_IDENTIFIER", "identifier", "Identifiers",
|
||||||
|
12, "SCE_C_STRINGEOL", "error literal string", "End of line where string is not closed",
|
||||||
|
13, "SCE_C_VERBATIM", "literal string multiline raw", "Verbatim strings for C#",
|
||||||
|
14, "SCE_C_REGEX", "literal regex", "Regular expressions for JavaScript",
|
||||||
|
15, "SCE_C_COMMENTLINEDOC", "comment documentation line", "Doc Comment Line: line comments beginning with /// or //!.",
|
||||||
|
16, "SCE_C_WORD2", "identifier", "Keywords2",
|
||||||
|
17, "SCE_C_COMMENTDOCKEYWORD", "comment documentation keyword", "Comment keyword",
|
||||||
|
18, "SCE_C_COMMENTDOCKEYWORDERROR", "error comment documentation keyword", "Comment keyword error",
|
||||||
|
19, "SCE_C_GLOBALCLASS", "identifier", "Global class",
|
||||||
|
20, "SCE_C_STRINGRAW", "literal string multiline raw", "Raw strings for C++0x",
|
||||||
|
21, "SCE_C_TRIPLEVERBATIM", "literal string multiline raw", "Triple-quoted strings for Vala",
|
||||||
|
22, "SCE_C_HASHQUOTEDSTRING", "literal string", "Hash-quoted strings for Pike",
|
||||||
|
23, "SCE_C_PREPROCESSORCOMMENT", "comment preprocessor", "Preprocessor stream comment",
|
||||||
|
24, "SCE_C_PREPROCESSORCOMMENTDOC", "comment preprocessor documentation", "Preprocessor stream doc comment",
|
||||||
|
25, "SCE_C_USERLITERAL", "literal", "User defined literals",
|
||||||
|
26, "SCE_C_TASKMARKER", "comment taskmarker", "Task Marker",
|
||||||
|
27, "SCE_C_ESCAPESEQUENCE", "literal string escapesequence", "Escape sequence",
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LexerCPP : public ILexerWithSubStyles {
|
class LexerCPP : public ILexerWithMetaData {
|
||||||
bool caseSensitive;
|
bool caseSensitive;
|
||||||
CharacterSet setWord;
|
CharacterSet setWord;
|
||||||
CharacterSet setNegationOp;
|
CharacterSet setNegationOp;
|
||||||
@ -460,7 +492,7 @@ class LexerCPP : public ILexerWithSubStyles {
|
|||||||
arguments.clear();
|
arguments.clear();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
bool IsMacro() const {
|
bool IsMacro() const noexcept {
|
||||||
return !arguments.empty();
|
return !arguments.empty();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -473,6 +505,7 @@ class LexerCPP : public ILexerWithSubStyles {
|
|||||||
enum { activeFlag = 0x40 };
|
enum { activeFlag = 0x40 };
|
||||||
enum { ssIdentifier, ssDocKeyword };
|
enum { ssIdentifier, ssDocKeyword };
|
||||||
SubStyles subStyles;
|
SubStyles subStyles;
|
||||||
|
std::string returnBuffer;
|
||||||
public:
|
public:
|
||||||
explicit LexerCPP(bool caseSensitive_) :
|
explicit LexerCPP(bool caseSensitive_) :
|
||||||
caseSensitive(caseSensitive_),
|
caseSensitive(caseSensitive_),
|
||||||
@ -489,7 +522,7 @@ public:
|
|||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
int SCI_METHOD Version() const override {
|
int SCI_METHOD Version() const override {
|
||||||
return lvSubStyles;
|
return lvMetaData;
|
||||||
}
|
}
|
||||||
const char * SCI_METHOD PropertyNames() override {
|
const char * SCI_METHOD PropertyNames() override {
|
||||||
return osCPP.PropertyNames();
|
return osCPP.PropertyNames();
|
||||||
@ -532,7 +565,7 @@ public:
|
|||||||
}
|
}
|
||||||
int SCI_METHOD PrimaryStyleFromStyle(int style) override {
|
int SCI_METHOD PrimaryStyleFromStyle(int style) override {
|
||||||
return MaskActive(style);
|
return MaskActive(style);
|
||||||
}
|
}
|
||||||
void SCI_METHOD FreeSubStyles() override {
|
void SCI_METHOD FreeSubStyles() override {
|
||||||
subStyles.Free();
|
subStyles.Free();
|
||||||
}
|
}
|
||||||
@ -545,6 +578,59 @@ public:
|
|||||||
const char * SCI_METHOD GetSubStyleBases() override {
|
const char * SCI_METHOD GetSubStyleBases() override {
|
||||||
return styleSubable;
|
return styleSubable;
|
||||||
}
|
}
|
||||||
|
int SCI_METHOD NamedStyles() override {
|
||||||
|
return std::max(subStyles.LastAllocated() + 1,
|
||||||
|
static_cast<int>(ELEMENTS(lexicalClasses))) +
|
||||||
|
activeFlag;
|
||||||
|
}
|
||||||
|
const char * SCI_METHOD NameOfStyle(int style) override {
|
||||||
|
if (style >= NamedStyles())
|
||||||
|
return "";
|
||||||
|
if (style < static_cast<int>(ELEMENTS(lexicalClasses)))
|
||||||
|
return lexicalClasses[style].name;
|
||||||
|
// TODO: inactive and substyles
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
const char * SCI_METHOD TagsOfStyle(int style) override {
|
||||||
|
if (style >= NamedStyles())
|
||||||
|
return "Excess";
|
||||||
|
returnBuffer.clear();
|
||||||
|
const int firstSubStyle = subStyles.FirstAllocated();
|
||||||
|
if (firstSubStyle >= 0) {
|
||||||
|
const int lastSubStyle = subStyles.LastAllocated();
|
||||||
|
if (((style >= firstSubStyle) && (style <= (lastSubStyle))) ||
|
||||||
|
((style >= firstSubStyle + activeFlag) && (style <= (lastSubStyle + activeFlag)))) {
|
||||||
|
int styleActive = style;
|
||||||
|
if (style > lastSubStyle) {
|
||||||
|
returnBuffer = "inactive ";
|
||||||
|
styleActive -= activeFlag;
|
||||||
|
}
|
||||||
|
const int styleMain = StyleFromSubStyle(styleActive);
|
||||||
|
returnBuffer += lexicalClasses[styleMain].tags;
|
||||||
|
return returnBuffer.c_str();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (style < static_cast<int>(ELEMENTS(lexicalClasses)))
|
||||||
|
return lexicalClasses[style].tags;
|
||||||
|
if (style >= activeFlag) {
|
||||||
|
returnBuffer = "inactive ";
|
||||||
|
const int styleActive = style - activeFlag;
|
||||||
|
if (styleActive < static_cast<int>(ELEMENTS(lexicalClasses)))
|
||||||
|
returnBuffer += lexicalClasses[styleActive].tags;
|
||||||
|
else
|
||||||
|
returnBuffer = "";
|
||||||
|
return returnBuffer.c_str();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
const char * SCI_METHOD DescriptionOfStyle(int style) override {
|
||||||
|
if (style >= NamedStyles())
|
||||||
|
return "";
|
||||||
|
if (style < static_cast<int>(ELEMENTS(lexicalClasses)))
|
||||||
|
return lexicalClasses[style].description;
|
||||||
|
// TODO: inactive and substyles
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
static ILexer *LexerFactoryCPP() {
|
static ILexer *LexerFactoryCPP() {
|
||||||
return new LexerCPP(true);
|
return new LexerCPP(true);
|
||||||
@ -552,7 +638,7 @@ public:
|
|||||||
static ILexer *LexerFactoryCPPInsensitive() {
|
static ILexer *LexerFactoryCPPInsensitive() {
|
||||||
return new LexerCPP(false);
|
return new LexerCPP(false);
|
||||||
}
|
}
|
||||||
static int MaskActive(int style) {
|
static int MaskActive(int style) noexcept {
|
||||||
return style & ~activeFlag;
|
return style & ~activeFlag;
|
||||||
}
|
}
|
||||||
void EvaluateTokens(std::vector<std::string> &tokens, const SymbolTable &preprocessorDefinitions);
|
void EvaluateTokens(std::vector<std::string> &tokens, const SymbolTable &preprocessorDefinitions);
|
||||||
@ -611,8 +697,8 @@ Sci_Position SCI_METHOD LexerCPP::WordListSet(int n, const char *wl) {
|
|||||||
if (cpEquals) {
|
if (cpEquals) {
|
||||||
std::string name(cpDefinition, cpEquals - cpDefinition);
|
std::string name(cpDefinition, cpEquals - cpDefinition);
|
||||||
std::string val(cpEquals+1);
|
std::string val(cpEquals+1);
|
||||||
size_t bracket = name.find('(');
|
const size_t bracket = name.find('(');
|
||||||
size_t bracketEnd = name.find(')');
|
const size_t bracketEnd = name.find(')');
|
||||||
if ((bracket != std::string::npos) && (bracketEnd != std::string::npos)) {
|
if ((bracket != std::string::npos) && (bracketEnd != std::string::npos)) {
|
||||||
// Macro
|
// Macro
|
||||||
std::string args = name.substr(bracket + 1, bracketEnd - bracket - 1);
|
std::string args = name.substr(bracket + 1, bracketEnd - bracket - 1);
|
||||||
@ -633,15 +719,6 @@ Sci_Position SCI_METHOD LexerCPP::WordListSet(int n, const char *wl) {
|
|||||||
return firstModification;
|
return firstModification;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Functor used to truncate history
|
|
||||||
struct After {
|
|
||||||
Sci_Position line;
|
|
||||||
explicit After(Sci_Position line_) : line(line_) {}
|
|
||||||
bool operator()(const PPDefinition &p) const {
|
|
||||||
return p.line > line;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void SCI_METHOD LexerCPP::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) {
|
void SCI_METHOD LexerCPP::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) {
|
||||||
LexAccessor styler(pAccess);
|
LexAccessor styler(pAccess);
|
||||||
|
|
||||||
@ -675,7 +752,7 @@ void SCI_METHOD LexerCPP::Lex(Sci_PositionU startPos, Sci_Position length, int i
|
|||||||
(MaskActive(initStyle) == SCE_C_COMMENTLINEDOC)) {
|
(MaskActive(initStyle) == SCE_C_COMMENTLINEDOC)) {
|
||||||
// Set continuationLine if last character of previous line is '\'
|
// Set continuationLine if last character of previous line is '\'
|
||||||
if (lineCurrent > 0) {
|
if (lineCurrent > 0) {
|
||||||
Sci_Position endLinePrevious = styler.LineEnd(lineCurrent - 1);
|
const Sci_Position endLinePrevious = styler.LineEnd(lineCurrent - 1);
|
||||||
if (endLinePrevious > 0) {
|
if (endLinePrevious > 0) {
|
||||||
continuationLine = styler.SafeGetCharAt(endLinePrevious-1) == '\\';
|
continuationLine = styler.SafeGetCharAt(endLinePrevious-1) == '\\';
|
||||||
}
|
}
|
||||||
@ -702,7 +779,8 @@ void SCI_METHOD LexerCPP::Lex(Sci_PositionU startPos, Sci_Position length, int i
|
|||||||
if (!options.updatePreprocessor)
|
if (!options.updatePreprocessor)
|
||||||
ppDefineHistory.clear();
|
ppDefineHistory.clear();
|
||||||
|
|
||||||
std::vector<PPDefinition>::iterator itInvalid = std::find_if(ppDefineHistory.begin(), ppDefineHistory.end(), After(lineCurrent-1));
|
std::vector<PPDefinition>::iterator itInvalid = std::find_if(ppDefineHistory.begin(), ppDefineHistory.end(),
|
||||||
|
[lineCurrent](const PPDefinition &p) { return p.line >= lineCurrent; });
|
||||||
if (itInvalid != ppDefineHistory.end()) {
|
if (itInvalid != ppDefineHistory.end()) {
|
||||||
ppDefineHistory.erase(itInvalid, ppDefineHistory.end());
|
ppDefineHistory.erase(itInvalid, ppDefineHistory.end());
|
||||||
definitionsChanged = true;
|
definitionsChanged = true;
|
||||||
@ -1060,7 +1138,7 @@ void SCI_METHOD LexerCPP::Lex(Sci_PositionU startPos, Sci_Position length, int i
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SCE_C_TRIPLEVERBATIM:
|
case SCE_C_TRIPLEVERBATIM:
|
||||||
if (sc.Match("\"\"\"")) {
|
if (sc.Match(R"(""")")) {
|
||||||
while (sc.Match('"')) {
|
while (sc.Match('"')) {
|
||||||
sc.Forward();
|
sc.Forward();
|
||||||
}
|
}
|
||||||
@ -1091,7 +1169,7 @@ void SCI_METHOD LexerCPP::Lex(Sci_PositionU startPos, Sci_Position length, int i
|
|||||||
if (sc.Match('@', '\"')) {
|
if (sc.Match('@', '\"')) {
|
||||||
sc.SetState(SCE_C_VERBATIM|activitySet);
|
sc.SetState(SCE_C_VERBATIM|activitySet);
|
||||||
sc.Forward();
|
sc.Forward();
|
||||||
} else if (options.triplequotedStrings && sc.Match("\"\"\"")) {
|
} else if (options.triplequotedStrings && sc.Match(R"(""")")) {
|
||||||
sc.SetState(SCE_C_TRIPLEVERBATIM|activitySet);
|
sc.SetState(SCE_C_TRIPLEVERBATIM|activitySet);
|
||||||
sc.Forward(2);
|
sc.Forward(2);
|
||||||
} else if (options.hashquotedStrings && sc.Match('#', '\"')) {
|
} else if (options.hashquotedStrings && sc.Match('#', '\"')) {
|
||||||
@ -1141,7 +1219,7 @@ void SCI_METHOD LexerCPP::Lex(Sci_PositionU startPos, Sci_Position length, int i
|
|||||||
sc.SetState(SCE_C_STRINGRAW|activitySet);
|
sc.SetState(SCE_C_STRINGRAW|activitySet);
|
||||||
rawStringTerminator = ")";
|
rawStringTerminator = ")";
|
||||||
for (Sci_Position termPos = sc.currentPos + 1;; termPos++) {
|
for (Sci_Position termPos = sc.currentPos + 1;; termPos++) {
|
||||||
char chTerminator = styler.SafeGetCharAt(termPos, '(');
|
const char chTerminator = styler.SafeGetCharAt(termPos, '(');
|
||||||
if (chTerminator == '(')
|
if (chTerminator == '(')
|
||||||
break;
|
break;
|
||||||
rawStringTerminator += chTerminator;
|
rawStringTerminator += chTerminator;
|
||||||
@ -1172,14 +1250,14 @@ void SCI_METHOD LexerCPP::Lex(Sci_PositionU startPos, Sci_Position length, int i
|
|||||||
} else {
|
} else {
|
||||||
if (options.trackPreprocessor) {
|
if (options.trackPreprocessor) {
|
||||||
if (sc.Match("ifdef") || sc.Match("ifndef")) {
|
if (sc.Match("ifdef") || sc.Match("ifndef")) {
|
||||||
bool isIfDef = sc.Match("ifdef");
|
const bool isIfDef = sc.Match("ifdef");
|
||||||
int i = isIfDef ? 5 : 6;
|
const int startRest = isIfDef ? 5 : 6;
|
||||||
std::string restOfLine = GetRestOfLine(styler, sc.currentPos + i + 1, false);
|
std::string restOfLine = GetRestOfLine(styler, sc.currentPos + startRest + 1, false);
|
||||||
bool foundDef = preprocessorDefinitions.find(restOfLine) != preprocessorDefinitions.end();
|
bool foundDef = preprocessorDefinitions.find(restOfLine) != preprocessorDefinitions.end();
|
||||||
preproc.StartSection(isIfDef == foundDef);
|
preproc.StartSection(isIfDef == foundDef);
|
||||||
} else if (sc.Match("if")) {
|
} else if (sc.Match("if")) {
|
||||||
std::string restOfLine = GetRestOfLine(styler, sc.currentPos + 2, true);
|
std::string restOfLine = GetRestOfLine(styler, sc.currentPos + 2, true);
|
||||||
bool ifGood = EvaluateExpression(restOfLine, preprocessorDefinitions);
|
const bool ifGood = EvaluateExpression(restOfLine, preprocessorDefinitions);
|
||||||
preproc.StartSection(ifGood);
|
preproc.StartSection(ifGood);
|
||||||
} else if (sc.Match("else")) {
|
} else if (sc.Match("else")) {
|
||||||
if (!preproc.CurrentIfTaken()) {
|
if (!preproc.CurrentIfTaken()) {
|
||||||
@ -1246,6 +1324,8 @@ void SCI_METHOD LexerCPP::Lex(Sci_PositionU startPos, Sci_Position length, int i
|
|||||||
while ((startValue < restOfLine.length()) && IsSpaceOrTab(restOfLine[startValue]))
|
while ((startValue < restOfLine.length()) && IsSpaceOrTab(restOfLine[startValue]))
|
||||||
startValue++;
|
startValue++;
|
||||||
std::string value = restOfLine.substr(startValue);
|
std::string value = restOfLine.substr(startValue);
|
||||||
|
if (OnlySpaceOrTab(value))
|
||||||
|
value = "1"; // No value defaults to 1
|
||||||
preprocessorDefinitions[key] = value;
|
preprocessorDefinitions[key] = value;
|
||||||
ppDefineHistory.push_back(PPDefinition(lineCurrent, key, value));
|
ppDefineHistory.push_back(PPDefinition(lineCurrent, key, value));
|
||||||
definitionsChanged = true;
|
definitionsChanged = true;
|
||||||
@ -1433,6 +1513,7 @@ void LexerCPP::EvaluateTokens(std::vector<std::string> &tokens, const SymbolTabl
|
|||||||
if (it != preprocessorDefinitions.end()) {
|
if (it != preprocessorDefinitions.end()) {
|
||||||
val = "1";
|
val = "1";
|
||||||
}
|
}
|
||||||
|
tokens.erase(tokens.begin() + i + 1, tokens.begin() + i + 2);
|
||||||
}
|
}
|
||||||
tokens[i] = val;
|
tokens[i] = val;
|
||||||
} else {
|
} else {
|
||||||
@ -1495,8 +1576,8 @@ void LexerCPP::EvaluateTokens(std::vector<std::string> &tokens, const SymbolTabl
|
|||||||
tokens.insert(tokens.begin() + i, macroTokens.begin(), macroTokens.end());
|
tokens.insert(tokens.begin() + i, macroTokens.begin(), macroTokens.end());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Identifier not found
|
// Identifier not found and value defaults to zero
|
||||||
tokens.erase(tokens.begin() + i);
|
tokens[i] = "0";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
i++;
|
i++;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
// Scintilla source code edit control
|
// Scintilla source code edit control
|
||||||
|
// Encoding: UTF-8
|
||||||
/** @file LexCSS.cxx
|
/** @file LexCSS.cxx
|
||||||
** Lexer for Cascading Style Sheets
|
** Lexer for Cascading Style Sheets
|
||||||
** Written by Jakub Vrána
|
** Written by Jakub Vrána
|
||||||
** Improved by Philippe Lhoste (CSS2)
|
** Improved by Philippe Lhoste (CSS2)
|
||||||
** Improved by Ross McKay (SCSS mode; see http://sass-lang.com/ )
|
** Improved by Ross McKay (SCSS mode; see http://sass-lang.com/ )
|
||||||
**/
|
**/
|
||||||
@ -31,9 +32,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
static inline bool IsAWordChar(const unsigned int ch) {
|
static inline bool IsAWordChar(const unsigned int ch) {
|
||||||
@ -347,6 +346,7 @@ static void ColouriseCssDoc(Sci_PositionU startPos, Sci_Position length, int ini
|
|||||||
case SCE_CSS_DEFAULT:
|
case SCE_CSS_DEFAULT:
|
||||||
if (isLessDocument) // give priority to pseudo elements
|
if (isLessDocument) // give priority to pseudo elements
|
||||||
break;
|
break;
|
||||||
|
// Falls through.
|
||||||
case SCE_CSS_VALUE:
|
case SCE_CSS_VALUE:
|
||||||
lastStateVar = sc.state;
|
lastStateVar = sc.state;
|
||||||
sc.SetState(SCE_CSS_VARIABLE);
|
sc.SetState(SCE_CSS_VARIABLE);
|
||||||
|
@ -37,6 +37,10 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
|
#if defined(__clang__)
|
||||||
|
#pragma clang diagnostic ignored "-Wcomma"
|
||||||
|
#endif
|
||||||
|
|
||||||
// Since the Microsoft __iscsym[f] funcs are not ANSI...
|
// Since the Microsoft __iscsym[f] funcs are not ANSI...
|
||||||
inline int iscaml(int c) {return isalnum(c) || c == '_';}
|
inline int iscaml(int c) {return isalnum(c) || c == '_';}
|
||||||
inline int iscamlf(int c) {return isalpha(c) || c == '_';}
|
inline int iscamlf(int c) {return isalpha(c) || c == '_';}
|
||||||
@ -46,9 +50,7 @@ static const int baseT[24] = {
|
|||||||
0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0,16 /* M - X */
|
0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0,16 /* M - X */
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef BUILD_AS_EXTERNAL_LEXER
|
#ifdef BUILD_AS_EXTERNAL_LEXER
|
||||||
/*
|
/*
|
||||||
@ -368,6 +370,7 @@ void ColouriseCamlDoc(
|
|||||||
break;
|
break;
|
||||||
}/* else
|
}/* else
|
||||||
// fall through for SML char literal (handle like string) */
|
// fall through for SML char literal (handle like string) */
|
||||||
|
// Falls through.
|
||||||
|
|
||||||
case SCE_CAML_STRING:
|
case SCE_CAML_STRING:
|
||||||
// [try to] interpret as [additional] [SML char/] string literal char
|
// [try to] interpret as [additional] [SML char/] string literal char
|
||||||
|
@ -24,9 +24,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
static bool isCmakeNumber(char ch)
|
static bool isCmakeNumber(char ch)
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,8 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
#include "Platform.h"
|
#include <algorithm>
|
||||||
|
|
||||||
#include "ILexer.h"
|
#include "ILexer.h"
|
||||||
#include "Scintilla.h"
|
#include "Scintilla.h"
|
||||||
#include "SciLexer.h"
|
#include "SciLexer.h"
|
||||||
@ -26,9 +27,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
static bool IsSpaceEquiv(int state) {
|
static bool IsSpaceEquiv(int state) {
|
||||||
return (state == SCE_COFFEESCRIPT_DEFAULT
|
return (state == SCE_COFFEESCRIPT_DEFAULT
|
||||||
@ -427,7 +426,7 @@ static void FoldCoffeeScriptDoc(Sci_PositionU startPos, Sci_Position length, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
const int levelAfterComments = indentNext & SC_FOLDLEVELNUMBERMASK;
|
const int levelAfterComments = indentNext & SC_FOLDLEVELNUMBERMASK;
|
||||||
const int levelBeforeComments = Platform::Maximum(indentCurrentLevel,levelAfterComments);
|
const int levelBeforeComments = std::max(indentCurrentLevel,levelAfterComments);
|
||||||
|
|
||||||
// Now set all the indent levels on the lines we skipped
|
// Now set all the indent levels on the lines we skipped
|
||||||
// Do this from end to start. Once we encounter one line
|
// Do this from end to start. Once we encounter one line
|
||||||
|
@ -27,10 +27,9 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
#include "OptionSet.h"
|
#include "OptionSet.h"
|
||||||
|
#include "DefaultLexer.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Nested comments require keeping the value of the nesting level for every
|
/* Nested comments require keeping the value of the nesting level for every
|
||||||
position in the document. But since scintilla always styles line by line,
|
position in the document. But since scintilla always styles line by line,
|
||||||
@ -145,7 +144,7 @@ struct OptionSetD : public OptionSet<OptionsD> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class LexerD : public ILexer {
|
class LexerD : public DefaultLexer {
|
||||||
bool caseSensitive;
|
bool caseSensitive;
|
||||||
WordList keywords;
|
WordList keywords;
|
||||||
WordList keywords2;
|
WordList keywords2;
|
||||||
|
@ -23,9 +23,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline bool AtEOL(Accessor &styler, Sci_PositionU i) {
|
static inline bool AtEOL(Accessor &styler, Sci_PositionU i) {
|
||||||
return (styler[i] == '\n') ||
|
return (styler[i] == '\n') ||
|
||||||
@ -80,6 +78,14 @@ static void ColouriseDiffLine(char *lineBuffer, Sci_Position endLine, Accessor &
|
|||||||
styler.ColourTo(endLine, SCE_DIFF_POSITION);
|
styler.ColourTo(endLine, SCE_DIFF_POSITION);
|
||||||
} else if (lineBuffer[0] >= '0' && lineBuffer[0] <= '9') {
|
} else if (lineBuffer[0] >= '0' && lineBuffer[0] <= '9') {
|
||||||
styler.ColourTo(endLine, SCE_DIFF_POSITION);
|
styler.ColourTo(endLine, SCE_DIFF_POSITION);
|
||||||
|
} else if (0 == strncmp(lineBuffer, "++", 2)) {
|
||||||
|
styler.ColourTo(endLine, SCE_DIFF_PATCH_ADD);
|
||||||
|
} else if (0 == strncmp(lineBuffer, "+-", 2)) {
|
||||||
|
styler.ColourTo(endLine, SCE_DIFF_PATCH_DELETE);
|
||||||
|
} else if (0 == strncmp(lineBuffer, "-+", 2)) {
|
||||||
|
styler.ColourTo(endLine, SCE_DIFF_REMOVED_PATCH_ADD);
|
||||||
|
} else if (0 == strncmp(lineBuffer, "--", 2)) {
|
||||||
|
styler.ColourTo(endLine, SCE_DIFF_REMOVED_PATCH_DELETE);
|
||||||
} else if (lineBuffer[0] == '-' || lineBuffer[0] == '<') {
|
} else if (lineBuffer[0] == '-' || lineBuffer[0] == '<') {
|
||||||
styler.ColourTo(endLine, SCE_DIFF_DELETED);
|
styler.ColourTo(endLine, SCE_DIFF_DELETED);
|
||||||
} else if (lineBuffer[0] == '+' || lineBuffer[0] == '>') {
|
} else if (lineBuffer[0] == '+' || lineBuffer[0] == '>') {
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
// Scintilla source code edit control
|
// Scintilla source code edit control
|
||||||
|
// Encoding: UTF-8
|
||||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||||
// The License.txt file describes the conditions under which this software may be distributed.
|
// The License.txt file describes the conditions under which this software may be distributed.
|
||||||
/** @file LexErlang.cxx
|
/** @file LexErlang.cxx
|
||||||
** Lexer for Erlang.
|
** Lexer for Erlang.
|
||||||
** Enhanced by Etienne 'Lenain' Girondel (lenaing@gmail.com)
|
** Enhanced by Etienne 'Lenain' Girondel (lenaing@gmail.com)
|
||||||
** Originally wrote by Peter-Henry Mander,
|
** Originally wrote by Peter-Henry Mander,
|
||||||
** based on Matlab lexer by José Fonseca.
|
** based on Matlab lexer by José Fonseca.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -26,9 +27,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
static int is_radix(int radix, int ch) {
|
static int is_radix(int radix, int ch) {
|
||||||
int digit;
|
int digit;
|
||||||
@ -116,6 +115,7 @@ static void ColouriseErlangDoc(Sci_PositionU startPos, Sci_Position length, int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// V--- Falling through!
|
// V--- Falling through!
|
||||||
|
// Falls through.
|
||||||
case COMMENT_FUNCTION : {
|
case COMMENT_FUNCTION : {
|
||||||
if (sc.ch != '%') {
|
if (sc.ch != '%') {
|
||||||
to_late_to_comment = true;
|
to_late_to_comment = true;
|
||||||
@ -128,6 +128,7 @@ static void ColouriseErlangDoc(Sci_PositionU startPos, Sci_Position length, int
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// V--- Falling through!
|
// V--- Falling through!
|
||||||
|
// Falls through.
|
||||||
case COMMENT_MODULE : {
|
case COMMENT_MODULE : {
|
||||||
if (parse_state != COMMENT) {
|
if (parse_state != COMMENT) {
|
||||||
// Search for comment documentation
|
// Search for comment documentation
|
||||||
|
@ -23,9 +23,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline bool IsAWordStart(int ch) {
|
static inline bool IsAWordStart(int ch) {
|
||||||
return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '.');
|
return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '.');
|
||||||
|
@ -25,9 +25,7 @@
|
|||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
/***************************************/
|
/***************************************/
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
/***********************************************/
|
/***********************************************/
|
||||||
static inline bool IsAWordChar(const int ch) {
|
static inline bool IsAWordChar(const int ch) {
|
||||||
@ -257,7 +255,7 @@ static void ColouriseFortranDoc(Sci_PositionU startPos, Sci_Position length, int
|
|||||||
}
|
}
|
||||||
/***************************************/
|
/***************************************/
|
||||||
static void CheckLevelCommentLine(const unsigned int nComL,
|
static void CheckLevelCommentLine(const unsigned int nComL,
|
||||||
int nComColB[], int nComColF[], int &nComCur,
|
Sci_Position nComColB[], Sci_Position nComColF[], Sci_Position &nComCur,
|
||||||
bool comLineB[], bool comLineF[], bool &comLineCur,
|
bool comLineB[], bool comLineF[], bool &comLineCur,
|
||||||
int &levelDeltaNext) {
|
int &levelDeltaNext) {
|
||||||
levelDeltaNext = 0;
|
levelDeltaNext = 0;
|
||||||
@ -362,7 +360,7 @@ static void CheckBackComLines(Accessor &styler, bool isFixFormat, Sci_Position l
|
|||||||
}
|
}
|
||||||
|
|
||||||
Sci_Position lineC = lineCurrent - nComL + 1;
|
Sci_Position lineC = lineCurrent - nComL + 1;
|
||||||
unsigned int iStart;
|
Sci_PositionU iStart;
|
||||||
if (lineC <= 0) {
|
if (lineC <= 0) {
|
||||||
lineC = 0;
|
lineC = 0;
|
||||||
iStart = nComL - lineCurrent;
|
iStart = nComL - lineCurrent;
|
||||||
@ -373,11 +371,11 @@ static void CheckBackComLines(Accessor &styler, bool isFixFormat, Sci_Position l
|
|||||||
bool levChanged = false;
|
bool levChanged = false;
|
||||||
int lev = styler.LevelAt(lineC) & SC_FOLDLEVELNUMBERMASK;
|
int lev = styler.LevelAt(lineC) & SC_FOLDLEVELNUMBERMASK;
|
||||||
|
|
||||||
for (unsigned int i=iStart; i<=nComL; i++) {
|
for (Sci_PositionU i=iStart; i<=nComL; i++) {
|
||||||
if (comL[i] && (!comL[i-1] || nComCol[i] != nComCol[i-1])) {
|
if (comL[i] && (!comL[i-1] || nComCol[i] != nComCol[i-1])) {
|
||||||
bool increase = true;
|
bool increase = true;
|
||||||
unsigned int until = i + nComL;
|
Sci_PositionU until = i + nComL;
|
||||||
for (unsigned int j=i+1; j<=until; j++) {
|
for (Sci_PositionU j=i+1; j<=until; j++) {
|
||||||
if (!comL[j] || nComCol[j] != nComCol[i]) {
|
if (!comL[j] || nComCol[j] != nComCol[i]) {
|
||||||
increase = false;
|
increase = false;
|
||||||
break;
|
break;
|
||||||
@ -445,7 +443,7 @@ static int classifyFoldPointFortran(const char* s, const char* prevWord, const c
|
|||||||
|| strcmp(s, "endsubroutine") == 0 || strcmp(s, "endtype") == 0
|
|| strcmp(s, "endsubroutine") == 0 || strcmp(s, "endtype") == 0
|
||||||
|| strcmp(s, "endwhere") == 0 || strcmp(s, "endcritical") == 0
|
|| strcmp(s, "endwhere") == 0 || strcmp(s, "endcritical") == 0
|
||||||
|| (strcmp(prevWord, "module") == 0 && strcmp(s, "procedure") == 0) // Take care of the "module procedure" statement
|
|| (strcmp(prevWord, "module") == 0 && strcmp(s, "procedure") == 0) // Take care of the "module procedure" statement
|
||||||
|| strcmp(s, "endsubmodule") == 0) {
|
|| strcmp(s, "endsubmodule") == 0 || strcmp(s, "endteam") == 0) {
|
||||||
lev = -1;
|
lev = -1;
|
||||||
} else if (strcmp(prevWord, "end") == 0 && strcmp(s, "if") == 0){ // end if
|
} else if (strcmp(prevWord, "end") == 0 && strcmp(s, "if") == 0){ // end if
|
||||||
lev = 0;
|
lev = 0;
|
||||||
@ -454,6 +452,8 @@ static int classifyFoldPointFortran(const char* s, const char* prevWord, const c
|
|||||||
} else if ((strcmp(prevWord, "end") == 0 && strcmp(s, "procedure") == 0)
|
} else if ((strcmp(prevWord, "end") == 0 && strcmp(s, "procedure") == 0)
|
||||||
|| strcmp(s, "endprocedure") == 0) {
|
|| strcmp(s, "endprocedure") == 0) {
|
||||||
lev = 1; // level back to 0, because no folding support for "module procedure" in submodule
|
lev = 1; // level back to 0, because no folding support for "module procedure" in submodule
|
||||||
|
} else if (strcmp(prevWord, "change") == 0 && strcmp(s, "team") == 0){ // change team
|
||||||
|
lev = 1;
|
||||||
}
|
}
|
||||||
return lev;
|
return lev;
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -41,10 +41,9 @@
|
|||||||
#include "CharacterCategory.h"
|
#include "CharacterCategory.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
#include "OptionSet.h"
|
#include "OptionSet.h"
|
||||||
|
#include "DefaultLexer.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
// See https://github.com/ghc/ghc/blob/master/compiler/parser/Lexer.x#L1682
|
// See https://github.com/ghc/ghc/blob/master/compiler/parser/Lexer.x#L1682
|
||||||
// Note, letter modifiers are prohibited.
|
// Note, letter modifiers are prohibited.
|
||||||
@ -269,7 +268,7 @@ struct OptionSetHaskell : public OptionSet<OptionsHaskell> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class LexerHaskell : public ILexer {
|
class LexerHaskell : public DefaultLexer {
|
||||||
bool literate;
|
bool literate;
|
||||||
Sci_Position firstImportLine;
|
Sci_Position firstImportLine;
|
||||||
int firstImportIndent;
|
int firstImportIndent;
|
||||||
|
@ -28,9 +28,7 @@
|
|||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
#include "LexerBase.h"
|
#include "LexerBase.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -42,7 +40,7 @@ struct latexFoldSave {
|
|||||||
for (int i = 0; i < 8; ++i) openBegins[i] = save.openBegins[i];
|
for (int i = 0; i < 8; ++i) openBegins[i] = save.openBegins[i];
|
||||||
}
|
}
|
||||||
int openBegins[8];
|
int openBegins[8];
|
||||||
int structLev;
|
Sci_Position structLev;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LexerLaTeX : public LexerBase {
|
class LexerLaTeX : public LexerBase {
|
||||||
|
@ -24,9 +24,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SCE_LISP_CHARACTER 29
|
#define SCE_LISP_CHARACTER 29
|
||||||
#define SCE_LISP_MACRO 30
|
#define SCE_LISP_MACRO 30
|
||||||
|
@ -14,10 +14,13 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "ILexer.h"
|
#include "ILexer.h"
|
||||||
#include "Scintilla.h"
|
#include "Scintilla.h"
|
||||||
#include "SciLexer.h"
|
#include "SciLexer.h"
|
||||||
|
|
||||||
|
#include "StringCopy.h"
|
||||||
#include "WordList.h"
|
#include "WordList.h"
|
||||||
#include "LexAccessor.h"
|
#include "LexAccessor.h"
|
||||||
#include "Accessor.h"
|
#include "Accessor.h"
|
||||||
@ -25,9 +28,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
// Test for [=[ ... ]=] delimiters, returns 0 if it's only a [ or ],
|
// Test for [=[ ... ]=] delimiters, returns 0 if it's only a [ or ],
|
||||||
// return 1 for [[ or ]], returns >=2 for [=[ or ]=] and so on.
|
// return 1 for [[ or ]], returns >=2 for [=[ or ]=] and so on.
|
||||||
@ -83,6 +84,12 @@ static void ColouriseLuaDoc(
|
|||||||
stringWs = lineState & 0x100;
|
stringWs = lineState & 0x100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// results of identifier/keyword matching
|
||||||
|
Sci_Position idenPos = 0;
|
||||||
|
Sci_Position idenWordPos = 0;
|
||||||
|
int idenStyle = SCE_LUA_IDENTIFIER;
|
||||||
|
bool foundGoto = false;
|
||||||
|
|
||||||
// Do not leak onto next line
|
// Do not leak onto next line
|
||||||
if (initStyle == SCE_LUA_STRINGEOL || initStyle == SCE_LUA_COMMENTLINE || initStyle == SCE_LUA_PREPROCESSOR) {
|
if (initStyle == SCE_LUA_STRINGEOL || initStyle == SCE_LUA_COMMENTLINE || initStyle == SCE_LUA_PREPROCESSOR) {
|
||||||
initStyle = SCE_LUA_DEFAULT;
|
initStyle = SCE_LUA_DEFAULT;
|
||||||
@ -178,40 +185,32 @@ static void ColouriseLuaDoc(
|
|||||||
sc.SetState(SCE_LUA_DEFAULT);
|
sc.SetState(SCE_LUA_DEFAULT);
|
||||||
}
|
}
|
||||||
} else if (sc.state == SCE_LUA_IDENTIFIER) {
|
} else if (sc.state == SCE_LUA_IDENTIFIER) {
|
||||||
if (!(setWord.Contains(sc.ch) || sc.ch == '.') || sc.Match('.', '.')) {
|
idenPos--; // commit already-scanned identitier/word parts
|
||||||
char s[100];
|
if (idenWordPos > 0) {
|
||||||
sc.GetCurrent(s, sizeof(s));
|
idenWordPos--;
|
||||||
if (keywords.InList(s)) {
|
sc.ChangeState(idenStyle);
|
||||||
sc.ChangeState(SCE_LUA_WORD);
|
sc.ForwardBytes(idenWordPos);
|
||||||
if (strcmp(s, "goto") == 0) { // goto <label> forward scan
|
idenPos -= idenWordPos;
|
||||||
sc.SetState(SCE_LUA_DEFAULT);
|
if (idenPos > 0) {
|
||||||
while (IsASpaceOrTab(sc.ch) && !sc.atLineEnd)
|
sc.SetState(SCE_LUA_IDENTIFIER);
|
||||||
sc.Forward();
|
sc.ForwardBytes(idenPos);
|
||||||
if (setWordStart.Contains(sc.ch)) {
|
}
|
||||||
sc.SetState(SCE_LUA_LABEL);
|
} else {
|
||||||
sc.Forward();
|
sc.ForwardBytes(idenPos);
|
||||||
while (setWord.Contains(sc.ch))
|
}
|
||||||
sc.Forward();
|
sc.SetState(SCE_LUA_DEFAULT);
|
||||||
sc.GetCurrent(s, sizeof(s));
|
if (foundGoto) { // goto <label> forward scan
|
||||||
if (keywords.InList(s))
|
while (IsASpaceOrTab(sc.ch) && !sc.atLineEnd)
|
||||||
sc.ChangeState(SCE_LUA_WORD);
|
sc.Forward();
|
||||||
}
|
if (setWordStart.Contains(sc.ch)) {
|
||||||
sc.SetState(SCE_LUA_DEFAULT);
|
sc.SetState(SCE_LUA_LABEL);
|
||||||
}
|
sc.Forward();
|
||||||
} else if (keywords2.InList(s)) {
|
while (setWord.Contains(sc.ch))
|
||||||
sc.ChangeState(SCE_LUA_WORD2);
|
sc.Forward();
|
||||||
} else if (keywords3.InList(s)) {
|
char s[100];
|
||||||
sc.ChangeState(SCE_LUA_WORD3);
|
sc.GetCurrent(s, sizeof(s));
|
||||||
} else if (keywords4.InList(s)) {
|
if (keywords.InList(s)) // labels cannot be keywords
|
||||||
sc.ChangeState(SCE_LUA_WORD4);
|
sc.ChangeState(SCE_LUA_WORD);
|
||||||
} else if (keywords5.InList(s)) {
|
|
||||||
sc.ChangeState(SCE_LUA_WORD5);
|
|
||||||
} else if (keywords6.InList(s)) {
|
|
||||||
sc.ChangeState(SCE_LUA_WORD6);
|
|
||||||
} else if (keywords7.InList(s)) {
|
|
||||||
sc.ChangeState(SCE_LUA_WORD7);
|
|
||||||
} else if (keywords8.InList(s)) {
|
|
||||||
sc.ChangeState(SCE_LUA_WORD8);
|
|
||||||
}
|
}
|
||||||
sc.SetState(SCE_LUA_DEFAULT);
|
sc.SetState(SCE_LUA_DEFAULT);
|
||||||
}
|
}
|
||||||
@ -285,6 +284,66 @@ static void ColouriseLuaDoc(
|
|||||||
sc.Forward();
|
sc.Forward();
|
||||||
}
|
}
|
||||||
} else if (setWordStart.Contains(sc.ch)) {
|
} else if (setWordStart.Contains(sc.ch)) {
|
||||||
|
// For matching various identifiers with dots and colons, multiple
|
||||||
|
// matches are done as identifier segments are added. Longest match is
|
||||||
|
// set to a word style. The non-matched part is in identifier style.
|
||||||
|
std::string ident;
|
||||||
|
idenPos = 0;
|
||||||
|
idenWordPos = 0;
|
||||||
|
idenStyle = SCE_LUA_IDENTIFIER;
|
||||||
|
foundGoto = false;
|
||||||
|
int cNext;
|
||||||
|
do {
|
||||||
|
int c;
|
||||||
|
const Sci_Position idenPosOld = idenPos;
|
||||||
|
std::string identSeg;
|
||||||
|
identSeg += static_cast<char>(sc.GetRelative(idenPos++));
|
||||||
|
while (setWord.Contains(c = sc.GetRelative(idenPos))) {
|
||||||
|
identSeg += static_cast<char>(c);
|
||||||
|
idenPos++;
|
||||||
|
}
|
||||||
|
if (keywords.InList(identSeg.c_str()) && (idenPosOld > 0)) {
|
||||||
|
idenPos = idenPosOld - 1; // keywords cannot mix
|
||||||
|
ident.pop_back();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ident += identSeg;
|
||||||
|
const char* s = ident.c_str();
|
||||||
|
int newStyle = SCE_LUA_IDENTIFIER;
|
||||||
|
if (keywords.InList(s)) {
|
||||||
|
newStyle = SCE_LUA_WORD;
|
||||||
|
} else if (keywords2.InList(s)) {
|
||||||
|
newStyle = SCE_LUA_WORD2;
|
||||||
|
} else if (keywords3.InList(s)) {
|
||||||
|
newStyle = SCE_LUA_WORD3;
|
||||||
|
} else if (keywords4.InList(s)) {
|
||||||
|
newStyle = SCE_LUA_WORD4;
|
||||||
|
} else if (keywords5.InList(s)) {
|
||||||
|
newStyle = SCE_LUA_WORD5;
|
||||||
|
} else if (keywords6.InList(s)) {
|
||||||
|
newStyle = SCE_LUA_WORD6;
|
||||||
|
} else if (keywords7.InList(s)) {
|
||||||
|
newStyle = SCE_LUA_WORD7;
|
||||||
|
} else if (keywords8.InList(s)) {
|
||||||
|
newStyle = SCE_LUA_WORD8;
|
||||||
|
}
|
||||||
|
if (newStyle != SCE_LUA_IDENTIFIER) {
|
||||||
|
idenStyle = newStyle;
|
||||||
|
idenWordPos = idenPos;
|
||||||
|
}
|
||||||
|
if (idenStyle == SCE_LUA_WORD) // keywords cannot mix
|
||||||
|
break;
|
||||||
|
cNext = sc.GetRelative(idenPos + 1);
|
||||||
|
if ((c == '.' || c == ':') && setWordStart.Contains(cNext)) {
|
||||||
|
ident += static_cast<char>(c);
|
||||||
|
idenPos++;
|
||||||
|
} else {
|
||||||
|
cNext = 0;
|
||||||
|
}
|
||||||
|
} while (cNext);
|
||||||
|
if ((idenStyle == SCE_LUA_WORD) && (ident.compare("goto") == 0)) {
|
||||||
|
foundGoto = true;
|
||||||
|
}
|
||||||
sc.SetState(SCE_LUA_IDENTIFIER);
|
sc.SetState(SCE_LUA_IDENTIFIER);
|
||||||
} else if (sc.ch == '\"') {
|
} else if (sc.ch == '\"') {
|
||||||
sc.SetState(SCE_LUA_STRING);
|
sc.SetState(SCE_LUA_STRING);
|
||||||
@ -322,28 +381,6 @@ static void ColouriseLuaDoc(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setWord.Contains(sc.chPrev) || sc.chPrev == '.') {
|
|
||||||
char s[100];
|
|
||||||
sc.GetCurrent(s, sizeof(s));
|
|
||||||
if (keywords.InList(s)) {
|
|
||||||
sc.ChangeState(SCE_LUA_WORD);
|
|
||||||
} else if (keywords2.InList(s)) {
|
|
||||||
sc.ChangeState(SCE_LUA_WORD2);
|
|
||||||
} else if (keywords3.InList(s)) {
|
|
||||||
sc.ChangeState(SCE_LUA_WORD3);
|
|
||||||
} else if (keywords4.InList(s)) {
|
|
||||||
sc.ChangeState(SCE_LUA_WORD4);
|
|
||||||
} else if (keywords5.InList(s)) {
|
|
||||||
sc.ChangeState(SCE_LUA_WORD5);
|
|
||||||
} else if (keywords6.InList(s)) {
|
|
||||||
sc.ChangeState(SCE_LUA_WORD6);
|
|
||||||
} else if (keywords7.InList(s)) {
|
|
||||||
sc.ChangeState(SCE_LUA_WORD7);
|
|
||||||
} else if (keywords8.InList(s)) {
|
|
||||||
sc.ChangeState(SCE_LUA_WORD8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sc.Complete();
|
sc.Complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,4 +470,33 @@ static const char * const luaWordListDesc[] = {
|
|||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
LexerModule lmLua(SCLEX_LUA, ColouriseLuaDoc, "lua", FoldLuaDoc, luaWordListDesc);
|
namespace {
|
||||||
|
|
||||||
|
LexicalClass lexicalClasses[] = {
|
||||||
|
// Lexer Lua SCLEX_LUA SCE_LUA_:
|
||||||
|
0, "SCE_LUA_DEFAULT", "default", "White space: Visible only in View Whitespace mode (or if it has a back colour)",
|
||||||
|
1, "SCE_LUA_COMMENT", "comment", "Block comment (Lua 5.0)",
|
||||||
|
2, "SCE_LUA_COMMENTLINE", "comment line", "Line comment",
|
||||||
|
3, "SCE_LUA_COMMENTDOC", "comment documentation", "Doc comment -- Not used in Lua (yet?)",
|
||||||
|
4, "SCE_LUA_NUMBER", "literal numeric", "Number",
|
||||||
|
5, "SCE_LUA_WORD", "keyword", "Keyword",
|
||||||
|
6, "SCE_LUA_STRING", "literal string", "(Double quoted) String",
|
||||||
|
7, "SCE_LUA_CHARACTER", "literal string character", "Character (Single quoted string)",
|
||||||
|
8, "SCE_LUA_LITERALSTRING", "literal string", "Literal string",
|
||||||
|
9, "SCE_LUA_PREPROCESSOR", "preprocessor", "Preprocessor (obsolete in Lua 4.0 and up)",
|
||||||
|
10, "SCE_LUA_OPERATOR", "operator", "Operators",
|
||||||
|
11, "SCE_LUA_IDENTIFIER", "identifier", "Identifier (everything else...)",
|
||||||
|
12, "SCE_LUA_STRINGEOL", "error literal string", "End of line where string is not closed",
|
||||||
|
13, "SCE_LUA_WORD2", "identifier", "Other keywords",
|
||||||
|
14, "SCE_LUA_WORD3", "identifier", "Other keywords",
|
||||||
|
15, "SCE_LUA_WORD4", "identifier", "Other keywords",
|
||||||
|
16, "SCE_LUA_WORD5", "identifier", "Other keywords",
|
||||||
|
17, "SCE_LUA_WORD6", "identifier", "Other keywords",
|
||||||
|
18, "SCE_LUA_WORD7", "identifier", "Other keywords",
|
||||||
|
19, "SCE_LUA_WORD8", "identifier", "Other keywords",
|
||||||
|
20, "SCE_LUA_LABEL", "label", "Labels",
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
LexerModule lmLua(SCLEX_LUA, ColouriseLuaDoc, "lua", FoldLuaDoc, luaWordListDesc, lexicalClasses, ELEMENTS(lexicalClasses));
|
||||||
|
@ -23,9 +23,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline bool AtEOL(Accessor &styler, Sci_PositionU i) {
|
static inline bool AtEOL(Accessor &styler, Sci_PositionU i) {
|
||||||
return (styler[i] == '\n') ||
|
return (styler[i] == '\n') ||
|
||||||
|
@ -51,9 +51,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline bool IsNewline(const int ch) {
|
static inline bool IsNewline(const int ch) {
|
||||||
return (ch == '\n' || ch == '\r');
|
return (ch == '\n' || ch == '\r');
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
// Scintilla source code edit control
|
// Scintilla source code edit control
|
||||||
|
// Encoding: UTF-8
|
||||||
/** @file LexMatlab.cxx
|
/** @file LexMatlab.cxx
|
||||||
** Lexer for Matlab.
|
** Lexer for Matlab.
|
||||||
** Written by José Fonseca
|
** Written by José Fonseca
|
||||||
**
|
**
|
||||||
** Changes by Christoph Dalitz 2003/12/04:
|
** Changes by Christoph Dalitz 2003/12/04:
|
||||||
** - added support for Octave
|
** - added support for Octave
|
||||||
@ -43,9 +44,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
static bool IsMatlabCommentChar(int c) {
|
static bool IsMatlabCommentChar(int c) {
|
||||||
return (c == '%') ;
|
return (c == '%') ;
|
||||||
@ -65,6 +64,7 @@ static int CheckKeywordFoldPoint(char *str) {
|
|||||||
if (strcmp ("if", str) == 0 ||
|
if (strcmp ("if", str) == 0 ||
|
||||||
strcmp ("for", str) == 0 ||
|
strcmp ("for", str) == 0 ||
|
||||||
strcmp ("switch", str) == 0 ||
|
strcmp ("switch", str) == 0 ||
|
||||||
|
strcmp ("while", str) == 0 ||
|
||||||
strcmp ("try", str) == 0 ||
|
strcmp ("try", str) == 0 ||
|
||||||
strcmp ("do", str) == 0 ||
|
strcmp ("do", str) == 0 ||
|
||||||
strcmp ("parfor", str) == 0 ||
|
strcmp ("parfor", str) == 0 ||
|
||||||
@ -100,6 +100,9 @@ static void ColouriseMatlabOctaveDoc(
|
|||||||
// of a string
|
// of a string
|
||||||
bool transpose = false;
|
bool transpose = false;
|
||||||
|
|
||||||
|
// count of brackets as boolean for when end could be an operator not a keyword
|
||||||
|
int allow_end_op = 0;
|
||||||
|
|
||||||
// approximate position of first non space character in a line
|
// approximate position of first non space character in a line
|
||||||
int nonSpaceColumn = -1;
|
int nonSpaceColumn = -1;
|
||||||
// approximate column position of the current character in a line
|
// approximate column position of the current character in a line
|
||||||
@ -153,7 +156,11 @@ static void ColouriseMatlabOctaveDoc(
|
|||||||
if (!isalnum(sc.ch) && sc.ch != '_') {
|
if (!isalnum(sc.ch) && sc.ch != '_') {
|
||||||
char s[100];
|
char s[100];
|
||||||
sc.GetCurrentLowered(s, sizeof(s));
|
sc.GetCurrentLowered(s, sizeof(s));
|
||||||
|
|
||||||
if (keywords.InList(s)) {
|
if (keywords.InList(s)) {
|
||||||
|
if (strcmp ("end", s) == 0 && allow_end_op) {
|
||||||
|
sc.ChangeState(SCE_MATLAB_NUMBER);
|
||||||
|
}
|
||||||
sc.SetState(SCE_MATLAB_DEFAULT);
|
sc.SetState(SCE_MATLAB_DEFAULT);
|
||||||
transpose = false;
|
transpose = false;
|
||||||
} else {
|
} else {
|
||||||
@ -253,6 +260,12 @@ static void ColouriseMatlabOctaveDoc(
|
|||||||
} else if (isalpha(sc.ch)) {
|
} else if (isalpha(sc.ch)) {
|
||||||
sc.SetState(SCE_MATLAB_KEYWORD);
|
sc.SetState(SCE_MATLAB_KEYWORD);
|
||||||
} else if (isoperator(static_cast<char>(sc.ch)) || sc.ch == '@' || sc.ch == '\\') {
|
} else if (isoperator(static_cast<char>(sc.ch)) || sc.ch == '@' || sc.ch == '\\') {
|
||||||
|
if (sc.ch == '(' || sc.ch == '[' || sc.ch == '{') {
|
||||||
|
allow_end_op ++;
|
||||||
|
} else if ((sc.ch == ')' || sc.ch == ']' || sc.ch == '}') && (allow_end_op > 0)) {
|
||||||
|
allow_end_op --;
|
||||||
|
}
|
||||||
|
|
||||||
if (sc.ch == ')' || sc.ch == ']' || sc.ch == '}') {
|
if (sc.ch == ')' || sc.ch == ']' || sc.ch == '}') {
|
||||||
transpose = true;
|
transpose = true;
|
||||||
} else {
|
} else {
|
||||||
@ -281,6 +294,12 @@ static void FoldMatlabOctaveDoc(Sci_PositionU startPos, Sci_Position length, int
|
|||||||
WordList *[], Accessor &styler,
|
WordList *[], Accessor &styler,
|
||||||
bool (*IsComment)(int ch)) {
|
bool (*IsComment)(int ch)) {
|
||||||
|
|
||||||
|
if (styler.GetPropertyInt("fold") == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
|
||||||
|
const bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
|
||||||
|
|
||||||
Sci_PositionU endPos = startPos + length;
|
Sci_PositionU endPos = startPos + length;
|
||||||
int visibleChars = 0;
|
int visibleChars = 0;
|
||||||
Sci_Position lineCurrent = styler.GetLine(startPos);
|
Sci_Position lineCurrent = styler.GetLine(startPos);
|
||||||
@ -301,7 +320,7 @@ static void FoldMatlabOctaveDoc(Sci_PositionU startPos, Sci_Position length, int
|
|||||||
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
|
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
|
||||||
|
|
||||||
// a line that starts with a comment
|
// a line that starts with a comment
|
||||||
if (style == SCE_MATLAB_COMMENT && IsComment(ch) && visibleChars == 0) {
|
if (foldComment && style == SCE_MATLAB_COMMENT && IsComment(ch) && visibleChars == 0) {
|
||||||
// start/end of block comment
|
// start/end of block comment
|
||||||
if (chNext == '{' && IsSpaceToEOL(i+2, styler))
|
if (chNext == '{' && IsSpaceToEOL(i+2, styler))
|
||||||
levelNext ++;
|
levelNext ++;
|
||||||
@ -327,7 +346,7 @@ static void FoldMatlabOctaveDoc(Sci_PositionU startPos, Sci_Position length, int
|
|||||||
if (atEOL || (i == endPos-1)) {
|
if (atEOL || (i == endPos-1)) {
|
||||||
int levelUse = levelCurrent;
|
int levelUse = levelCurrent;
|
||||||
int lev = levelUse | levelNext << 16;
|
int lev = levelUse | levelNext << 16;
|
||||||
if (visibleChars == 0)
|
if (visibleChars == 0 && foldCompact)
|
||||||
lev |= SC_FOLDLEVELWHITEFLAG;
|
lev |= SC_FOLDLEVELWHITEFLAG;
|
||||||
if (levelUse < levelNext)
|
if (levelUse < levelNext)
|
||||||
lev |= SC_FOLDLEVELHEADERFLAG;
|
lev |= SC_FOLDLEVELHEADERFLAG;
|
||||||
|
@ -24,9 +24,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// located in SciLexer.h
|
// located in SciLexer.h
|
||||||
|
@ -23,9 +23,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
static void ColouriseNullDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[],
|
static void ColouriseNullDoc(Sci_PositionU startPos, Sci_Position length, int, WordList *[],
|
||||||
Accessor &styler) {
|
Accessor &styler) {
|
||||||
|
@ -31,9 +31,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
static void ColourisePODoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *[], Accessor &styler) {
|
static void ColourisePODoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *[], Accessor &styler) {
|
||||||
StyleContext sc(startPos, length, initStyle, styler);
|
StyleContext sc(startPos, length, initStyle, styler);
|
||||||
|
@ -128,9 +128,7 @@ contains requires
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
static void GetRangeLowered(Sci_PositionU start,
|
static void GetRangeLowered(Sci_PositionU start,
|
||||||
Sci_PositionU end,
|
Sci_PositionU end,
|
||||||
|
@ -27,10 +27,9 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
#include "OptionSet.h"
|
#include "OptionSet.h"
|
||||||
|
#include "DefaultLexer.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
// Info for HERE document handling from perldata.pod (reformatted):
|
// Info for HERE document handling from perldata.pod (reformatted):
|
||||||
// ----------------------------------------------------------------
|
// ----------------------------------------------------------------
|
||||||
@ -122,8 +121,8 @@ static int disambiguateBareword(LexAccessor &styler, Sci_PositionU bk, Sci_Posit
|
|||||||
// if ch isn't one of '[{(,' we can skip the test
|
// if ch isn't one of '[{(,' we can skip the test
|
||||||
if ((ch == '{' || ch == '(' || ch == '['|| ch == ',')
|
if ((ch == '{' || ch == '(' || ch == '['|| ch == ',')
|
||||||
&& fw < endPos) {
|
&& fw < endPos) {
|
||||||
while (ch = static_cast<unsigned char>(styler.SafeGetCharAt(fw)),
|
while (IsASpaceOrTab(ch = static_cast<unsigned char>(styler.SafeGetCharAt(fw)))
|
||||||
IsASpaceOrTab(ch) && fw < endPos) {
|
&& fw < endPos) {
|
||||||
fw++;
|
fw++;
|
||||||
}
|
}
|
||||||
if ((ch == '}' && brace)
|
if ((ch == '}' && brace)
|
||||||
@ -138,10 +137,12 @@ static int disambiguateBareword(LexAccessor &styler, Sci_PositionU bk, Sci_Posit
|
|||||||
|
|
||||||
static void skipWhitespaceComment(LexAccessor &styler, Sci_PositionU &p) {
|
static void skipWhitespaceComment(LexAccessor &styler, Sci_PositionU &p) {
|
||||||
// when backtracking, we need to skip whitespace and comments
|
// when backtracking, we need to skip whitespace and comments
|
||||||
int style;
|
while (p > 0) {
|
||||||
while ((p > 0) && (style = styler.StyleAt(p),
|
const int style = styler.StyleAt(p);
|
||||||
style == SCE_PL_DEFAULT || style == SCE_PL_COMMENTLINE))
|
if (style != SCE_PL_DEFAULT && style != SCE_PL_COMMENTLINE)
|
||||||
|
break;
|
||||||
p--;
|
p--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int findPrevLexeme(LexAccessor &styler, Sci_PositionU &bk, int &style) {
|
static int findPrevLexeme(LexAccessor &styler, Sci_PositionU &bk, int &style) {
|
||||||
@ -398,7 +399,7 @@ struct OptionSetPerl : public OptionSet<OptionsPerl> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class LexerPerl : public ILexer {
|
class LexerPerl : public DefaultLexer {
|
||||||
CharacterSet setWordStart;
|
CharacterSet setWordStart;
|
||||||
CharacterSet setWord;
|
CharacterSet setWord;
|
||||||
CharacterSet setSpecialVar;
|
CharacterSet setSpecialVar;
|
||||||
@ -1174,6 +1175,7 @@ void SCI_METHOD LexerPerl::Lex(Sci_PositionU startPos, Sci_Position length, int
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// (continued for ' delim)
|
// (continued for ' delim)
|
||||||
|
// Falls through.
|
||||||
default: // non-interpolated path
|
default: // non-interpolated path
|
||||||
sc.Forward(sLen);
|
sc.Forward(sLen);
|
||||||
}
|
}
|
||||||
|
@ -23,9 +23,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
// Extended to accept accented characters
|
// Extended to accept accented characters
|
||||||
static inline bool IsAWordChar(int ch) {
|
static inline bool IsAWordChar(int ch) {
|
||||||
|
@ -23,9 +23,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline bool AtEOL(Accessor &styler, Sci_PositionU i) {
|
static inline bool AtEOL(Accessor &styler, Sci_PositionU i) {
|
||||||
return (styler[i] == '\n') ||
|
return (styler[i] == '\n') ||
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
#include "ILexer.h"
|
#include "ILexer.h"
|
||||||
#include "Scintilla.h"
|
#include "Scintilla.h"
|
||||||
@ -30,10 +31,9 @@
|
|||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
#include "OptionSet.h"
|
#include "OptionSet.h"
|
||||||
#include "SubStyles.h"
|
#include "SubStyles.h"
|
||||||
|
#include "DefaultLexer.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace {
|
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
|
||||||
@ -308,21 +308,46 @@ struct OptionSetPython : public OptionSet<OptionsPython> {
|
|||||||
|
|
||||||
const char styleSubable[] = { SCE_P_IDENTIFIER, 0 };
|
const char styleSubable[] = { SCE_P_IDENTIFIER, 0 };
|
||||||
|
|
||||||
|
LexicalClass lexicalClasses[] = {
|
||||||
|
// Lexer Python SCLEX_PYTHON SCE_P_:
|
||||||
|
0, "SCE_P_DEFAULT", "default", "White space",
|
||||||
|
1, "SCE_P_COMMENTLINE", "comment line", "Comment",
|
||||||
|
2, "SCE_P_NUMBER", "literal numeric", "Number",
|
||||||
|
3, "SCE_P_STRING", "literal string", "String",
|
||||||
|
4, "SCE_P_CHARACTER", "literal string", "Single quoted string",
|
||||||
|
5, "SCE_P_WORD", "keyword", "Keyword",
|
||||||
|
6, "SCE_P_TRIPLE", "literal string", "Triple quotes",
|
||||||
|
7, "SCE_P_TRIPLEDOUBLE", "literal string", "Triple double quotes",
|
||||||
|
8, "SCE_P_CLASSNAME", "identifier", "Class name definition",
|
||||||
|
9, "SCE_P_DEFNAME", "identifier", "Function or method name definition",
|
||||||
|
10, "SCE_P_OPERATOR", "operator", "Operators",
|
||||||
|
11, "SCE_P_IDENTIFIER", "identifier", "Identifiers",
|
||||||
|
12, "SCE_P_COMMENTBLOCK", "comment", "Comment-blocks",
|
||||||
|
13, "SCE_P_STRINGEOL", "error literal string", "End of line where string is not closed",
|
||||||
|
14, "SCE_P_WORD2", "identifier", "Highlighted identifiers",
|
||||||
|
15, "SCE_P_DECORATOR", "preprocessor", "Decorators",
|
||||||
|
16, "SCE_P_FSTRING", "literal string interpolated", "F-String",
|
||||||
|
17, "SCE_P_FCHARACTER", "literal string interpolated", "Single quoted f-string",
|
||||||
|
18, "SCE_P_FTRIPLE", "literal string interpolated", "Triple quoted f-string",
|
||||||
|
19, "SCE_P_FTRIPLEDOUBLE", "literal string interpolated", "Triple double quoted f-string",
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LexerPython : public ILexerWithSubStyles {
|
class LexerPython : public DefaultLexer {
|
||||||
WordList keywords;
|
WordList keywords;
|
||||||
WordList keywords2;
|
WordList keywords2;
|
||||||
OptionsPython options;
|
OptionsPython options;
|
||||||
OptionSetPython osPython;
|
OptionSetPython osPython;
|
||||||
enum { ssIdentifier };
|
enum { ssIdentifier };
|
||||||
SubStyles subStyles;
|
SubStyles subStyles;
|
||||||
std::map<int, std::vector<SingleFStringExpState> > ftripleStateAtEol;
|
std::map<Sci_Position, std::vector<SingleFStringExpState> > ftripleStateAtEol;
|
||||||
public:
|
public:
|
||||||
explicit LexerPython() :
|
explicit LexerPython() :
|
||||||
|
DefaultLexer(lexicalClasses, ELEMENTS(lexicalClasses)),
|
||||||
subStyles(styleSubable, 0x80, 0x40, 0) {
|
subStyles(styleSubable, 0x80, 0x40, 0) {
|
||||||
}
|
}
|
||||||
virtual ~LexerPython() {
|
~LexerPython() override {
|
||||||
}
|
}
|
||||||
void SCI_METHOD Release() override {
|
void SCI_METHOD Release() override {
|
||||||
delete this;
|
delete this;
|
||||||
@ -440,7 +465,7 @@ void LexerPython::ProcessLineEnd(StyleContext &sc, std::vector<SingleFStringExpS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!fstringStateStack.empty()) {
|
if (!fstringStateStack.empty()) {
|
||||||
std::pair<int, std::vector<SingleFStringExpState> > val;
|
std::pair<Sci_Position, std::vector<SingleFStringExpState> > val;
|
||||||
val.first = sc.currentLine;
|
val.first = sc.currentLine;
|
||||||
val.second = fstringStateStack;
|
val.second = fstringStateStack;
|
||||||
|
|
||||||
@ -503,7 +528,7 @@ void SCI_METHOD LexerPython::Lex(Sci_PositionU startPos, Sci_Position length, in
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set up fstate stack from last line and remove any subsequent ftriple at eol states
|
// Set up fstate stack from last line and remove any subsequent ftriple at eol states
|
||||||
std::map<int, std::vector<SingleFStringExpState> >::iterator it;
|
std::map<Sci_Position, std::vector<SingleFStringExpState> >::iterator it;
|
||||||
it = ftripleStateAtEol.find(lineCurrent - 1);
|
it = ftripleStateAtEol.find(lineCurrent - 1);
|
||||||
if (it != ftripleStateAtEol.end() && !it->second.empty()) {
|
if (it != ftripleStateAtEol.end() && !it->second.empty()) {
|
||||||
fstringStateStack = it->second;
|
fstringStateStack = it->second;
|
||||||
@ -659,7 +684,7 @@ void SCI_METHOD LexerPython::Lex(Sci_PositionU startPos, Sci_Position length, in
|
|||||||
} else if ((sc.state == SCE_P_TRIPLE) || (sc.state == SCE_P_FTRIPLE)) {
|
} else if ((sc.state == SCE_P_TRIPLE) || (sc.state == SCE_P_FTRIPLE)) {
|
||||||
if (sc.ch == '\\') {
|
if (sc.ch == '\\') {
|
||||||
sc.Forward();
|
sc.Forward();
|
||||||
} else if (sc.Match("\'\'\'")) {
|
} else if (sc.Match(R"(''')")) {
|
||||||
sc.Forward();
|
sc.Forward();
|
||||||
sc.Forward();
|
sc.Forward();
|
||||||
sc.ForwardSetState(SCE_P_DEFAULT);
|
sc.ForwardSetState(SCE_P_DEFAULT);
|
||||||
@ -668,7 +693,7 @@ void SCI_METHOD LexerPython::Lex(Sci_PositionU startPos, Sci_Position length, in
|
|||||||
} else if ((sc.state == SCE_P_TRIPLEDOUBLE) || (sc.state == SCE_P_FTRIPLEDOUBLE)) {
|
} else if ((sc.state == SCE_P_TRIPLEDOUBLE) || (sc.state == SCE_P_FTRIPLEDOUBLE)) {
|
||||||
if (sc.ch == '\\') {
|
if (sc.ch == '\\') {
|
||||||
sc.Forward();
|
sc.Forward();
|
||||||
} else if (sc.Match("\"\"\"")) {
|
} else if (sc.Match(R"(""")")) {
|
||||||
sc.Forward();
|
sc.Forward();
|
||||||
sc.Forward();
|
sc.Forward();
|
||||||
sc.ForwardSetState(SCE_P_DEFAULT);
|
sc.ForwardSetState(SCE_P_DEFAULT);
|
||||||
@ -699,7 +724,7 @@ void SCI_METHOD LexerPython::Lex(Sci_PositionU startPos, Sci_Position length, in
|
|||||||
if (sc.ch == quote) {
|
if (sc.ch == quote) {
|
||||||
if (IsPySingleQuoteStringState(stack_state)) {
|
if (IsPySingleQuoteStringState(stack_state)) {
|
||||||
matching_stack_i = stack_i;
|
matching_stack_i = stack_i;
|
||||||
} else if (quote == '"' ? sc.Match("\"\"\"") : sc.Match("'''")) {
|
} else if (quote == '"' ? sc.Match(R"(""")") : sc.Match("'''")) {
|
||||||
matching_stack_i = stack_i;
|
matching_stack_i = stack_i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -812,7 +837,7 @@ static bool IsCommentLine(Sci_Position line, Accessor &styler) {
|
|||||||
|
|
||||||
static bool IsQuoteLine(Sci_Position line, const Accessor &styler) {
|
static bool IsQuoteLine(Sci_Position line, const Accessor &styler) {
|
||||||
const int style = styler.StyleAt(styler.LineStart(line)) & 31;
|
const int style = styler.StyleAt(styler.LineStart(line)) & 31;
|
||||||
return ((style == SCE_P_TRIPLE) || (style == SCE_P_TRIPLEDOUBLE));
|
return IsPyTripleQuoteStringState(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -848,7 +873,7 @@ void SCI_METHOD LexerPython::Fold(Sci_PositionU startPos, Sci_Position length, i
|
|||||||
int prev_state = SCE_P_DEFAULT & 31;
|
int prev_state = SCE_P_DEFAULT & 31;
|
||||||
if (lineCurrent >= 1)
|
if (lineCurrent >= 1)
|
||||||
prev_state = styler.StyleAt(startPos - 1) & 31;
|
prev_state = styler.StyleAt(startPos - 1) & 31;
|
||||||
int prevQuote = options.foldQuotes && ((prev_state == SCE_P_TRIPLE) || (prev_state == SCE_P_TRIPLEDOUBLE));
|
int prevQuote = options.foldQuotes && IsPyTripleQuoteStringState(prev_state);
|
||||||
|
|
||||||
// Process all characters to end of requested range or end of any triple quote
|
// Process all characters to end of requested range or end of any triple quote
|
||||||
//that hangs over the end of the range. Cap processing in all cases
|
//that hangs over the end of the range. Cap processing in all cases
|
||||||
@ -865,7 +890,7 @@ void SCI_METHOD LexerPython::Fold(Sci_PositionU startPos, Sci_Position length, i
|
|||||||
indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
|
indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL);
|
||||||
Sci_Position lookAtPos = (styler.LineStart(lineNext) == styler.Length()) ? styler.Length() - 1 : styler.LineStart(lineNext);
|
Sci_Position lookAtPos = (styler.LineStart(lineNext) == styler.Length()) ? styler.Length() - 1 : styler.LineStart(lineNext);
|
||||||
const int style = styler.StyleAt(lookAtPos) & 31;
|
const int style = styler.StyleAt(lookAtPos) & 31;
|
||||||
quote = options.foldQuotes && ((style == SCE_P_TRIPLE) || (style == SCE_P_TRIPLEDOUBLE));
|
quote = options.foldQuotes && IsPyTripleQuoteStringState(style);
|
||||||
}
|
}
|
||||||
const int quote_start = (quote && !prevQuote);
|
const int quote_start = (quote && !prevQuote);
|
||||||
const int quote_continue = (quote && prevQuote);
|
const int quote_continue = (quote && prevQuote);
|
||||||
@ -905,7 +930,7 @@ void SCI_METHOD LexerPython::Fold(Sci_PositionU startPos, Sci_Position length, i
|
|||||||
}
|
}
|
||||||
|
|
||||||
const int levelAfterComments = ((lineNext < docLines) ? indentNext & SC_FOLDLEVELNUMBERMASK : minCommentLevel);
|
const int levelAfterComments = ((lineNext < docLines) ? indentNext & SC_FOLDLEVELNUMBERMASK : minCommentLevel);
|
||||||
const int levelBeforeComments = Maximum(indentCurrentLevel, levelAfterComments);
|
const int levelBeforeComments = std::max(indentCurrentLevel, levelAfterComments);
|
||||||
|
|
||||||
// Now set all the indent levels on the lines we skipped
|
// Now set all the indent levels on the lines we skipped
|
||||||
// Do this from end to start. Once we encounter one line
|
// Do this from end to start. Once we encounter one line
|
||||||
|
@ -24,9 +24,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline bool IsAWordChar(const int ch) {
|
static inline bool IsAWordChar(const int ch) {
|
||||||
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
|
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
|
||||||
|
@ -23,9 +23,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
//XXX Identical to Perl, put in common area
|
//XXX Identical to Perl, put in common area
|
||||||
static inline bool isEOLChar(char ch) {
|
static inline bool isEOLChar(char ch) {
|
||||||
@ -346,7 +344,7 @@ static bool RE_CanFollowKeyword(const char *keyword) {
|
|||||||
// Look at chars up to but not including endPos
|
// Look at chars up to but not including endPos
|
||||||
// Don't look at styles in case we're looking forward
|
// Don't look at styles in case we're looking forward
|
||||||
|
|
||||||
static int skipWhitespace(Sci_Position startPos,
|
static Sci_Position skipWhitespace(Sci_Position startPos,
|
||||||
Sci_Position endPos,
|
Sci_Position endPos,
|
||||||
Accessor &styler) {
|
Accessor &styler) {
|
||||||
for (Sci_Position i = startPos; i < endPos; i++) {
|
for (Sci_Position i = startPos; i < endPos; i++) {
|
||||||
|
@ -29,10 +29,9 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
#include "OptionSet.h"
|
#include "OptionSet.h"
|
||||||
|
#include "DefaultLexer.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
static const int NUM_RUST_KEYWORD_LISTS = 7;
|
static const int NUM_RUST_KEYWORD_LISTS = 7;
|
||||||
static const int MAX_RUST_IDENT_CHARS = 1023;
|
static const int MAX_RUST_IDENT_CHARS = 1023;
|
||||||
@ -116,7 +115,7 @@ struct OptionSetRust : public OptionSet<OptionsRust> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class LexerRust : public ILexer {
|
class LexerRust : public DefaultLexer {
|
||||||
WordList keywords[NUM_RUST_KEYWORD_LISTS];
|
WordList keywords[NUM_RUST_KEYWORD_LISTS];
|
||||||
OptionsRust options;
|
OptionsRust options;
|
||||||
OptionSetRust osRust;
|
OptionSetRust osRust;
|
||||||
@ -213,7 +212,7 @@ static void ScanIdentifier(Accessor& styler, Sci_Position& pos, WordList *keywor
|
|||||||
styler.ColourTo(pos - 1, SCE_RUST_MACRO);
|
styler.ColourTo(pos - 1, SCE_RUST_MACRO);
|
||||||
} else {
|
} else {
|
||||||
char s[MAX_RUST_IDENT_CHARS + 1];
|
char s[MAX_RUST_IDENT_CHARS + 1];
|
||||||
int len = pos - start;
|
Sci_Position len = pos - start;
|
||||||
len = len > MAX_RUST_IDENT_CHARS ? MAX_RUST_IDENT_CHARS : len;
|
len = len > MAX_RUST_IDENT_CHARS ? MAX_RUST_IDENT_CHARS : len;
|
||||||
GrabString(s, styler, start, len);
|
GrabString(s, styler, start, len);
|
||||||
bool keyword = false;
|
bool keyword = false;
|
||||||
@ -271,7 +270,7 @@ static void ScanNumber(Accessor& styler, Sci_Position& pos) {
|
|||||||
pos++;
|
pos++;
|
||||||
c = styler.SafeGetCharAt(pos, '\0');
|
c = styler.SafeGetCharAt(pos, '\0');
|
||||||
n = styler.SafeGetCharAt(pos + 1, '\0');
|
n = styler.SafeGetCharAt(pos + 1, '\0');
|
||||||
if (c == '8' || c == 's') {
|
if (c == '8') {
|
||||||
pos++;
|
pos++;
|
||||||
} else if (c == '1' && n == '6') {
|
} else if (c == '1' && n == '6') {
|
||||||
pos += 2;
|
pos += 2;
|
||||||
@ -279,6 +278,8 @@ static void ScanNumber(Accessor& styler, Sci_Position& pos) {
|
|||||||
pos += 2;
|
pos += 2;
|
||||||
} else if (c == '6' && n == '4') {
|
} else if (c == '6' && n == '4') {
|
||||||
pos += 2;
|
pos += 2;
|
||||||
|
} else if (styler.Match(pos, "size")) {
|
||||||
|
pos += 4;
|
||||||
} else {
|
} else {
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
|
@ -31,10 +31,9 @@
|
|||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
#include "OptionSet.h"
|
#include "OptionSet.h"
|
||||||
#include "SparseState.h"
|
#include "SparseState.h"
|
||||||
|
#include "DefaultLexer.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline bool IsAWordChar(int ch, bool sqlAllowDottedWord) {
|
static inline bool IsAWordChar(int ch, bool sqlAllowDottedWord) {
|
||||||
if (!sqlAllowDottedWord)
|
if (!sqlAllowDottedWord)
|
||||||
@ -302,7 +301,7 @@ struct OptionSetSQL : public OptionSet<OptionsSQL> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class LexerSQL : public ILexer {
|
class LexerSQL : public DefaultLexer {
|
||||||
public :
|
public :
|
||||||
LexerSQL() {}
|
LexerSQL() {}
|
||||||
|
|
||||||
@ -546,7 +545,7 @@ void SCI_METHOD LexerSQL::Lex(Sci_PositionU startPos, Sci_Position length, int i
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SCE_SQL_STRING:
|
case SCE_SQL_STRING:
|
||||||
if (sc.ch == '\\') {
|
if (options.sqlBackslashEscapes && sc.ch == '\\') {
|
||||||
// Escape sequence
|
// Escape sequence
|
||||||
sc.Forward();
|
sc.Forward();
|
||||||
} else if (sc.ch == '\"') {
|
} else if (sc.ch == '\"') {
|
||||||
|
@ -23,9 +23,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
// Extended to accept accented characters
|
// Extended to accept accented characters
|
||||||
static inline bool IsAWordChar(int ch) {
|
static inline bool IsAWordChar(int ch) {
|
||||||
@ -314,6 +312,7 @@ next:
|
|||||||
break;
|
break;
|
||||||
case '[':
|
case '[':
|
||||||
expected = true;
|
expected = true;
|
||||||
|
// Falls through.
|
||||||
case ']':
|
case ']':
|
||||||
case '(':
|
case '(':
|
||||||
case ')':
|
case ')':
|
||||||
|
@ -34,9 +34,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,9 +28,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
static void ColouriseVHDLDoc(
|
static void ColouriseVHDLDoc(
|
||||||
Sci_PositionU startPos,
|
Sci_PositionU startPos,
|
||||||
@ -52,7 +50,7 @@ static inline bool IsAWordStart(const int ch) {
|
|||||||
|
|
||||||
/***************************************/
|
/***************************************/
|
||||||
static inline bool IsABlank(unsigned int ch) {
|
static inline bool IsABlank(unsigned int ch) {
|
||||||
return (ch == ' ') || (ch == 0x09) || (ch == 0x0b) ;
|
return (ch == ' ') || (ch == 0x09) || (ch == 0x0b) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************/
|
/***************************************/
|
||||||
@ -74,8 +72,9 @@ static void ColouriseVHDLDoc(
|
|||||||
StyleContext sc(startPos, length, initStyle, styler);
|
StyleContext sc(startPos, length, initStyle, styler);
|
||||||
bool isExtendedId = false; // true when parsing an extended identifier
|
bool isExtendedId = false; // true when parsing an extended identifier
|
||||||
|
|
||||||
for (; sc.More(); sc.Forward())
|
while (sc.More())
|
||||||
{
|
{
|
||||||
|
bool advance = true;
|
||||||
|
|
||||||
// Determine if the current state should terminate.
|
// Determine if the current state should terminate.
|
||||||
if (sc.state == SCE_VHDL_OPERATOR) {
|
if (sc.state == SCE_VHDL_OPERATOR) {
|
||||||
@ -108,24 +107,28 @@ static void ColouriseVHDLDoc(
|
|||||||
// extended identifiers are terminated by backslash, check for end of line in case we have invalid syntax
|
// extended identifiers are terminated by backslash, check for end of line in case we have invalid syntax
|
||||||
isExtendedId = false;
|
isExtendedId = false;
|
||||||
sc.ForwardSetState(SCE_VHDL_DEFAULT);
|
sc.ForwardSetState(SCE_VHDL_DEFAULT);
|
||||||
|
advance = false;
|
||||||
}
|
}
|
||||||
} else if (sc.state == SCE_VHDL_COMMENT || sc.state == SCE_VHDL_COMMENTLINEBANG) {
|
} else if (sc.state == SCE_VHDL_COMMENT || sc.state == SCE_VHDL_COMMENTLINEBANG) {
|
||||||
if (sc.atLineEnd) {
|
if (sc.atLineEnd) {
|
||||||
sc.SetState(SCE_VHDL_DEFAULT);
|
sc.SetState(SCE_VHDL_DEFAULT);
|
||||||
}
|
}
|
||||||
} else if (sc.state == SCE_VHDL_STRING) {
|
} else if (sc.state == SCE_VHDL_STRING) {
|
||||||
if (sc.ch == '\\') {
|
if (sc.ch == '"') {
|
||||||
if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
|
advance = false;
|
||||||
|
sc.Forward();
|
||||||
|
if (sc.ch == '"')
|
||||||
sc.Forward();
|
sc.Forward();
|
||||||
}
|
else
|
||||||
} else if (sc.ch == '\"') {
|
sc.SetState(SCE_VHDL_DEFAULT);
|
||||||
sc.ForwardSetState(SCE_VHDL_DEFAULT);
|
|
||||||
} else if (sc.atLineEnd) {
|
} else if (sc.atLineEnd) {
|
||||||
|
advance = false;
|
||||||
sc.ChangeState(SCE_VHDL_STRINGEOL);
|
sc.ChangeState(SCE_VHDL_STRINGEOL);
|
||||||
sc.ForwardSetState(SCE_VHDL_DEFAULT);
|
sc.ForwardSetState(SCE_VHDL_DEFAULT);
|
||||||
}
|
}
|
||||||
} else if (sc.state == SCE_VHDL_BLOCK_COMMENT){
|
} else if (sc.state == SCE_VHDL_BLOCK_COMMENT){
|
||||||
if(sc.ch == '*' && sc.chNext == '/'){
|
if(sc.ch == '*' && sc.chNext == '/'){
|
||||||
|
advance = false;
|
||||||
sc.Forward();
|
sc.Forward();
|
||||||
sc.ForwardSetState(SCE_VHDL_DEFAULT);
|
sc.ForwardSetState(SCE_VHDL_DEFAULT);
|
||||||
}
|
}
|
||||||
@ -144,8 +147,19 @@ static void ColouriseVHDLDoc(
|
|||||||
sc.SetState(SCE_VHDL_COMMENT);
|
sc.SetState(SCE_VHDL_COMMENT);
|
||||||
} else if (sc.Match('/', '*')){
|
} else if (sc.Match('/', '*')){
|
||||||
sc.SetState(SCE_VHDL_BLOCK_COMMENT);
|
sc.SetState(SCE_VHDL_BLOCK_COMMENT);
|
||||||
} else if (sc.ch == '\"') {
|
} else if (sc.ch == '"') {
|
||||||
sc.SetState(SCE_VHDL_STRING);
|
sc.SetState(SCE_VHDL_STRING);
|
||||||
|
} else if (sc.ch == '\'') {
|
||||||
|
if (sc.GetRelative(2) == '\''){
|
||||||
|
if (sc.chNext != '(' || sc.GetRelative(4) != '\''){
|
||||||
|
// Can only be a character literal
|
||||||
|
sc.SetState(SCE_VHDL_STRING);
|
||||||
|
sc.Forward();
|
||||||
|
sc.Forward();
|
||||||
|
sc.ForwardSetState(SCE_VHDL_DEFAULT);
|
||||||
|
advance = false;
|
||||||
|
} // else can be a tick or a character literal, need more context, eg.: identifier'('x')
|
||||||
|
} // else can only be a tick
|
||||||
} else if (sc.ch == '\\') {
|
} else if (sc.ch == '\\') {
|
||||||
isExtendedId = true;
|
isExtendedId = true;
|
||||||
sc.SetState(SCE_VHDL_IDENTIFIER);
|
sc.SetState(SCE_VHDL_IDENTIFIER);
|
||||||
@ -153,55 +167,58 @@ static void ColouriseVHDLDoc(
|
|||||||
sc.SetState(SCE_VHDL_OPERATOR);
|
sc.SetState(SCE_VHDL_OPERATOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (advance)
|
||||||
|
sc.Forward();
|
||||||
}
|
}
|
||||||
sc.Complete();
|
sc.Complete();
|
||||||
}
|
}
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
static bool IsCommentLine(Sci_Position line, Accessor &styler) {
|
static bool IsCommentLine(Sci_Position line, Accessor &styler) {
|
||||||
Sci_Position pos = styler.LineStart(line);
|
Sci_Position pos = styler.LineStart(line);
|
||||||
Sci_Position eol_pos = styler.LineStart(line + 1) - 1;
|
Sci_Position eol_pos = styler.LineStart(line + 1) - 1;
|
||||||
for (Sci_Position i = pos; i < eol_pos; i++) {
|
for (Sci_Position i = pos; i < eol_pos; i++) {
|
||||||
char ch = styler[i];
|
char ch = styler[i];
|
||||||
char chNext = styler[i+1];
|
char chNext = styler[i+1];
|
||||||
if ((ch == '-') && (chNext == '-'))
|
if ((ch == '-') && (chNext == '-'))
|
||||||
return true;
|
return true;
|
||||||
else if (ch != ' ' && ch != '\t')
|
else if (ch != ' ' && ch != '\t')
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
static bool IsCommentBlockStart(Sci_Position line, Accessor &styler)
|
static bool IsCommentBlockStart(Sci_Position line, Accessor &styler)
|
||||||
{
|
{
|
||||||
Sci_Position pos = styler.LineStart(line);
|
Sci_Position pos = styler.LineStart(line);
|
||||||
Sci_Position eol_pos = styler.LineStart(line + 1) - 1;
|
Sci_Position eol_pos = styler.LineStart(line + 1) - 1;
|
||||||
for (Sci_Position i = pos; i < eol_pos; i++) {
|
for (Sci_Position i = pos; i < eol_pos; i++) {
|
||||||
char ch = styler[i];
|
char ch = styler[i];
|
||||||
char chNext = styler[i+1];
|
char chNext = styler[i+1];
|
||||||
char style = styler.StyleAt(i);
|
char style = styler.StyleAt(i);
|
||||||
if ((style == SCE_VHDL_BLOCK_COMMENT) && (ch == '/') && (chNext == '*'))
|
if ((style == SCE_VHDL_BLOCK_COMMENT) && (ch == '/') && (chNext == '*'))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsCommentBlockEnd(Sci_Position line, Accessor &styler)
|
static bool IsCommentBlockEnd(Sci_Position line, Accessor &styler)
|
||||||
{
|
{
|
||||||
Sci_Position pos = styler.LineStart(line);
|
Sci_Position pos = styler.LineStart(line);
|
||||||
Sci_Position eol_pos = styler.LineStart(line + 1) - 1;
|
Sci_Position eol_pos = styler.LineStart(line + 1) - 1;
|
||||||
|
|
||||||
for (Sci_Position i = pos; i < eol_pos; i++) {
|
for (Sci_Position i = pos; i < eol_pos; i++) {
|
||||||
char ch = styler[i];
|
char ch = styler[i];
|
||||||
char chNext = styler[i+1];
|
char chNext = styler[i+1];
|
||||||
char style = styler.StyleAt(i);
|
char style = styler.StyleAt(i);
|
||||||
if ((style == SCE_VHDL_BLOCK_COMMENT) && (ch == '*') && (chNext == '/'))
|
if ((style == SCE_VHDL_BLOCK_COMMENT) && (ch == '*') && (chNext == '/'))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsCommentStyle(char style)
|
static bool IsCommentStyle(char style)
|
||||||
{
|
{
|
||||||
return style == SCE_VHDL_BLOCK_COMMENT || style == SCE_VHDL_COMMENT || style == SCE_VHDL_COMMENTLINEBANG;
|
return style == SCE_VHDL_BLOCK_COMMENT || style == SCE_VHDL_COMMENT || style == SCE_VHDL_COMMENTLINEBANG;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
@ -31,10 +31,9 @@
|
|||||||
|
|
||||||
#include "OptionSet.h"
|
#include "OptionSet.h"
|
||||||
#include "SubStyles.h"
|
#include "SubStyles.h"
|
||||||
|
#include "DefaultLexer.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace {
|
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
|
||||||
@ -172,7 +171,7 @@ const char styleSubable[] = {0};
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class LexerVerilog : public ILexerWithSubStyles {
|
class LexerVerilog : public DefaultLexer {
|
||||||
CharacterSet setWord;
|
CharacterSet setWord;
|
||||||
WordList keywords;
|
WordList keywords;
|
||||||
WordList keywords2;
|
WordList keywords2;
|
||||||
|
@ -23,9 +23,7 @@
|
|||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
static const char * const yamlWordListDesc[] = {
|
static const char * const yamlWordListDesc[] = {
|
||||||
"Keywords",
|
"Keywords",
|
||||||
|
@ -17,9 +17,7 @@
|
|||||||
#include "LexAccessor.h"
|
#include "LexAccessor.h"
|
||||||
#include "Accessor.h"
|
#include "Accessor.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
Accessor::Accessor(IDocument *pAccess_, PropSetSimple *pprops_) : LexAccessor(pAccess_), pprops(pprops_) {
|
Accessor::Accessor(IDocument *pAccess_, PropSetSimple *pprops_) : LexAccessor(pAccess_), pprops(pprops_) {
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,7 @@
|
|||||||
#ifndef ACCESSOR_H
|
#ifndef ACCESSOR_H
|
||||||
#define ACCESSOR_H
|
#define ACCESSOR_H
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
enum { wsSpace=1, wsTab=2, wsSpaceTab=4, wsInconsistent=8 };
|
enum { wsSpace=1, wsTab=2, wsSpaceTab=4, wsInconsistent=8 };
|
||||||
|
|
||||||
@ -28,8 +26,6 @@ public:
|
|||||||
int IndentAmount(Sci_Position line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0);
|
int IndentAmount(Sci_Position line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -8,13 +8,11 @@
|
|||||||
// The License.txt file describes the conditions under which this software may be distributed.
|
// The License.txt file describes the conditions under which this software may be distributed.
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
#include "StringCopy.h"
|
|
||||||
#include "CharacterCategory.h"
|
#include "CharacterCategory.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
// Use an unnamed namespace to protect the declarations from name conflicts
|
// Use an unnamed namespace to protect the declarations from name conflicts
|
||||||
@ -3681,7 +3679,6 @@ const int catRanges[] = {
|
|||||||
|
|
||||||
const int maxUnicode = 0x10ffff;
|
const int maxUnicode = 0x10ffff;
|
||||||
const int maskCategory = 0x1F;
|
const int maskCategory = 0x1F;
|
||||||
const int nRanges = ELEMENTS(catRanges);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3700,7 +3697,7 @@ CharacterCategory CategoriseCharacter(int character) {
|
|||||||
if (character < 0 || character > maxUnicode)
|
if (character < 0 || character > maxUnicode)
|
||||||
return ccCn;
|
return ccCn;
|
||||||
const int baseValue = character * (maskCategory+1) + maskCategory;
|
const int baseValue = character * (maskCategory+1) + maskCategory;
|
||||||
const int *placeAfter = std::lower_bound(catRanges, catRanges+nRanges, baseValue);
|
const int *placeAfter = std::lower_bound(catRanges, std::end(catRanges), baseValue);
|
||||||
return static_cast<CharacterCategory>(*(placeAfter-1) & maskCategory);
|
return static_cast<CharacterCategory>(*(placeAfter-1) & maskCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3850,6 +3847,4 @@ bool IsXidContinue(int character) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
@ -8,9 +8,7 @@
|
|||||||
#ifndef CHARACTERCATEGORY_H
|
#ifndef CHARACTERCATEGORY_H
|
||||||
#define CHARACTERCATEGORY_H
|
#define CHARACTERCATEGORY_H
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
enum CharacterCategory {
|
enum CharacterCategory {
|
||||||
ccLu, ccLl, ccLt, ccLm, ccLo,
|
ccLu, ccLl, ccLt, ccLm, ccLo,
|
||||||
@ -30,8 +28,6 @@ bool IsIdContinue(int character);
|
|||||||
bool IsXidStart(int character);
|
bool IsXidStart(int character);
|
||||||
bool IsXidContinue(int character);
|
bool IsXidContinue(int character);
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -11,19 +11,15 @@
|
|||||||
|
|
||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
int CompareCaseInsensitive(const char *a, const char *b) {
|
int CompareCaseInsensitive(const char *a, const char *b) {
|
||||||
while (*a && *b) {
|
while (*a && *b) {
|
||||||
if (*a != *b) {
|
if (*a != *b) {
|
||||||
const char upperA = static_cast<char>(MakeUpperCase(*a));
|
const char upperA = MakeUpperCase(*a);
|
||||||
const char upperB = static_cast<char>(MakeUpperCase(*b));
|
const char upperB = MakeUpperCase(*b);
|
||||||
if (upperA != upperB)
|
if (upperA != upperB)
|
||||||
return upperA - upperB;
|
return upperA - upperB;
|
||||||
}
|
}
|
||||||
@ -37,8 +33,8 @@ int CompareCaseInsensitive(const char *a, const char *b) {
|
|||||||
int CompareNCaseInsensitive(const char *a, const char *b, size_t len) {
|
int CompareNCaseInsensitive(const char *a, const char *b, size_t len) {
|
||||||
while (*a && *b && len) {
|
while (*a && *b && len) {
|
||||||
if (*a != *b) {
|
if (*a != *b) {
|
||||||
const char upperA = static_cast<char>(MakeUpperCase(*a));
|
const char upperA = MakeUpperCase(*a);
|
||||||
const char upperB = static_cast<char>(MakeUpperCase(*b));
|
const char upperB = MakeUpperCase(*b);
|
||||||
if (upperA != upperB)
|
if (upperA != upperB)
|
||||||
return upperA - upperB;
|
return upperA - upperB;
|
||||||
}
|
}
|
||||||
@ -53,6 +49,4 @@ int CompareNCaseInsensitive(const char *a, const char *b, size_t len) {
|
|||||||
return *a - *b;
|
return *a - *b;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
@ -8,9 +8,7 @@
|
|||||||
#ifndef CHARACTERSET_H
|
#ifndef CHARACTERSET_H
|
||||||
#define CHARACTERSET_H
|
#define CHARACTERSET_H
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
class CharacterSet {
|
class CharacterSet {
|
||||||
int size;
|
int size;
|
||||||
@ -61,7 +59,7 @@ public:
|
|||||||
}
|
}
|
||||||
~CharacterSet() {
|
~CharacterSet() {
|
||||||
delete []bset;
|
delete []bset;
|
||||||
bset = 0;
|
bset = nullptr;
|
||||||
size = 0;
|
size = 0;
|
||||||
}
|
}
|
||||||
CharacterSet &operator=(const CharacterSet &other) {
|
CharacterSet &operator=(const CharacterSet &other) {
|
||||||
@ -169,16 +167,18 @@ inline bool isoperator(int ch) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simple case functions for ASCII.
|
// Simple case functions for ASCII supersets.
|
||||||
|
|
||||||
inline int MakeUpperCase(int ch) {
|
template <typename T>
|
||||||
|
inline T MakeUpperCase(T ch) {
|
||||||
if (ch < 'a' || ch > 'z')
|
if (ch < 'a' || ch > 'z')
|
||||||
return ch;
|
return ch;
|
||||||
else
|
else
|
||||||
return static_cast<char>(ch - 'a' + 'A');
|
return ch - 'a' + 'A';
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int MakeLowerCase(int ch) {
|
template <typename T>
|
||||||
|
inline T MakeLowerCase(T ch) {
|
||||||
if (ch < 'A' || ch > 'Z')
|
if (ch < 'A' || ch > 'Z')
|
||||||
return ch;
|
return ch;
|
||||||
else
|
else
|
||||||
@ -188,8 +188,6 @@ inline int MakeLowerCase(int ch) {
|
|||||||
int CompareCaseInsensitive(const char *a, const char *b);
|
int CompareCaseInsensitive(const char *a, const char *b);
|
||||||
int CompareNCaseInsensitive(const char *a, const char *b, size_t len);
|
int CompareNCaseInsensitive(const char *a, const char *b, size_t len);
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
125
scintilla/lexlib/DefaultLexer.cxx
Normal file
125
scintilla/lexlib/DefaultLexer.cxx
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
// Scintilla source code edit control
|
||||||
|
/** @file DefaultLexer.cxx
|
||||||
|
** A lexer base class that provides reasonable default behaviour.
|
||||||
|
**/
|
||||||
|
// Copyright 2017 by Neil Hodgson <neilh@scintilla.org>
|
||||||
|
// The License.txt file describes the conditions under which this software may be distributed.
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
#include "ILexer.h"
|
||||||
|
#include "Scintilla.h"
|
||||||
|
#include "SciLexer.h"
|
||||||
|
|
||||||
|
#include "PropSetSimple.h"
|
||||||
|
#include "WordList.h"
|
||||||
|
#include "LexAccessor.h"
|
||||||
|
#include "Accessor.h"
|
||||||
|
#include "LexerModule.h"
|
||||||
|
#include "DefaultLexer.h"
|
||||||
|
|
||||||
|
using namespace Scintilla;
|
||||||
|
|
||||||
|
static const char styleSubable[] = { 0 };
|
||||||
|
|
||||||
|
DefaultLexer::DefaultLexer(const LexicalClass *lexClasses_, size_t nClasses_) :
|
||||||
|
lexClasses(lexClasses_), nClasses(nClasses_) {
|
||||||
|
}
|
||||||
|
|
||||||
|
DefaultLexer::~DefaultLexer() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void SCI_METHOD DefaultLexer::Release() {
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SCI_METHOD DefaultLexer::Version() const {
|
||||||
|
return lvMetaData;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * SCI_METHOD DefaultLexer::PropertyNames() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
int SCI_METHOD DefaultLexer::PropertyType(const char *) {
|
||||||
|
return SC_TYPE_BOOLEAN;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * SCI_METHOD DefaultLexer::DescribeProperty(const char *) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
Sci_Position SCI_METHOD DefaultLexer::PropertySet(const char *, const char *) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * SCI_METHOD DefaultLexer::DescribeWordListSets() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
Sci_Position SCI_METHOD DefaultLexer::WordListSet(int, const char *) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SCI_METHOD DefaultLexer::Fold(Sci_PositionU, Sci_Position, int, IDocument *) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void * SCI_METHOD DefaultLexer::PrivateCall(int, void *) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SCI_METHOD DefaultLexer::LineEndTypesSupported() {
|
||||||
|
return SC_LINE_END_TYPE_DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SCI_METHOD DefaultLexer::AllocateSubStyles(int, int) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SCI_METHOD DefaultLexer::SubStylesStart(int) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SCI_METHOD DefaultLexer::SubStylesLength(int) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SCI_METHOD DefaultLexer::StyleFromSubStyle(int subStyle) {
|
||||||
|
return subStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SCI_METHOD DefaultLexer::PrimaryStyleFromStyle(int style) {
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SCI_METHOD DefaultLexer::FreeSubStyles() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void SCI_METHOD DefaultLexer::SetIdentifiers(int, const char *) {
|
||||||
|
}
|
||||||
|
|
||||||
|
int SCI_METHOD DefaultLexer::DistanceToSecondaryStyles() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * SCI_METHOD DefaultLexer::GetSubStyleBases() {
|
||||||
|
return styleSubable;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SCI_METHOD DefaultLexer::NamedStyles() {
|
||||||
|
return static_cast<int>(nClasses);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * SCI_METHOD DefaultLexer::NameOfStyle(int style) {
|
||||||
|
return (style < NamedStyles()) ? lexClasses[style].name : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * SCI_METHOD DefaultLexer::TagsOfStyle(int style) {
|
||||||
|
return (style < NamedStyles()) ? lexClasses[style].tags : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * SCI_METHOD DefaultLexer::DescriptionOfStyle(int style) {
|
||||||
|
return (style < NamedStyles()) ? lexClasses[style].description : "";
|
||||||
|
}
|
51
scintilla/lexlib/DefaultLexer.h
Normal file
51
scintilla/lexlib/DefaultLexer.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// Scintilla source code edit control
|
||||||
|
/** @file DefaultLexer.h
|
||||||
|
** A lexer base class with default empty implementations of methods.
|
||||||
|
** For lexers that do not support all features so do not need real implementations.
|
||||||
|
** Does have real implementation for style metadata.
|
||||||
|
**/
|
||||||
|
// Copyright 2017 by Neil Hodgson <neilh@scintilla.org>
|
||||||
|
// The License.txt file describes the conditions under which this software may be distributed.
|
||||||
|
|
||||||
|
#ifndef DEFAULTLEXER_H
|
||||||
|
#define DEFAULTLEXER_H
|
||||||
|
|
||||||
|
namespace Scintilla {
|
||||||
|
|
||||||
|
// A simple lexer with no state
|
||||||
|
class DefaultLexer : public ILexerWithMetaData {
|
||||||
|
const LexicalClass *lexClasses;
|
||||||
|
size_t nClasses;
|
||||||
|
public:
|
||||||
|
DefaultLexer(const LexicalClass *lexClasses_ = nullptr, size_t nClasses_ = 0);
|
||||||
|
virtual ~DefaultLexer();
|
||||||
|
void SCI_METHOD Release() override;
|
||||||
|
int SCI_METHOD Version() const override;
|
||||||
|
const char * SCI_METHOD PropertyNames() override;
|
||||||
|
int SCI_METHOD PropertyType(const char *name) override;
|
||||||
|
const char * SCI_METHOD DescribeProperty(const char *name) override;
|
||||||
|
Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override;
|
||||||
|
const char * SCI_METHOD DescribeWordListSets() override;
|
||||||
|
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 = 0;
|
||||||
|
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) override;
|
||||||
|
void * SCI_METHOD PrivateCall(int operation, void *pointer) override;
|
||||||
|
int SCI_METHOD LineEndTypesSupported() override;
|
||||||
|
int SCI_METHOD AllocateSubStyles(int styleBase, int numberStyles) override;
|
||||||
|
int SCI_METHOD SubStylesStart(int styleBase) override;
|
||||||
|
int SCI_METHOD SubStylesLength(int styleBase) override;
|
||||||
|
int SCI_METHOD StyleFromSubStyle(int subStyle) override;
|
||||||
|
int SCI_METHOD PrimaryStyleFromStyle(int style) override;
|
||||||
|
void SCI_METHOD FreeSubStyles() override;
|
||||||
|
void SCI_METHOD SetIdentifiers(int style, const char *identifiers) override;
|
||||||
|
int SCI_METHOD DistanceToSecondaryStyles() override;
|
||||||
|
const char * SCI_METHOD GetSubStyleBases() override;
|
||||||
|
int SCI_METHOD NamedStyles() override;
|
||||||
|
const char * SCI_METHOD NameOfStyle(int style) override;
|
||||||
|
const char * SCI_METHOD TagsOfStyle(int style) override;
|
||||||
|
const char * SCI_METHOD DescriptionOfStyle(int style) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -8,9 +8,7 @@
|
|||||||
#ifndef LEXACCESSOR_H
|
#ifndef LEXACCESSOR_H
|
||||||
#define LEXACCESSOR_H
|
#define LEXACCESSOR_H
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
enum EncodingType { enc8bit, encUnicode, encDBCS };
|
enum EncodingType { enc8bit, encUnicode, encDBCS };
|
||||||
|
|
||||||
@ -111,7 +109,7 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
char StyleAt(Sci_Position position) const {
|
char StyleAt(Sci_Position position) const {
|
||||||
return static_cast<char>(pAccess->StyleAt(position));
|
return pAccess->StyleAt(position);
|
||||||
}
|
}
|
||||||
Sci_Position GetLine(Sci_Position position) const {
|
Sci_Position GetLine(Sci_Position position) const {
|
||||||
return pAccess->LineFromPosition(position);
|
return pAccess->LineFromPosition(position);
|
||||||
@ -172,13 +170,14 @@ public:
|
|||||||
|
|
||||||
if (validLen + (pos - startSeg + 1) >= bufferSize)
|
if (validLen + (pos - startSeg + 1) >= bufferSize)
|
||||||
Flush();
|
Flush();
|
||||||
|
const char attr = static_cast<char>(chAttr);
|
||||||
if (validLen + (pos - startSeg + 1) >= bufferSize) {
|
if (validLen + (pos - startSeg + 1) >= bufferSize) {
|
||||||
// Too big for buffer so send directly
|
// Too big for buffer so send directly
|
||||||
pAccess->SetStyleFor(pos - startSeg + 1, static_cast<char>(chAttr));
|
pAccess->SetStyleFor(pos - startSeg + 1, attr);
|
||||||
} else {
|
} else {
|
||||||
for (Sci_PositionU i = startSeg; i <= pos; i++) {
|
for (Sci_PositionU i = startSeg; i <= pos; i++) {
|
||||||
assert((startPosStyling + validLen) < Length());
|
assert((startPosStyling + validLen) < Length());
|
||||||
styleBuf[validLen++] = static_cast<char>(chAttr);
|
styleBuf[validLen++] = attr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,8 +196,13 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
struct LexicalClass {
|
||||||
|
int value;
|
||||||
|
const char *name;
|
||||||
|
const char *tags;
|
||||||
|
const char *description;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -20,11 +20,12 @@
|
|||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
#include "LexerBase.h"
|
#include "LexerBase.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
LexerBase::LexerBase() {
|
static const char styleSubable[] = { 0 };
|
||||||
|
|
||||||
|
LexerBase::LexerBase(const LexicalClass *lexClasses_, size_t nClasses_) :
|
||||||
|
lexClasses(lexClasses_), nClasses(nClasses_) {
|
||||||
for (int wl = 0; wl < numWordLists; wl++)
|
for (int wl = 0; wl < numWordLists; wl++)
|
||||||
keyWordLists[wl] = new WordList;
|
keyWordLists[wl] = new WordList;
|
||||||
keyWordLists[numWordLists] = 0;
|
keyWordLists[numWordLists] = 0;
|
||||||
@ -43,7 +44,7 @@ void SCI_METHOD LexerBase::Release() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int SCI_METHOD LexerBase::Version() const {
|
int SCI_METHOD LexerBase::Version() const {
|
||||||
return lvOriginal;
|
return lvMetaData;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * SCI_METHOD LexerBase::PropertyNames() {
|
const char * SCI_METHOD LexerBase::PropertyNames() {
|
||||||
@ -61,7 +62,7 @@ const char * SCI_METHOD LexerBase::DescribeProperty(const char *) {
|
|||||||
Sci_Position SCI_METHOD LexerBase::PropertySet(const char *key, const char *val) {
|
Sci_Position SCI_METHOD LexerBase::PropertySet(const char *key, const char *val) {
|
||||||
const char *valOld = props.Get(key);
|
const char *valOld = props.Get(key);
|
||||||
if (strcmp(val, valOld) != 0) {
|
if (strcmp(val, valOld) != 0) {
|
||||||
props.Set(key, val);
|
props.Set(key, val, strlen(key), strlen(val));
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
@ -85,5 +86,59 @@ Sci_Position SCI_METHOD LexerBase::WordListSet(int n, const char *wl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void * SCI_METHOD LexerBase::PrivateCall(int, void *) {
|
void * SCI_METHOD LexerBase::PrivateCall(int, void *) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SCI_METHOD LexerBase::LineEndTypesSupported() {
|
||||||
|
return SC_LINE_END_TYPE_DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SCI_METHOD LexerBase::AllocateSubStyles(int, int) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SCI_METHOD LexerBase::SubStylesStart(int) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SCI_METHOD LexerBase::SubStylesLength(int) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SCI_METHOD LexerBase::StyleFromSubStyle(int subStyle) {
|
||||||
|
return subStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SCI_METHOD LexerBase::PrimaryStyleFromStyle(int style) {
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SCI_METHOD LexerBase::FreeSubStyles() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void SCI_METHOD LexerBase::SetIdentifiers(int, const char *) {
|
||||||
|
}
|
||||||
|
|
||||||
|
int SCI_METHOD LexerBase::DistanceToSecondaryStyles() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * SCI_METHOD LexerBase::GetSubStyleBases() {
|
||||||
|
return styleSubable;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SCI_METHOD LexerBase::NamedStyles() {
|
||||||
|
return static_cast<int>(nClasses);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * SCI_METHOD LexerBase::NameOfStyle(int style) {
|
||||||
|
return (style < NamedStyles()) ? lexClasses[style].name : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * SCI_METHOD LexerBase::TagsOfStyle(int style) {
|
||||||
|
return (style < NamedStyles()) ? lexClasses[style].tags : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * SCI_METHOD LexerBase::DescriptionOfStyle(int style) {
|
||||||
|
return (style < NamedStyles()) ? lexClasses[style].description : "";
|
||||||
|
}
|
||||||
|
@ -8,34 +8,46 @@
|
|||||||
#ifndef LEXERBASE_H
|
#ifndef LEXERBASE_H
|
||||||
#define LEXERBASE_H
|
#define LEXERBASE_H
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
// A simple lexer with no state
|
// A simple lexer with no state
|
||||||
class LexerBase : public ILexer {
|
class LexerBase : public ILexerWithMetaData {
|
||||||
protected:
|
protected:
|
||||||
|
const LexicalClass *lexClasses;
|
||||||
|
size_t nClasses;
|
||||||
PropSetSimple props;
|
PropSetSimple props;
|
||||||
enum {numWordLists=KEYWORDSET_MAX+1};
|
enum {numWordLists=KEYWORDSET_MAX+1};
|
||||||
WordList *keyWordLists[numWordLists+1];
|
WordList *keyWordLists[numWordLists+1];
|
||||||
public:
|
public:
|
||||||
LexerBase();
|
LexerBase(const LexicalClass *lexClasses_=nullptr, size_t nClasses_=0);
|
||||||
virtual ~LexerBase();
|
virtual ~LexerBase();
|
||||||
void SCI_METHOD Release();
|
void SCI_METHOD Release() override;
|
||||||
int SCI_METHOD Version() const;
|
int SCI_METHOD Version() const override;
|
||||||
const char * SCI_METHOD PropertyNames();
|
const char * SCI_METHOD PropertyNames() override;
|
||||||
int SCI_METHOD PropertyType(const char *name);
|
int SCI_METHOD PropertyType(const char *name) override;
|
||||||
const char * SCI_METHOD DescribeProperty(const char *name);
|
const char * SCI_METHOD DescribeProperty(const char *name) override;
|
||||||
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;
|
||||||
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 lengthDoc, int initStyle, IDocument *pAccess) = 0;
|
void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) override = 0;
|
||||||
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) = 0;
|
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) override = 0;
|
||||||
void * SCI_METHOD PrivateCall(int operation, void *pointer);
|
void * SCI_METHOD PrivateCall(int operation, void *pointer) override;
|
||||||
|
int SCI_METHOD LineEndTypesSupported() override;
|
||||||
|
int SCI_METHOD AllocateSubStyles(int styleBase, int numberStyles) override;
|
||||||
|
int SCI_METHOD SubStylesStart(int styleBase) override;
|
||||||
|
int SCI_METHOD SubStylesLength(int styleBase) override;
|
||||||
|
int SCI_METHOD StyleFromSubStyle(int subStyle) override;
|
||||||
|
int SCI_METHOD PrimaryStyleFromStyle(int style) override;
|
||||||
|
void SCI_METHOD FreeSubStyles() override;
|
||||||
|
void SCI_METHOD SetIdentifiers(int style, const char *identifiers) override;
|
||||||
|
int SCI_METHOD DistanceToSecondaryStyles() override;
|
||||||
|
const char * SCI_METHOD GetSubStyleBases() override;
|
||||||
|
int SCI_METHOD NamedStyles() override;
|
||||||
|
const char * SCI_METHOD NameOfStyle(int style) override;
|
||||||
|
const char * SCI_METHOD TagsOfStyle(int style) override;
|
||||||
|
const char * SCI_METHOD DescriptionOfStyle(int style) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -22,20 +22,22 @@
|
|||||||
#include "LexerBase.h"
|
#include "LexerBase.h"
|
||||||
#include "LexerSimple.h"
|
#include "LexerSimple.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
LexerModule::LexerModule(int language_,
|
LexerModule::LexerModule(int language_,
|
||||||
LexerFunction fnLexer_,
|
LexerFunction fnLexer_,
|
||||||
const char *languageName_,
|
const char *languageName_,
|
||||||
LexerFunction fnFolder_,
|
LexerFunction fnFolder_,
|
||||||
const char *const wordListDescriptions_[]) :
|
const char *const wordListDescriptions_[],
|
||||||
|
const LexicalClass *lexClasses_,
|
||||||
|
size_t nClasses_) :
|
||||||
language(language_),
|
language(language_),
|
||||||
fnLexer(fnLexer_),
|
fnLexer(fnLexer_),
|
||||||
fnFolder(fnFolder_),
|
fnFolder(fnFolder_),
|
||||||
fnFactory(0),
|
fnFactory(nullptr),
|
||||||
wordListDescriptions(wordListDescriptions_),
|
wordListDescriptions(wordListDescriptions_),
|
||||||
|
lexClasses(lexClasses_),
|
||||||
|
nClasses(nClasses_),
|
||||||
languageName(languageName_) {
|
languageName(languageName_) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,15 +46,24 @@ LexerModule::LexerModule(int language_,
|
|||||||
const char *languageName_,
|
const char *languageName_,
|
||||||
const char * const wordListDescriptions_[]) :
|
const char * const wordListDescriptions_[]) :
|
||||||
language(language_),
|
language(language_),
|
||||||
fnLexer(0),
|
fnLexer(nullptr),
|
||||||
fnFolder(0),
|
fnFolder(nullptr),
|
||||||
fnFactory(fnFactory_),
|
fnFactory(fnFactory_),
|
||||||
wordListDescriptions(wordListDescriptions_),
|
wordListDescriptions(wordListDescriptions_),
|
||||||
|
lexClasses(nullptr),
|
||||||
|
nClasses(0),
|
||||||
languageName(languageName_) {
|
languageName(languageName_) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LexerModule::~LexerModule() {
|
||||||
|
}
|
||||||
|
|
||||||
|
int LexerModule::GetLanguage() const {
|
||||||
|
return language;
|
||||||
|
}
|
||||||
|
|
||||||
int LexerModule::GetNumWordLists() const {
|
int LexerModule::GetNumWordLists() const {
|
||||||
if (wordListDescriptions == NULL) {
|
if (!wordListDescriptions) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
int numWordLists = 0;
|
int numWordLists = 0;
|
||||||
@ -74,6 +85,14 @@ const char *LexerModule::GetWordListDescription(int index) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const LexicalClass *LexerModule::LexClasses() const {
|
||||||
|
return lexClasses;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t LexerModule::NamedStyles() const {
|
||||||
|
return nClasses;
|
||||||
|
}
|
||||||
|
|
||||||
ILexer *LexerModule::Create() const {
|
ILexer *LexerModule::Create() const {
|
||||||
if (fnFactory)
|
if (fnFactory)
|
||||||
return fnFactory();
|
return fnFactory();
|
||||||
@ -94,7 +113,7 @@ void LexerModule::Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initS
|
|||||||
// Move back one line in case deletion wrecked current line fold state
|
// Move back one line in case deletion wrecked current line fold state
|
||||||
if (lineCurrent > 0) {
|
if (lineCurrent > 0) {
|
||||||
lineCurrent--;
|
lineCurrent--;
|
||||||
Sci_Position newStartPos = styler.LineStart(lineCurrent);
|
const Sci_Position newStartPos = styler.LineStart(lineCurrent);
|
||||||
lengthDoc += startPos - newStartPos;
|
lengthDoc += startPos - newStartPos;
|
||||||
startPos = newStartPos;
|
startPos = newStartPos;
|
||||||
initStyle = 0;
|
initStyle = 0;
|
||||||
|
@ -8,12 +8,11 @@
|
|||||||
#ifndef LEXERMODULE_H
|
#ifndef LEXERMODULE_H
|
||||||
#define LEXERMODULE_H
|
#define LEXERMODULE_H
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
class Accessor;
|
class Accessor;
|
||||||
class WordList;
|
class WordList;
|
||||||
|
struct LexicalClass;
|
||||||
|
|
||||||
typedef void (*LexerFunction)(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle,
|
typedef void (*LexerFunction)(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle,
|
||||||
WordList *keywordlists[], Accessor &styler);
|
WordList *keywordlists[], Accessor &styler);
|
||||||
@ -21,8 +20,9 @@ typedef ILexer *(*LexerFactoryFunction)();
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A LexerModule is responsible for lexing and folding a particular language.
|
* A LexerModule is responsible for lexing and folding a particular language.
|
||||||
* The class maintains a list of LexerModules which can be searched to find a
|
* The Catalogue class maintains a list of LexerModules which can be searched to find a
|
||||||
* module appropriate to a particular language.
|
* module appropriate to a particular language.
|
||||||
|
* The ExternalLexerModule subclass holds lexers loaded from DLLs or shared libraries.
|
||||||
*/
|
*/
|
||||||
class LexerModule {
|
class LexerModule {
|
||||||
protected:
|
protected:
|
||||||
@ -31,25 +31,32 @@ protected:
|
|||||||
LexerFunction fnFolder;
|
LexerFunction fnFolder;
|
||||||
LexerFactoryFunction fnFactory;
|
LexerFactoryFunction fnFactory;
|
||||||
const char * const * wordListDescriptions;
|
const char * const * wordListDescriptions;
|
||||||
|
const LexicalClass *lexClasses;
|
||||||
|
size_t nClasses;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const char *languageName;
|
const char *languageName;
|
||||||
LexerModule(int language_,
|
LexerModule(
|
||||||
|
int language_,
|
||||||
LexerFunction fnLexer_,
|
LexerFunction fnLexer_,
|
||||||
const char *languageName_=0,
|
const char *languageName_=nullptr,
|
||||||
LexerFunction fnFolder_=0,
|
LexerFunction fnFolder_= nullptr,
|
||||||
const char * const wordListDescriptions_[] = NULL);
|
const char * const wordListDescriptions_[]=nullptr,
|
||||||
LexerModule(int language_,
|
const LexicalClass *lexClasses_=nullptr,
|
||||||
|
size_t nClasses_=0);
|
||||||
|
LexerModule(
|
||||||
|
int language_,
|
||||||
LexerFactoryFunction fnFactory_,
|
LexerFactoryFunction fnFactory_,
|
||||||
const char *languageName_,
|
const char *languageName_,
|
||||||
const char * const wordListDescriptions_[] = NULL);
|
const char * const wordListDescriptions_[]=nullptr);
|
||||||
virtual ~LexerModule() {
|
virtual ~LexerModule();
|
||||||
}
|
int GetLanguage() const;
|
||||||
int GetLanguage() const { return language; }
|
|
||||||
|
|
||||||
// -1 is returned if no WordList information is available
|
// -1 is returned if no WordList information is available
|
||||||
int GetNumWordLists() const;
|
int GetNumWordLists() const;
|
||||||
const char *GetWordListDescription(int index) const;
|
const char *GetWordListDescription(int index) const;
|
||||||
|
const LexicalClass *LexClasses() const;
|
||||||
|
size_t NamedStyles() const;
|
||||||
|
|
||||||
ILexer *Create() const;
|
ILexer *Create() const;
|
||||||
|
|
||||||
@ -75,8 +82,6 @@ inline int Maximum(int a, int b) {
|
|||||||
#pragma GCC diagnostic ignored "-Wshadow"
|
#pragma GCC diagnostic ignored "-Wshadow"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -20,9 +20,7 @@
|
|||||||
#include "LexerBase.h"
|
#include "LexerBase.h"
|
||||||
#include "LexerNoExceptions.h"
|
#include "LexerNoExceptions.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
Sci_Position SCI_METHOD LexerNoExceptions::PropertySet(const char *key, const char *val) {
|
Sci_Position SCI_METHOD LexerNoExceptions::PropertySet(const char *key, const char *val) {
|
||||||
try {
|
try {
|
||||||
|
@ -8,25 +8,21 @@
|
|||||||
#ifndef LEXERNOEXCEPTIONS_H
|
#ifndef LEXERNOEXCEPTIONS_H
|
||||||
#define LEXERNOEXCEPTIONS_H
|
#define LEXERNOEXCEPTIONS_H
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
// A simple lexer with no state
|
// A simple lexer with no state
|
||||||
class LexerNoExceptions : public LexerBase {
|
class LexerNoExceptions : public LexerBase {
|
||||||
public:
|
public:
|
||||||
// TODO Also need to prevent exceptions in constructor and destructor
|
// TODO Also need to prevent exceptions in constructor and destructor
|
||||||
Sci_Position SCI_METHOD PropertySet(const char *key, const char *val);
|
Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override;
|
||||||
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 lengthDoc, int initStyle, IDocument *pAccess);
|
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 *);
|
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *) override;
|
||||||
|
|
||||||
virtual void Lexer(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess, Accessor &styler) = 0;
|
virtual void Lexer(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess, Accessor &styler) = 0;
|
||||||
virtual void Folder(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess, Accessor &styler) = 0;
|
virtual void Folder(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess, Accessor &styler) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -22,11 +22,11 @@
|
|||||||
#include "LexerBase.h"
|
#include "LexerBase.h"
|
||||||
#include "LexerSimple.h"
|
#include "LexerSimple.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
LexerSimple::LexerSimple(const LexerModule *module_) : module(module_) {
|
LexerSimple::LexerSimple(const LexerModule *module_) :
|
||||||
|
LexerBase(module_->LexClasses(), module_->NamedStyles()),
|
||||||
|
module(module_) {
|
||||||
for (int wl = 0; wl < module->GetNumWordLists(); wl++) {
|
for (int wl = 0; wl < module->GetNumWordLists(); wl++) {
|
||||||
if (!wordLists.empty())
|
if (!wordLists.empty())
|
||||||
wordLists += "\n";
|
wordLists += "\n";
|
||||||
|
@ -8,9 +8,7 @@
|
|||||||
#ifndef LEXERSIMPLE_H
|
#ifndef LEXERSIMPLE_H
|
||||||
#define LEXERSIMPLE_H
|
#define LEXERSIMPLE_H
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
// A simple lexer with no state
|
// A simple lexer with no state
|
||||||
class LexerSimple : public LexerBase {
|
class LexerSimple : public LexerBase {
|
||||||
@ -18,13 +16,11 @@ class LexerSimple : public LexerBase {
|
|||||||
std::string wordLists;
|
std::string wordLists;
|
||||||
public:
|
public:
|
||||||
explicit LexerSimple(const LexerModule *module_);
|
explicit LexerSimple(const LexerModule *module_);
|
||||||
const char * SCI_METHOD DescribeWordListSets();
|
const char * SCI_METHOD DescribeWordListSets() override;
|
||||||
void SCI_METHOD Lex(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess);
|
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);
|
void SCI_METHOD Fold(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyle, IDocument *pAccess) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -10,9 +10,7 @@
|
|||||||
#ifndef OPTIONSET_H
|
#ifndef OPTIONSET_H
|
||||||
#define OPTIONSET_H
|
#define OPTIONSET_H
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class OptionSet {
|
class OptionSet {
|
||||||
@ -135,8 +133,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// SciTE - Scintilla based Text Editor
|
// Scintilla source code edit control
|
||||||
/** @file PropSetSimple.cxx
|
/** @file PropSetSimple.cxx
|
||||||
** A Java style properties file module.
|
** A basic string to string map.
|
||||||
**/
|
**/
|
||||||
// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
|
// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
|
||||||
// The License.txt file describes the conditions under which this software may be distributed.
|
// The License.txt file describes the conditions under which this software may be distributed.
|
||||||
@ -15,31 +15,33 @@
|
|||||||
|
|
||||||
#include "PropSetSimple.h"
|
#include "PropSetSimple.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
typedef std::map<std::string, std::string> mapss;
|
typedef std::map<std::string, std::string> mapss;
|
||||||
|
|
||||||
|
mapss *PropsFromPointer(void *impl) {
|
||||||
|
return static_cast<mapss *>(impl);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
PropSetSimple::PropSetSimple() {
|
PropSetSimple::PropSetSimple() {
|
||||||
mapss *props = new mapss;
|
mapss *props = new mapss;
|
||||||
impl = static_cast<void *>(props);
|
impl = static_cast<void *>(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
PropSetSimple::~PropSetSimple() {
|
PropSetSimple::~PropSetSimple() {
|
||||||
mapss *props = static_cast<mapss *>(impl);
|
mapss *props = PropsFromPointer(impl);
|
||||||
delete props;
|
delete props;
|
||||||
impl = 0;
|
impl = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropSetSimple::Set(const char *key, const char *val, int lenKey, int lenVal) {
|
void PropSetSimple::Set(const char *key, const char *val, size_t lenKey, size_t lenVal) {
|
||||||
mapss *props = static_cast<mapss *>(impl);
|
mapss *props = PropsFromPointer(impl);
|
||||||
if (!*key) // Empty keys are not supported
|
if (!*key) // Empty keys are not supported
|
||||||
return;
|
return;
|
||||||
if (lenKey == -1)
|
|
||||||
lenKey = static_cast<int>(strlen(key));
|
|
||||||
if (lenVal == -1)
|
|
||||||
lenVal = static_cast<int>(strlen(val));
|
|
||||||
(*props)[std::string(key, lenKey)] = std::string(val, lenVal);
|
(*props)[std::string(key, lenKey)] = std::string(val, lenVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,10 +57,10 @@ void PropSetSimple::Set(const char *keyVal) {
|
|||||||
endVal++;
|
endVal++;
|
||||||
const char *eqAt = strchr(keyVal, '=');
|
const char *eqAt = strchr(keyVal, '=');
|
||||||
if (eqAt) {
|
if (eqAt) {
|
||||||
Set(keyVal, eqAt + 1, static_cast<int>(eqAt-keyVal),
|
Set(keyVal, eqAt + 1, eqAt-keyVal,
|
||||||
static_cast<int>(endVal - eqAt - 1));
|
endVal - eqAt - 1);
|
||||||
} else if (*keyVal) { // No '=' so assume '=1'
|
} else if (*keyVal) { // No '=' so assume '=1'
|
||||||
Set(keyVal, "1", static_cast<int>(endVal-keyVal), 1);
|
Set(keyVal, "1", endVal-keyVal, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +75,7 @@ void PropSetSimple::SetMultiple(const char *s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char *PropSetSimple::Get(const char *key) const {
|
const char *PropSetSimple::Get(const char *key) const {
|
||||||
mapss *props = static_cast<mapss *>(impl);
|
mapss *props = PropsFromPointer(impl);
|
||||||
mapss::const_iterator keyPos = props->find(std::string(key));
|
mapss::const_iterator keyPos = props->find(std::string(key));
|
||||||
if (keyPos != props->end()) {
|
if (keyPos != props->end()) {
|
||||||
return keyPos->second.c_str();
|
return keyPos->second.c_str();
|
||||||
@ -88,7 +90,7 @@ const char *PropSetSimple::Get(const char *key) const {
|
|||||||
// for that, through a recursive function and a simple chain of pointers.
|
// for that, through a recursive function and a simple chain of pointers.
|
||||||
|
|
||||||
struct VarChain {
|
struct VarChain {
|
||||||
VarChain(const char *var_=NULL, const VarChain *link_=NULL): var(var_), link(link_) {}
|
VarChain(const char *var_=nullptr, const VarChain *link_= nullptr): var(var_), link(link_) {}
|
||||||
|
|
||||||
bool contains(const char *testVar) const {
|
bool contains(const char *testVar) const {
|
||||||
return (var && (0 == strcmp(var, testVar)))
|
return (var && (0 == strcmp(var, testVar)))
|
||||||
@ -102,7 +104,7 @@ struct VarChain {
|
|||||||
static int ExpandAllInPlace(const PropSetSimple &props, std::string &withVars, int maxExpands, const VarChain &blankVars) {
|
static int ExpandAllInPlace(const PropSetSimple &props, std::string &withVars, int maxExpands, const VarChain &blankVars) {
|
||||||
size_t varStart = withVars.find("$(");
|
size_t varStart = withVars.find("$(");
|
||||||
while ((varStart != std::string::npos) && (maxExpands > 0)) {
|
while ((varStart != std::string::npos) && (maxExpands > 0)) {
|
||||||
size_t varEnd = withVars.find(")", varStart+2);
|
const size_t varEnd = withVars.find(')', varStart+2);
|
||||||
if (varEnd == std::string::npos) {
|
if (varEnd == std::string::npos) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,7 @@
|
|||||||
#ifndef PROPSETSIMPLE_H
|
#ifndef PROPSETSIMPLE_H
|
||||||
#define PROPSETSIMPLE_H
|
#define PROPSETSIMPLE_H
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
class PropSetSimple {
|
class PropSetSimple {
|
||||||
void *impl;
|
void *impl;
|
||||||
@ -18,15 +16,13 @@ class PropSetSimple {
|
|||||||
public:
|
public:
|
||||||
PropSetSimple();
|
PropSetSimple();
|
||||||
virtual ~PropSetSimple();
|
virtual ~PropSetSimple();
|
||||||
void Set(const char *key, const char *val, int lenKey=-1, int lenVal=-1);
|
void Set(const char *key, const char *val, size_t lenKey, size_t lenVal);
|
||||||
void SetMultiple(const char *);
|
void SetMultiple(const char *);
|
||||||
const char *Get(const char *key) const;
|
const char *Get(const char *key) const;
|
||||||
int GetExpanded(const char *key, char *result) const;
|
int GetExpanded(const char *key, char *result) const;
|
||||||
int GetInt(const char *key, int defaultValue=0) const;
|
int GetInt(const char *key, int defaultValue=0) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -10,16 +10,14 @@
|
|||||||
#ifndef SPARSESTATE_H
|
#ifndef SPARSESTATE_H
|
||||||
#define SPARSESTATE_H
|
#define SPARSESTATE_H
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class SparseState {
|
class SparseState {
|
||||||
struct State {
|
struct State {
|
||||||
int position;
|
Sci_Position position;
|
||||||
T value;
|
T value;
|
||||||
State(int position_, T value_) : position(position_), value(value_) {
|
State(Sci_Position position_, T value_) : position(position_), value(value_) {
|
||||||
}
|
}
|
||||||
inline bool operator<(const State &other) const {
|
inline bool operator<(const State &other) const {
|
||||||
return position < other.position;
|
return position < other.position;
|
||||||
@ -28,26 +26,26 @@ class SparseState {
|
|||||||
return (position == other.position) && (value == other.value);
|
return (position == other.position) && (value == other.value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
int positionFirst;
|
Sci_Position positionFirst;
|
||||||
typedef std::vector<State> stateVector;
|
typedef std::vector<State> stateVector;
|
||||||
stateVector states;
|
stateVector states;
|
||||||
|
|
||||||
typename stateVector::iterator Find(int position) {
|
typename stateVector::iterator Find(Sci_Position position) {
|
||||||
State searchValue(position, T());
|
State searchValue(position, T());
|
||||||
return std::lower_bound(states.begin(), states.end(), searchValue);
|
return std::lower_bound(states.begin(), states.end(), searchValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SparseState(int positionFirst_=-1) {
|
explicit SparseState(Sci_Position positionFirst_=-1) {
|
||||||
positionFirst = positionFirst_;
|
positionFirst = positionFirst_;
|
||||||
}
|
}
|
||||||
void Set(int position, T value) {
|
void Set(Sci_Position position, T value) {
|
||||||
Delete(position);
|
Delete(position);
|
||||||
if (states.empty() || (value != states[states.size()-1].value)) {
|
if (states.empty() || (value != states[states.size()-1].value)) {
|
||||||
states.push_back(State(position, value));
|
states.push_back(State(position, value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
T ValueAt(int position) {
|
T ValueAt(Sci_Position position) {
|
||||||
if (states.empty())
|
if (states.empty())
|
||||||
return T();
|
return T();
|
||||||
if (position < states[0].position)
|
if (position < states[0].position)
|
||||||
@ -62,7 +60,7 @@ public:
|
|||||||
return low->value;
|
return low->value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool Delete(int position) {
|
bool Delete(Sci_Position position) {
|
||||||
typename stateVector::iterator low = Find(position);
|
typename stateVector::iterator low = Find(position);
|
||||||
if (low != states.end()) {
|
if (low != states.end()) {
|
||||||
states.erase(low, states.end());
|
states.erase(low, states.end());
|
||||||
@ -75,7 +73,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if Merge caused a significant change
|
// Returns true if Merge caused a significant change
|
||||||
bool Merge(const SparseState<T> &other, int ignoreAfter) {
|
bool Merge(const SparseState<T> &other, Sci_Position ignoreAfter) {
|
||||||
// Changes caused beyond ignoreAfter are not significant
|
// Changes caused beyond ignoreAfter are not significant
|
||||||
Delete(ignoreAfter+1);
|
Delete(ignoreAfter+1);
|
||||||
|
|
||||||
@ -103,8 +101,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -9,9 +9,7 @@
|
|||||||
#ifndef STRINGCOPY_H
|
#ifndef STRINGCOPY_H
|
||||||
#define STRINGCOPY_H
|
#define STRINGCOPY_H
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
// Safer version of string copy functions like strcpy, wcsncpy, etc.
|
// Safer version of string copy functions like strcpy, wcsncpy, etc.
|
||||||
// Instantiate over fixed length strings of both char and wchar_t.
|
// Instantiate over fixed length strings of both char and wchar_t.
|
||||||
@ -29,8 +27,6 @@ void StringCopy(T (&dest)[count], const T* source) {
|
|||||||
|
|
||||||
#define ELEMENTS(a) (sizeof(a) / sizeof(a[0]))
|
#define ELEMENTS(a) (sizeof(a) / sizeof(a[0]))
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -16,9 +16,7 @@
|
|||||||
#include "StyleContext.h"
|
#include "StyleContext.h"
|
||||||
#include "CharacterSet.h"
|
#include "CharacterSet.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
bool StyleContext::MatchIgnoreCase(const char *s) {
|
bool StyleContext::MatchIgnoreCase(const char *s) {
|
||||||
if (MakeLowerCase(ch) != static_cast<unsigned char>(*s))
|
if (MakeLowerCase(ch) != static_cast<unsigned char>(*s))
|
||||||
@ -28,8 +26,8 @@ bool StyleContext::MatchIgnoreCase(const char *s) {
|
|||||||
return false;
|
return false;
|
||||||
s++;
|
s++;
|
||||||
for (int n = 2; *s; n++) {
|
for (int n = 2; *s; n++) {
|
||||||
if (static_cast<unsigned char>(*s) !=
|
if (*s !=
|
||||||
MakeLowerCase(static_cast<unsigned char>(styler.SafeGetCharAt(currentPos + n, 0))))
|
MakeLowerCase(styler.SafeGetCharAt(currentPos + n, 0)))
|
||||||
return false;
|
return false;
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
@ -60,7 +58,7 @@ static void getRangeLowered(Sci_PositionU start,
|
|||||||
Sci_PositionU len) {
|
Sci_PositionU len) {
|
||||||
Sci_PositionU i = 0;
|
Sci_PositionU i = 0;
|
||||||
while ((i < end - start + 1) && (i < len-1)) {
|
while ((i < end - start + 1) && (i < len-1)) {
|
||||||
s[i] = static_cast<char>(tolower(styler[start + i]));
|
s[i] = MakeLowerCase(styler[start + i]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
s[i] = '\0';
|
s[i] = '\0';
|
||||||
|
@ -8,9 +8,7 @@
|
|||||||
#ifndef STYLECONTEXT_H
|
#ifndef STYLECONTEXT_H
|
||||||
#define STYLECONTEXT_H
|
#define STYLECONTEXT_H
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
// All languages handled so far can treat all characters >= 0x80 as one class
|
// All languages handled so far can treat all characters >= 0x80 as one class
|
||||||
// which just continues the current token or starts an identifier if in default.
|
// which just continues the current token or starts an identifier if in default.
|
||||||
@ -59,7 +57,7 @@ public:
|
|||||||
StyleContext(Sci_PositionU startPos, Sci_PositionU length,
|
StyleContext(Sci_PositionU startPos, Sci_PositionU length,
|
||||||
int initStyle, LexAccessor &styler_, char chMask='\377') :
|
int initStyle, LexAccessor &styler_, char chMask='\377') :
|
||||||
styler(styler_),
|
styler(styler_),
|
||||||
multiByteAccess(0),
|
multiByteAccess(nullptr),
|
||||||
endPos(startPos + length),
|
endPos(startPos + length),
|
||||||
posRelative(0),
|
posRelative(0),
|
||||||
currentPosLastRelative(0x7FFFFFFF),
|
currentPosLastRelative(0x7FFFFFFF),
|
||||||
@ -133,7 +131,12 @@ public:
|
|||||||
void ForwardBytes(Sci_Position nb) {
|
void ForwardBytes(Sci_Position nb) {
|
||||||
const Sci_PositionU forwardPos = currentPos + nb;
|
const Sci_PositionU forwardPos = currentPos + nb;
|
||||||
while (forwardPos > currentPos) {
|
while (forwardPos > currentPos) {
|
||||||
|
const Sci_PositionU currentPosStart = currentPos;
|
||||||
Forward();
|
Forward();
|
||||||
|
if (currentPos == currentPosStart) {
|
||||||
|
// Reached end
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void ChangeState(int state_) {
|
void ChangeState(int state_) {
|
||||||
@ -164,9 +167,9 @@ public:
|
|||||||
posRelative = currentPos;
|
posRelative = currentPos;
|
||||||
offsetRelative = 0;
|
offsetRelative = 0;
|
||||||
}
|
}
|
||||||
Sci_Position diffRelative = n - offsetRelative;
|
const Sci_Position diffRelative = n - offsetRelative;
|
||||||
Sci_Position posNew = multiByteAccess->GetRelativePosition(posRelative, diffRelative);
|
const Sci_Position posNew = multiByteAccess->GetRelativePosition(posRelative, diffRelative);
|
||||||
const int chReturn = multiByteAccess->GetCharacterAndWidth(posNew, 0);
|
const int chReturn = multiByteAccess->GetCharacterAndWidth(posNew, nullptr);
|
||||||
posRelative = posNew;
|
posRelative = posNew;
|
||||||
currentPosLastRelative = currentPos;
|
currentPosLastRelative = currentPos;
|
||||||
offsetRelative = n;
|
offsetRelative = n;
|
||||||
@ -204,8 +207,6 @@ public:
|
|||||||
void GetCurrentLowered(char *s, Sci_PositionU len);
|
void GetCurrentLowered(char *s, Sci_PositionU len);
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -8,9 +8,7 @@
|
|||||||
#ifndef SUBSTYLES_H
|
#ifndef SUBSTYLES_H
|
||||||
#define SUBSTYLES_H
|
#define SUBSTYLES_H
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
class WordClassifier {
|
class WordClassifier {
|
||||||
int baseStyle;
|
int baseStyle;
|
||||||
@ -37,6 +35,10 @@ public:
|
|||||||
return firstStyle;
|
return firstStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Last() const {
|
||||||
|
return firstStyle + lenStyles - 1;
|
||||||
|
}
|
||||||
|
|
||||||
int Length() const {
|
int Length() const {
|
||||||
return lenStyles;
|
return lenStyles;
|
||||||
}
|
}
|
||||||
@ -118,11 +120,11 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Allocate(int styleBase, int numberStyles) {
|
int Allocate(int styleBase, int numberStyles) {
|
||||||
int block = BlockFromBaseStyle(styleBase);
|
const int block = BlockFromBaseStyle(styleBase);
|
||||||
if (block >= 0) {
|
if (block >= 0) {
|
||||||
if ((allocated + numberStyles) > stylesAvailable)
|
if ((allocated + numberStyles) > stylesAvailable)
|
||||||
return -1;
|
return -1;
|
||||||
int startBlock = styleFirst + allocated;
|
const int startBlock = styleFirst + allocated;
|
||||||
allocated += numberStyles;
|
allocated += numberStyles;
|
||||||
classifiers[block].Allocate(startBlock, numberStyles);
|
classifiers[block].Allocate(startBlock, numberStyles);
|
||||||
return startBlock;
|
return startBlock;
|
||||||
@ -132,17 +134,17 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int Start(int styleBase) {
|
int Start(int styleBase) {
|
||||||
int block = BlockFromBaseStyle(styleBase);
|
const int block = BlockFromBaseStyle(styleBase);
|
||||||
return (block >= 0) ? classifiers[block].Start() : -1;
|
return (block >= 0) ? classifiers[block].Start() : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Length(int styleBase) {
|
int Length(int styleBase) {
|
||||||
int block = BlockFromBaseStyle(styleBase);
|
const int block = BlockFromBaseStyle(styleBase);
|
||||||
return (block >= 0) ? classifiers[block].Length() : 0;
|
return (block >= 0) ? classifiers[block].Length() : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BaseStyle(int subStyle) const {
|
int BaseStyle(int subStyle) const {
|
||||||
int block = BlockFromStyle(subStyle);
|
const int block = BlockFromStyle(subStyle);
|
||||||
if (block >= 0)
|
if (block >= 0)
|
||||||
return classifiers[block].Base();
|
return classifiers[block].Base();
|
||||||
else
|
else
|
||||||
@ -153,8 +155,26 @@ public:
|
|||||||
return secondaryDistance;
|
return secondaryDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int FirstAllocated() const {
|
||||||
|
int start = 257;
|
||||||
|
for (std::vector<WordClassifier>::const_iterator it = classifiers.begin(); it != classifiers.end(); ++it) {
|
||||||
|
if (start > it->Start())
|
||||||
|
start = it->Start();
|
||||||
|
}
|
||||||
|
return (start < 256) ? start : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int LastAllocated() const {
|
||||||
|
int last = -1;
|
||||||
|
for (std::vector<WordClassifier>::const_iterator it = classifiers.begin(); it != classifiers.end(); ++it) {
|
||||||
|
if (last < it->Last())
|
||||||
|
last = it->Last();
|
||||||
|
}
|
||||||
|
return last;
|
||||||
|
}
|
||||||
|
|
||||||
void SetIdentifiers(int style, const char *identifiers) {
|
void SetIdentifiers(int style, const char *identifiers) {
|
||||||
int block = BlockFromStyle(style);
|
const int block = BlockFromStyle(style);
|
||||||
if (block >= 0)
|
if (block >= 0)
|
||||||
classifiers[block].SetIdentifiers(style, identifiers);
|
classifiers[block].SetIdentifiers(style, identifiers);
|
||||||
}
|
}
|
||||||
@ -171,8 +191,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -10,13 +10,11 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <iterator>
|
||||||
|
|
||||||
#include "StringCopy.h"
|
|
||||||
#include "WordList.h"
|
#include "WordList.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an array that points into each word in the string and puts \0 terminators
|
* Creates an array that points into each word in the string and puts \0 terminators
|
||||||
@ -114,7 +112,7 @@ static int cmpWords(const void *a, const void *b) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void SortWordList(char **words, unsigned int len) {
|
static void SortWordList(char **words, unsigned int len) {
|
||||||
qsort(static_cast<void *>(words), len, sizeof(*words), cmpWords);
|
qsort(words, len, sizeof(*words), cmpWords);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -130,7 +128,7 @@ void WordList::Set(const char *s) {
|
|||||||
#else
|
#else
|
||||||
SortWordList(words, len);
|
SortWordList(words, len);
|
||||||
#endif
|
#endif
|
||||||
std::fill(starts, starts + ELEMENTS(starts), -1);
|
std::fill(starts, std::end(starts), -1);
|
||||||
for (int l = len - 1; l >= 0; l--) {
|
for (int l = len - 1; l >= 0; l--) {
|
||||||
unsigned char indexChar = words[l][0];
|
unsigned char indexChar = words[l][0];
|
||||||
starts[indexChar] = l;
|
starts[indexChar] = l;
|
||||||
@ -148,7 +146,7 @@ bool WordList::InList(const char *s) const {
|
|||||||
const unsigned char firstChar = s[0];
|
const unsigned char firstChar = s[0];
|
||||||
int j = starts[firstChar];
|
int j = starts[firstChar];
|
||||||
if (j >= 0) {
|
if (j >= 0) {
|
||||||
while (static_cast<unsigned char>(words[j][0]) == firstChar) {
|
while (words[j][0] == firstChar) {
|
||||||
if (s[1] == words[j][1]) {
|
if (s[1] == words[j][1]) {
|
||||||
const char *a = words[j] + 1;
|
const char *a = words[j] + 1;
|
||||||
const char *b = s + 1;
|
const char *b = s + 1;
|
||||||
@ -190,7 +188,7 @@ bool WordList::InListAbbreviated(const char *s, const char marker) const {
|
|||||||
const unsigned char firstChar = s[0];
|
const unsigned char firstChar = s[0];
|
||||||
int j = starts[firstChar];
|
int j = starts[firstChar];
|
||||||
if (j >= 0) {
|
if (j >= 0) {
|
||||||
while (static_cast<unsigned char>(words[j][0]) == firstChar) {
|
while (words[j][0] == firstChar) {
|
||||||
bool isSubword = false;
|
bool isSubword = false;
|
||||||
int start = 1;
|
int start = 1;
|
||||||
if (words[j][1] == marker) {
|
if (words[j][1] == marker) {
|
||||||
@ -244,7 +242,7 @@ bool WordList::InListAbridged(const char *s, const char marker) const {
|
|||||||
const unsigned char firstChar = s[0];
|
const unsigned char firstChar = s[0];
|
||||||
int j = starts[firstChar];
|
int j = starts[firstChar];
|
||||||
if (j >= 0) {
|
if (j >= 0) {
|
||||||
while (static_cast<unsigned char>(words[j][0]) == firstChar) {
|
while (words[j][0] == firstChar) {
|
||||||
const char *a = words[j];
|
const char *a = words[j];
|
||||||
const char *b = s;
|
const char *b = s;
|
||||||
while (*a && *a == *b) {
|
while (*a && *a == *b) {
|
||||||
|
@ -8,9 +8,7 @@
|
|||||||
#ifndef WORDLIST_H
|
#ifndef WORDLIST_H
|
||||||
#define WORDLIST_H
|
#define WORDLIST_H
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
@ -35,8 +33,6 @@ public:
|
|||||||
const char *WordAt(int n) const;
|
const char *WordAt(int n) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -62,7 +62,7 @@ diff --git scintilla/src/Catalogue.cxx scintilla/src/Catalogue.cxx
|
|||||||
index ed47aa8..e58f1ab 100644
|
index ed47aa8..e58f1ab 100644
|
||||||
--- scintilla/src/Catalogue.cxx
|
--- scintilla/src/Catalogue.cxx
|
||||||
+++ scintilla/src/Catalogue.cxx
|
+++ scintilla/src/Catalogue.cxx
|
||||||
@@ -77,123 +77,50 @@ int Scintilla_LinkLexers() {
|
@@ -77,125 +77,50 @@ int Scintilla_LinkLexers() {
|
||||||
|
|
||||||
//++Autogenerated -- run scripts/LexGen.py to regenerate
|
//++Autogenerated -- run scripts/LexGen.py to regenerate
|
||||||
//**\(\tLINK_LEXER(\*);\n\)
|
//**\(\tLINK_LEXER(\*);\n\)
|
||||||
@ -125,11 +125,13 @@ index ed47aa8..e58f1ab 100644
|
|||||||
- LINK_LEXER(lmLiterateHaskell);
|
- LINK_LEXER(lmLiterateHaskell);
|
||||||
- LINK_LEXER(lmLot);
|
- LINK_LEXER(lmLot);
|
||||||
- LINK_LEXER(lmLout);
|
- LINK_LEXER(lmLout);
|
||||||
|
- LINK_LEXER(lmLPeg);
|
||||||
LINK_LEXER(lmLua);
|
LINK_LEXER(lmLua);
|
||||||
- LINK_LEXER(lmMagikSF);
|
- LINK_LEXER(lmMagikSF);
|
||||||
LINK_LEXER(lmMake);
|
LINK_LEXER(lmMake);
|
||||||
LINK_LEXER(lmMarkdown);
|
LINK_LEXER(lmMarkdown);
|
||||||
- LINK_LEXER(lmMatlab);
|
- LINK_LEXER(lmMatlab);
|
||||||
|
- LINK_LEXER(lmMaxima);
|
||||||
- LINK_LEXER(lmMETAPOST);
|
- LINK_LEXER(lmMETAPOST);
|
||||||
- LINK_LEXER(lmMMIXAL);
|
- LINK_LEXER(lmMMIXAL);
|
||||||
- LINK_LEXER(lmModula);
|
- LINK_LEXER(lmModula);
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
|
// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
|
||||||
// The License.txt file describes the conditions under which this software may be distributed.
|
// The License.txt file describes the conditions under which this software may be distributed.
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
@ -23,9 +24,7 @@
|
|||||||
#include "Position.h"
|
#include "Position.h"
|
||||||
#include "AutoComplete.h"
|
#include "AutoComplete.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
AutoComplete::AutoComplete() :
|
AutoComplete::AutoComplete() :
|
||||||
active(false),
|
active(false),
|
||||||
@ -51,12 +50,12 @@ AutoComplete::~AutoComplete() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AutoComplete::Active() const {
|
bool AutoComplete::Active() const noexcept {
|
||||||
return active;
|
return active;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoComplete::Start(Window &parent, int ctrlID,
|
void AutoComplete::Start(Window &parent, int ctrlID,
|
||||||
Sci::Position position, Point location, int startLen_,
|
Sci::Position position, Point location, Sci::Position startLen_,
|
||||||
int lineHeight, bool unicodeMode, int technology) {
|
int lineHeight, bool unicodeMode, int technology) {
|
||||||
if (active) {
|
if (active) {
|
||||||
Cancel();
|
Cancel();
|
||||||
@ -72,7 +71,7 @@ void AutoComplete::SetStopChars(const char *stopChars_) {
|
|||||||
stopChars = stopChars_;
|
stopChars = stopChars_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AutoComplete::IsStopChar(char ch) {
|
bool AutoComplete::IsStopChar(char ch) const noexcept {
|
||||||
return ch && (stopChars.find(ch) != std::string::npos);
|
return ch && (stopChars.find(ch) != std::string::npos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +79,7 @@ void AutoComplete::SetFillUpChars(const char *fillUpChars_) {
|
|||||||
fillUpChars = fillUpChars_;
|
fillUpChars = fillUpChars_;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AutoComplete::IsFillUpChar(char ch) {
|
bool AutoComplete::IsFillUpChar(char ch) const noexcept {
|
||||||
return ch && (fillUpChars.find(ch) != std::string::npos);
|
return ch && (fillUpChars.find(ch) != std::string::npos);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +87,7 @@ void AutoComplete::SetSeparator(char separator_) {
|
|||||||
separator = separator_;
|
separator = separator_;
|
||||||
}
|
}
|
||||||
|
|
||||||
char AutoComplete::GetSeparator() const {
|
char AutoComplete::GetSeparator() const noexcept {
|
||||||
return separator;
|
return separator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +95,7 @@ void AutoComplete::SetTypesep(char separator_) {
|
|||||||
typesep = separator_;
|
typesep = separator_;
|
||||||
}
|
}
|
||||||
|
|
||||||
char AutoComplete::GetTypesep() const {
|
char AutoComplete::GetTypesep() const noexcept {
|
||||||
return typesep;
|
return typesep;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,7 +225,7 @@ void AutoComplete::Move(int delta) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AutoComplete::Select(const char *word) {
|
void AutoComplete::Select(const char *word) {
|
||||||
size_t lenWord = strlen(word);
|
const size_t lenWord = strlen(word);
|
||||||
int location = -1;
|
int location = -1;
|
||||||
int start = 0; // lower bound of the api array block to search
|
int start = 0; // lower bound of the api array block to search
|
||||||
int end = lb->Length() - 1; // upper bound of the api array block to search
|
int end = lb->Length() - 1; // upper bound of the api array block to search
|
||||||
|
@ -8,9 +8,7 @@
|
|||||||
#ifndef AUTOCOMPLETE_H
|
#ifndef AUTOCOMPLETE_H
|
||||||
#define AUTOCOMPLETE_H
|
#define AUTOCOMPLETE_H
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
@ -29,7 +27,7 @@ public:
|
|||||||
bool chooseSingle;
|
bool chooseSingle;
|
||||||
std::unique_ptr<ListBox> lb;
|
std::unique_ptr<ListBox> lb;
|
||||||
Sci::Position posStart;
|
Sci::Position posStart;
|
||||||
int startLen;
|
Sci::Position startLen;
|
||||||
/// Should autocompletion be canceled if editor's currentPos <= startPos?
|
/// Should autocompletion be canceled if editor's currentPos <= startPos?
|
||||||
bool cancelAtStartPos;
|
bool cancelAtStartPos;
|
||||||
bool autoHide;
|
bool autoHide;
|
||||||
@ -47,27 +45,27 @@ public:
|
|||||||
~AutoComplete();
|
~AutoComplete();
|
||||||
|
|
||||||
/// Is the auto completion list displayed?
|
/// Is the auto completion list displayed?
|
||||||
bool Active() const;
|
bool Active() const noexcept;
|
||||||
|
|
||||||
/// Display the auto completion list positioned to be near a character position
|
/// Display the auto completion list positioned to be near a character position
|
||||||
void Start(Window &parent, int ctrlID, Sci::Position position, Point location,
|
void Start(Window &parent, int ctrlID, Sci::Position position, Point location,
|
||||||
int startLen_, int lineHeight, bool unicodeMode, int technology);
|
Sci::Position startLen_, int lineHeight, bool unicodeMode, int technology);
|
||||||
|
|
||||||
/// The stop chars are characters which, when typed, cause the auto completion list to disappear
|
/// The stop chars are characters which, when typed, cause the auto completion list to disappear
|
||||||
void SetStopChars(const char *stopChars_);
|
void SetStopChars(const char *stopChars_);
|
||||||
bool IsStopChar(char ch);
|
bool IsStopChar(char ch) const noexcept;
|
||||||
|
|
||||||
/// The fillup chars are characters which, when typed, fill up the selected word
|
/// The fillup chars are characters which, when typed, fill up the selected word
|
||||||
void SetFillUpChars(const char *fillUpChars_);
|
void SetFillUpChars(const char *fillUpChars_);
|
||||||
bool IsFillUpChar(char ch);
|
bool IsFillUpChar(char ch) const noexcept;
|
||||||
|
|
||||||
/// The separator character is used when interpreting the list in SetList
|
/// The separator character is used when interpreting the list in SetList
|
||||||
void SetSeparator(char separator_);
|
void SetSeparator(char separator_);
|
||||||
char GetSeparator() const;
|
char GetSeparator() const noexcept;
|
||||||
|
|
||||||
/// The typesep character is used for separating the word from the type
|
/// The typesep character is used for separating the word from the type
|
||||||
void SetTypesep(char separator_);
|
void SetTypesep(char separator_);
|
||||||
char GetTypesep() const;
|
char GetTypesep() const noexcept;
|
||||||
|
|
||||||
/// The list string contains a sequence of words separated by the separator character
|
/// The list string contains a sequence of words separated by the separator character
|
||||||
void SetList(const char *list);
|
void SetList(const char *list);
|
||||||
@ -88,8 +86,6 @@ public:
|
|||||||
void Select(const char *word);
|
void Select(const char *word);
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -5,12 +5,15 @@
|
|||||||
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
|
||||||
// The License.txt file describes the conditions under which this software may be distributed.
|
// The License.txt file describes the conditions under which this software may be distributed.
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@ -20,11 +23,10 @@
|
|||||||
|
|
||||||
#include "StringCopy.h"
|
#include "StringCopy.h"
|
||||||
#include "Position.h"
|
#include "Position.h"
|
||||||
|
#include "IntegerRectangle.h"
|
||||||
#include "CallTip.h"
|
#include "CallTip.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
CallTip::CallTip() {
|
CallTip::CallTip() {
|
||||||
wCallTip = 0;
|
wCallTip = 0;
|
||||||
@ -110,7 +112,7 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
|
|||||||
int startSeg = 0;
|
int startSeg = 0;
|
||||||
int xEnd;
|
int xEnd;
|
||||||
for (int seg = 0; seg<maxEnd; seg++) {
|
for (int seg = 0; seg<maxEnd; seg++) {
|
||||||
int endSeg = ends[seg];
|
const int endSeg = ends[seg];
|
||||||
if (endSeg > startSeg) {
|
if (endSeg > startSeg) {
|
||||||
if (IsArrowCharacter(s[startSeg])) {
|
if (IsArrowCharacter(s[startSeg])) {
|
||||||
xEnd = x + widthArrow;
|
xEnd = x + widthArrow;
|
||||||
@ -123,7 +125,7 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
|
|||||||
const int centreX = x + widthArrow / 2 - 1;
|
const int centreX = x + widthArrow / 2 - 1;
|
||||||
const int centreY = static_cast<int>(rcClient.top + rcClient.bottom) / 2;
|
const int centreY = static_cast<int>(rcClient.top + rcClient.bottom) / 2;
|
||||||
surface->FillRectangle(rcClient, colourBG);
|
surface->FillRectangle(rcClient, colourBG);
|
||||||
PRectangle rcClientInner(rcClient.left + 1, rcClient.top + 1,
|
const PRectangle rcClientInner(rcClient.left + 1, rcClient.top + 1,
|
||||||
rcClient.right - 2, rcClient.bottom - 1);
|
rcClient.right - 2, rcClient.bottom - 1);
|
||||||
surface->FillRectangle(rcClientInner, colourUnSel);
|
surface->FillRectangle(rcClientInner, colourUnSel);
|
||||||
|
|
||||||
@ -152,7 +154,7 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
|
|||||||
} else if (IsTabCharacter(s[startSeg])) {
|
} else if (IsTabCharacter(s[startSeg])) {
|
||||||
xEnd = NextTabPos(x);
|
xEnd = NextTabPos(x);
|
||||||
} else {
|
} else {
|
||||||
xEnd = x + RoundXYPosition(surface->WidthText(font, s + startSeg, endSeg - startSeg));
|
xEnd = x + static_cast<int>(lround(surface->WidthText(font, s + startSeg, endSeg - startSeg)));
|
||||||
if (draw) {
|
if (draw) {
|
||||||
rcClient.left = static_cast<XYPOSITION>(x);
|
rcClient.left = static_cast<XYPOSITION>(x);
|
||||||
rcClient.right = static_cast<XYPOSITION>(xEnd);
|
rcClient.right = static_cast<XYPOSITION>(xEnd);
|
||||||
@ -168,13 +170,13 @@ void CallTip::DrawChunk(Surface *surface, int &x, const char *s,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int CallTip::PaintContents(Surface *surfaceWindow, bool draw) {
|
int CallTip::PaintContents(Surface *surfaceWindow, bool draw) {
|
||||||
PRectangle rcClientPos = wCallTip.GetClientPosition();
|
const PRectangle rcClientPos = wCallTip.GetClientPosition();
|
||||||
PRectangle rcClientSize(0.0f, 0.0f, rcClientPos.right - rcClientPos.left,
|
const PRectangle rcClientSize(0.0f, 0.0f, rcClientPos.right - rcClientPos.left,
|
||||||
rcClientPos.bottom - rcClientPos.top);
|
rcClientPos.bottom - rcClientPos.top);
|
||||||
PRectangle rcClient(1.0f, 1.0f, rcClientSize.right - 1, rcClientSize.bottom - 1);
|
PRectangle rcClient(1.0f, 1.0f, rcClientSize.right - 1, rcClientSize.bottom - 1);
|
||||||
|
|
||||||
// To make a nice small call tip window, it is only sized to fit most normal characters without accents
|
// To make a nice small call tip window, it is only sized to fit most normal characters without accents
|
||||||
int ascent = RoundXYPosition(surfaceWindow->Ascent(font) - surfaceWindow->InternalLeading(font));
|
const int ascent = static_cast<int>(lround(surfaceWindow->Ascent(font) - surfaceWindow->InternalLeading(font)));
|
||||||
|
|
||||||
// For each line...
|
// For each line...
|
||||||
// Draw the definition in three parts: before highlight, highlighted, after highlight
|
// Draw the definition in three parts: before highlight, highlighted, after highlight
|
||||||
@ -186,7 +188,7 @@ int CallTip::PaintContents(Surface *surfaceWindow, bool draw) {
|
|||||||
|
|
||||||
while (moreChunks) {
|
while (moreChunks) {
|
||||||
const char *chunkEnd = strchr(chunkVal, '\n');
|
const char *chunkEnd = strchr(chunkVal, '\n');
|
||||||
if (chunkEnd == NULL) {
|
if (!chunkEnd) {
|
||||||
chunkEnd = chunkVal + strlen(chunkVal);
|
chunkEnd = chunkVal + strlen(chunkVal);
|
||||||
moreChunks = false;
|
moreChunks = false;
|
||||||
}
|
}
|
||||||
@ -221,10 +223,10 @@ int CallTip::PaintContents(Surface *surfaceWindow, bool draw) {
|
|||||||
void CallTip::PaintCT(Surface *surfaceWindow) {
|
void CallTip::PaintCT(Surface *surfaceWindow) {
|
||||||
if (val.empty())
|
if (val.empty())
|
||||||
return;
|
return;
|
||||||
PRectangle rcClientPos = wCallTip.GetClientPosition();
|
const PRectangle rcClientPos = wCallTip.GetClientPosition();
|
||||||
PRectangle rcClientSize(0.0f, 0.0f, rcClientPos.right - rcClientPos.left,
|
const PRectangle rcClientSize(0.0f, 0.0f, rcClientPos.right - rcClientPos.left,
|
||||||
rcClientPos.bottom - rcClientPos.top);
|
rcClientPos.bottom - rcClientPos.top);
|
||||||
PRectangle rcClient(1.0f, 1.0f, rcClientSize.right - 1, rcClientSize.bottom - 1);
|
const PRectangle rcClient(1.0f, 1.0f, rcClientSize.right - 1, rcClientSize.bottom - 1);
|
||||||
|
|
||||||
surfaceWindow->FillRectangle(rcClient, colourBG);
|
surfaceWindow->FillRectangle(rcClient, colourBG);
|
||||||
|
|
||||||
@ -234,13 +236,14 @@ void CallTip::PaintCT(Surface *surfaceWindow) {
|
|||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
// OSX doesn't put borders on "help tags"
|
// OSX doesn't put borders on "help tags"
|
||||||
// Draw a raised border around the edges of the window
|
// Draw a raised border around the edges of the window
|
||||||
surfaceWindow->MoveTo(0, static_cast<int>(rcClientSize.bottom) - 1);
|
const IntegerRectangle ircClientSize(rcClientSize);
|
||||||
|
surfaceWindow->MoveTo(0, ircClientSize.bottom - 1);
|
||||||
surfaceWindow->PenColour(colourShade);
|
surfaceWindow->PenColour(colourShade);
|
||||||
surfaceWindow->LineTo(static_cast<int>(rcClientSize.right) - 1, static_cast<int>(rcClientSize.bottom) - 1);
|
surfaceWindow->LineTo(ircClientSize.right - 1, ircClientSize.bottom - 1);
|
||||||
surfaceWindow->LineTo(static_cast<int>(rcClientSize.right) - 1, 0);
|
surfaceWindow->LineTo(ircClientSize.right - 1, 0);
|
||||||
surfaceWindow->PenColour(colourLight);
|
surfaceWindow->PenColour(colourLight);
|
||||||
surfaceWindow->LineTo(0, 0);
|
surfaceWindow->LineTo(0, 0);
|
||||||
surfaceWindow->LineTo(0, static_cast<int>(rcClientSize.bottom) - 1);
|
surfaceWindow->LineTo(0, ircClientSize.bottom - 1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,7 +258,7 @@ void CallTip::MouseClick(Point pt) {
|
|||||||
PRectangle CallTip::CallTipStart(Sci::Position 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,
|
const char *faceName, int size,
|
||||||
int codePage_, int characterSet,
|
int codePage_, int characterSet,
|
||||||
int technology, Window &wParent) {
|
int technology, const Window &wParent) {
|
||||||
clickPlace = 0;
|
clickPlace = 0;
|
||||||
val = defn;
|
val = defn;
|
||||||
codePage = codePage_;
|
codePage = codePage_;
|
||||||
@ -267,28 +270,22 @@ PRectangle CallTip::CallTipStart(Sci::Position pos, Point pt, int textHeight, co
|
|||||||
endHighlight = 0;
|
endHighlight = 0;
|
||||||
inCallTipMode = true;
|
inCallTipMode = true;
|
||||||
posStartCallTip = pos;
|
posStartCallTip = pos;
|
||||||
XYPOSITION deviceHeight = static_cast<XYPOSITION>(surfaceMeasure->DeviceHeightFont(size));
|
const XYPOSITION deviceHeight = static_cast<XYPOSITION>(surfaceMeasure->DeviceHeightFont(size));
|
||||||
FontParameters fp(faceName, deviceHeight / SC_FONT_SIZE_MULTIPLIER, SC_WEIGHT_NORMAL, false, 0, technology, characterSet);
|
const FontParameters fp(faceName, deviceHeight / SC_FONT_SIZE_MULTIPLIER, SC_WEIGHT_NORMAL, false, 0, technology, characterSet);
|
||||||
font.Create(fp);
|
font.Create(fp);
|
||||||
// Look for multiple lines in the text
|
// Look for multiple lines in the text
|
||||||
// Only support \n here - simply means container must avoid \r!
|
// Only support \n here - simply means container must avoid \r!
|
||||||
int numLines = 1;
|
const int numLines = 1 + static_cast<int>(std::count(val.begin(), val.end(), '\n'));
|
||||||
const char *newline;
|
|
||||||
const char *look = val.c_str();
|
|
||||||
rectUp = PRectangle(0,0,0,0);
|
rectUp = PRectangle(0,0,0,0);
|
||||||
rectDown = PRectangle(0,0,0,0);
|
rectDown = PRectangle(0,0,0,0);
|
||||||
offsetMain = insetX; // changed to right edge of any arrows
|
offsetMain = insetX; // changed to right edge of any arrows
|
||||||
const int width = PaintContents(surfaceMeasure.get(), false) + insetX;
|
const int width = PaintContents(surfaceMeasure.get(), false) + insetX;
|
||||||
while ((newline = strchr(look, '\n')) != NULL) {
|
lineHeight = static_cast<int>(lround(surfaceMeasure->Height(font)));
|
||||||
look = newline + 1;
|
|
||||||
numLines++;
|
|
||||||
}
|
|
||||||
lineHeight = RoundXYPosition(surfaceMeasure->Height(font));
|
|
||||||
|
|
||||||
// The returned
|
// The returned
|
||||||
// rectangle is aligned to the right edge of the last arrow encountered in
|
// rectangle is aligned to the right edge of the last arrow encountered in
|
||||||
// the tip text, else to the tip text left edge.
|
// the tip text, else to the tip text left edge.
|
||||||
int height = lineHeight * numLines - static_cast<int>(surfaceMeasure->InternalLeading(font)) + borderHeight * 2;
|
const int height = lineHeight * numLines - static_cast<int>(surfaceMeasure->InternalLeading(font)) + borderHeight * 2;
|
||||||
if (above) {
|
if (above) {
|
||||||
return PRectangle(pt.x - offsetMain, pt.y - verticalOffset - height, pt.x + width - offsetMain, pt.y - verticalOffset);
|
return PRectangle(pt.x - offsetMain, pt.y - verticalOffset - height, pt.x + width - offsetMain, pt.y - verticalOffset);
|
||||||
} else {
|
} else {
|
||||||
|
@ -8,9 +8,7 @@
|
|||||||
#ifndef CALLTIP_H
|
#ifndef CALLTIP_H
|
||||||
#define CALLTIP_H
|
#define CALLTIP_H
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
@ -55,7 +53,9 @@ public:
|
|||||||
CallTip();
|
CallTip();
|
||||||
// Deleted so CallTip objects can not be copied.
|
// Deleted so CallTip objects can not be copied.
|
||||||
CallTip(const CallTip &) = delete;
|
CallTip(const CallTip &) = delete;
|
||||||
|
CallTip(CallTip &&) = delete;
|
||||||
CallTip &operator=(const CallTip &) = delete;
|
CallTip &operator=(const CallTip &) = delete;
|
||||||
|
CallTip &operator=(CallTip &&) = delete;
|
||||||
~CallTip();
|
~CallTip();
|
||||||
|
|
||||||
void PaintCT(Surface *surfaceWindow);
|
void PaintCT(Surface *surfaceWindow);
|
||||||
@ -65,7 +65,7 @@ public:
|
|||||||
/// Setup the calltip and return a rectangle of the area required.
|
/// Setup the calltip and return a rectangle of the area required.
|
||||||
PRectangle CallTipStart(Sci::Position 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_,
|
const char *faceName, int size, int codePage_,
|
||||||
int characterSet, int technology, Window &wParent);
|
int characterSet, int technology, const Window &wParent);
|
||||||
|
|
||||||
void CallTipCancel();
|
void CallTipCancel();
|
||||||
|
|
||||||
@ -86,8 +86,6 @@ public:
|
|||||||
void SetForeBack(const ColourDesired &fore, const ColourDesired &back);
|
void SetForeBack(const ColourDesired &fore, const ColourDesired &back);
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -18,11 +18,8 @@
|
|||||||
#include "StringCopy.h"
|
#include "StringCopy.h"
|
||||||
#include "CaseConvert.h"
|
#include "CaseConvert.h"
|
||||||
#include "UniConversion.h"
|
#include "UniConversion.h"
|
||||||
#include "UnicodeFromUTF8.h"
|
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
// Use an unnamed namespace to protect the declarations from name conflicts
|
// Use an unnamed namespace to protect the declarations from name conflicts
|
||||||
@ -566,8 +563,7 @@ class CaseConverter : public ICaseConverter {
|
|||||||
enum { maxConversionLength=6 };
|
enum { maxConversionLength=6 };
|
||||||
struct ConversionString {
|
struct ConversionString {
|
||||||
char conversion[maxConversionLength+1];
|
char conversion[maxConversionLength+1];
|
||||||
ConversionString() {
|
ConversionString() : conversion{} {
|
||||||
conversion[0] = '\0';
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// Conversions are initially store in a vector of structs but then decomposed into
|
// Conversions are initially store in a vector of structs but then decomposed into
|
||||||
@ -575,10 +571,10 @@ class CaseConverter : public ICaseConverter {
|
|||||||
struct CharacterConversion {
|
struct CharacterConversion {
|
||||||
int character;
|
int character;
|
||||||
ConversionString conversion;
|
ConversionString conversion;
|
||||||
CharacterConversion(int character_=0, const char *conversion_="") : character(character_) {
|
CharacterConversion(int character_=0, const char *conversion_="") noexcept : character(character_) {
|
||||||
StringCopy(conversion.conversion, conversion_);
|
StringCopy(conversion.conversion, conversion_);
|
||||||
}
|
}
|
||||||
bool operator<(const CharacterConversion &other) const {
|
bool operator<(const CharacterConversion &other) const noexcept {
|
||||||
return character < other.character;
|
return character < other.character;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -591,11 +587,12 @@ class CaseConverter : public ICaseConverter {
|
|||||||
public:
|
public:
|
||||||
CaseConverter() {
|
CaseConverter() {
|
||||||
}
|
}
|
||||||
|
virtual ~CaseConverter() = default;
|
||||||
bool Initialised() const {
|
bool Initialised() const {
|
||||||
return characters.size() > 0;
|
return characters.size() > 0;
|
||||||
}
|
}
|
||||||
void Add(int character, const char *conversion) {
|
void Add(int character, const char *conversion) {
|
||||||
characterToConversion.push_back(CharacterConversion(character, conversion));
|
characterToConversion.emplace_back(character, conversion);
|
||||||
}
|
}
|
||||||
const char *Find(int character) {
|
const char *Find(int character) {
|
||||||
const std::vector<int>::iterator it = std::lower_bound(characters.begin(), characters.end(), character);
|
const std::vector<int>::iterator it = std::lower_bound(characters.begin(), characters.end(), character);
|
||||||
@ -609,9 +606,9 @@ public:
|
|||||||
size_t CaseConvertString(char *converted, size_t sizeConverted, const char *mixed, size_t lenMixed) override {
|
size_t CaseConvertString(char *converted, size_t sizeConverted, const char *mixed, size_t lenMixed) override {
|
||||||
size_t lenConverted = 0;
|
size_t lenConverted = 0;
|
||||||
size_t mixedPos = 0;
|
size_t mixedPos = 0;
|
||||||
unsigned char bytes[UTF8MaxBytes + 1];
|
unsigned char bytes[UTF8MaxBytes + 1]{};
|
||||||
while (mixedPos < lenMixed) {
|
while (mixedPos < lenMixed) {
|
||||||
const unsigned char leadByte = static_cast<unsigned char>(mixed[mixedPos]);
|
const unsigned char leadByte = mixed[mixedPos];
|
||||||
const char *caseConverted = 0;
|
const char *caseConverted = 0;
|
||||||
size_t lenMixedChar = 1;
|
size_t lenMixedChar = 1;
|
||||||
if (UTF8IsAscii(leadByte)) {
|
if (UTF8IsAscii(leadByte)) {
|
||||||
@ -622,11 +619,11 @@ public:
|
|||||||
for (int b=1; b<widthCharBytes; b++) {
|
for (int b=1; b<widthCharBytes; b++) {
|
||||||
bytes[b] = (mixedPos+b < lenMixed) ? mixed[mixedPos+b] : 0;
|
bytes[b] = (mixedPos+b < lenMixed) ? mixed[mixedPos+b] : 0;
|
||||||
}
|
}
|
||||||
int classified = UTF8Classify(bytes, widthCharBytes);
|
const int classified = UTF8Classify(bytes, widthCharBytes);
|
||||||
if (!(classified & UTF8MaskInvalid)) {
|
if (!(classified & UTF8MaskInvalid)) {
|
||||||
// valid UTF-8
|
// valid UTF-8
|
||||||
lenMixedChar = classified & UTF8MaskWidth;
|
lenMixedChar = classified & UTF8MaskWidth;
|
||||||
int character = UnicodeFromUTF8(bytes);
|
const int character = UnicodeFromUTF8(bytes);
|
||||||
caseConverted = Find(character);
|
caseConverted = Find(character);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -666,26 +663,6 @@ CaseConverter caseConvFold;
|
|||||||
CaseConverter caseConvUp;
|
CaseConverter caseConvUp;
|
||||||
CaseConverter caseConvLow;
|
CaseConverter caseConvLow;
|
||||||
|
|
||||||
void UTF8FromUTF32Character(int uch, char *putf) {
|
|
||||||
size_t k = 0;
|
|
||||||
if (uch < 0x80) {
|
|
||||||
putf[k++] = static_cast<char>(uch);
|
|
||||||
} else if (uch < 0x800) {
|
|
||||||
putf[k++] = static_cast<char>(0xC0 | (uch >> 6));
|
|
||||||
putf[k++] = static_cast<char>(0x80 | (uch & 0x3f));
|
|
||||||
} else if (uch < 0x10000) {
|
|
||||||
putf[k++] = static_cast<char>(0xE0 | (uch >> 12));
|
|
||||||
putf[k++] = static_cast<char>(0x80 | ((uch >> 6) & 0x3f));
|
|
||||||
putf[k++] = static_cast<char>(0x80 | (uch & 0x3f));
|
|
||||||
} else {
|
|
||||||
putf[k++] = static_cast<char>(0xF0 | (uch >> 18));
|
|
||||||
putf[k++] = static_cast<char>(0x80 | ((uch >> 12) & 0x3f));
|
|
||||||
putf[k++] = static_cast<char>(0x80 | ((uch >> 6) & 0x3f));
|
|
||||||
putf[k++] = static_cast<char>(0x80 | (uch & 0x3f));
|
|
||||||
}
|
|
||||||
putf[k] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddSymmetric(enum CaseConversion conversion, int lower,int upper) {
|
void AddSymmetric(enum CaseConversion conversion, int lower,int upper) {
|
||||||
char lowerUTF8[UTF8MaxBytes+1];
|
char lowerUTF8[UTF8MaxBytes+1];
|
||||||
UTF8FromUTF32Character(lower, lowerUTF8);
|
UTF8FromUTF32Character(lower, lowerUTF8);
|
||||||
@ -727,10 +704,10 @@ void SetupConversions(enum CaseConversion conversion) {
|
|||||||
while (*sComplex) {
|
while (*sComplex) {
|
||||||
// Longest ligature is 3 character so 5 for safety
|
// Longest ligature is 3 character so 5 for safety
|
||||||
const size_t lenUTF8 = 5*UTF8MaxBytes+1;
|
const size_t lenUTF8 = 5*UTF8MaxBytes+1;
|
||||||
char originUTF8[lenUTF8];
|
unsigned char originUTF8[lenUTF8]{};
|
||||||
char foldedUTF8[lenUTF8];
|
char foldedUTF8[lenUTF8]{};
|
||||||
char lowerUTF8[lenUTF8];
|
char lowerUTF8[lenUTF8]{};
|
||||||
char upperUTF8[lenUTF8];
|
char upperUTF8[lenUTF8]{};
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
while (*sComplex && *sComplex != '|') {
|
while (*sComplex && *sComplex != '|') {
|
||||||
originUTF8[i++] = *sComplex;
|
originUTF8[i++] = *sComplex;
|
||||||
@ -760,7 +737,7 @@ void SetupConversions(enum CaseConversion conversion) {
|
|||||||
sComplex++;
|
sComplex++;
|
||||||
lowerUTF8[i] = 0;
|
lowerUTF8[i] = 0;
|
||||||
|
|
||||||
int character = UnicodeFromUTF8(reinterpret_cast<unsigned char *>(originUTF8));
|
const int character = UnicodeFromUTF8(originUTF8);
|
||||||
|
|
||||||
if (conversion == CaseConversionFold && foldedUTF8[0]) {
|
if (conversion == CaseConversionFold && foldedUTF8[0]) {
|
||||||
caseConvFold.Add(character, foldedUTF8);
|
caseConvFold.Add(character, foldedUTF8);
|
||||||
@ -802,9 +779,7 @@ CaseConverter *ConverterForConversion(enum CaseConversion conversion) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
ICaseConverter *ConverterFor(enum CaseConversion conversion) {
|
ICaseConverter *ConverterFor(enum CaseConversion conversion) {
|
||||||
CaseConverter *pCaseConv = ConverterForConversion(conversion);
|
CaseConverter *pCaseConv = ConverterForConversion(conversion);
|
||||||
@ -829,12 +804,10 @@ size_t CaseConvertString(char *converted, size_t sizeConverted, const char *mixe
|
|||||||
|
|
||||||
std::string CaseConvertString(const std::string &s, enum CaseConversion conversion) {
|
std::string CaseConvertString(const std::string &s, enum CaseConversion conversion) {
|
||||||
std::string retMapped(s.length() * maxExpansionCaseConversion, 0);
|
std::string retMapped(s.length() * maxExpansionCaseConversion, 0);
|
||||||
size_t lenMapped = CaseConvertString(&retMapped[0], retMapped.length(), s.c_str(), s.length(),
|
const size_t lenMapped = CaseConvertString(&retMapped[0], retMapped.length(), s.c_str(), s.length(),
|
||||||
conversion);
|
conversion);
|
||||||
retMapped.resize(lenMapped);
|
retMapped.resize(lenMapped);
|
||||||
return retMapped;
|
return retMapped;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
@ -10,9 +10,7 @@
|
|||||||
#ifndef CASECONVERT_H
|
#ifndef CASECONVERT_H
|
||||||
#define CASECONVERT_H
|
#define CASECONVERT_H
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
enum CaseConversion {
|
enum CaseConversion {
|
||||||
CaseConversionFold,
|
CaseConversionFold,
|
||||||
@ -43,8 +41,6 @@ size_t CaseConvertString(char *converted, size_t sizeConverted, const char *mixe
|
|||||||
// Converts a mixed case string using a particular conversion.
|
// Converts a mixed case string using a particular conversion.
|
||||||
std::string CaseConvertString(const std::string &s, enum CaseConversion conversion);
|
std::string CaseConvertString(const std::string &s, enum CaseConversion conversion);
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -11,16 +11,13 @@
|
|||||||
|
|
||||||
#include "CaseFolder.h"
|
#include "CaseFolder.h"
|
||||||
#include "CaseConvert.h"
|
#include "CaseConvert.h"
|
||||||
#include "UniConversion.h"
|
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
CaseFolder::~CaseFolder() {
|
CaseFolder::~CaseFolder() {
|
||||||
}
|
}
|
||||||
|
|
||||||
CaseFolderTable::CaseFolderTable() {
|
CaseFolderTable::CaseFolderTable() : mapping{} {
|
||||||
for (size_t iChar=0; iChar<sizeof(mapping); iChar++) {
|
for (size_t iChar=0; iChar<sizeof(mapping); iChar++) {
|
||||||
mapping[iChar] = static_cast<char>(iChar);
|
mapping[iChar] = static_cast<char>(iChar);
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,7 @@
|
|||||||
#ifndef CASEFOLDER_H
|
#ifndef CASEFOLDER_H
|
||||||
#define CASEFOLDER_H
|
#define CASEFOLDER_H
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
class CaseFolder {
|
class CaseFolder {
|
||||||
public:
|
public:
|
||||||
@ -23,7 +21,7 @@ protected:
|
|||||||
char mapping[256];
|
char mapping[256];
|
||||||
public:
|
public:
|
||||||
CaseFolderTable();
|
CaseFolderTable();
|
||||||
virtual ~CaseFolderTable();
|
~CaseFolderTable() override;
|
||||||
size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) override;
|
size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) override;
|
||||||
void SetTranslation(char ch, char chTranslation);
|
void SetTranslation(char ch, char chTranslation);
|
||||||
void StandardASCII();
|
void StandardASCII();
|
||||||
@ -38,8 +36,6 @@ public:
|
|||||||
size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) override;
|
size_t Fold(char *folded, size_t sizeFolded, const char *mixed, size_t lenMixed) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
// Scintilla source code edit control
|
// Scintilla source code edit control
|
||||||
/** @file Catalogue.cxx
|
/** @file Catalogue.cxx
|
||||||
** Colourise for particular languages.
|
** Lexer infrastructure.
|
||||||
|
** Contains a list of LexerModules which can be searched to find a module appropriate for a
|
||||||
|
** particular language.
|
||||||
**/
|
**/
|
||||||
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
|
||||||
// The License.txt file describes the conditions under which this software may be distributed.
|
// The License.txt file describes the conditions under which this software may be distributed.
|
||||||
@ -19,9 +21,7 @@
|
|||||||
#include "LexerModule.h"
|
#include "LexerModule.h"
|
||||||
#include "Catalogue.h"
|
#include "Catalogue.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
static std::vector<LexerModule *> lexerCatalogue;
|
static std::vector<LexerModule *> lexerCatalogue;
|
||||||
static int nextLanguage = SCLEX_AUTOMATIC+1;
|
static int nextLanguage = SCLEX_AUTOMATIC+1;
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
// Scintilla source code edit control
|
// Scintilla source code edit control
|
||||||
/** @file Catalogue.h
|
/** @file Catalogue.h
|
||||||
** Lexer infrastructure.
|
** Lexer infrastructure.
|
||||||
|
** Contains a list of LexerModules which can be searched to find a module appropriate for a
|
||||||
|
** particular language.
|
||||||
**/
|
**/
|
||||||
// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
|
// Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
|
||||||
// The License.txt file describes the conditions under which this software may be distributed.
|
// The License.txt file describes the conditions under which this software may be distributed.
|
||||||
@ -8,9 +10,7 @@
|
|||||||
#ifndef CATALOGUE_H
|
#ifndef CATALOGUE_H
|
||||||
#define CATALOGUE_H
|
#define CATALOGUE_H
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
namespace Scintilla {
|
namespace Scintilla {
|
||||||
#endif
|
|
||||||
|
|
||||||
class Catalogue {
|
class Catalogue {
|
||||||
public:
|
public:
|
||||||
@ -19,8 +19,6 @@ public:
|
|||||||
static void AddLexerModule(LexerModule *plm);
|
static void AddLexerModule(LexerModule *plm);
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -25,56 +25,80 @@
|
|||||||
#include "CellBuffer.h"
|
#include "CellBuffer.h"
|
||||||
#include "UniConversion.h"
|
#include "UniConversion.h"
|
||||||
|
|
||||||
#ifdef SCI_NAMESPACE
|
namespace Scintilla {
|
||||||
|
|
||||||
|
class ILineVector {
|
||||||
|
public:
|
||||||
|
virtual void Init() = 0;
|
||||||
|
virtual void SetPerLine(PerLine *pl) = 0;
|
||||||
|
virtual void InsertText(Sci::Line line, Sci::Position delta) = 0;
|
||||||
|
virtual void InsertLine(Sci::Line line, Sci::Position position, bool lineStart) = 0;
|
||||||
|
virtual void SetLineStart(Sci::Line line, Sci::Position position) = 0;
|
||||||
|
virtual void RemoveLine(Sci::Line line) = 0;
|
||||||
|
virtual Sci::Line Lines() const noexcept = 0;
|
||||||
|
virtual Sci::Line LineFromPosition(Sci::Position pos) const noexcept = 0;
|
||||||
|
virtual Sci::Position LineStart(Sci::Line line) const noexcept = 0;
|
||||||
|
virtual ~ILineVector() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
using namespace Scintilla;
|
using namespace Scintilla;
|
||||||
#endif
|
|
||||||
|
|
||||||
LineVector::LineVector() : starts(256), perLine(0) {
|
template <typename POS>
|
||||||
Init();
|
class LineVector : public ILineVector {
|
||||||
}
|
Partitioning<POS> starts;
|
||||||
|
PerLine *perLine;
|
||||||
LineVector::~LineVector() {
|
public:
|
||||||
starts.DeleteAll();
|
LineVector() : starts(256), perLine(0) {
|
||||||
}
|
Init();
|
||||||
|
}
|
||||||
void LineVector::Init() {
|
// Deleted so LineVector objects can not be copied.
|
||||||
starts.DeleteAll();
|
LineVector(const LineVector &) = delete;
|
||||||
if (perLine) {
|
LineVector(LineVector &&) = delete;
|
||||||
perLine->Init();
|
LineVector &operator=(const LineVector &) = delete;
|
||||||
|
LineVector &operator=(LineVector &&) = delete;
|
||||||
|
~LineVector() override {
|
||||||
|
}
|
||||||
|
void Init() override {
|
||||||
|
starts.DeleteAll();
|
||||||
|
if (perLine) {
|
||||||
|
perLine->Init();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void SetPerLine(PerLine *pl) override {
|
||||||
|
perLine = pl;
|
||||||
}
|
}
|
||||||
}
|
void InsertText(Sci::Line line, Sci::Position delta) override {
|
||||||
|
starts.InsertText(static_cast<POS>(line), static_cast<POS>(delta));
|
||||||
void LineVector::SetPerLine(PerLine *pl) {
|
|
||||||
perLine = pl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LineVector::InsertText(Sci::Line line, Sci::Position delta) {
|
|
||||||
starts.InsertText(line, delta);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LineVector::InsertLine(Sci::Line line, Sci::Position position, bool lineStart) {
|
|
||||||
starts.InsertPartition(line, position);
|
|
||||||
if (perLine) {
|
|
||||||
if ((line > 0) && lineStart)
|
|
||||||
line--;
|
|
||||||
perLine->InsertLine(line);
|
|
||||||
}
|
}
|
||||||
}
|
void InsertLine(Sci::Line line, Sci::Position position, bool lineStart) override {
|
||||||
|
starts.InsertPartition(static_cast<POS>(line), static_cast<POS>(position));
|
||||||
void LineVector::SetLineStart(Sci::Line line, Sci::Position position) {
|
if (perLine) {
|
||||||
starts.SetPartitionStartPosition(line, position);
|
if ((line > 0) && lineStart)
|
||||||
}
|
line--;
|
||||||
|
perLine->InsertLine(line);
|
||||||
void LineVector::RemoveLine(Sci::Line line) {
|
}
|
||||||
starts.RemovePartition(line);
|
|
||||||
if (perLine) {
|
|
||||||
perLine->RemoveLine(line);
|
|
||||||
}
|
}
|
||||||
}
|
void SetLineStart(Sci::Line line, Sci::Position position) override {
|
||||||
|
starts.SetPartitionStartPosition(static_cast<POS>(line), static_cast<POS>(position));
|
||||||
Sci::Line LineVector::LineFromPosition(Sci::Position pos) const {
|
}
|
||||||
return starts.PartitionFromPosition(pos);
|
void RemoveLine(Sci::Line line) override {
|
||||||
}
|
starts.RemovePartition(static_cast<POS>(line));
|
||||||
|
if (perLine) {
|
||||||
|
perLine->RemoveLine(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Sci::Line Lines() const noexcept override {
|
||||||
|
return static_cast<Sci::Line>(starts.Partitions());
|
||||||
|
}
|
||||||
|
Sci::Line LineFromPosition(Sci::Position pos) const noexcept override {
|
||||||
|
return static_cast<Sci::Line>(starts.PartitionFromPosition(static_cast<POS>(pos)));
|
||||||
|
}
|
||||||
|
Sci::Position LineStart(Sci::Line line) const noexcept override {
|
||||||
|
return starts.PositionFromPartition(static_cast<POS>(line));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Action::Action() {
|
Action::Action() {
|
||||||
at = startAction;
|
at = startAction;
|
||||||
@ -83,14 +107,6 @@ Action::Action() {
|
|||||||
mayCoalesce = false;
|
mayCoalesce = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Action::Action(Action &&other) {
|
|
||||||
at = other.at;
|
|
||||||
position = other.position;
|
|
||||||
data = std::move(other.data);
|
|
||||||
lenData = other.lenData;
|
|
||||||
mayCoalesce = other.mayCoalesce;
|
|
||||||
}
|
|
||||||
|
|
||||||
Action::~Action() {
|
Action::~Action() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,16 +360,25 @@ void UndoHistory::CompletedRedoStep() {
|
|||||||
currentAction++;
|
currentAction++;
|
||||||
}
|
}
|
||||||
|
|
||||||
CellBuffer::CellBuffer() {
|
CellBuffer::CellBuffer(bool hasStyles_, bool largeDocument_) :
|
||||||
|
hasStyles(hasStyles_), largeDocument(largeDocument_) {
|
||||||
readOnly = false;
|
readOnly = false;
|
||||||
utf8LineEnds = 0;
|
utf8LineEnds = 0;
|
||||||
collectingUndo = true;
|
collectingUndo = true;
|
||||||
|
if (largeDocument)
|
||||||
|
plv = std::unique_ptr<LineVector<Sci::Position>>(new LineVector<Sci::Position>());
|
||||||
|
else
|
||||||
|
plv = std::unique_ptr<LineVector<int>>(new LineVector<int>());
|
||||||
}
|
}
|
||||||
|
|
||||||
CellBuffer::~CellBuffer() {
|
CellBuffer::~CellBuffer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
char CellBuffer::CharAt(Sci::Position position) const {
|
char CellBuffer::CharAt(Sci::Position position) const noexcept {
|
||||||
|
return substance.ValueAt(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char CellBuffer::UCharAt(Sci::Position position) const noexcept {
|
||||||
return substance.ValueAt(position);
|
return substance.ValueAt(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,8 +395,8 @@ void CellBuffer::GetCharRange(char *buffer, Sci::Position position, Sci::Positio
|
|||||||
substance.GetRange(buffer, position, lengthRetrieve);
|
substance.GetRange(buffer, position, lengthRetrieve);
|
||||||
}
|
}
|
||||||
|
|
||||||
char CellBuffer::StyleAt(Sci::Position position) const {
|
char CellBuffer::StyleAt(Sci::Position position) const noexcept {
|
||||||
return style.ValueAt(position);
|
return hasStyles ? style.ValueAt(position) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellBuffer::GetStyleRange(unsigned char *buffer, Sci::Position position, Sci::Position lengthRetrieve) const {
|
void CellBuffer::GetStyleRange(unsigned char *buffer, Sci::Position position, Sci::Position lengthRetrieve) const {
|
||||||
@ -379,6 +404,10 @@ void CellBuffer::GetStyleRange(unsigned char *buffer, Sci::Position position, Sc
|
|||||||
return;
|
return;
|
||||||
if (position < 0)
|
if (position < 0)
|
||||||
return;
|
return;
|
||||||
|
if (!hasStyles) {
|
||||||
|
std::fill(buffer, buffer + lengthRetrieve, static_cast<unsigned char>(0));
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ((position + lengthRetrieve) > style.Length()) {
|
if ((position + lengthRetrieve) > style.Length()) {
|
||||||
Platform::DebugPrintf("Bad GetStyleRange %d for %d of %d\n", position,
|
Platform::DebugPrintf("Bad GetStyleRange %d for %d of %d\n", position,
|
||||||
lengthRetrieve, style.Length());
|
lengthRetrieve, style.Length());
|
||||||
@ -416,6 +445,9 @@ const char *CellBuffer::InsertString(Sci::Position position, const char *s, Sci:
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CellBuffer::SetStyleAt(Sci::Position position, char styleValue) {
|
bool CellBuffer::SetStyleAt(Sci::Position position, char styleValue) {
|
||||||
|
if (!hasStyles) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
const char curVal = style.ValueAt(position);
|
const char curVal = style.ValueAt(position);
|
||||||
if (curVal != styleValue) {
|
if (curVal != styleValue) {
|
||||||
style.SetValueAt(position, styleValue);
|
style.SetValueAt(position, styleValue);
|
||||||
@ -426,6 +458,9 @@ bool CellBuffer::SetStyleAt(Sci::Position position, char styleValue) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CellBuffer::SetStyleFor(Sci::Position position, Sci::Position lengthStyle, char styleValue) {
|
bool CellBuffer::SetStyleFor(Sci::Position position, Sci::Position lengthStyle, char styleValue) {
|
||||||
|
if (!hasStyles) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
PLATFORM_ASSERT(lengthStyle == 0 ||
|
PLATFORM_ASSERT(lengthStyle == 0 ||
|
||||||
(lengthStyle > 0 && lengthStyle + position <= style.Length()));
|
(lengthStyle > 0 && lengthStyle + position <= style.Length()));
|
||||||
@ -458,13 +493,15 @@ const char *CellBuffer::DeleteChars(Sci::Position position, Sci::Position delete
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sci::Position CellBuffer::Length() const {
|
Sci::Position CellBuffer::Length() const noexcept {
|
||||||
return substance.Length();
|
return substance.Length();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellBuffer::Allocate(Sci::Position newSize) {
|
void CellBuffer::Allocate(Sci::Position newSize) {
|
||||||
substance.ReAllocate(newSize);
|
substance.ReAllocate(newSize);
|
||||||
style.ReAllocate(newSize);
|
if (hasStyles) {
|
||||||
|
style.ReAllocate(newSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellBuffer::SetLineEndTypes(int utf8LineEnds_) {
|
void CellBuffer::SetLineEndTypes(int utf8LineEnds_) {
|
||||||
@ -494,20 +531,24 @@ bool CellBuffer::ContainsLineEnd(const char *s, Sci::Position length) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CellBuffer::SetPerLine(PerLine *pl) {
|
void CellBuffer::SetPerLine(PerLine *pl) {
|
||||||
lv.SetPerLine(pl);
|
plv->SetPerLine(pl);
|
||||||
}
|
}
|
||||||
|
|
||||||
Sci::Line CellBuffer::Lines() const {
|
Sci::Line CellBuffer::Lines() const noexcept {
|
||||||
return lv.Lines();
|
return plv->Lines();
|
||||||
}
|
}
|
||||||
|
|
||||||
Sci::Position CellBuffer::LineStart(Sci::Line line) const {
|
Sci::Position CellBuffer::LineStart(Sci::Line line) const noexcept {
|
||||||
if (line < 0)
|
if (line < 0)
|
||||||
return 0;
|
return 0;
|
||||||
else if (line >= Lines())
|
else if (line >= Lines())
|
||||||
return Length();
|
return Length();
|
||||||
else
|
else
|
||||||
return lv.LineStart(line);
|
return plv->LineStart(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
Sci::Line CellBuffer::LineFromPosition(Sci::Position pos) const noexcept {
|
||||||
|
return plv->LineFromPosition(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CellBuffer::IsReadOnly() const {
|
bool CellBuffer::IsReadOnly() const {
|
||||||
@ -518,6 +559,14 @@ void CellBuffer::SetReadOnly(bool set) {
|
|||||||
readOnly = set;
|
readOnly = set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CellBuffer::IsLarge() const {
|
||||||
|
return largeDocument;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CellBuffer::HasStyles() const {
|
||||||
|
return hasStyles;
|
||||||
|
}
|
||||||
|
|
||||||
void CellBuffer::SetSavePoint() {
|
void CellBuffer::SetSavePoint() {
|
||||||
uh.SetSavePoint();
|
uh.SetSavePoint();
|
||||||
}
|
}
|
||||||
@ -545,11 +594,11 @@ bool CellBuffer::TentativeActive() const {
|
|||||||
// Without undo
|
// Without undo
|
||||||
|
|
||||||
void CellBuffer::InsertLine(Sci::Line line, Sci::Position position, bool lineStart) {
|
void CellBuffer::InsertLine(Sci::Line line, Sci::Position position, bool lineStart) {
|
||||||
lv.InsertLine(line, position, lineStart);
|
plv->InsertLine(line, position, lineStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellBuffer::RemoveLine(Sci::Line line) {
|
void CellBuffer::RemoveLine(Sci::Line line) {
|
||||||
lv.RemoveLine(line);
|
plv->RemoveLine(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CellBuffer::UTF8LineEndOverlaps(Sci::Position position) const {
|
bool CellBuffer::UTF8LineEndOverlaps(Sci::Position position) const {
|
||||||
@ -564,13 +613,13 @@ bool CellBuffer::UTF8LineEndOverlaps(Sci::Position position) const {
|
|||||||
|
|
||||||
void CellBuffer::ResetLineEnds() {
|
void CellBuffer::ResetLineEnds() {
|
||||||
// Reinitialize line data -- too much work to preserve
|
// Reinitialize line data -- too much work to preserve
|
||||||
lv.Init();
|
plv->Init();
|
||||||
|
|
||||||
Sci::Position position = 0;
|
const Sci::Position position = 0;
|
||||||
Sci::Position length = Length();
|
const Sci::Position length = Length();
|
||||||
Sci::Line lineInsert = 1;
|
Sci::Line lineInsert = 1;
|
||||||
bool atLineStart = true;
|
const bool atLineStart = true;
|
||||||
lv.InsertText(lineInsert-1, length);
|
plv->InsertText(lineInsert-1, length);
|
||||||
unsigned char chBeforePrev = 0;
|
unsigned char chBeforePrev = 0;
|
||||||
unsigned char chPrev = 0;
|
unsigned char chPrev = 0;
|
||||||
for (Sci::Position i = 0; i < length; i++) {
|
for (Sci::Position i = 0; i < length; i++) {
|
||||||
@ -581,7 +630,7 @@ void CellBuffer::ResetLineEnds() {
|
|||||||
} else if (ch == '\n') {
|
} else if (ch == '\n') {
|
||||||
if (chPrev == '\r') {
|
if (chPrev == '\r') {
|
||||||
// Patch up what was end of line
|
// Patch up what was end of line
|
||||||
lv.SetLineStart(lineInsert - 1, (position + i) + 1);
|
plv->SetLineStart(lineInsert - 1, (position + i) + 1);
|
||||||
} else {
|
} else {
|
||||||
InsertLine(lineInsert, (position + i) + 1, atLineStart);
|
InsertLine(lineInsert, (position + i) + 1, atLineStart);
|
||||||
lineInsert++;
|
lineInsert++;
|
||||||
@ -610,12 +659,14 @@ void CellBuffer::BasicInsertString(Sci::Position position, const char *s, Sci::P
|
|||||||
}
|
}
|
||||||
|
|
||||||
substance.InsertFromArray(position, s, 0, insertLength);
|
substance.InsertFromArray(position, s, 0, insertLength);
|
||||||
style.InsertValue(position, insertLength, 0);
|
if (hasStyles) {
|
||||||
|
style.InsertValue(position, insertLength, 0);
|
||||||
|
}
|
||||||
|
|
||||||
Sci::Line lineInsert = lv.LineFromPosition(position) + 1;
|
Sci::Line lineInsert = plv->LineFromPosition(position) + 1;
|
||||||
bool atLineStart = lv.LineStart(lineInsert-1) == position;
|
const bool atLineStart = plv->LineStart(lineInsert-1) == position;
|
||||||
// Point all the lines after the insertion point further along in the buffer
|
// Point all the lines after the insertion point further along in the buffer
|
||||||
lv.InsertText(lineInsert-1, insertLength);
|
plv->InsertText(lineInsert-1, insertLength);
|
||||||
unsigned char chBeforePrev = substance.ValueAt(position - 2);
|
unsigned char chBeforePrev = substance.ValueAt(position - 2);
|
||||||
unsigned char chPrev = substance.ValueAt(position - 1);
|
unsigned char chPrev = substance.ValueAt(position - 1);
|
||||||
if (chPrev == '\r' && chAfter == '\n') {
|
if (chPrev == '\r' && chAfter == '\n') {
|
||||||
@ -635,7 +686,7 @@ void CellBuffer::BasicInsertString(Sci::Position position, const char *s, Sci::P
|
|||||||
} else if (ch == '\n') {
|
} else if (ch == '\n') {
|
||||||
if (chPrev == '\r') {
|
if (chPrev == '\r') {
|
||||||
// Patch up what was end of line
|
// Patch up what was end of line
|
||||||
lv.SetLineStart(lineInsert - 1, (position + i) + 1);
|
plv->SetLineStart(lineInsert - 1, (position + i) + 1);
|
||||||
} else {
|
} else {
|
||||||
InsertLine(lineInsert, (position + i) + 1, atLineStart);
|
InsertLine(lineInsert, (position + i) + 1, atLineStart);
|
||||||
lineInsert++;
|
lineInsert++;
|
||||||
@ -682,20 +733,20 @@ void CellBuffer::BasicDeleteChars(Sci::Position position, Sci::Position deleteLe
|
|||||||
if ((position == 0) && (deleteLength == substance.Length())) {
|
if ((position == 0) && (deleteLength == substance.Length())) {
|
||||||
// If whole buffer is being deleted, faster to reinitialise lines data
|
// If whole buffer is being deleted, faster to reinitialise lines data
|
||||||
// than to delete each line.
|
// than to delete each line.
|
||||||
lv.Init();
|
plv->Init();
|
||||||
} else {
|
} else {
|
||||||
// Have to fix up line positions before doing deletion as looking at text in buffer
|
// Have to fix up line positions before doing deletion as looking at text in buffer
|
||||||
// to work out which lines have been removed
|
// to work out which lines have been removed
|
||||||
|
|
||||||
Sci::Line lineRemove = lv.LineFromPosition(position) + 1;
|
Sci::Line lineRemove = plv->LineFromPosition(position) + 1;
|
||||||
lv.InsertText(lineRemove-1, - (deleteLength));
|
plv->InsertText(lineRemove-1, - (deleteLength));
|
||||||
const unsigned char chPrev = substance.ValueAt(position - 1);
|
const unsigned char chPrev = substance.ValueAt(position - 1);
|
||||||
const unsigned char chBefore = chPrev;
|
const unsigned char chBefore = chPrev;
|
||||||
unsigned char chNext = substance.ValueAt(position);
|
unsigned char chNext = substance.ValueAt(position);
|
||||||
bool ignoreNL = false;
|
bool ignoreNL = false;
|
||||||
if (chPrev == '\r' && chNext == '\n') {
|
if (chPrev == '\r' && chNext == '\n') {
|
||||||
// Move back one
|
// Move back one
|
||||||
lv.SetLineStart(lineRemove, position);
|
plv->SetLineStart(lineRemove, position);
|
||||||
lineRemove++;
|
lineRemove++;
|
||||||
ignoreNL = true; // First \n is not real deletion
|
ignoreNL = true; // First \n is not real deletion
|
||||||
}
|
}
|
||||||
@ -736,11 +787,13 @@ void CellBuffer::BasicDeleteChars(Sci::Position position, Sci::Position deleteLe
|
|||||||
if (chBefore == '\r' && chAfter == '\n') {
|
if (chBefore == '\r' && chAfter == '\n') {
|
||||||
// Using lineRemove-1 as cr ended line before start of deletion
|
// Using lineRemove-1 as cr ended line before start of deletion
|
||||||
RemoveLine(lineRemove - 1);
|
RemoveLine(lineRemove - 1);
|
||||||
lv.SetLineStart(lineRemove - 1, position + 1);
|
plv->SetLineStart(lineRemove - 1, position + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
substance.DeleteRange(position, deleteLength);
|
substance.DeleteRange(position, deleteLength);
|
||||||
style.DeleteRange(position, deleteLength);
|
if (hasStyles) {
|
||||||
|
style.DeleteRange(position, deleteLength);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CellBuffer::SetUndoCollection(bool collectUndo) {
|
bool CellBuffer::SetUndoCollection(bool collectUndo) {
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user