Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Tue, 26 Jun 2012 18:48:16 Commit: 4dd0fe917501e1d67bf840f8f183acb32ad92b5b https://github.com/geany/geany/commit/4dd0fe917501e1d67bf840f8f183acb32ad92b...
Log Message: ----------- Update Scintilla to version 3.2.0
Modified Paths: -------------- scintilla/gtk/PlatGTK.cxx scintilla/gtk/ScintillaGTK.cxx scintilla/include/ILexer.h scintilla/include/Platform.h scintilla/include/SciLexer.h scintilla/include/Scintilla.h scintilla/include/Scintilla.iface scintilla/lexers/LexAda.cxx scintilla/lexers/LexAsm.cxx scintilla/lexers/LexBash.cxx scintilla/lexers/LexBasic.cxx scintilla/lexers/LexCPP.cxx scintilla/lexers/LexCSS.cxx scintilla/lexers/LexD.cxx scintilla/lexers/LexHTML.cxx scintilla/lexers/LexNsis.cxx scintilla/lexers/LexOthers.cxx scintilla/lexers/LexPascal.cxx scintilla/lexers/LexPerl.cxx scintilla/lexers/LexRuby.cxx scintilla/lexers/LexSQL.cxx scintilla/lexers/LexVHDL.cxx scintilla/lexlib/LexAccessor.h scintilla/lexlib/PropSetSimple.cxx scintilla/scintilla_changes.patch scintilla/src/AutoComplete.cxx scintilla/src/AutoComplete.h scintilla/src/CallTip.cxx scintilla/src/CallTip.h scintilla/src/CellBuffer.cxx scintilla/src/CellBuffer.h scintilla/src/Decoration.cxx scintilla/src/Document.cxx scintilla/src/Document.h scintilla/src/Editor.cxx scintilla/src/Editor.h scintilla/src/FontQuality.h scintilla/src/Indicator.cxx scintilla/src/Indicator.h scintilla/src/LineMarker.cxx scintilla/src/LineMarker.h scintilla/src/PerLine.cxx scintilla/src/PerLine.h scintilla/src/PositionCache.cxx scintilla/src/PositionCache.h scintilla/src/ScintillaBase.cxx scintilla/src/ScintillaBase.h scintilla/src/SplitVector.h scintilla/src/Style.cxx scintilla/src/Style.h scintilla/src/UniConversion.cxx scintilla/src/UniConversion.h scintilla/src/ViewStyle.cxx scintilla/src/ViewStyle.h scintilla/src/XPM.cxx scintilla/src/XPM.h scintilla/version.txt
Modified: scintilla/gtk/PlatGTK.cxx 1204 files changed, 150 insertions(+), 1054 deletions(-) =================================================================== @@ -25,15 +25,17 @@ #include "UniConversion.h" #include "XPM.h"
+#if defined(__clang__) +// Clang 3.0 incorrectly displays sentinel warnings. Fixed by clang 3.1. +#pragma GCC diagnostic ignored "-Wsentinel" +#endif + /* GLIB must be compiled with thread support, otherwise we will bail on trying to use locks, and that could lead to problems for someone. `glib-config --libs gthread` needs to be used to get the glib libraries for linking, otherwise g_thread_init will fail */ #define USE_LOCK defined(G_THREADS_ENABLED) && !defined(G_THREADS_IMPL_NONE) -/* Use fast way of getting char data on win32 to work around problems - with gdk_string_extents. */ -#define FAST_WAY
#include "Converter.h"
@@ -43,9 +45,16 @@ #define IS_WIDGET_FOCUSSED(w) (GTK_WIDGET_HAS_FOCUS(w)) #endif
-#define USE_CAIRO 1 +// The Pango version guard for pango_units_from_double and pango_units_to_double +// is more complex than simply implementing these here.
-#ifdef USE_CAIRO +static int pangoUnitsFromDouble(double d) { + return static_cast<int>(d * PANGO_SCALE + 0.5); +} + +static double doubleFromPangoUnits(int pu) { + return static_cast<double>(pu) / PANGO_SCALE; +}
static cairo_surface_t *CreateSimilarSurface(GdkWindow *window, cairo_content_t content, int width, int height) { #if GTK_CHECK_VERSION(2,22,0) @@ -65,8 +74,6 @@ static cairo_surface_t *CreateSimilarSurface(GdkWindow *window, cairo_content_t #endif }
-#endif - static GdkWindow *WindowFromWidget(GtkWidget *w) { #if GTK_CHECK_VERSION(3,0,0) return gtk_widget_get_window(w); @@ -75,10 +82,6 @@ static GdkWindow *WindowFromWidget(GtkWidget *w) { #endif }
-#ifdef USE_CAIRO -#define DISABLE_GDK_FONT 1 -#endif - #ifdef _MSC_VER // Ignore unreferenced local functions in GTK+ headers #pragma warning(disable: 4505) @@ -92,7 +95,7 @@ static GdkWindow *WindowFromWidget(GtkWidget *w) {
struct LOGFONT { int size; - bool bold; + int weight; bool italic; int characterSet; char faceName[300]; @@ -143,45 +146,23 @@ static void FontMutexUnlock() { // On GTK+ 1.x holds a GdkFont* but on GTK+ 2.x can hold a GdkFont* or a // PangoFontDescription*. class FontHandle { - int width[128]; + XYPOSITION width[128]; encodingType et; public: int ascent; -#ifndef DISABLE_GDK_FONT - GdkFont *pfont; -#endif PangoFontDescription *pfd; int characterSet; -#ifdef DISABLE_GDK_FONT FontHandle() : et(singleByte), ascent(0), pfd(0), characterSet(-1) { ResetWidths(et); } -#else - FontHandle(GdkFont *pfont_=0) { - et = singleByte; - ascent = 0; - pfont = pfont_; - pfd = 0; - characterSet = -1; - ResetWidths(et); - } -#endif FontHandle(PangoFontDescription *pfd_, int characterSet_) { et = singleByte; ascent = 0; -#ifndef DISABLE_GDK_FONT - pfont = 0; -#endif pfd = pfd_; characterSet = characterSet_; ResetWidths(et); } ~FontHandle() { -#ifndef DISABLE_GDK_FONT - if (pfont) - gdk_font_unref(pfont); - pfont = 0; -#endif if (pfd) pango_font_description_free(pfd); pfd = 0; @@ -192,8 +173,8 @@ class FontHandle { width[i] = 0; } } - int CharWidth(unsigned char ch, encodingType et_) { - int w = 0; + XYPOSITION CharWidth(unsigned char ch, encodingType et_) { + XYPOSITION w = 0; FontMutexLock(); if ((ch <= 127) && (et == et_)) { w = width[ch]; @@ -201,7 +182,7 @@ class FontHandle { FontMutexUnlock(); return w; } - void SetCharWidth(unsigned char ch, int w, encodingType et_) { + void SetCharWidth(unsigned char ch, XYPOSITION w, encodingType et_) { if (ch <= 127) { FontMutexLock(); if (et != et_) { @@ -224,229 +205,16 @@ static GtkWidget *PWidget(WindowID wid) { return reinterpret_cast<GtkWidget *>(wid); }
-#if !GTK_CHECK_VERSION(3,0,0) -static GtkWidget *PWidget(Window &w) { - return PWidget(w.GetID()); -} -#endif - Point Point::FromLong(long lpoint) { return Point( Platform::LowShortFromLong(lpoint), Platform::HighShortFromLong(lpoint)); }
-Palette::Palette() { - used = 0; - allowRealization = false; - allocatedPalette = 0; - allocatedLen = 0; - size = 100; - entries = new ColourPair[size]; -} - -Palette::~Palette() { - Release(); - delete []entries; - entries = 0; -} - -void Palette::Release() { - used = 0; - delete [](reinterpret_cast<GdkColor *>(allocatedPalette)); - allocatedPalette = 0; - allocatedLen = 0; - delete []entries; - size = 100; - entries = new ColourPair[size]; -} - -// This method either adds a colour to the list of wanted colours (want==true) -// or retrieves the allocated colour back to the ColourPair. -// This is one method to make it easier to keep the code for wanting and retrieving in sync. -void Palette::WantFind(ColourPair &cp, bool want) { - if (want) { - for (int i=0; i < used; i++) { - if (entries[i].desired == cp.desired) - return; - } - - if (used >= size) { - int sizeNew = size * 2; - ColourPair *entriesNew = new ColourPair[sizeNew]; - for (int j=0; j<size; j++) { - entriesNew[j] = entries[j]; - } - delete []entries; - entries = entriesNew; - size = sizeNew; - } - - entries[used].desired = cp.desired; - entries[used].allocated.Set(cp.desired.AsLong()); - used++; - } else { - for (int i=0; i < used; i++) { - if (entries[i].desired == cp.desired) { - cp.allocated = entries[i].allocated; - return; - } - } - cp.allocated.Set(cp.desired.AsLong()); - } -} - -void Palette::Allocate(Window &w) { -#if !GTK_CHECK_VERSION(3,0,0) - // Disable palette on GTK+ 3. - if (allocatedPalette) { - gdk_colormap_free_colors(gtk_widget_get_colormap(PWidget(w)), - reinterpret_cast<GdkColor *>(allocatedPalette), - allocatedLen); - delete [](reinterpret_cast<GdkColor *>(allocatedPalette)); - allocatedPalette = 0; - allocatedLen = 0; - } - GdkColor *paletteNew = new GdkColor[used]; - allocatedPalette = paletteNew; - gboolean *successPalette = new gboolean[used]; - if (paletteNew) { - allocatedLen = used; - int iPal = 0; - for (iPal = 0; iPal < used; iPal++) { - paletteNew[iPal].red = entries[iPal].desired.GetRed() * (65535 / 255); - paletteNew[iPal].green = entries[iPal].desired.GetGreen() * (65535 / 255); - paletteNew[iPal].blue = entries[iPal].desired.GetBlue() * (65535 / 255); - paletteNew[iPal].pixel = entries[iPal].desired.AsLong(); - } -#ifndef USE_CAIRO - gdk_colormap_alloc_colors(gtk_widget_get_colormap(PWidget(w)), - paletteNew, allocatedLen, FALSE, TRUE, - successPalette); -#endif - for (iPal = 0; iPal < used; iPal++) { - entries[iPal].allocated.Set(paletteNew[iPal].pixel); - } - } - delete []successPalette; -#endif -} - -#ifndef DISABLE_GDK_FONT - -static const char *CharacterSetName(int characterSet) { - switch (characterSet) { - case SC_CHARSET_ANSI: - return "iso8859-*"; - case SC_CHARSET_DEFAULT: - return "iso8859-*"; - case SC_CHARSET_BALTIC: - return "iso8859-13"; - case SC_CHARSET_CHINESEBIG5: - return "*-*"; - case SC_CHARSET_EASTEUROPE: - return "*-2"; - case SC_CHARSET_GB2312: - return "gb2312.1980-*"; - case SC_CHARSET_GREEK: - return "*-7"; - case SC_CHARSET_HANGUL: - return "ksc5601.1987-*"; - case SC_CHARSET_MAC: - return "*-*"; - case SC_CHARSET_OEM: - return "*-*"; - case SC_CHARSET_RUSSIAN: - return "*-r"; - case SC_CHARSET_CYRILLIC: - return "*-cp1251"; - case SC_CHARSET_SHIFTJIS: - return "jisx0208.1983-*"; - case SC_CHARSET_SYMBOL: - return "*-*"; - case SC_CHARSET_TURKISH: - return "*-9"; - case SC_CHARSET_JOHAB: - return "*-*"; - case SC_CHARSET_HEBREW: - return "*-8"; - case SC_CHARSET_ARABIC: - return "*-6"; - case SC_CHARSET_VIETNAMESE: - return "*-*"; - case SC_CHARSET_THAI: - return "iso8859-11"; - case SC_CHARSET_8859_15: - return "iso8859-15"; - default: - return "*-*"; - } -} - -static bool IsDBCSCharacterSet(int characterSet) { - switch (characterSet) { - case SC_CHARSET_GB2312: - case SC_CHARSET_HANGUL: - case SC_CHARSET_SHIFTJIS: - case SC_CHARSET_CHINESEBIG5: - return true; - default: - return false; - } -} - -static void GenerateFontSpecStrings(const char *fontName, int characterSet, - char *foundary, int foundary_len, - char *faceName, int faceName_len, - char *charset, int charset_len) { - // supported font strings include: - // foundary-fontface-isoxxx-x - // fontface-isoxxx-x - // foundary-fontface - // fontface - if (strchr(fontName, '-')) { - char tmp[300]; - char *d1 = NULL, *d2 = NULL, *d3 = NULL; - strncpy(tmp, fontName, sizeof(tmp) - 1); - tmp[sizeof(tmp) - 1] = '\0'; - d1 = strchr(tmp, '-'); - // we know the first dash exists - d2 = strchr(d1 + 1, '-'); - if (d2) - d3 = strchr(d2 + 1, '-'); - if (d3 && d2) { - // foundary-fontface-isoxxx-x - *d2 = '\0'; - foundary[0] = '-'; - foundary[1] = '\0'; - strncpy(faceName, tmp, foundary_len - 1); - strncpy(charset, d2 + 1, charset_len - 1); - } else if (d2) { - // fontface-isoxxx-x - *d1 = '\0'; - strcpy(foundary, "-*-"); - strncpy(faceName, tmp, faceName_len - 1); - strncpy(charset, d1 + 1, charset_len - 1); - } else { - // foundary-fontface - foundary[0] = '-'; - foundary[1] = '\0'; - strncpy(faceName, tmp, faceName_len - 1); - strncpy(charset, CharacterSetName(characterSet), charset_len - 1); - } - } else { - strncpy(foundary, "-*-", foundary_len); - strncpy(faceName, fontName, faceName_len - 1); - strncpy(charset, CharacterSetName(characterSet), charset_len - 1); - } -} - -#endif - -static void SetLogFont(LOGFONT &lf, const char *faceName, int characterSet, int size, bool bold, bool italic) { +static void SetLogFont(LOGFONT &lf, const char *faceName, int characterSet, float size, int weight, bool italic) { memset(&lf, 0, sizeof(lf)); lf.size = size; - lf.bold = bold; + lf.weight = weight; lf.italic = italic; lf.characterSet = characterSet; strncpy(lf.faceName, faceName, sizeof(lf.faceName) - 1); @@ -457,13 +225,13 @@ static void SetLogFont(LOGFONT &lf, const char *faceName, int characterSet, int * If one font is the same as another, its hash will be the same, but if the hash is the * same then they may still be different. */ -static int HashFont(const char *faceName, int characterSet, int size, bool bold, bool italic) { +static int HashFont(const FontParameters &fp) { return - size ^ - (characterSet << 10) ^ - (bold ? 0x10000000 : 0) ^ - (italic ? 0x20000000 : 0) ^ - faceName[0]; + static_cast<int>(fp.size+0.5) ^ + (fp.characterSet << 10) ^ + ((fp.weight / 100) << 12) ^ + (fp.italic ? 0x20000000 : 0) ^ + fp.faceName[0]; }
class FontCached : Font { @@ -471,35 +239,34 @@ class FontCached : Font { int usage; LOGFONT lf; int hash; - FontCached(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_); + FontCached(const FontParameters &fp); ~FontCached() {} - bool SameAs(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_); + bool SameAs(const FontParameters &fp); virtual void Release(); - static FontID CreateNewFont(const char *fontName, int characterSet, - int size, bool bold, bool italic); + static FontID CreateNewFont(const FontParameters &fp); static FontCached *first; public: - static FontID FindOrCreate(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_); + static FontID FindOrCreate(const FontParameters &fp); static void ReleaseId(FontID fid_); };
FontCached *FontCached::first = 0;
-FontCached::FontCached(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_) : +FontCached::FontCached(const FontParameters &fp) : next(0), usage(0), hash(0) { - ::SetLogFont(lf, faceName_, characterSet_, size_, bold_, italic_); - hash = HashFont(faceName_, characterSet_, size_, bold_, italic_); - fid = CreateNewFont(faceName_, characterSet_, size_, bold_, italic_); + ::SetLogFont(lf, fp.faceName, fp.characterSet, fp.size, fp.weight, fp.italic); + hash = HashFont(fp); + fid = CreateNewFont(fp); usage = 1; }
-bool FontCached::SameAs(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_) { +bool FontCached::SameAs(const FontParameters &fp) { return - lf.size == size_ && - lf.bold == bold_ && - lf.italic == italic_ && - lf.characterSet == characterSet_ && - 0 == strcmp(lf.faceName, faceName_); + lf.size == fp.size && + lf.weight == fp.weight && + lf.italic == fp.italic && + lf.characterSet == fp.characterSet && + 0 == strcmp(lf.faceName, fp.faceName); }
void FontCached::Release() { @@ -508,19 +275,19 @@ void FontCached::Release() { fid = 0; }
-FontID FontCached::FindOrCreate(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_) { +FontID FontCached::FindOrCreate(const FontParameters &fp) { FontID ret = 0; FontMutexLock(); - int hashFind = HashFont(faceName_, characterSet_, size_, bold_, italic_); + int hashFind = HashFont(fp); for (FontCached *cur = first; cur; cur = cur->next) { if ((cur->hash == hashFind) && - cur->SameAs(faceName_, characterSet_, size_, bold_, italic_)) { + cur->SameAs(fp)) { cur->usage++; ret = cur->fid; } } if (ret == 0) { - FontCached *fc = new FontCached(faceName_, characterSet_, size_, bold_, italic_); + FontCached *fc = new FontCached(fp); if (fc) { fc->next = first; first = fc; @@ -550,187 +317,27 @@ void FontCached::ReleaseId(FontID fid_) { FontMutexUnlock(); }
-#ifndef DISABLE_GDK_FONT -static GdkFont *LoadFontOrSet(const char *fontspec, int characterSet) { - if (IsDBCSCharacterSet(characterSet)) { - return gdk_fontset_load(fontspec); - } else { - return gdk_font_load(fontspec); +FontID FontCached::CreateNewFont(const FontParameters &fp) { + PangoFontDescription *pfd = pango_font_description_new(); + if (pfd) { + pango_font_description_set_family(pfd, + (fp.faceName[0] == '!') ? fp.faceName+1 : fp.faceName); + pango_font_description_set_size(pfd, pangoUnitsFromDouble(fp.size)); + pango_font_description_set_weight(pfd, static_cast<PangoWeight>(fp.weight)); + pango_font_description_set_style(pfd, fp.italic ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL); + return new FontHandle(pfd, fp.characterSet); } -} -#endif - -FontID FontCached::CreateNewFont(const char *fontName, int characterSet, - int size, bool bold, bool italic) { - if (fontName[0] == '!') { - PangoFontDescription *pfd = pango_font_description_new(); - if (pfd) { - pango_font_description_set_family(pfd, fontName+1); - pango_font_description_set_size(pfd, size * PANGO_SCALE); - pango_font_description_set_weight(pfd, bold ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL); - pango_font_description_set_style(pfd, italic ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL); - return new FontHandle(pfd, characterSet); - } - } - -#ifndef DISABLE_GDK_FONT - char fontset[1024]; - char fontspec[300]; - char foundary[50]; - char faceName[100]; - char charset[50]; - fontset[0] = '\0'; - fontspec[0] = '\0'; - foundary[0] = '\0'; - faceName[0] = '\0'; - charset[0] = '\0'; - - GdkFont *newid = 0; - // If name of the font begins with a '-', assume, that it is - // a full fontspec. - if (fontName[0] == '-') { - if (strchr(fontName, ',') || IsDBCSCharacterSet(characterSet)) { - newid = gdk_fontset_load(fontName); - } else { - newid = gdk_font_load(fontName); - } - if (!newid) { - // Font not available so substitute a reasonable code font - // iso8859 appears to only allow western characters. - newid = LoadFontOrSet("-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-*", - characterSet); - } - return new FontHandle(newid); - } - - // it's not a full fontspec, build one. - - // This supports creating a FONT_SET - // in a method that allows us to also set size, slant and - // weight for the fontset. The expected input is multiple - // partial fontspecs seperated by comma - // eg. adobe-courier-iso10646-1,*-courier-iso10646-1,*-*-*-* - if (strchr(fontName, ',')) { - // build a fontspec and use gdk_fontset_load - int remaining = sizeof(fontset); - char fontNameCopy[1024]; - strncpy(fontNameCopy, fontName, sizeof(fontNameCopy) - 1); - char *fn = fontNameCopy; - char *fp = strchr(fn, ','); - for (;;) { - const char *spec = "%s%s%s%s-*-*-*-%0d-*-*-*-*-%s"; - if (fontset[0] != '\0') { - // if this is not the first font in the list, - // append a comma seperator - spec = ",%s%s%s%s-*-*-*-%0d-*-*-*-*-%s"; - }
- if (fp) - *fp = '\0'; // nullify the comma - GenerateFontSpecStrings(fn, characterSet, - foundary, sizeof(foundary), - faceName, sizeof(faceName), - charset, sizeof(charset)); - - g_snprintf(fontspec, - sizeof(fontspec) - 1, - spec, - foundary, faceName, - bold ? "-bold" : "-medium", - italic ? "-i" : "-r", - size * 10, - charset); - - // if this is the first font in the list, and - // we are doing italic, add an oblique font - // to the list - if (italic && fontset[0] == '\0') { - strncat(fontset, fontspec, remaining - 1); - remaining -= strlen(fontset); - - g_snprintf(fontspec, - sizeof(fontspec) - 1, - ",%s%s%s-o-*-*-*-%0d-*-*-*-*-%s", - foundary, faceName, - bold ? "-bold" : "-medium", - size * 10, - charset); - } - - strncat(fontset, fontspec, remaining - 1); - remaining -= strlen(fontset); - - if (!fp) - break; - - fn = fp + 1; - fp = strchr(fn, ','); - } - - newid = gdk_fontset_load(fontset); - if (newid) - return new FontHandle(newid); - // if fontset load failed, fall through, we'll use - // the last font entry and continue to try and - // get something that matches - } - - // single fontspec support - - GenerateFontSpecStrings(fontName, characterSet, - foundary, sizeof(foundary), - faceName, sizeof(faceName), - charset, sizeof(charset)); - - g_snprintf(fontspec, - sizeof(fontspec) - 1, - "%s%s%s%s-*-*-*-%0d-*-*-*-*-%s", - foundary, faceName, - bold ? "-bold" : "-medium", - italic ? "-i" : "-r", - size * 10, - charset); - newid = LoadFontOrSet(fontspec, characterSet); - if (!newid) { - // some fonts have oblique, not italic - g_snprintf(fontspec, - sizeof(fontspec) - 1, - "%s%s%s%s-*-*-*-%0d-*-*-*-*-%s", - foundary, faceName, - bold ? "-bold" : "-medium", - italic ? "-o" : "-r", - size * 10, - charset); - newid = LoadFontOrSet(fontspec, characterSet); - } - if (!newid) { - g_snprintf(fontspec, - sizeof(fontspec) - 1, - "-*-*-*-*-*-*-*-%0d-*-*-*-*-%s", - size * 10, - charset); - newid = gdk_font_load(fontspec); - } - if (!newid) { - // Font not available so substitute a reasonable code font - // iso8859 appears to only allow western characters. - newid = LoadFontOrSet("-*-*-*-*-*-*-*-*-*-*-*-*-iso8859-*", - characterSet); - } - return new FontHandle(newid); -#else return new FontHandle(); -#endif }
Font::Font() : fid(0) {}
Font::~Font() {}
-void Font::Create(const char *faceName, int characterSet, int size, - bool bold, bool italic, int) { +void Font::Create(const FontParameters &fp) { Release(); - fid = FontCached::FindOrCreate(faceName, characterSet, size, bold, italic); + fid = FontCached::FindOrCreate(fp); }
void Font::Release() { @@ -744,17 +351,11 @@ void Font::Release() { namespace Scintilla { #endif
-// On GTK+ 2.x, SurfaceID is a GdkDrawable* and on GTK+ 3.x, it is a cairo_t* +// SurfaceID is a cairo_t* class SurfaceImpl : public Surface { encodingType et; -#ifdef USE_CAIRO cairo_t *context; cairo_surface_t *psurf; -#else - GdkDrawable *drawable; - GdkGC *gc; - GdkPixmap *ppixmap; -#endif int x; int y; bool inited; @@ -774,37 +375,36 @@ class SurfaceImpl : public Surface {
void Release(); bool Initialised(); - void PenColour(ColourAllocated fore); + void PenColour(ColourDesired fore); int LogPixelsY(); int DeviceHeightFont(int points); void MoveTo(int x_, int y_); void LineTo(int x_, int y_); - void Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back); - void RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back); - void FillRectangle(PRectangle rc, ColourAllocated back); + void Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired back); + void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back); + void FillRectangle(PRectangle rc, ColourDesired back); void FillRectangle(PRectangle rc, Surface &surfacePattern); - void RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back); - void AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill, - ColourAllocated outline, int alphaOutline, int flags); + void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back); + void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill, + ColourDesired outline, int alphaOutline, int flags); void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage); - void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back); + void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back); void Copy(PRectangle rc, Point from, Surface &surfaceSource);
- void DrawTextBase(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore); - void DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back); - void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back); - void DrawTextTransparent(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore); - void MeasureWidths(Font &font_, const char *s, int len, int *positions); - int WidthText(Font &font_, const char *s, int len); - int WidthChar(Font &font_, char ch); - int Ascent(Font &font_); - int Descent(Font &font_); - int InternalLeading(Font &font_); - int ExternalLeading(Font &font_); - int Height(Font &font_); - int AverageCharWidth(Font &font_); - - int SetPalette(Palette *pal, bool inBackGround); + void DrawTextBase(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore); + void DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back); + void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back); + void DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore); + void MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions); + XYPOSITION WidthText(Font &font_, const char *s, int len); + XYPOSITION WidthChar(Font &font_, char ch); + XYPOSITION Ascent(Font &font_); + XYPOSITION Descent(Font &font_); + XYPOSITION InternalLeading(Font &font_); + XYPOSITION ExternalLeading(Font &font_); + XYPOSITION Height(Font &font_); + XYPOSITION AverageCharWidth(Font &font_); + void SetClip(PRectangle rc); void FlushCachedState();
@@ -872,14 +472,8 @@ void SurfaceImpl::SetConverter(int characterSet_) { }
SurfaceImpl::SurfaceImpl() : et(singleByte), -#ifdef USE_CAIRO context(0), psurf(0), -#else -drawable(0), -gc(0), -ppixmap(0), -#endif x(0), y(0), inited(false), createdGC(false) , pcontext(0), layout(0), characterSet(-1) { } @@ -890,28 +484,14 @@ void SurfaceImpl::SetConverter(int characterSet_) {
void SurfaceImpl::Release() { et = singleByte; -#ifndef USE_CAIRO - drawable = 0; -#endif if (createdGC) { createdGC = false; -#ifdef USE_CAIRO cairo_destroy(context); -#else - g_object_unref(gc); -#endif } -#ifdef USE_CAIRO context = 0; if (psurf) cairo_surface_destroy(psurf); psurf = 0; -#else - gc = 0; - if (ppixmap) - g_object_unref(ppixmap); - ppixmap = 0; -#endif if (layout) g_object_unref(layout); layout = 0; @@ -933,7 +513,6 @@ bool SurfaceImpl::Initialised() { void SurfaceImpl::Init(WindowID wid) { Release(); PLATFORM_ASSERT(wid); -#ifdef USE_CAIRO #if GTK_CHECK_VERSION(3,0,0) GdkWindow *drawable_ = gtk_widget_get_window(PWidget(wid)); #else @@ -949,7 +528,6 @@ void SurfaceImpl::Init(WindowID wid) { context = cairo_create(psurf); } createdGC = true; -#endif pcontext = gtk_widget_create_pango_context(PWidget(wid)); PLATFORM_ASSERT(pcontext); layout = pango_layout_new(pcontext); @@ -961,24 +539,10 @@ void SurfaceImpl::Init(SurfaceID sid, WindowID wid) { PLATFORM_ASSERT(sid); Release(); PLATFORM_ASSERT(wid); -#ifdef USE_CAIRO -#if GTK_CHECK_VERSION(3,0,0) context = cairo_reference(reinterpret_cast<cairo_t *>(sid)); -#else - context = gdk_cairo_create(reinterpret_cast<GdkDrawable *>(sid)); -#endif -#else - drawable = reinterpret_cast<GdkDrawable *>(sid); - gc = gdk_gc_new(drawable); -#endif pcontext = gtk_widget_create_pango_context(PWidget(wid)); layout = pango_layout_new(pcontext); -#ifdef USE_CAIRO cairo_set_line_width(context, 1); -#else - // Ask for lines that do not paint the last pixel so is like Win32 - gdk_gc_set_line_attributes(gc, 0, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER); -#endif createdGC = true; inited = true; } @@ -988,27 +552,15 @@ void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_, WindowID Release(); SurfaceImpl *surfImpl = static_cast<SurfaceImpl *>(surface_); PLATFORM_ASSERT(wid); -#ifdef USE_CAIRO context = cairo_reference(surfImpl->context); -#else - PLATFORM_ASSERT(surfImpl->drawable); - gc = gdk_gc_new(surfImpl->drawable); -#endif pcontext = gtk_widget_create_pango_context(PWidget(wid)); PLATFORM_ASSERT(pcontext); layout = pango_layout_new(pcontext); PLATFORM_ASSERT(layout); -#ifdef USE_CAIRO if (height > 0 && width > 0) psurf = CreateSimilarSurface( WindowFromWidget(PWidget(wid)), CAIRO_CONTENT_COLOR_ALPHA, width, height); -#else - if (height > 0 && width > 0) - ppixmap = gdk_pixmap_new(surfImpl->drawable, width, height, -1); - drawable = ppixmap; -#endif -#ifdef USE_CAIRO cairo_destroy(context); context = cairo_create(psurf); cairo_rectangle(context, 0, 0, width, height); @@ -1016,19 +568,12 @@ void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_, WindowID cairo_fill(context); // This produces sharp drawing more similar to GDK: //cairo_set_antialias(context, CAIRO_ANTIALIAS_NONE); -#endif -#ifdef USE_CAIRO cairo_set_line_width(context, 1); -#else - // Ask for lines that do not paint the last pixel so is like Win32 - gdk_gc_set_line_attributes(gc, 0, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER); -#endif createdGC = true; inited = true; }
-void SurfaceImpl::PenColour(ColourAllocated fore) { -#ifdef USE_CAIRO +void SurfaceImpl::PenColour(ColourDesired fore) { if (context) { ColourDesired cdFore(fore.AsLong()); cairo_set_source_rgb(context, @@ -1036,13 +581,6 @@ void SurfaceImpl::PenColour(ColourAllocated fore) { cdFore.GetGreen() / 255.0, cdFore.GetBlue() / 255.0); } -#else - if (gc) { - GdkColor co; - co.pixel = fore.AsLong(); - gdk_gc_set_foreground(gc, &co); - } -#endif }
int SurfaceImpl::LogPixelsY() { @@ -1059,7 +597,6 @@ void SurfaceImpl::MoveTo(int x_, int y_) { y = y_; }
-#ifdef USE_CAIRO static int Delta(int difference) { if (difference < 0) return -1; @@ -1068,10 +605,8 @@ static int Delta(int difference) { else return 0; } -#endif
void SurfaceImpl::LineTo(int x_, int y_) { -#ifdef USE_CAIRO // cairo_line_to draws the end position, unlike Win32 or GDK with GDK_CAP_NOT_LAST. // For simple cases, move back one pixel from end. if (context) { @@ -1100,20 +635,12 @@ void SurfaceImpl::LineTo(int x_, int y_) { } cairo_stroke(context); } -#else - if (drawable && gc) { - gdk_draw_line(drawable, gc, - x, y, - x_, y_); - } -#endif x = x_; y = y_; }
-void SurfaceImpl::Polygon(Point *pts, int npts, ColourAllocated fore, - ColourAllocated back) { -#ifdef USE_CAIRO +void SurfaceImpl::Polygon(Point *pts, int npts, ColourDesired fore, + ColourDesired back) { PenColour(back); cairo_move_to(context, pts[0].x + 0.5, pts[0].y + 0.5); for (int i = 1;i < npts;i++) { @@ -1123,73 +650,33 @@ void SurfaceImpl::Polygon(Point *pts, int npts, ColourAllocated fore, cairo_fill_preserve(context); PenColour(fore); cairo_stroke(context); -#else - GdkPoint gpts[20]; - if (npts < static_cast<int>((sizeof(gpts) / sizeof(gpts[0])))) { - for (int i = 0;i < npts;i++) { - gpts[i].x = pts[i].x; - gpts[i].y = pts[i].y; - } - PenColour(back); - gdk_draw_polygon(drawable, gc, 1, gpts, npts); - PenColour(fore); - gdk_draw_polygon(drawable, gc, 0, gpts, npts); - } -#endif }
-void SurfaceImpl::RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back) { -#ifdef USE_CAIRO +void SurfaceImpl::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) { if (context) { -#else - if (gc && drawable) { -#endif -#ifdef USE_CAIRO cairo_rectangle(context, rc.left + 0.5, rc.top + 0.5, rc.right - rc.left - 1, rc.bottom - rc.top - 1); PenColour(back); cairo_fill_preserve(context); PenColour(fore); cairo_stroke(context); -#else - PenColour(back); - gdk_draw_rectangle(drawable, gc, 1, - rc.left + 1, rc.top + 1, - rc.right - rc.left - 2, rc.bottom - rc.top - 2); - PenColour(fore); - // The subtraction of 1 off the width and height here shouldn't be needed but - // otherwise a different rectangle is drawn than would be done if the fill parameter == 1 - gdk_draw_rectangle(drawable, gc, 0, - rc.left, rc.top, - rc.right - rc.left - 1, rc.bottom - rc.top - 1); -#endif } }
-void SurfaceImpl::FillRectangle(PRectangle rc, ColourAllocated back) { +void SurfaceImpl::FillRectangle(PRectangle rc, ColourDesired back) { PenColour(back); -#ifdef USE_CAIRO if (context && (rc.left < maxCoordinate)) { // Protect against out of range + rc.left = lround(rc.left); + rc.right = lround(rc.right); cairo_rectangle(context, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top); cairo_fill(context); } -#else - if (drawable && (rc.left < maxCoordinate)) { // Protect against out of range - gdk_draw_rectangle(drawable, gc, 1, - rc.left, rc.top, - rc.right - rc.left, rc.bottom - rc.top); - } -#endif }
void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) { SurfaceImpl &surfi = static_cast<SurfaceImpl &>(surfacePattern); -#ifdef USE_CAIRO bool canDraw = surfi.psurf; -#else - bool canDraw = surfi.drawable; -#endif if (canDraw) { // Tile pattern over rectangle // Currently assumes 8x8 pattern @@ -1199,28 +686,19 @@ void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) { int widthx = (xTile + widthPat > rc.right) ? rc.right - xTile : widthPat; for (int yTile = rc.top; yTile < rc.bottom; yTile += heightPat) { int heighty = (yTile + heightPat > rc.bottom) ? rc.bottom - yTile : heightPat; -#ifdef USE_CAIRO cairo_set_source_surface(context, surfi.psurf, xTile, yTile); cairo_rectangle(context, xTile, yTile, widthx, heighty); cairo_fill(context); -#else - gdk_draw_drawable(drawable, - gc, - static_cast<SurfaceImpl &>(surfacePattern).drawable, - 0, 0, - xTile, yTile, - widthx, heighty); -#endif } } } else { // Something is wrong so try to show anyway // Shows up black because colour not allocated - FillRectangle(rc, ColourAllocated(0)); + FillRectangle(rc, ColourDesired(0)); } }
-void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back) { +void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back) { if (((rc.right - rc.left) > 4) && ((rc.bottom - rc.top) > 4)) { // Approximate a round rect with some cut off corners Point pts[] = { @@ -1239,8 +717,6 @@ void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAl } }
-#ifdef USE_CAIRO - static void PathRoundRectangle(cairo_t *context, double left, double top, double width, double height, int radius) { double degrees = M_PI / 180.0;
@@ -1257,45 +733,8 @@ static void PathRoundRectangle(cairo_t *context, double left, double top, double cairo_close_path(context); }
-#else - -// Plot a point into a guint32 buffer symetrically to all 4 qudrants -static void AllFour(guint32 *pixels, int stride, int width, int height, int x, int y, guint32 val) { - pixels[y*stride+x] = val; - pixels[y*stride+width-1-x] = val; - pixels[(height-1-y)*stride+x] = val; - pixels[(height-1-y)*stride+width-1-x] = val; -} - -static guint32 u32FromRGBA(guint8 r, guint8 g, guint8 b, guint8 a) { - union { - guint8 pixVal[4]; - guint32 val; - } converter; - converter.pixVal[0] = r; - converter.pixVal[1] = g; - converter.pixVal[2] = b; - converter.pixVal[3] = a; - return converter.val; -} - -static unsigned int GetRValue(unsigned int co) { - return (co >> 16) & 0xff; -} - -static unsigned int GetGValue(unsigned int co) { - return (co >> 8) & 0xff; -} - -static unsigned int GetBValue(unsigned int co) { - return co & 0xff; -} - -#endif - -void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill, - ColourAllocated outline, int alphaOutline, int flags) { -#ifdef USE_CAIRO +void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill, + ColourDesired outline, int alphaOutline, int flags) { if (context && rc.Width() > 0) { ColourDesired cdFill(fill.AsLong()); cairo_set_source_rgba(context, @@ -1321,47 +760,6 @@ void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated cairo_rectangle(context, rc.left + 0.5, rc.top + 0.5, rc.right - rc.left - 1, rc.bottom - rc.top - 1); cairo_stroke(context); } -#else - if (gc && drawable && rc.Width() > 0) { - int width = rc.Width(); - int height = rc.Height(); - // Ensure not distorted too much by corners when small - cornerSize = Platform::Minimum(cornerSize, (Platform::Minimum(width, height) / 2) - 2); - // Make a 32 bit deep pixbuf with alpha - GdkPixbuf *pixalpha = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height); - - guint32 valEmpty = u32FromRGBA(0,0,0,0); - guint32 valFill = u32FromRGBA(GetRValue(fill.AsLong()), - GetGValue(fill.AsLong()), GetBValue(fill.AsLong()), alphaFill); - guint32 valOutline = u32FromRGBA(GetRValue(outline.AsLong()), - GetGValue(outline.AsLong()), GetBValue(outline.AsLong()), alphaOutline); - guint32 *pixels = reinterpret_cast<guint32 *>(gdk_pixbuf_get_pixels(pixalpha)); - int stride = gdk_pixbuf_get_rowstride(pixalpha) / 4; - for (int yr=0; yr<height; yr++) { - for (int xr=0; xr<width; xr++) { - if ((xr==0) || (xr==width-1) || (yr == 0) || (yr == height-1)) { - pixels[yr*stride+xr] = valOutline; - } else { - pixels[yr*stride+xr] = valFill; - } - } - } - for (int c=0;c<cornerSize; c++) { - for (int xr=0;xr<c+1; xr++) { - AllFour(pixels, stride, width, height, xr, c-xr, valEmpty); - } - } - for (int xr=1;xr<cornerSize; xr++) { - AllFour(pixels, stride, width, height, xr, cornerSize-xr, valOutline); - } - - // Draw with alpha - gdk_draw_pixbuf(drawable, gc, pixalpha, - 0,0, rc.left,rc.top, width,height, GDK_RGB_DITHER_NORMAL, 0, 0); - - g_object_unref(pixalpha); - } -#endif }
void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) { @@ -1372,8 +770,11 @@ void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsi rc.top += (rc.Height() - height) / 2; rc.bottom = rc.top + height;
-#ifdef USE_CAIRO +#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1,6,0) int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width); +#else + int stride = width * 4; +#endif int ucs = stride * height; std::vector<unsigned char> image(ucs); for (int y=0; y<height; y++) { @@ -1393,81 +794,28 @@ void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsi cairo_fill(context);
cairo_surface_destroy(psurf); -#else - GdkPixbuf *pixbuf = gdk_pixbuf_new_from_data(pixelsImage, - GDK_COLORSPACE_RGB, - TRUE, - 8, - width, - height, - width * 4, - NULL, - NULL); - gdk_draw_pixbuf(drawable, gc, pixbuf, - 0,0, rc.left,rc.top, width,height, GDK_RGB_DITHER_NORMAL, 0, 0); - g_object_unref(pixbuf); -#endif }
-void SurfaceImpl::Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back) { +void SurfaceImpl::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) { PenColour(back); -#ifdef USE_CAIRO cairo_arc(context, (rc.left + rc.right) / 2 + 0.5, (rc.top + rc.bottom) / 2 + 0.5, Platform::Minimum(rc.Width(), rc.Height()) / 2, 0, 2*M_PI); cairo_fill_preserve(context); PenColour(fore); cairo_stroke(context); -#else - gdk_draw_arc(drawable, gc, 1, - rc.left + 1, rc.top + 1, - rc.right - rc.left - 2, rc.bottom - rc.top - 2, - 0, 32767); - - // The subtraction of 1 here is similar to the case for RectangleDraw - PenColour(fore); - gdk_draw_arc(drawable, gc, 0, - rc.left, rc.top, - rc.right - rc.left - 1, rc.bottom - rc.top - 1, - 0, 32767); -#endif }
void SurfaceImpl::Copy(PRectangle rc, Point from, Surface &surfaceSource) { SurfaceImpl &surfi = static_cast<SurfaceImpl &>(surfaceSource); -#ifdef USE_CAIRO bool canDraw = surfi.psurf; -#else - bool canDraw = surfi.drawable; -#endif if (canDraw) { -#ifdef USE_CAIRO cairo_set_source_surface(context, surfi.psurf, rc.left - from.x, rc.top - from.y); cairo_rectangle(context, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top); cairo_fill(context); -#else - gdk_draw_drawable(drawable, - gc, - static_cast<SurfaceImpl &>(surfaceSource).drawable, - from.x, from.y, - rc.left, rc.top, - rc.right - rc.left, rc.bottom - rc.top); -#endif } }
-#ifndef DISABLE_GDK_FONT -static size_t UTF8Len(char ch) { - unsigned char uch = static_cast<unsigned char>(ch); - if (uch < 0x80) - return 1; - else if (uch < (0x80 + 0x40 + 0x20)) - return 2; - else - return 3; -} -#endif - char *UTF8FromLatin1(const char *s, int &len) { char *utfForm = new char[len*2+1]; size_t lenU = 0; @@ -1520,49 +868,6 @@ static size_t MultiByteLenFromIconv(const Converter &conv, const char *s, size_t return 1; }
-#ifndef DISABLE_GDK_FONT -static char *UTF8FromGdkWChar(GdkWChar *wctext, int wclen) { - char *utfForm = new char[wclen*3+1]; // Maximum of 3 UTF-8 bytes per character - size_t lenU = 0; - for (int i = 0; i < wclen && wctext[i]; i++) { - unsigned int uch = wctext[i]; - if (uch < 0x80) { - utfForm[lenU++] = static_cast<char>(uch); - } else if (uch < 0x800) { - utfForm[lenU++] = static_cast<char>(0xC0 | (uch >> 6)); - utfForm[lenU++] = static_cast<char>(0x80 | (uch & 0x3f)); - } else { - utfForm[lenU++] = static_cast<char>(0xE0 | (uch >> 12)); - utfForm[lenU++] = static_cast<char>(0x80 | ((uch >> 6) & 0x3f)); - utfForm[lenU++] = static_cast<char>(0x80 | (uch & 0x3f)); - } - } - utfForm[lenU] = '\0'; - return utfForm; -} -#endif - -static char *UTF8FromDBCS(const char *s, int &len) { -#ifndef DISABLE_GDK_FONT - GdkWChar *wctext = new GdkWChar[len + 1]; - GdkWChar *wcp = wctext; - int wclen = gdk_mbstowcs(wcp, s, len); - if (wclen < 1) { - // In the annoying case when non-locale chars in the line. - // e.g. latin1 chars in Japanese locale. - delete []wctext; - return 0; - } - - char *utfForm = UTF8FromGdkWChar(wctext, wclen); - delete []wctext; - len = strlen(utfForm); - return utfForm; -#else - return 0; -#endif -} - static size_t UTF8CharLength(const char *s) { const unsigned char *us = reinterpret_cast<const unsigned char *>(s); unsigned char ch = *us; @@ -1575,19 +880,11 @@ static size_t UTF8CharLength(const char *s) { } }
-// On GTK+, wchar_t is 4 bytes - -const int maxLengthTextRun = 10000; - -void SurfaceImpl::DrawTextBase(PRectangle rc, Font &font_, int ybase, const char *s, int len, - ColourAllocated fore) { +void SurfaceImpl::DrawTextBase(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, + ColourDesired fore) { PenColour(fore); -#ifdef USE_CAIRO if (context) { -#else - if (gc && drawable) { -#endif - int xText = rc.left; + XYPOSITION xText = rc.left; if (PFont(font_)->pfd) { char *utfForm = 0; if (et == UTF8) { @@ -1597,102 +894,40 @@ void SurfaceImpl::DrawTextBase(PRectangle rc, Font &font_, int ybase, const char SetConverter(PFont(font_)->characterSet); utfForm = UTF8FromIconv(conv, s, len); } - if (!utfForm) { // iconv failed so try DBCS if DBCS mode - if (et == dbcs) { - // Convert to utf8 - utfForm = UTF8FromDBCS(s, len); - } - } - if (!utfForm) { // iconv and DBCS failed so treat as Latin1 + if (!utfForm) { // iconv failed so treat as Latin1 utfForm = UTF8FromLatin1(s, len); } pango_layout_set_text(layout, utfForm, len); } pango_layout_set_font_description(layout, PFont(font_)->pfd); -#ifdef USE_CAIRO pango_cairo_update_layout(context, layout); -#endif #ifdef PANGO_VERSION PangoLayoutLine *pll = pango_layout_get_line_readonly(layout,0); #else PangoLayoutLine *pll = pango_layout_get_line(layout,0); #endif -#ifdef USE_CAIRO cairo_move_to(context, xText, ybase); pango_cairo_show_layout_line(context, pll); -#else - gdk_draw_layout_line(drawable, gc, xText, ybase, pll); -#endif delete []utfForm; - return; } -#ifndef DISABLE_GDK_FONT - // Draw text as a series of segments to avoid limitations in X servers - const int segmentLength = 1000; - bool draw8bit = true; - if (et != singleByte) { - GdkWChar wctext[maxLengthTextRun]; - if (len >= maxLengthTextRun) - len = maxLengthTextRun-1; - int wclen; - if (et == UTF8) { - wclen = UTF16FromUTF8(s, len, - static_cast<wchar_t *>(static_cast<void *>(wctext)), maxLengthTextRun - 1); - } else { // dbcs, so convert using current locale - char sMeasure[maxLengthTextRun]; - memcpy(sMeasure, s, len); - sMeasure[len] = '\0'; - wclen = gdk_mbstowcs( - wctext, sMeasure, maxLengthTextRun - 1); - } - if (wclen > 0) { - draw8bit = false; - wctext[wclen] = L'\0'; - GdkWChar *wcp = wctext; - while ((wclen > 0) && (xText < maxCoordinate)) { - int lenDraw = Platform::Minimum(wclen, segmentLength); - gdk_draw_text_wc(drawable, PFont(font_)->pfont, gc, - xText, ybase, wcp, lenDraw); - wclen -= lenDraw; - if (wclen > 0) { // Avoid next calculation if possible as may be expensive - xText += gdk_text_width_wc(PFont(font_)->pfont, - wcp, lenDraw); - } - wcp += lenDraw; - } - } - } - if (draw8bit) { - while ((len > 0) && (xText < maxCoordinate)) { - int lenDraw = Platform::Minimum(len, segmentLength); - gdk_draw_text(drawable, PFont(font_)->pfont, gc, - xText, ybase, s, lenDraw); - len -= lenDraw; - if (len > 0) { // Avoid next calculation if possible as may be expensive - xText += gdk_text_width(PFont(font_)->pfont, s, lenDraw); - } - s += lenDraw; - } - } -#endif } }
-void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, - ColourAllocated fore, ColourAllocated back) { +void SurfaceImpl::DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, + ColourDesired fore, ColourDesired back) { FillRectangle(rc, back); DrawTextBase(rc, font_, ybase, s, len, fore); }
// On GTK+, exactly same as DrawTextNoClip -void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, - ColourAllocated fore, ColourAllocated back) { +void SurfaceImpl::DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, + ColourDesired fore, ColourDesired back) { FillRectangle(rc, back); DrawTextBase(rc, font_, ybase, s, len, fore); }
-void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font_, int ybase, const char *s, int len, - ColourAllocated fore) { +void SurfaceImpl::DrawTextTransparent(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, + ColourDesired fore) { // Avoid drawing spaces in transparent mode for (int i=0;i<len;i++) { if (s[i] != ' ') { @@ -1708,9 +943,9 @@ class ClusterIterator { int lenPositions; public: bool finished; - int positionStart; - int position; - int distance; + XYPOSITION positionStart; + XYPOSITION position; + XYPOSITION distance; int curIndex; ClusterIterator(PangoLayout *layout, int len) : lenPositions(len), finished(false), positionStart(0), position(0), distance(0), curIndex(0) { @@ -1725,18 +960,18 @@ class ClusterIterator { positionStart = position; if (pango_layout_iter_next_cluster(iter)) { pango_layout_iter_get_cluster_extents(iter, NULL, &pos); - position = PANGO_PIXELS(pos.x); + position = doubleFromPangoUnits(pos.x); curIndex = pango_layout_iter_get_index(iter); } else { finished = true; - position = PANGO_PIXELS(pos.x + pos.width); + position = doubleFromPangoUnits(pos.x + pos.width); curIndex = lenPositions; } distance = position - positionStart; } };
-void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positions) { +void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, XYPOSITION *positions) { if (font_.GetID()) { const int lenPositions = len; if (PFont(font_)->pfd) { @@ -1831,59 +1066,6 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi } return; } -#ifndef DISABLE_GDK_FONT - int totalWidth = 0; - GdkFont *gf = PFont(font_)->pfont; - bool measure8bit = true; - if (et != singleByte) { - GdkWChar wctext[maxLengthTextRun]; - if (len >= maxLengthTextRun) - len = maxLengthTextRun-1; - int wclen; - if (et == UTF8) { - wclen = UTF16FromUTF8(s, len, - static_cast<wchar_t *>(static_cast<void *>(wctext)), maxLengthTextRun - 1); - } else { // dbcsMode, so convert using current locale - char sDraw[maxLengthTextRun]; - memcpy(sDraw, s, len); - sDraw[len] = '\0'; - wclen = gdk_mbstowcs( - wctext, sDraw, maxLengthTextRun - 1); - } - if (wclen > 0) { - measure8bit = false; - wctext[wclen] = L'\0'; - // Map widths back to utf-8 or DBCS input string - int i = 0; - for (int iU = 0; iU < wclen; iU++) { - int width = gdk_char_width_wc(gf, wctext[iU]); - totalWidth += width; - int lenChar; - if (et == UTF8) { - lenChar = UTF8Len(s[i]); - } else { - lenChar = mblen(s+i, MB_CUR_MAX); - if (lenChar < 0) - lenChar = 1; - } - while (lenChar--) { - positions[i++] = totalWidth; - } - } - while (i < len) { // In case of problems with lengths - positions[i++] = totalWidth; - } - } - } - if (measure8bit) { - // Either Latin1 or conversion failed so treat as Latin1. - for (int i = 0; i < len; i++) { - int width = gdk_char_width(gf, s[i]); - totalWidth += width; - positions[i] = totalWidth; - } - } -#endif } else { // No font so return an ascending range of values for (int i = 0; i < len; i++) { @@ -1892,7 +1074,7 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi } }
-int SurfaceImpl::WidthText(Font &font_, const char *s, int len) { +XYPOSITION SurfaceImpl::WidthText(Font &font_, const char *s, int len) { if (font_.GetID()) { if (PFont(font_)->pfd) { char *utfForm = 0; @@ -1901,15 +1083,11 @@ int SurfaceImpl::WidthText(Font &font_, const char *s, int len) { if (et == UTF8) { pango_layout_set_text(layout, s, len); } else { - if (et == dbcs) { - // Convert to utf8 - utfForm = UTF8FromDBCS(s, len); - } - if (!utfForm) { // DBCS failed so treat as iconv + if (!utfForm) { // use iconv SetConverter(PFont(font_)->characterSet); utfForm = UTF8FromIconv(conv, s, len); } - if (!utfForm) { // g_locale_to_utf8 failed so treat as Latin1 + if (!utfForm) { // iconv failed so treat as Latin1 utfForm = UTF8FromLatin1(s, len); } pango_layout_set_text(layout, utfForm, len); @@ -1921,157 +1099,79 @@ int SurfaceImpl::WidthText(Font &font_, const char *s, int len) { #endif pango_layout_line_get_extents(pangoLine, NULL, &pos); delete []utfForm; - return PANGO_PIXELS(pos.width); - } -#ifndef DISABLE_GDK_FONT - if (et == UTF8) { - GdkWChar wctext[maxLengthTextRun]; - size_t wclen = UTF16FromUTF8(s, len, static_cast<wchar_t *>(static_cast<void *>(wctext)), - sizeof(wctext) / sizeof(GdkWChar) - 1); - wctext[wclen] = L'\0'; - return gdk_text_width_wc(PFont(font_)->pfont, wctext, wclen); - } else { - return gdk_text_width(PFont(font_)->pfont, s, len); + return doubleFromPangoUnits(pos.width); } -#else return 1; -#endif } else { return 1; } }
-int SurfaceImpl::WidthChar(Font &font_, char ch) { +XYPOSITION SurfaceImpl::WidthChar(Font &font_, char ch) { if (font_.GetID()) { if (PFont(font_)->pfd) { return WidthText(font_, &ch, 1); } -#ifndef DISABLE_GDK_FONT - return gdk_char_width(PFont(font_)->pfont, ch); -#else return 1; -#endif } else { return 1; } }
-// Three possible strategies for determining ascent and descent of font: -// 1) Call gdk_string_extents with string containing all letters, numbers and punctuation. -// 2) Use the ascent and descent fields of GdkFont. -// 3) Call gdk_string_extents with string as 1 but also including accented capitals. -// Smallest values given by 1 and largest by 3 with 2 in between. -// Techniques 1 and 2 sometimes chop off extreme portions of ascenders and -// descenders but are mostly OK except for accented characters like Å which are -// rarely used in code. +// Ascent and descent determined by Pango font metrics.
-// This string contains a good range of characters to test for size. -//const char largeSizeString[] = "ÂÃÅÄ `~!@#$%^&*()-_=+\|[]{};:"'<,>.?/1234567890" -// "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; -#ifndef FAST_WAY -const char sizeString[] = "`~!@#$%^&*()-_=+\|[]{};:"'<,>.?/1234567890" - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; -#endif - -int SurfaceImpl::Ascent(Font &font_) { +XYPOSITION SurfaceImpl::Ascent(Font &font_) { if (!(font_.GetID())) return 1; -#ifdef FAST_WAY FontMutexLock(); int ascent = PFont(font_)->ascent; if ((ascent == 0) && (PFont(font_)->pfd)) { PangoFontMetrics *metrics = pango_context_get_metrics(pcontext, PFont(font_)->pfd, pango_context_get_language(pcontext)); PFont(font_)->ascent = - PANGO_PIXELS(pango_font_metrics_get_ascent(metrics)); + doubleFromPangoUnits(pango_font_metrics_get_ascent(metrics)); pango_font_metrics_unref(metrics); ascent = PFont(font_)->ascent; } -#ifndef DISABLE_GDK_FONT - if ((ascent == 0) && (PFont(font_)->pfont)) { - ascent = PFont(font_)->pfont->ascent; - } -#endif if (ascent == 0) { ascent = 1; } FontMutexUnlock(); return ascent; -#else - - gint lbearing; - gint rbearing; - gint width; - gint ascent; - gint descent; - - gdk_string_extents(PFont(font_)->pfont, sizeString, - &lbearing, &rbearing, &width, &ascent, &descent); - return ascent; -#endif }
-int SurfaceImpl::Descent(Font &font_) { +XYPOSITION SurfaceImpl::Descent(Font &font_) { if (!(font_.GetID())) return 1; -#ifdef FAST_WAY - if (PFont(font_)->pfd) { PangoFontMetrics *metrics = pango_context_get_metrics(pcontext, PFont(font_)->pfd, pango_context_get_language(pcontext)); - int descent = PANGO_PIXELS(pango_font_metrics_get_descent(metrics)); + int descent = doubleFromPangoUnits(pango_font_metrics_get_descent(metrics)); pango_font_metrics_unref(metrics); return descent; } -#ifndef DISABLE_GDK_FONT - return PFont(font_)->pfont->descent; -#else return 0; -#endif -#else - - gint lbearing; - gint rbearing; - gint width; - gint ascent; - gint descent; - - gdk_string_extents(PFont(font_)->pfont, sizeString, - &lbearing, &rbearing, &width, &ascent, &descent); - return descent; -#endif }
-int SurfaceImpl::InternalLeading(Font &) { +XYPOSITION SurfaceImpl::InternalLeading(Font &) { return 0; }
-int SurfaceImpl::ExternalLeading(Font &) { +XYPOSITION SurfaceImpl::ExternalLeading(Font &) { return 0; }
-int SurfaceImpl::Height(Font &font_) { +XYPOSITION SurfaceImpl::Height(Font &font_) { return Ascent(font_) + Descent(font_); }
-int SurfaceImpl::AverageCharWidth(Font &font_) { +XYPOSITION SurfaceImpl::AverageCharWidth(Font &font_) { return WidthChar(font_, 'n'); }
-int SurfaceImpl::SetPalette(Palette *, bool) { - // Handled in palette allocation for GTK so this does nothing - return 0; -} - void SurfaceImpl::SetClip(PRectangle rc) { -#ifdef USE_CAIRO cairo_rectangle(context, rc.left, rc.top, rc.right, rc.bottom); cairo_clip(context); -#else - GdkRectangle area = {rc.left, rc.top, - rc.right - rc.left, rc.bottom - rc.top}; - gdk_gc_set_clip_rectangle(gc, &area); -#endif }
void SurfaceImpl::FlushCachedState() {} @@ -2086,8 +1186,8 @@ void SurfaceImpl::SetDBCSMode(int codePage) { et = dbcs; }
-Surface *Surface::Allocate() { - return new SurfaceImpl; +Surface *Surface::Allocate(int) { + return new SurfaceImpl(); }
Window::~Window() {} @@ -2240,25 +1340,16 @@ PRectangle Window::GetMonitorRect(Point pt) {
gdk_window_get_origin(WindowFromWidget(PWidget(wid)), &x_offset, &y_offset);
-#if GTK_CHECK_VERSION(2,2,0) - // GTK+ 2.2+ - { - GdkScreen* screen; - gint monitor_num; - GdkRectangle rect; + GdkScreen* screen; + gint monitor_num; + GdkRectangle rect;
- screen = gtk_widget_get_screen(PWidget(wid)); - monitor_num = gdk_screen_get_monitor_at_point(screen, pt.x + x_offset, pt.y + y_offset); - gdk_screen_get_monitor_geometry(screen, monitor_num, &rect); - rect.x -= x_offset; - rect.y -= y_offset; - return PRectangle(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height); - } -#else - pt = pt; - return PRectangle(-x_offset, -y_offset, (-x_offset) + gdk_screen_width(), - (-y_offset) + gdk_screen_height()); -#endif + screen = gtk_widget_get_screen(PWidget(wid)); + monitor_num = gdk_screen_get_monitor_at_point(screen, pt.x + x_offset, pt.y + y_offset); + gdk_screen_get_monitor_geometry(screen, monitor_num, &rect); + rect.x -= x_offset; + rect.y -= y_offset; + return PRectangle(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height); }
typedef std::map<int, RGBAImage*> ImageMap; @@ -2269,7 +1360,7 @@ struct ListImage { };
static void list_image_free(gpointer, gpointer value, gpointer) { - ListImage *list_image = (ListImage *) value; + ListImage *list_image = static_cast<ListImage *>(value); if (list_image->pixbuf) g_object_unref(list_image->pixbuf); g_free(list_image); @@ -2311,7 +1402,7 @@ class ListBoxX : public ListBox { } } virtual void SetFont(Font &font); - virtual void Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_); + virtual void Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_, int technology_); virtual void SetAverageCharWidth(int width); virtual void SetVisibleRows(int rows); virtual int GetVisibleRows() const; @@ -2400,7 +1491,7 @@ static void StyleSet(GtkWidget *w, GtkStyle*, void*) { #endif }
-void ListBoxX::Create(Window &, int, Point, int, bool) { +void ListBoxX::Create(Window &, int, Point, int, bool, int) { wid = gtk_window_new(GTK_WINDOW_POPUP);
GtkWidget *frame = gtk_frame_new(NULL); @@ -2491,6 +1582,11 @@ PRectangle ListBoxX::GetDesiredRect() { rows = desiredVisibleRows;
GtkRequisition req; +#if GTK_CHECK_VERSION(3,0,0) + // This, apparently unnecessary call, ensures gtk_tree_view_column_cell_get_size + // returns reasonable values. + gtk_widget_get_preferred_size(GTK_WIDGET(scroller), NULL, &req); +#endif int height;
// First calculate height of the clist for our desired visible @@ -2524,7 +1620,7 @@ PRectangle ListBoxX::GetDesiredRect() { gtk_widget_size_request(GTK_WIDGET(scroller), &req); #endif rc.right = req.width; - rc.bottom = req.height; + rc.bottom = Platform::Maximum(height, req.height);
gtk_widget_set_size_request(GTK_WIDGET(list), -1, -1); int width = maxItemCharacters; @@ -2573,8 +1669,8 @@ static void init_pixmap(ListImage *list_image) { void ListBoxX::Append(char *s, int type) { ListImage *list_image = NULL; if ((type >= 0) && pixhash) { - list_image = (ListImage *) g_hash_table_lookup((GHashTable *) pixhash - , (gconstpointer) GINT_TO_POINTER(type)); + list_image = static_cast<ListImage *>(g_hash_table_lookup((GHashTable *) pixhash + , (gconstpointer) GINT_TO_POINTER(type))); } GtkTreeIter iter; GtkListStore *store = @@ -2739,8 +1835,8 @@ void ListBoxX::RegisterRGBA(int type, RGBAImage *image) { if (!pixhash) { pixhash = g_hash_table_new(g_direct_hash, g_direct_equal); } - ListImage *list_image = (ListImage *) g_hash_table_lookup((GHashTable *) pixhash, - (gconstpointer) GINT_TO_POINTER(type)); + ListImage *list_image = static_cast<ListImage *>(g_hash_table_lookup((GHashTable *) pixhash, + (gconstpointer) GINT_TO_POINTER(type))); if (list_image) { // Drop icon already registered if (list_image->pixbuf) @@ -2842,7 +1938,7 @@ void Menu::Show(Point pt, Window &) { pt.y = screenHeight - requisition.height; } gtk_menu_popup(widget, NULL, NULL, MenuPositionFunc, - reinterpret_cast<void *>((pt.y << 16) | pt.x), 0, + reinterpret_cast<void *>((static_cast<int>(pt.y) << 16) | static_cast<int>(pt.x)), 0, gtk_get_current_event_time()); }
Modified: scintilla/gtk/ScintillaGTK.cxx 142 files changed, 48 insertions(+), 94 deletions(-) =================================================================== @@ -64,6 +64,11 @@
#include "Converter.h"
+#if defined(__clang__) +// Clang 3.0 incorrectly displays sentinel warnings. Fixed by clang 3.1. +#pragma GCC diagnostic ignored "-Wsentinel" +#endif + #if GTK_CHECK_VERSION(2,20,0) #define IS_WIDGET_REALIZED(w) (gtk_widget_get_realized(GTK_WIDGET(w))) #define IS_WIDGET_MAPPED(w) (gtk_widget_get_mapped(GTK_WIDGET(w))) @@ -74,8 +79,6 @@ #define IS_WIDGET_VISIBLE(w) (GTK_WIDGET_VISIBLE(w)) #endif
-#define USE_CAIRO 1 - static GdkWindow *WindowFromWidget(GtkWidget *w) { #if GTK_CHECK_VERSION(3,0,0) return gtk_widget_get_window(w); @@ -100,10 +103,6 @@ static GdkWindow *PWindow(const Window &w) { #pragma warning(disable: 4505) #endif
-#if GTK_CHECK_VERSION(2,6,0) -#define USE_GTK_CLIPBOARD -#endif - #define OBJECT_CLASS GObjectClass
#ifdef SCI_NAMESPACE @@ -122,11 +121,6 @@ class ScintillaGTK : public ScintillaBase { int scrollBarWidth; int scrollBarHeight;
- // Because clipboard access is asynchronous, copyText is created by Copy -#ifndef USE_GTK_CLIPBOARD - SelectionText copyText; -#endif - SelectionText primary;
GdkEventButton evbtn; @@ -218,11 +212,9 @@ class ScintillaGTK : public ScintillaBase { void ReceivedSelection(GtkSelectionData *selection_data); void ReceivedDrop(GtkSelectionData *selection_data); static void GetSelection(GtkSelectionData *selection_data, guint info, SelectionText *selected); -#ifdef USE_GTK_CLIPBOARD void StoreOnClipboard(SelectionText *clipText); static void ClipboardGetSelection(GtkClipboard* clip, GtkSelectionData *selection_data, guint info, void *data); static void ClipboardClearSelection(GtkClipboard* clip, void *data); -#endif
void UnclaimSelection(GdkEventSelection *selection_event); void Resize(int width, int height); @@ -505,10 +497,6 @@ void ScintillaGTK::RealizeThis(GtkWidget *widget) {
gtk_selection_add_targets(widget, GDK_SELECTION_PRIMARY, clipboardCopyTargets, nClipboardCopyTargets); -#ifndef USE_GTK_CLIPBOARD - gtk_selection_add_targets(widget, atomClipboard, - clipboardPasteTargets, nClipboardPasteTargets); -#endif }
void ScintillaGTK::Realize(GtkWidget *widget) { @@ -519,9 +507,6 @@ void ScintillaGTK::Realize(GtkWidget *widget) { void ScintillaGTK::UnRealizeThis(GtkWidget *widget) { try { gtk_selection_clear_targets(widget, GDK_SELECTION_PRIMARY); -#ifndef USE_GTK_CLIPBOARD - gtk_selection_clear_targets(widget, atomClipboard); -#endif
if (IS_WIDGET_MAPPED(widget)) { gtk_widget_unmap(widget); @@ -594,7 +579,7 @@ void ScintillaGTK::UnMapThis() { #else GTK_WIDGET_UNSET_FLAGS(PWidget(wMain), GTK_MAPPED); #endif - DropGraphics(); + DropGraphics(false); gdk_window_hide(PWindow(wMain)); gtk_widget_unmap(PWidget(wText)); gtk_widget_unmap(PWidget(scrollbarh)); @@ -739,6 +724,7 @@ void ScintillaGTK::Initialise() { #endif gtk_widget_set_events(PWidget(wMain), GDK_EXPOSURE_MASK + | GDK_SCROLL_MASK | GDK_STRUCTURE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK @@ -765,7 +751,11 @@ void ScintillaGTK::Initialise() { gtk_widget_set_double_buffered(widtxt, FALSE); gtk_widget_set_size_request(widtxt, 100, 100); adjustmentv = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 201.0, 1.0, 20.0, 20.0)); +#if GTK_CHECK_VERSION(3,0,0) + scrollbarv = gtk_scrollbar_new(GTK_ORIENTATION_VERTICAL, GTK_ADJUSTMENT(adjustmentv)); +#else scrollbarv = gtk_vscrollbar_new(GTK_ADJUSTMENT(adjustmentv)); +#endif #if GTK_CHECK_VERSION(2,20,0) gtk_widget_set_can_focus(PWidget(scrollbarv), FALSE); #else @@ -777,7 +767,11 @@ void ScintillaGTK::Initialise() { gtk_widget_show(PWidget(scrollbarv));
adjustmenth = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 101.0, 1.0, 20.0, 20.0)); +#if GTK_CHECK_VERSION(3,0,0) + scrollbarh = gtk_scrollbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_ADJUSTMENT(adjustmenth)); +#else scrollbarh = gtk_hscrollbar_new(GTK_ADJUSTMENT(adjustmenth)); +#endif #if GTK_CHECK_VERSION(2,20,0) gtk_widget_set_can_focus(PWidget(scrollbarh), FALSE); #else @@ -1085,8 +1079,8 @@ bool ScintillaGTK::PaintContains(PRectangle rc) { rc.right - rc.left, rc.bottom - rc.top}; contains = CRectListContains(rgnUpdate, grc); #else - GdkRectangle grc = {rc.left, rc.top, - rc.right - rc.left, rc.bottom - rc.top}; + GdkRectangle grc = {static_cast<gint>(rc.left), static_cast<gint>(rc.top), + static_cast<gint>(rc.right - rc.left), static_cast<gint>(rc.bottom - rc.top)}; if (gdk_region_rect_in(rgnUpdate, &grc) != GDK_OVERLAP_RECTANGLE_IN) { contains = false; } @@ -1122,20 +1116,14 @@ void ScintillaGTK::SyncPaint(PRectangle rc) { PRectangle rcClient = GetClientRectangle(); paintingAllText = rcPaint.Contains(rcClient); if (PWindow(wText)) { - Surface *sw = Surface::Allocate(); + Surface *sw = Surface::Allocate(SC_TECHNOLOGY_DEFAULT); if (sw) { -#if GTK_CHECK_VERSION(3,0,0) cairo_t *cr = gdk_cairo_create(PWindow(wText)); sw->Init(cr, PWidget(wText)); -#else - sw->Init(PWindow(wText), PWidget(wText)); -#endif Paint(sw, rc); sw->Release(); delete sw; -#if GTK_CHECK_VERSION(3,0,0) cairo_destroy(cr); -#endif } } if (paintState == paintAbandoned) { @@ -1151,8 +1139,10 @@ void ScintillaGTK::ScrollText(int linesToMove) { // rc.left, rc.top, rc.right, rc.bottom); GtkWidget *wi = PWidget(wText);
- gdk_window_scroll(WindowFromWidget(wi), 0, -diff); - gdk_window_process_updates(WindowFromWidget(wi), FALSE); + if (IS_WIDGET_REALIZED(wi)) { + gdk_window_scroll(WindowFromWidget(wi), 0, -diff); + gdk_window_process_updates(WindowFromWidget(wi), FALSE); + } }
void ScintillaGTK::SetVerticalScrollPos() { @@ -1416,48 +1406,22 @@ CaseFolder *ScintillaGTK::CaseFolderForEncoding() { }
int ScintillaGTK::KeyDefault(int key, int modifiers) { - if (!(modifiers & SCI_CTRL) && !(modifiers & SCI_ALT)) { - if (key < 256) { - NotifyKey(key, modifiers); - return 0; - } else { - // Pass up to container in case it is an accelerator - NotifyKey(key, modifiers); - return 0; - } - } else { - // Pass up to container in case it is an accelerator - NotifyKey(key, modifiers); - return 0; - } - //Platform::DebugPrintf("SK-key: %d %x %x\n",key, modifiers); + // Pass up to container in case it is an accelerator + NotifyKey(key, modifiers); + return 0; }
void ScintillaGTK::CopyToClipboard(const SelectionText &selectedText) { -#ifndef USE_GTK_CLIPBOARD - copyText.Copy(selectedText); - gtk_selection_owner_set(GTK_WIDGET(PWidget(wMain)), - atomClipboard, - GDK_CURRENT_TIME); -#else SelectionText *clipText = new SelectionText(); clipText->Copy(selectedText); StoreOnClipboard(clipText); -#endif }
void ScintillaGTK::Copy() { if (!sel.Empty()) { -#ifndef USE_GTK_CLIPBOARD - CopySelectionRange(©Text); - gtk_selection_owner_set(GTK_WIDGET(PWidget(wMain)), - atomClipboard, - GDK_CURRENT_TIME); -#else SelectionText *clipText = new SelectionText(); CopySelectionRange(clipText); StoreOnClipboard(clipText); -#endif #if PLAT_GTK_WIN32 if (sel.IsRectangular()) { ::OpenClipboard(NULL); @@ -1717,7 +1681,6 @@ void ScintillaGTK::GetSelection(GtkSelectionData *selection_data, guint info, Se #endif }
-#ifdef USE_GTK_CLIPBOARD void ScintillaGTK::StoreOnClipboard(SelectionText *clipText) { GtkClipboard *clipBoard = gtk_widget_get_clipboard(GTK_WIDGET(PWidget(wMain)), atomClipboard); @@ -1738,7 +1701,6 @@ void ScintillaGTK::ClipboardClearSelection(GtkClipboard *, void *data) { SelectionText *obj = static_cast<SelectionText*>(data); delete obj; } -#endif
void ScintillaGTK::UnclaimSelection(GdkEventSelection *selection_event) { try { @@ -2010,6 +1972,13 @@ gint ScintillaGTK::ScrollEvent(GtkWidget *widget, return FALSE; }
+#if GTK_CHECK_VERSION(3,4,0) + // Smooth scrolling not supported + if (event->direction == GDK_SCROLL_SMOOTH) { + return FALSE; + } +#endif + // Horizontal scrolling if (event->direction == GDK_SCROLL_LEFT || event->direction == GDK_SCROLL_RIGHT) { sciThis->HorizontalScrollTo(sciThis->xOffset + cLineScroll); @@ -2043,7 +2012,12 @@ gint ScintillaGTK::Motion(GtkWidget *widget, GdkEventMotion *event) { int y = 0; GdkModifierType state; if (event->is_hint) { +#if GTK_CHECK_VERSION(3,0,0) + gdk_window_get_device_position(event->window, + event->device, &x, &y, &state); +#else gdk_window_get_pointer(event->window, &x, &y, &state); +#endif } else { x = static_cast<int>(event->x); y = static_cast<int>(event->y); @@ -2235,8 +2209,7 @@ gboolean ScintillaGTK::KeyThis(GdkEventKey *event) { bool added = KeyDown(key, shift, ctrl, alt, &consumed) != 0; #else bool meta = ctrl; - ctrl = alt; - alt = (event->state & GDK_MOD5_MASK) != 0; + ctrl = (event->state & GDK_META_MASK) != 0; bool added = KeyDownWithModifiers(key, (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | (alt ? SCI_ALT : 0) | @@ -2312,28 +2285,10 @@ gboolean ScintillaGTK::ExposePreeditThis(GtkWidget *widget, GdkEventExpose *ose) PangoLayout *layout = gtk_widget_create_pango_layout(PWidget(wText), str); pango_layout_set_attributes(layout, attrs);
-#ifdef USE_CAIRO cairo_t *context = gdk_cairo_create(reinterpret_cast<GdkDrawable *>(WindowFromWidget(widget))); cairo_move_to(context, 0, 0); pango_cairo_show_layout(context, layout); cairo_destroy(context); -#else - GdkGC *gc = gdk_gc_new(widget->window); - GdkColor color[2] = { {0, 0x0000, 0x0000, 0x0000}, - {0, 0xffff, 0xffff, 0xffff} - }; - gdk_colormap_alloc_color(gdk_colormap_get_system(), color, FALSE, TRUE); - gdk_colormap_alloc_color(gdk_colormap_get_system(), color + 1, FALSE, TRUE); - - gdk_gc_set_foreground(gc, color + 1); - gdk_draw_rectangle(widget->window, gc, TRUE, ose->area.x, ose->area.y, - ose->area.width, ose->area.height); - - gdk_gc_set_foreground(gc, color); - gdk_gc_set_background(gc, color + 1); - gdk_draw_layout(widget->window, gc, 0, 0, layout); - g_object_unref(gc); -#endif g_free(str); pango_attr_list_unref(attrs); g_object_unref(layout); @@ -2483,7 +2438,7 @@ gboolean ScintillaGTK::DrawTextThis(cairo_t *cr) { rcPaint.bottom = y2; PRectangle rcClient = GetClientRectangle(); paintingAllText = rcPaint.Contains(rcClient); - Surface *surfaceWindow = Surface::Allocate(); + Surface *surfaceWindow = Surface::Allocate(SC_TECHNOLOGY_DEFAULT); if (surfaceWindow) { surfaceWindow->Init(cr, PWidget(wText)); Paint(surfaceWindow, rcPaint); @@ -2544,12 +2499,14 @@ gboolean ScintillaGTK::ExposeTextThis(GtkWidget * /*widget*/, GdkEventExpose *os rgnUpdate = gdk_region_copy(ose->region); PRectangle rcClient = GetClientRectangle(); paintingAllText = rcPaint.Contains(rcClient); - Surface *surfaceWindow = Surface::Allocate(); + Surface *surfaceWindow = Surface::Allocate(SC_TECHNOLOGY_DEFAULT); if (surfaceWindow) { - surfaceWindow->Init(PWindow(wText), PWidget(wText)); + cairo_t *cr = gdk_cairo_create(PWindow(wText)); + surfaceWindow->Init(cr, PWidget(wText)); Paint(surfaceWindow, rcPaint); surfaceWindow->Release(); delete surfaceWindow; + cairo_destroy(cr); } if (paintState == paintAbandoned) { // Painting area was insufficient to cover new styling or brace highlight positions @@ -2640,11 +2597,6 @@ void ScintillaGTK::SelectionGet(GtkWidget *widget, } sciThis->GetSelection(selection_data, info, &sciThis->primary); } -#ifndef USE_GTK_CLIPBOARD - else { - sciThis->GetSelection(selection_data, info, &sciThis->copyText); - } -#endif } catch (...) { sciThis->errorStatus = SC_STATUS_FAILURE; } @@ -2841,7 +2793,7 @@ gboolean ScintillaGTK::PressCT(GtkWidget *widget, GdkEventButton *event, Scintil
gboolean ScintillaGTK::DrawCT(GtkWidget *widget, cairo_t *cr, CallTip *ctip) { try { - Surface *surfaceWindow = Surface::Allocate(); + Surface *surfaceWindow = Surface::Allocate(SC_TECHNOLOGY_DEFAULT); if (surfaceWindow) { surfaceWindow->Init(cr, widget); surfaceWindow->SetUnicodeMode(SC_CP_UTF8 == ctip->codePage); @@ -2860,14 +2812,16 @@ gboolean ScintillaGTK::DrawCT(GtkWidget *widget, cairo_t *cr, CallTip *ctip) {
gboolean ScintillaGTK::ExposeCT(GtkWidget *widget, GdkEventExpose * /*ose*/, CallTip *ctip) { try { - Surface *surfaceWindow = Surface::Allocate(); + Surface *surfaceWindow = Surface::Allocate(SC_TECHNOLOGY_DEFAULT); if (surfaceWindow) { - surfaceWindow->Init(WindowFromWidget(widget), widget); + cairo_t *cr = gdk_cairo_create(WindowFromWidget(widget)); + surfaceWindow->Init(cr, widget); surfaceWindow->SetUnicodeMode(SC_CP_UTF8 == ctip->codePage); surfaceWindow->SetDBCSMode(ctip->codePage); ctip->PaintCT(surfaceWindow); surfaceWindow->Release(); delete surfaceWindow; + cairo_destroy(cr); } } catch (...) { // No pointer back to Scintilla to save status
Modified: scintilla/include/ILexer.h 8 files changed, 8 insertions(+), 0 deletions(-) =================================================================== @@ -62,6 +62,14 @@ class ILexer { virtual void * SCI_METHOD PrivateCall(int operation, void *pointer) = 0; };
+class ILoader { +public: + virtual int SCI_METHOD Release() = 0; + // Returns a status code from SC_STATUS_* + virtual int SCI_METHOD AddData(char *data, int length) = 0; + virtual void * SCI_METHOD ConvertToDocument() = 0; +}; + #ifdef SCI_NAMESPACE } #endif
Modified: scintilla/include/Platform.h 196 files changed, 77 insertions(+), 119 deletions(-) =================================================================== @@ -20,6 +20,7 @@ #define PLAT_MACOSX 0 #define PLAT_WIN 0 #define PLAT_WX 0 +#define PLAT_QT 0 #define PLAT_FOX 0
#if defined(FOX) @@ -34,6 +35,10 @@ #undef PLAT_GTK #define PLAT_GTK 1
+#elif defined(SCINTILLA_QT) +#undef PLAT_QT +#define PLAT_QT 1 + #if defined(__WIN32__) || defined(_MSC_VER) #undef PLAT_GTK_WIN32 #define PLAT_GTK_WIN32 1 @@ -59,6 +64,10 @@ namespace Scintilla { #endif
+typedef float XYPOSITION; +typedef double XYACCUMULATOR; +//#define XYPOSITION int + // 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
@@ -76,10 +85,10 @@ */ class Point { public: - int x; - int y; + XYPOSITION x; + XYPOSITION y;
- explicit Point(int x_=0, int y_=0) : x(x_), y(y_) { + explicit Point(XYPOSITION x_=0, XYPOSITION y_=0) : x(x_), y(y_) { }
// Other automatically defined methods (assignment, copy constructor, destructor) are fine @@ -94,12 +103,12 @@ class Point { */ class PRectangle { public: - int left; - int top; - int right; - int bottom; + XYPOSITION left; + XYPOSITION top; + XYPOSITION right; + XYPOSITION bottom;
- PRectangle(int left_=0, int top_=0, int right_=0, int bottom_ = 0) : + PRectangle(XYPOSITION left_=0, XYPOSITION top_=0, XYPOSITION right_=0, XYPOSITION bottom_ = 0) : left(left_), top(top_), right(right_), bottom(bottom_) { }
@@ -121,32 +130,20 @@ class PRectangle { return (right > other.left) && (left < other.right) && (bottom > other.top) && (top < other.bottom); } - void Move(int xDelta, int yDelta) { + void Move(XYPOSITION xDelta, XYPOSITION yDelta) { left += xDelta; top += yDelta; right += xDelta; bottom += yDelta; } - int Width() { return right - left; } - int Height() { return bottom - top; } + XYPOSITION Width() { return right - left; } + XYPOSITION Height() { return bottom - top; } bool Empty() { return (Height() <= 0) || (Width() <= 0); } };
/** - * In some circumstances, including Win32 in paletted mode and GTK+, each colour - * must be allocated before use. The desired colours are held in the ColourDesired class, - * and after allocation the allocation entry is stored in the ColourAllocated class. In other - * circumstances, such as Win32 in true colour mode, the allocation process just copies - * the RGB values from the desired to the allocated class. - * As each desired colour requires allocation before it can be used, the ColourPair class - * holds both a ColourDesired and a ColourAllocated - * The Palette class is responsible for managing the palette of colours which contains a - * list of ColourPair objects and performs the allocation. - */ - -/** * Holds a desired RGB colour. */ class ColourDesired { @@ -211,82 +208,39 @@ class ColourDesired { };
/** - * Holds an allocated RGB colour which may be an approximation to the desired colour. - */ -class ColourAllocated { - long coAllocated; - -public: - - ColourAllocated(long lcol=0) { - coAllocated = lcol; - } - - void Set(long lcol) { - coAllocated = lcol; - } - - long AsLong() const { - return coAllocated; - } -}; - -/** - * Colour pairs hold a desired colour and an allocated colour. + * Font management. */ -struct ColourPair { - ColourDesired desired; - ColourAllocated allocated;
- ColourPair(ColourDesired desired_=ColourDesired(0,0,0)) { - desired = desired_; - allocated.Set(desired.AsLong()); - } - void Copy() { - allocated.Set(desired.AsLong()); +struct FontParameters { + const char *faceName; + float size; + int weight; + bool italic; + int extraFontFlag; + int technology; + int characterSet; + + FontParameters( + const char *faceName_, + float size_=10, + int weight_=400, + bool italic_=false, + int extraFontFlag_=0, + int technology_=0, + int characterSet_=0) : + + faceName(faceName_), + size(size_), + weight(weight_), + italic(italic_), + extraFontFlag(extraFontFlag_), + technology(technology_), + characterSet(characterSet_) + { } -}; - -class Window; // Forward declaration for Palette - -/** - * Colour palette management. - */ -class Palette { - int used; - int size; - ColourPair *entries; -#if PLAT_GTK - void *allocatedPalette; // GdkColor * - int allocatedLen; -#endif - // Private so Palette objects can not be copied - Palette(const Palette &); - Palette &operator=(const Palette &); -public: -#if PLAT_WIN - void *hpal; -#endif - bool allowRealization;
- Palette(); - ~Palette(); - - void Release(); - - /** - * This method either adds a colour to the list of wanted colours (want==true) - * or retrieves the allocated colour back to the ColourPair. - * This is one method to make it easier to keep the code for wanting and retrieving in sync. - */ - void WantFind(ColourPair &cp, bool want); - - void Allocate(Window &w); };
-/** - * Font management. - */ class Font { protected: FontID fid; @@ -300,8 +254,7 @@ class Font { Font(); virtual ~Font();
- virtual void Create(const char *faceName, int characterSet, int size, - bool bold, bool italic, int extraFontFlag=0); + virtual void Create(const FontParameters &fp); virtual void Release();
FontID GetID() { return fid; } @@ -325,7 +278,7 @@ class Surface { public: Surface() {} virtual ~Surface() {} - static Surface *Allocate(); + static Surface *Allocate(int technology);
virtual void Init(WindowID wid)=0; virtual void Init(SurfaceID sid, WindowID wid)=0; @@ -333,36 +286,35 @@ class Surface {
virtual void Release()=0; virtual bool Initialised()=0; - virtual void PenColour(ColourAllocated fore)=0; + virtual void PenColour(ColourDesired fore)=0; virtual int LogPixelsY()=0; virtual int DeviceHeightFont(int points)=0; virtual void MoveTo(int x_, int y_)=0; virtual void LineTo(int x_, int y_)=0; - virtual void Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back)=0; - virtual void RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0; - virtual void FillRectangle(PRectangle rc, ColourAllocated back)=0; + virtual void Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired back)=0; + virtual void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back)=0; + virtual void FillRectangle(PRectangle rc, ColourDesired back)=0; virtual void FillRectangle(PRectangle rc, Surface &surfacePattern)=0; - virtual void RoundedRectangle(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0; - virtual void AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill, - ColourAllocated outline, int alphaOutline, int flags)=0; + virtual void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back)=0; + virtual void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill, + ColourDesired outline, int alphaOutline, int flags)=0; virtual void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) = 0; - virtual void Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back)=0; + virtual void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back)=0; virtual void Copy(PRectangle rc, Point from, Surface &surfaceSource)=0;
- virtual void DrawTextNoClip(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0; - virtual void DrawTextClipped(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore, ColourAllocated back)=0; - virtual void DrawTextTransparent(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore)=0; - virtual void MeasureWidths(Font &font_, const char *s, int len, int *positions)=0; - virtual int WidthText(Font &font_, const char *s, int len)=0; - virtual int WidthChar(Font &font_, char ch)=0; - virtual int Ascent(Font &font_)=0; - virtual int Descent(Font &font_)=0; - virtual int InternalLeading(Font &font_)=0; - virtual int ExternalLeading(Font &font_)=0; - virtual int Height(Font &font_)=0; - virtual int AverageCharWidth(Font &font_)=0; - - virtual int SetPalette(Palette *pal, bool inBackGround)=0; + virtual void DrawTextNoClip(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back)=0; + virtual void DrawTextClipped(PRectangle rc, Font &font_, XYPOSITION ybase, const char *s, int len, ColourDesired fore, ColourDesired back)=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 XYPOSITION WidthText(Font &font_, const char *s, int len)=0; + virtual XYPOSITION WidthChar(Font &font_, char ch)=0; + virtual XYPOSITION Ascent(Font &font_)=0; + virtual XYPOSITION Descent(Font &font_)=0; + virtual XYPOSITION InternalLeading(Font &font_)=0; + virtual XYPOSITION ExternalLeading(Font &font_)=0; + virtual XYPOSITION Height(Font &font_)=0; + virtual XYPOSITION AverageCharWidth(Font &font_)=0; + virtual void SetClip(PRectangle rc)=0; virtual void FlushCachedState()=0;
@@ -439,7 +391,7 @@ class ListBox : public Window { static ListBox *Allocate();
virtual void SetFont(Font &font)=0; - virtual void Create(Window &parent, int ctrlID, Point location, int lineHeight_, bool unicodeMode_)=0; + virtual void Create(Window &parent, int ctrlID, Point location, int lineHeight_, bool unicodeMode_, int technology_)=0; virtual void SetAverageCharWidth(int width)=0; virtual void SetVisibleRows(int rows)=0; virtual int GetVisibleRows() const=0; @@ -564,4 +516,10 @@ class Platform { #pragma warning(disable: 4244 4309 4514 4710) #endif
+#if defined(__GNUC__) && defined(SCINTILLA_QT) +#pragma GCC diagnostic ignored "-Wmissing-braces" +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#pragma GCC diagnostic ignored "-Wchar-subscripts" +#endif + #endif
Modified: scintilla/include/SciLexer.h 130 files changed, 130 insertions(+), 0 deletions(-) =================================================================== @@ -114,6 +114,12 @@ #define SCLEX_TXT2TAGS 99 #define SCLEX_A68K 100 #define SCLEX_MODULA 101 +#define SCLEX_COFFEESCRIPT 102 +#define SCLEX_TCMD 103 +#define SCLEX_AVS 104 +#define SCLEX_ECL 105 +#define SCLEX_OSCRIPT 106 +#define SCLEX_VISUALPROLOG 107 #define SCLEX_AUTOMATIC 1000 #define SCE_P_DEFAULT 0 #define SCE_P_COMMENTLINE 1 @@ -153,6 +159,7 @@ #define SCE_C_GLOBALCLASS 19 #define SCE_C_STRINGRAW 20 #define SCE_C_TRIPLEVERBATIM 21 +#define SCE_C_HASHQUOTEDSTRING 22 #define SCE_D_DEFAULT 0 #define SCE_D_COMMENT 1 #define SCE_D_COMMENTLINE 2 @@ -477,6 +484,17 @@ #define SCE_BAT_COMMAND 5 #define SCE_BAT_IDENTIFIER 6 #define SCE_BAT_OPERATOR 7 +#define SCE_TCMD_DEFAULT 0 +#define SCE_TCMD_COMMENT 1 +#define SCE_TCMD_WORD 2 +#define SCE_TCMD_LABEL 3 +#define SCE_TCMD_HIDE 4 +#define SCE_TCMD_COMMAND 5 +#define SCE_TCMD_IDENTIFIER 6 +#define SCE_TCMD_OPERATOR 7 +#define SCE_TCMD_ENVIRONMENT 8 +#define SCE_TCMD_EXPANSION 9 +#define SCE_TCMD_CLABEL 10 #define SCE_MAKE_DEFAULT 0 #define SCE_MAKE_COMMENT 1 #define SCE_MAKE_PREPROCESSOR 2 @@ -663,6 +681,7 @@ #define SCE_CSS_EXTENDED_PSEUDOCLASS 20 #define SCE_CSS_EXTENDED_PSEUDOELEMENT 21 #define SCE_CSS_MEDIA 22 +#define SCE_CSS_VARIABLE 23 #define SCE_POV_DEFAULT 0 #define SCE_POV_COMMENT 1 #define SCE_POV_COMMENTLINE 2 @@ -1476,6 +1495,117 @@ #define SCE_MODULA_PRGKEY 15 #define SCE_MODULA_OPERATOR 16 #define SCE_MODULA_BADSTR 17 +#define SCE_COFFEESCRIPT_DEFAULT 0 +#define SCE_COFFEESCRIPT_COMMENT 1 +#define SCE_COFFEESCRIPT_COMMENTLINE 2 +#define SCE_COFFEESCRIPT_COMMENTDOC 3 +#define SCE_COFFEESCRIPT_NUMBER 4 +#define SCE_COFFEESCRIPT_WORD 5 +#define SCE_COFFEESCRIPT_STRING 6 +#define SCE_COFFEESCRIPT_CHARACTER 7 +#define SCE_COFFEESCRIPT_UUID 8 +#define SCE_COFFEESCRIPT_PREPROCESSOR 9 +#define SCE_COFFEESCRIPT_OPERATOR 10 +#define SCE_COFFEESCRIPT_IDENTIFIER 11 +#define SCE_COFFEESCRIPT_STRINGEOL 12 +#define SCE_COFFEESCRIPT_VERBATIM 13 +#define SCE_COFFEESCRIPT_REGEX 14 +#define SCE_COFFEESCRIPT_COMMENTLINEDOC 15 +#define SCE_COFFEESCRIPT_WORD2 16 +#define SCE_COFFEESCRIPT_COMMENTDOCKEYWORD 17 +#define SCE_COFFEESCRIPT_COMMENTDOCKEYWORDERROR 18 +#define SCE_COFFEESCRIPT_GLOBALCLASS 19 +#define SCE_COFFEESCRIPT_STRINGRAW 20 +#define SCE_COFFEESCRIPT_TRIPLEVERBATIM 21 +#define SCE_COFFEESCRIPT_HASHQUOTEDSTRING 22 +#define SCE_COFFEESCRIPT_COMMENTBLOCK 22 +#define SCE_COFFEESCRIPT_VERBOSE_REGEX 23 +#define SCE_COFFEESCRIPT_VERBOSE_REGEX_COMMENT 24 +#define SCE_AVS_DEFAULT 0 +#define SCE_AVS_COMMENTBLOCK 1 +#define SCE_AVS_COMMENTBLOCKN 2 +#define SCE_AVS_COMMENTLINE 3 +#define SCE_AVS_NUMBER 4 +#define SCE_AVS_OPERATOR 5 +#define SCE_AVS_IDENTIFIER 6 +#define SCE_AVS_STRING 7 +#define SCE_AVS_TRIPLESTRING 8 +#define SCE_AVS_KEYWORD 9 +#define SCE_AVS_FILTER 10 +#define SCE_AVS_PLUGIN 11 +#define SCE_AVS_FUNCTION 12 +#define SCE_AVS_CLIPPROP 13 +#define SCE_AVS_USERDFN 14 +#define SCE_ECL_DEFAULT 0 +#define SCE_ECL_COMMENT 1 +#define SCE_ECL_COMMENTLINE 2 +#define SCE_ECL_NUMBER 3 +#define SCE_ECL_STRING 4 +#define SCE_ECL_WORD0 5 +#define SCE_ECL_OPERATOR 6 +#define SCE_ECL_CHARACTER 7 +#define SCE_ECL_UUID 8 +#define SCE_ECL_PREPROCESSOR 9 +#define SCE_ECL_UNKNOWN 10 +#define SCE_ECL_IDENTIFIER 11 +#define SCE_ECL_STRINGEOL 12 +#define SCE_ECL_VERBATIM 13 +#define SCE_ECL_REGEX 14 +#define SCE_ECL_COMMENTLINEDOC 15 +#define SCE_ECL_WORD1 16 +#define SCE_ECL_COMMENTDOCKEYWORD 17 +#define SCE_ECL_COMMENTDOCKEYWORDERROR 18 +#define SCE_ECL_WORD2 19 +#define SCE_ECL_WORD3 20 +#define SCE_ECL_WORD4 21 +#define SCE_ECL_WORD5 22 +#define SCE_ECL_COMMENTDOC 23 +#define SCE_ECL_ADDED 24 +#define SCE_ECL_DELETED 25 +#define SCE_ECL_CHANGED 26 +#define SCE_ECL_MOVED 27 +#define SCE_OSCRIPT_DEFAULT 0 +#define SCE_OSCRIPT_LINE_COMMENT 1 +#define SCE_OSCRIPT_BLOCK_COMMENT 2 +#define SCE_OSCRIPT_DOC_COMMENT 3 +#define SCE_OSCRIPT_PREPROCESSOR 4 +#define SCE_OSCRIPT_NUMBER 5 +#define SCE_OSCRIPT_SINGLEQUOTE_STRING 6 +#define SCE_OSCRIPT_DOUBLEQUOTE_STRING 7 +#define SCE_OSCRIPT_CONSTANT 8 +#define SCE_OSCRIPT_IDENTIFIER 9 +#define SCE_OSCRIPT_GLOBAL 10 +#define SCE_OSCRIPT_KEYWORD 11 +#define SCE_OSCRIPT_OPERATOR 12 +#define SCE_OSCRIPT_LABEL 13 +#define SCE_OSCRIPT_TYPE 14 +#define SCE_OSCRIPT_FUNCTION 15 +#define SCE_OSCRIPT_OBJECT 16 +#define SCE_OSCRIPT_PROPERTY 17 +#define SCE_OSCRIPT_METHOD 18 +#define SCE_VISUALPROLOG_DEFAULT 0 +#define SCE_VISUALPROLOG_KEY_MAJOR 1 +#define SCE_VISUALPROLOG_KEY_MINOR 2 +#define SCE_VISUALPROLOG_KEY_DIRECTIVE 3 +#define SCE_VISUALPROLOG_COMMENT_BLOCK 4 +#define SCE_VISUALPROLOG_COMMENT_LINE 5 +#define SCE_VISUALPROLOG_COMMENT_KEY 6 +#define SCE_VISUALPROLOG_COMMENT_KEY_ERROR 7 +#define SCE_VISUALPROLOG_IDENTIFIER 8 +#define SCE_VISUALPROLOG_VARIABLE 9 +#define SCE_VISUALPROLOG_ANONYMOUS 10 +#define SCE_VISUALPROLOG_NUMBER 11 +#define SCE_VISUALPROLOG_OPERATOR 12 +#define SCE_VISUALPROLOG_CHARACTER 13 +#define SCE_VISUALPROLOG_CHARACTER_TOO_MANY 14 +#define SCE_VISUALPROLOG_CHARACTER_ESCAPE_ERROR 15 +#define SCE_VISUALPROLOG_STRING 16 +#define SCE_VISUALPROLOG_STRING_ESCAPE 17 +#define SCE_VISUALPROLOG_STRING_ESCAPE_ERROR 18 +#define SCE_VISUALPROLOG_STRING_EOL_OPEN 19 +#define SCE_VISUALPROLOG_STRING_VERBATIM 20 +#define SCE_VISUALPROLOG_STRING_VERBATIM_SPECIAL 21 +#define SCE_VISUALPROLOG_STRING_VERBATIM_EOL 22 /* --Autogenerated -- end of section automatically generated from Scintilla.iface */
#endif
Modified: scintilla/include/Scintilla.h 31 files changed, 29 insertions(+), 2 deletions(-) =================================================================== @@ -51,6 +51,7 @@ #define SCI_ADDSTYLEDTEXT 2002 #define SCI_INSERTTEXT 2003 #define SCI_CLEARALL 2004 +#define SCI_DELETERANGE 2645 #define SCI_CLEARDOCUMENTSTYLE 2005 #define SCI_GETLENGTH 2006 #define SCI_GETCHARAT 2007 @@ -92,7 +93,6 @@ #define SCI_GETTABWIDTH 2121 #define SC_CP_UTF8 65001 #define SCI_SETCODEPAGE 2037 -#define SCI_SETUSEPALETTE 2039 #define MARKER_MAX 31 #define SC_MARK_CIRCLE 0 #define SC_MARK_ROUNDRECT 1 @@ -221,6 +221,14 @@ #define SCI_STYLEGETCHANGEABLE 2492 #define SCI_STYLEGETHOTSPOT 2493 #define SCI_STYLESETCASE 2060 +#define SC_FONT_SIZE_MULTIPLIER 100 +#define SCI_STYLESETSIZEFRACTIONAL 2061 +#define SCI_STYLEGETSIZEFRACTIONAL 2062 +#define SC_WEIGHT_NORMAL 400 +#define SC_WEIGHT_SEMIBOLD 600 +#define SC_WEIGHT_BOLD 700 +#define SCI_STYLESETWEIGHT 2063 +#define SCI_STYLEGETWEIGHT 2064 #define SCI_STYLESETCHARACTERSET 2066 #define SCI_STYLESETHOTSPOT 2409 #define SCI_SETSELFORE 2067 @@ -316,6 +324,7 @@ #define SCI_GETLINEINDENTATION 2127 #define SCI_GETLINEINDENTPOSITION 2128 #define SCI_GETCOLUMN 2129 +#define SCI_COUNTCHARACTERS 2633 #define SCI_SETHSCROLLBAR 2130 #define SCI_GETHSCROLLBAR 2131 #define SC_IV_NONE 0 @@ -329,7 +338,6 @@ #define SCI_GETLINEENDPOSITION 2136 #define SCI_GETCODEPAGE 2137 #define SCI_GETCARETFORE 2138 -#define SCI_GETUSEPALETTE 2139 #define SCI_GETREADONLY 2140 #define SCI_SETCURRENTPOS 2141 #define SCI_SETSELECTIONSTART 2142 @@ -409,6 +417,7 @@ #define SCI_CALLTIPSETFORE 2206 #define SCI_CALLTIPSETFOREHLT 2207 #define SCI_CALLTIPUSESTYLE 2212 +#define SCI_CALLTIPSETPOSITION 2213 #define SCI_VISIBLEFROMDOCLINE 2220 #define SCI_DOCLINEFROMVISIBLE 2221 #define SCI_WRAPCOUNT 2235 @@ -423,6 +432,7 @@ #define SCI_SHOWLINES 2226 #define SCI_HIDELINES 2227 #define SCI_GETLINEVISIBLE 2228 +#define SCI_GETALLLINESVISIBLE 2236 #define SCI_SETFOLDEXPANDED 2229 #define SCI_GETFOLDEXPANDED 2230 #define SCI_TOGGLEFOLD 2231 @@ -451,6 +461,7 @@ #define SC_WRAPVISUALFLAG_NONE 0x0000 #define SC_WRAPVISUALFLAG_END 0x0001 #define SC_WRAPVISUALFLAG_START 0x0002 +#define SC_WRAPVISUALFLAG_MARGIN 0x0004 #define SCI_SETWRAPVISUALFLAGS 2460 #define SCI_GETWRAPVISUALFLAGS 2461 #define SC_WRAPVISUALFLAGLOC_DEFAULT 0x0000 @@ -676,6 +687,10 @@ #define SCI_SETCHARSDEFAULT 2444 #define SCI_AUTOCGETCURRENT 2445 #define SCI_AUTOCGETCURRENTTEXT 2610 +#define SC_CASEINSENSITIVEBEHAVIOUR_RESPECTCASE 0 +#define SC_CASEINSENSITIVEBEHAVIOUR_IGNORECASE 1 +#define SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR 2634 +#define SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR 2635 #define SCI_ALLOCATE 2446 #define SCI_TARGETASUTF8 2447 #define SCI_SETLENGTHFORENCODE 2448 @@ -714,6 +729,8 @@ #define SCI_GETPOSITIONCACHE 2515 #define SCI_COPYALLOWLINE 2519 #define SCI_GETCHARACTERPOINTER 2520 +#define SCI_GETRANGEPOINTER 2643 +#define SCI_GETGAPPOSITION 2644 #define SCI_SETKEYSUNICODE 2521 #define SCI_GETKEYSUNICODE 2522 #define SCI_INDICSETALPHA 2523 @@ -819,6 +836,14 @@ #define SCI_REGISTERRGBAIMAGE 2627 #define SCI_SCROLLTOSTART 2628 #define SCI_SCROLLTOEND 2629 +#define SC_TECHNOLOGY_DEFAULT 0 +#define SC_TECHNOLOGY_DIRECTWRITE 1 +#define SCI_SETTECHNOLOGY 2630 +#define SCI_GETTECHNOLOGY 2631 +#define SCI_CREATELOADER 2632 +#define SCI_FINDINDICATORSHOW 2640 +#define SCI_FINDINDICATORFLASH 2641 +#define SCI_FINDINDICATORHIDE 2642 #define SCI_STARTRECORD 3001 #define SCI_STOPRECORD 3002 #define SCI_SETLEXER 4001 @@ -1028,6 +1053,8 @@ struct SCNotification { #ifdef INCLUDE_DEPRECATED_FEATURES
#define SC_CP_DBCS 1 +#define SCI_SETUSEPALETTE 2039 +#define SCI_GETUSEPALETTE 2139
#endif
Modified: scintilla/include/Scintilla.iface 233 files changed, 224 insertions(+), 9 deletions(-) =================================================================== @@ -101,6 +101,9 @@ fun void InsertText=2003(position pos, string text) # Delete all text in the document. fun void ClearAll=2004(,)
+# Delete a range of text in the document. +fun void DeleteRange=2645(position pos, int deleteLength) + # Set all style bytes to 0, remove all folding information. fun void ClearDocumentStyle=2005(,)
@@ -228,10 +231,6 @@ val SC_CP_UTF8=65001 # The SC_CP_UTF8 value can be used to enter Unicode mode. set void SetCodePage=2037(int codePage,)
-# In palette mode, Scintilla uses the environment's palette calls to display -# more colours. This may lead to ugly displays. -set void SetUsePalette=2039(bool usePalette,) - enu MarkerSymbol=SC_MARK_ val MARKER_MAX=31 val SC_MARK_CIRCLE=0 @@ -482,6 +481,25 @@ get bool StyleGetHotSpot=2493(int style,) # Set a style to be mixed case, or to force upper or lower case. set void StyleSetCase=2060(int style, int caseForce)
+val SC_FONT_SIZE_MULTIPLIER=100 + +# Set the size of characters of a style. Size is in points multiplied by 100. +set void StyleSetSizeFractional=2061(int style, int caseForce) + +# Get the size of characters of a style in points multiplied by 100 +get int StyleGetSizeFractional=2062(int style,) + +enu FontWeight=SC_WEIGHT_ +val SC_WEIGHT_NORMAL=400 +val SC_WEIGHT_SEMIBOLD=600 +val SC_WEIGHT_BOLD=700 + +# Set the weight of characters of a style. +set void StyleSetWeight=2063(int style, int weight) + +# Get the weight of characters of a style. +get int StyleGetWeight=2064(int style,) + # Set the character set of the font in a style. set void StyleSetCharacterSet=2066(int style, int characterSet)
@@ -748,9 +766,11 @@ get position GetLineIndentPosition=2128(int line,) # Retrieve the column number of a position, taking tab width into account. get int GetColumn=2129(position pos,)
+# Count characters between two positions. +fun int CountCharacters=2633(int startPos, int endPos) + # Show or hide the horizontal scroll bar. set void SetHScrollBar=2130(bool show,) - # Is the horizontal scroll bar visible? get bool GetHScrollBar=2131(,)
@@ -774,7 +794,7 @@ set void SetHighlightGuide=2134(int column,) get int GetHighlightGuide=2135(,)
# Get the position after the last visible characters on a line. -get int GetLineEndPosition=2136(int line,) +get position GetLineEndPosition=2136(int line,)
# Get the code page used to interpret the bytes of the document as characters. get int GetCodePage=2137(,) @@ -782,9 +802,6 @@ get int GetCodePage=2137(,) # Get the foreground colour of the caret. get colour GetCaretFore=2138(,)
-# In palette mode? -get bool GetUsePalette=2139(,) - # In read-only mode? get bool GetReadOnly=2140(,)
@@ -1027,6 +1044,9 @@ set void CallTipSetForeHlt=2207(colour fore,) # Enable use of STYLE_CALLTIP and set call tip tab size in pixels. set void CallTipUseStyle=2212(int tabSize,)
+# Set position of calltip, above or below text. +set void CallTipSetPosition=2213(bool above,) + # Find the display line of a document line taking hidden lines into account. fun int VisibleFromDocLine=2220(int line,)
@@ -1065,6 +1085,9 @@ fun void HideLines=2227(int lineStart, int lineEnd) # Is a line visible? get bool GetLineVisible=2228(int line,)
+# Are all lines visible? +get bool GetAllLinesVisible=2236(,) + # Show the children of a header line. set void SetFoldExpanded=2229(int line, bool expanded)
@@ -1132,6 +1155,7 @@ enu WrapVisualFlag=SC_WRAPVISUALFLAG_ val SC_WRAPVISUALFLAG_NONE=0x0000 val SC_WRAPVISUALFLAG_END=0x0001 val SC_WRAPVISUALFLAG_START=0x0002 +val SC_WRAPVISUALFLAG_MARGIN=0x0004
# Set the display mode of visual flags for wrapped lines. set void SetWrapVisualFlags=2460(int wrapVisualFlags,) @@ -1786,6 +1810,16 @@ fun int AutoCGetCurrent=2445(,) # Returns the length of the item text fun int AutoCGetCurrentText=2610(, stringresult s)
+enu CaseInsensitiveBehaviour=SC_CASEINSENSITIVEBEHAVIOUR_ +val SC_CASEINSENSITIVEBEHAVIOUR_RESPECTCASE=0 +val SC_CASEINSENSITIVEBEHAVIOUR_IGNORECASE=1 + +# Set auto-completion case insensitive behaviour to either prefer case-sensitive matches or have no preference. +set void AutoCSetCaseInsensitiveBehaviour=2634(int behaviour,) + +# Get auto-completion case insensitive behaviour. +get int AutoCGetCaseInsensitiveBehaviour=2635(,) + # Enlarge the document to a particular size of text bytes. fun void Allocate=2446(int bytes,)
@@ -1893,6 +1927,15 @@ fun void CopyAllowLine=2519(,) # characters in the document. get int GetCharacterPointer=2520(,)
+# Return a read-only pointer to a range of characters in the document. +# May move the gap so that the range is contiguous, but will only move up +# to rangeLength bytes. +get int GetRangePointer=2643(int position, int rangeLength) + +# Return a position which, to avoid performance costs, should not be within +# the range of a call to GetRangePointer. +get position GetGapPosition=2644(,) + # Always interpret keyboard input as Unicode set void SetKeysUnicode=2521(bool keysUnicode,)
@@ -2175,6 +2218,27 @@ fun void ScrollToStart=2628(,) # Scroll to end of document. fun void ScrollToEnd=2629(,)
+val SC_TECHNOLOGY_DEFAULT=0 +val SC_TECHNOLOGY_DIRECTWRITE=1 + +# Set the technolgy used. +set void SetTechnology=2630(int technology,) + +# Get the tech. +get int GetTechnology=2631(,) + +# Create an ILoader*. +fun int CreateLoader=2632(int bytes,) + +# On OS X, show a find indicator. +fun void FindIndicatorShow=2640(position start, position end) + +# On OS X, flash a find indicator, then fade out. +fun void FindIndicatorFlash=2641(position start, position end) + +# On OS X, hide the find indicator. +fun void FindIndicatorHide=2642(,) + # Start notifying the container of all key presses and commands. fun void StartRecord=3001(,)
@@ -2421,6 +2485,12 @@ val SCLEX_MARKDOWN=98 val SCLEX_TXT2TAGS=99 val SCLEX_A68K=100 val SCLEX_MODULA=101 +val SCLEX_COFFEESCRIPT=102 +val SCLEX_TCMD=103 +val SCLEX_AVS=104 +val SCLEX_ECL=105 +val SCLEX_OSCRIPT=106 +val SCLEX_VISUALPROLOG=107
# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a # value assigned in sequence from SCLEX_AUTOMATIC+1. @@ -2469,6 +2539,7 @@ val SCE_C_COMMENTDOCKEYWORDERROR=18 val SCE_C_GLOBALCLASS=19 val SCE_C_STRINGRAW=20 val SCE_C_TRIPLEVERBATIM=21 +val SCE_C_HASHQUOTEDSTRING=22 # Lexical states for SCLEX_D lex D=SCLEX_D SCE_D_ val SCE_D_DEFAULT=0 @@ -2832,6 +2903,19 @@ val SCE_BAT_HIDE=4 val SCE_BAT_COMMAND=5 val SCE_BAT_IDENTIFIER=6 val SCE_BAT_OPERATOR=7 +# Lexical states for SCLEX_TCMD +lex TCMD=SCLEX_TCMD SCE_TCMD_ +val SCE_TCMD_DEFAULT=0 +val SCE_TCMD_COMMENT=1 +val SCE_TCMD_WORD=2 +val SCE_TCMD_LABEL=3 +val SCE_TCMD_HIDE=4 +val SCE_TCMD_COMMAND=5 +val SCE_TCMD_IDENTIFIER=6 +val SCE_TCMD_OPERATOR=7 +val SCE_TCMD_ENVIRONMENT=8 +val SCE_TCMD_EXPANSION=9 +val SCE_TCMD_CLABEL=10 # Lexical states for SCLEX_MAKEFILE lex MakeFile=SCLEX_MAKEFILE SCE_MAKE_ val SCE_MAKE_DEFAULT=0 @@ -3051,6 +3135,7 @@ val SCE_CSS_EXTENDED_IDENTIFIER=19 val SCE_C@@ Diff output truncated at 100000 characters. @@
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: TBD).