lists.geany.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
List overview
Commits
July 2014
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
commits@lists.geany.org
1 participants
23 discussions
Start a n
N
ew thread
[geany/geany] 11b504: Use ui_button_new_with_image() to build image buttons
by Colomban Wendling
04 Jul '14
04 Jul '14
Branch: refs/heads/master Author: Colomban Wendling <ban(a)herbesfolles.org> Committer: Colomban Wendling <ban(a)herbesfolles.org> Date: Fri, 04 Jul 2014 15:50:37 UTC Commit: 11b50493fcd65216014d4bcab157d79cc33d9e7b
https://github.com/geany/geany/commit/11b50493fcd65216014d4bcab157d79cc33d9…
Log Message: ----------- Use ui_button_new_with_image() to build image buttons Modified Paths: -------------- src/project.c Modified: src/project.c 8 lines changed, 1 insertions(+), 7 deletions(-) =================================================================== @@ -123,15 +123,9 @@ void project_new(void) GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); gtk_widget_set_name(e->dialog, "GeanyDialogProject"); - bbox = gtk_hbox_new(FALSE, 0); - button = gtk_button_new(); + button = ui_button_new_with_image(GTK_STOCK_NEW, _("C_reate")); gtk_widget_set_can_default(button, TRUE); gtk_window_set_default(GTK_WINDOW(e->dialog), button); - image = gtk_image_new_from_stock(GTK_STOCK_NEW, GTK_ICON_SIZE_BUTTON); - label = gtk_label_new_with_mnemonic(_("C_reate")); - gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 3); - gtk_box_pack_start(GTK_BOX(bbox), label, FALSE, FALSE, 3); - gtk_container_add(GTK_CONTAINER(button), bbox); gtk_dialog_add_action_widget(GTK_DIALOG(e->dialog), button, GTK_RESPONSE_OK); vbox = ui_dialog_vbox_new(GTK_DIALOG(e->dialog)); -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany] 98fa60: Update Scintilla to version 3.4.4
by Colomban Wendling
04 Jul '14
04 Jul '14
Branch: refs/heads/master Author: Colomban Wendling <ban(a)herbesfolles.org> Committer: Colomban Wendling <ban(a)herbesfolles.org> Date: Fri, 04 Jul 2014 01:06:17 UTC Commit: 98fa600a2ff40cd55ec8010bff258ed0b32ff8aa
https://github.com/geany/geany/commit/98fa600a2ff40cd55ec8010bff258ed0b32ff…
Log Message: ----------- Update Scintilla to version 3.4.4 Modified Paths: -------------- scintilla/gtk/PlatGTK.cxx scintilla/gtk/ScintillaGTK.cxx scintilla/include/Scintilla.h scintilla/include/Scintilla.iface scintilla/lexers/LexBash.cxx scintilla/lexers/LexCPP.cxx scintilla/lexers/LexHTML.cxx scintilla/lexers/LexHaskell.cxx scintilla/lexers/LexPerl.cxx scintilla/lexers/LexRuby.cxx scintilla/lexers/LexRust.cxx scintilla/lexers/LexTCL.cxx scintilla/lexers/LexVHDL.cxx scintilla/lexlib/Accessor.cxx scintilla/lexlib/CharacterCategory.cxx scintilla/lexlib/CharacterSet.cxx scintilla/lexlib/LexAccessor.h scintilla/lexlib/LexerBase.cxx scintilla/lexlib/LexerModule.cxx scintilla/lexlib/LexerModule.h scintilla/lexlib/LexerNoExceptions.cxx scintilla/lexlib/LexerSimple.cxx scintilla/lexlib/StyleContext.cxx scintilla/lexlib/StyleContext.h scintilla/lexlib/WordList.cxx scintilla/src/CaseFolder.cxx scintilla/src/Catalogue.cxx scintilla/src/CellBuffer.cxx scintilla/src/CellBuffer.h scintilla/src/Document.cxx scintilla/src/Document.h scintilla/src/Editor.cxx scintilla/src/Editor.h scintilla/src/ExternalLexer.cxx scintilla/src/Indicator.cxx scintilla/src/Indicator.h scintilla/src/LineMarker.cxx scintilla/src/LineMarker.h scintilla/src/PositionCache.cxx scintilla/src/PositionCache.h scintilla/src/ScintillaBase.cxx scintilla/src/ScintillaBase.h scintilla/src/Selection.cxx scintilla/src/Selection.h scintilla/src/Style.cxx scintilla/src/Style.h scintilla/src/ViewStyle.cxx scintilla/src/ViewStyle.h scintilla/version.txt Modified: scintilla/gtk/PlatGTK.cxx 41 lines changed, 26 insertions(+), 15 deletions(-) =================================================================== @@ -527,27 +527,32 @@ void SurfaceImpl::Release() { } bool SurfaceImpl::Initialised() { + if (inited && context) { + if (cairo_status(context) == CAIRO_STATUS_SUCCESS) { + // Even when status is success, the target surface may have been + // finished whch may cause an assertion to fail crashing the application. + // The cairo_surface_has_show_text_glyphs call checks the finished flag + // and when set, sets the status to CAIRO_STATUS_SURFACE_FINISHED + // which leads to warning messages instead of crashes. + // Performing the check in this method as it is called rarely and has no + // other side effects. + cairo_surface_t *psurfContext = cairo_get_target(context); + if (psurfContext) { + cairo_surface_has_show_text_glyphs(psurfContext); + } + } + return cairo_status(context) == CAIRO_STATUS_SUCCESS; + } return inited; } void SurfaceImpl::Init(WindowID wid) { Release(); PLATFORM_ASSERT(wid); -#if GTK_CHECK_VERSION(3,0,0) - GdkWindow *drawable_ = gtk_widget_get_window(PWidget(wid)); -#else - GdkDrawable *drawable_ = GDK_DRAWABLE(PWidget(wid)->window); -#endif - if (drawable_) { - context = gdk_cairo_create(drawable_); - PLATFORM_ASSERT(context); - } else { - // Shouldn't happen with valid window but may when calls made before - // window completely allocated and mapped. - psurf = cairo_image_surface_create(CAIRO_FORMAT_RGB24, 1, 1); - context = cairo_create(psurf); - } - createdGC = true; + // if we are only created from a window ID, we can't perform drawing + psurf = 0; + context = 0; + createdGC = false; pcontext = gtk_widget_create_pango_context(PWidget(wid)); PLATFORM_ASSERT(pcontext); layout = pango_layout_new(pcontext); @@ -665,6 +670,7 @@ void SurfaceImpl::LineTo(int x_, int y_) { void SurfaceImpl::Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired back) { + PLATFORM_ASSERT(context); PenColour(back); cairo_move_to(context, pts[0].x + 0.5, pts[0].y + 0.5); for (int i = 1; i < npts; i++) { @@ -702,6 +708,7 @@ void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) { SurfaceImpl &surfi = static_cast<SurfaceImpl &>(surfacePattern); bool canDraw = surfi.psurf; if (canDraw) { + PLATFORM_ASSERT(context); // Tile pattern over rectangle // Currently assumes 8x8 pattern int widthPat = 8; @@ -787,6 +794,7 @@ void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fi } void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) { + PLATFORM_ASSERT(context); if (rc.Width() > width) rc.left += (rc.Width() - width) / 2; rc.right = rc.left + width; @@ -821,6 +829,7 @@ void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsi } void SurfaceImpl::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) { + PLATFORM_ASSERT(context); PenColour(back); cairo_arc(context, (rc.left + rc.right) / 2, (rc.top + rc.bottom) / 2, Platform::Minimum(rc.Width(), rc.Height()) / 2, 0, 2*kPi); @@ -833,6 +842,7 @@ void SurfaceImpl::Copy(PRectangle rc, Point from, Surface &surfaceSource) { SurfaceImpl &surfi = static_cast<SurfaceImpl &>(surfaceSource); bool canDraw = surfi.psurf; if (canDraw) { + PLATFORM_ASSERT(context); 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); @@ -1185,6 +1195,7 @@ XYPOSITION SurfaceImpl::AverageCharWidth(Font &font_) { } void SurfaceImpl::SetClip(PRectangle rc) { + PLATFORM_ASSERT(context); cairo_rectangle(context, rc.left, rc.top, rc.right, rc.bottom); cairo_clip(context); } Modified: scintilla/gtk/ScintillaGTK.cxx 28 lines changed, 15 insertions(+), 13 deletions(-) =================================================================== @@ -6,9 +6,9 @@ #include <stdlib.h> #include <string.h> #include <stdio.h> -#include <ctype.h> #include <time.h> #include <assert.h> +#include <ctype.h> #include <new> #include <string> @@ -16,15 +16,17 @@ #include <map> #include <algorithm> +#include <glib.h> +#include <gmodule.h> #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> -#include "Platform.h" - -#if PLAT_GTK_WIN32 +#if defined(__WIN32__) || defined(_MSC_VER) #include <windows.h> #endif +#include "Platform.h" + #include "ILexer.h" #include "Scintilla.h" #include "ScintillaWidget.h" @@ -32,6 +34,9 @@ #include "SciLexer.h" #endif #include "StringCopy.h" +#ifdef SCI_LEXER +#include "LexerModule.h" +#endif #include "SplitVector.h" #include "Partitioning.h" #include "RunStyles.h" @@ -43,28 +48,25 @@ #include "XPM.h" #include "LineMarker.h" #include "Style.h" -#include "AutoComplete.h" #include "ViewStyle.h" -#include "Decoration.h" #include "CharClassify.h" +#include "Decoration.h" #include "CaseFolder.h" #include "Document.h" +#include "CaseConvert.h" +#include "UniConversion.h" #include "Selection.h" #include "PositionCache.h" #include "Editor.h" +#include "AutoComplete.h" #include "ScintillaBase.h" -#include "UniConversion.h" -#include "CaseConvert.h" - -#include "scintilla-marshal.h" #ifdef SCI_LEXER -#include <glib.h> -#include <gmodule.h> -#include "LexerModule.h" #include "ExternalLexer.h" #endif +#include "scintilla-marshal.h" + #include "Converter.h" #if defined(__clang__) Modified: scintilla/include/Scintilla.h 8 lines changed, 6 insertions(+), 2 deletions(-) =================================================================== @@ -717,6 +717,10 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_CASEINSENSITIVEBEHAVIOUR_IGNORECASE 1 #define SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR 2634 #define SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR 2635 +#define SC_MULTIAUTOC_ONCE 0 +#define SC_MULTIAUTOC_EACH 1 +#define SCI_AUTOCSETMULTI 2636 +#define SCI_AUTOCGETMULTI 2637 #define SC_ORDER_PRESORTED 0 #define SC_ORDER_PERFORMSORT 1 #define SC_ORDER_CUSTOM 2 @@ -1017,7 +1021,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, * CHARRANGE, TEXTRANGE, FINDTEXTEX, FORMATRANGE, and NMHDR structs. * So older code that treats Scintilla as a RichEdit will work. */ -#ifdef SCI_NAMESPACE +#if defined(__cplusplus) && defined(SCI_NAMESPACE) namespace Scintilla { #endif @@ -1109,7 +1113,7 @@ struct SCNotification { int updated; /* SCN_UPDATEUI */ }; -#ifdef SCI_NAMESPACE +#if defined(__cplusplus) && defined(SCI_NAMESPACE) } #endif Modified: scintilla/include/Scintilla.iface 10 lines changed, 10 insertions(+), 0 deletions(-) =================================================================== @@ -1884,6 +1884,16 @@ set void AutoCSetCaseInsensitiveBehaviour=2634(int behaviour,) # Get auto-completion case insensitive behaviour. get int AutoCGetCaseInsensitiveBehaviour=2635(,) +enu MultiAutoComplete=SC_MULTIAUTOC_ +val SC_MULTIAUTOC_ONCE=0 +val SC_MULTIAUTOC_EACH=1 + +# Change the effect of autocompleting when there are multiple selections. +set void AutoCSetMulti=2636(int multi,) + +# Retrieve the effect of autocompleting when there are multiple selections.. +get int AutoCGetMulti=2637(,) + enu Ordering=SC_ORDER_ val SC_ORDER_PRESORTED=0 val SC_ORDER_PERFORMSORT=1 Modified: scintilla/lexers/LexBash.cxx 11 lines changed, 10 insertions(+), 1 deletions(-) =================================================================== @@ -767,6 +767,7 @@ static void FoldBashDoc(unsigned int startPos, int length, int, WordList *[], bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; unsigned int endPos = startPos + length; int visibleChars = 0; + int skipHereCh = 0; int lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; @@ -798,7 +799,15 @@ static void FoldBashDoc(unsigned int startPos, int length, int, WordList *[], // Here Document folding if (style == SCE_SH_HERE_DELIM) { if (ch == '<' && chNext == '<') { - levelCurrent++; + if (styler.SafeGetCharAt(i + 2) == '<') { + skipHereCh = 1; + } else { + if (skipHereCh == 0) { + levelCurrent++; + } else { + skipHereCh = 0; + } + } } } else if (style == SCE_SH_HERE_Q && styler.StyleAt(i+1) == SCE_SH_DEFAULT) { levelCurrent--; Modified: scintilla/lexers/LexCPP.cxx 22 lines changed, 16 insertions(+), 6 deletions(-) =================================================================== @@ -8,10 +8,10 @@ #include <stdlib.h> #include <string.h> -#include <ctype.h> #include <stdio.h> #include <stdarg.h> #include <assert.h> +#include <ctype.h> #include <string> #include <vector> @@ -821,10 +821,18 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, ((lenS == 1) && ((s[0] == 'L') || (s[0] == 'u') || (s[0] == 'U'))) || ((lenS == 2) && literalString && (s[0] == 'u') && (s[1] == '8')); if (valid) { - if (literalString) - sc.ChangeState((raw ? SCE_C_STRINGRAW : SCE_C_STRING)|activitySet); - else + if (literalString) { + if (raw) { + // Set the style of the string prefix to SCE_C_STRINGRAW but then change to + // SCE_C_DEFAULT as that allows the raw string start code to run. + sc.ChangeState(SCE_C_STRINGRAW|activitySet); + sc.SetState(SCE_C_DEFAULT|activitySet); + } else { + sc.ChangeState(SCE_C_STRING|activitySet); + } + } else { sc.ChangeState(SCE_C_CHARACTER|activitySet); + } } else { sc.SetState(SCE_C_DEFAULT | activitySet); } @@ -1203,7 +1211,7 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, while ((endName < restOfLine.length()) && setWord.Contains(static_cast<unsigned char>(restOfLine[endName]))) endName++; std::string key = restOfLine.substr(startName, endName-startName); - if (restOfLine[endName] == '(') { + if ((endName < restOfLine.length()) && (restOfLine.at(endName) == '(')) { // Macro size_t endArgs = endName; while ((endArgs < restOfLine.length()) && (restOfLine[endArgs] != ')')) @@ -1212,7 +1220,9 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, size_t startValue = endArgs+1; while ((startValue < restOfLine.length()) && IsSpaceOrTab(restOfLine[startValue])) startValue++; - std::string value = restOfLine.substr(startValue); + std::string value; + if (startValue < restOfLine.length()) + value = restOfLine.substr(startValue); preprocessorDefinitions[key] = SymbolValue(value, args); ppDefineHistory.push_back(PPDefinition(lineCurrent, key, value, false, args)); definitionsChanged = true; Modified: scintilla/lexers/LexHTML.cxx 11 lines changed, 5 insertions(+), 6 deletions(-) =================================================================== @@ -576,8 +576,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty WordList &keywords5 = *keywordlists[4]; WordList &keywords6 = *keywordlists[5]; // SGML (DTD) keywords - // Lexer for HTML requires more lexical states (8 bits worth) than most lexers - styler.StartAt(startPos, static_cast<unsigned char>(STYLE_MAX)); + styler.StartAt(startPos); char prevWord[200]; prevWord[0] = '\0'; char phpStringDelimiter[200]; // PHP is not limited in length, we are @@ -609,7 +608,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty if (startPos == 0) state = SCE_H_DEFAULT; } - styler.StartAt(startPos, static_cast<unsigned char>(STYLE_MAX)); + styler.StartAt(startPos); int lineCurrent = styler.GetLine(startPos); int lineState; @@ -2180,6 +2179,6 @@ static const char * const phpscriptWordListDesc[] = { 0, }; -LexerModule lmHTML(SCLEX_HTML, ColouriseHTMLDoc, "hypertext", 0, htmlWordListDesc, 8); -LexerModule lmXML(SCLEX_XML, ColouriseXMLDoc, "xml", 0, htmlWordListDesc, 8); -LexerModule lmPHPSCRIPT(SCLEX_PHPSCRIPT, ColourisePHPScriptDoc, "phpscript", 0, phpscriptWordListDesc, 8); +LexerModule lmHTML(SCLEX_HTML, ColouriseHTMLDoc, "hypertext", 0, htmlWordListDesc); +LexerModule lmXML(SCLEX_XML, ColouriseXMLDoc, "xml", 0, htmlWordListDesc); +LexerModule lmPHPSCRIPT(SCLEX_PHPSCRIPT, ColourisePHPScriptDoc, "phpscript", 0, phpscriptWordListDesc); Modified: scintilla/lexers/LexHaskell.cxx 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -38,9 +38,9 @@ #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" +#include "CharacterCategory.h" #include "LexerModule.h" #include "OptionSet.h" -#include "CharacterCategory.h" #ifdef SCI_NAMESPACE using namespace Scintilla; Modified: scintilla/lexers/LexPerl.cxx 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -1726,4 +1726,4 @@ void SCI_METHOD LexerPerl::Fold(unsigned int startPos, int length, int /* initSt styler.SetLevel(lineCurrent, levelPrev | flagsNext); } -LexerModule lmPerl(SCLEX_PERL, LexerPerl::LexerFactoryPerl, "perl", perlWordListDesc, 8); +LexerModule lmPerl(SCLEX_PERL, LexerPerl::LexerFactoryPerl, "perl", perlWordListDesc); Modified: scintilla/lexers/LexRuby.cxx 5 lines changed, 2 insertions(+), 3 deletions(-) =================================================================== @@ -705,8 +705,7 @@ static void ColouriseRbDoc(unsigned int startPos, int length, int initStyle, char chPrev = styler.SafeGetCharAt(startPos - 1); char chNext = styler.SafeGetCharAt(startPos); bool is_real_number = true; // Differentiate between constants and ?-sequences. - // Ruby uses a different mask because bad indentation is marked by oring with 32 - styler.StartAt(startPos, 127); + styler.StartAt(startPos); styler.StartSegment(startPos); static int q_states[] = {SCE_RB_STRING_Q, @@ -1776,4 +1775,4 @@ static const char * const rubyWordListDesc[] = { 0 }; -LexerModule lmRuby(SCLEX_RUBY, ColouriseRbDoc, "ruby", FoldRbDoc, rubyWordListDesc, 6); +LexerModule lmRuby(SCLEX_RUBY, ColouriseRbDoc, "ruby", FoldRbDoc, rubyWordListDesc); Modified: scintilla/lexers/LexRust.cxx 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -21,6 +21,7 @@ #include "Scintilla.h" #include "SciLexer.h" +#include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" @@ -28,7 +29,6 @@ #include "CharacterSet.h" #include "LexerModule.h" #include "OptionSet.h" -#include "PropSetSimple.h" #ifdef SCI_NAMESPACE using namespace Scintilla; Modified: scintilla/lexers/LexTCL.cxx 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -358,7 +358,7 @@ static const char * const tclWordListDesc[] = { "TK Keywords", "iTCL Keywords", "tkCommands", - "expand" + "expand", "user1", "user2", "user3", Modified: scintilla/lexers/LexVHDL.cxx 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -12,10 +12,10 @@ #include <stdlib.h> #include <string.h> -#include <ctype.h> #include <stdio.h> #include <stdarg.h> #include <assert.h> +#include <ctype.h> #include "ILexer.h" #include "Scintilla.h" Modified: scintilla/lexlib/Accessor.cxx 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -8,9 +8,9 @@ #include <stdlib.h> #include <string.h> #include <stdio.h> -#include <ctype.h> #include <stdarg.h> #include <assert.h> +#include <ctype.h> #include "ILexer.h" #include "Scintilla.h" Modified: scintilla/lexlib/CharacterCategory.cxx 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -3287,7 +3287,7 @@ const int nRanges = ELEMENTS(catRanges); // Initial version has 3249 entries and adds about 13K to the executable. // The array is in ascending order so can be searched using binary search. // Therefore the average call takes log2(3249) = 12 comparisons. -// For speed, it may be an useful to make a linear table for the common values, +// For speed, it may be useful to make a linear table for the common values, // possibly for 0..0xff for most Western European text or 0..0xfff for most // alphabetic languages. Modified: scintilla/lexlib/CharacterSet.cxx 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -9,8 +9,8 @@ #include <stdlib.h> #include <string.h> #include <stdio.h> -#include <ctype.h> #include <assert.h> +#include <ctype.h> #include "CharacterSet.h" Modified: scintilla/lexlib/LexAccessor.h 20 lines changed, 4 insertions(+), 16 deletions(-) =================================================================== @@ -29,11 +29,8 @@ class LexAccessor { int codePage; enum EncodingType encodingType; int lenDoc; - int mask; char styleBuf[bufferSize]; int validLen; - char chFlags; - char chWhile; unsigned int startSeg; int startPosStyling; int documentVersion; @@ -58,7 +55,7 @@ class LexAccessor { codePage(pAccess->CodePage()), encodingType(enc8bit), lenDoc(pAccess->Length()), - mask(127), validLen(0), chFlags(0), chWhile(0), + validLen(0), startSeg(0), startPosStyling(0), documentVersion(pAccess->Version()) { switch (codePage) { @@ -111,7 +108,7 @@ class LexAccessor { return true; } char StyleAt(int position) const { - return static_cast<char>(pAccess->StyleAt(position) & mask); + return static_cast<char>(pAccess->StyleAt(position)); } int GetLine(int position) const { return pAccess->LineFromPosition(position); @@ -152,16 +149,10 @@ class LexAccessor { return pAccess->SetLineState(line, state); } // Style setting - void StartAt(unsigned int start, char chMask=31) { - // Store the mask specified for use with StyleAt. - mask = chMask; - pAccess->StartStyling(start, chMask); + void StartAt(unsigned int start) { + pAccess->StartStyling(start, '\377'); startPosStyling = start; } - void SetFlags(char chFlags_, char chWhile_) { - chFlags = chFlags_; - chWhile = chWhile_; - } unsigned int GetStartSegment() const { return startSeg; } @@ -182,9 +173,6 @@ class LexAccessor { // Too big for buffer so send directly pAccess->SetStyleFor(pos - startSeg + 1, static_cast<char>(chAttr)); } else { - if (chAttr != chWhile) - chFlags = 0; - chAttr = static_cast<char>(chAttr | chFlags); for (unsigned int i = startSeg; i <= pos; i++) { assert((startPosStyling + validLen) < Length()); styleBuf[validLen++] = static_cast<char>(chAttr); Modified: scintilla/lexlib/LexerBase.cxx 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -8,9 +8,9 @@ #include <stdlib.h> #include <string.h> #include <stdio.h> -#include <ctype.h> #include <stdarg.h> #include <assert.h> +#include <ctype.h> #include "ILexer.h" #include "Scintilla.h" Modified: scintilla/lexlib/LexerModule.cxx 14 lines changed, 3 insertions(+), 11 deletions(-) =================================================================== @@ -8,9 +8,9 @@ #include <stdlib.h> #include <string.h> #include <stdio.h> -#include <ctype.h> #include <stdarg.h> #include <assert.h> +#include <ctype.h> #include <string> @@ -34,28 +34,24 @@ LexerModule::LexerModule(int language_, LexerFunction fnLexer_, const char *languageName_, LexerFunction fnFolder_, - const char *const wordListDescriptions_[], - int styleBits_) : + const char *const wordListDescriptions_[]) : language(language_), fnLexer(fnLexer_), fnFolder(fnFolder_), fnFactory(0), wordListDescriptions(wordListDescriptions_), - styleBits(styleBits_), languageName(languageName_) { } LexerModule::LexerModule(int language_, LexerFactoryFunction fnFactory_, const char *languageName_, - const char * const wordListDescriptions_[], - int styleBits_) : + const char * const wordListDescriptions_[]) : language(language_), fnLexer(0), fnFolder(0), fnFactory(fnFactory_), wordListDescriptions(wordListDescriptions_), - styleBits(styleBits_), languageName(languageName_) { } @@ -82,10 +78,6 @@ const char *LexerModule::GetWordListDescription(int index) const { } } -int LexerModule::GetStyleBitsNeeded() const { - return styleBits; -} - ILexer *LexerModule::Create() const { if (fnFactory) return fnFactory(); Modified: scintilla/lexlib/LexerModule.h 9 lines changed, 2 insertions(+), 7 deletions(-) =================================================================== @@ -31,7 +31,6 @@ class LexerModule { LexerFunction fnFolder; LexerFactoryFunction fnFactory; const char * const * wordListDescriptions; - int styleBits; public: const char *languageName; @@ -39,13 +38,11 @@ class LexerModule { LexerFunction fnLexer_, const char *languageName_=0, LexerFunction fnFolder_=0, - const char * const wordListDescriptions_[] = NULL, - int styleBits_=5); + const char * const wordListDescriptions_[] = NULL); LexerModule(int language_, LexerFactoryFunction fnFactory_, const char *languageName_, - const char * const wordListDescriptions_[] = NULL, - int styleBits_=8); + const char * const wordListDescriptions_[] = NULL); virtual ~LexerModule() { } int GetLanguage() const { return language; } @@ -54,8 +51,6 @@ class LexerModule { int GetNumWordLists() const; const char *GetWordListDescription(int index) const; - int GetStyleBitsNeeded() const; - ILexer *Create() const; virtual void Lex(unsigned int startPos, int length, int initStyle, Modified: scintilla/lexlib/LexerNoExceptions.cxx 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -8,9 +8,9 @@ #include <stdlib.h> #include <string.h> #include <stdio.h> -#include <ctype.h> #include <stdarg.h> #include <assert.h> +#include <ctype.h> #include "ILexer.h" #include "Scintilla.h" Modified: scintilla/lexlib/LexerSimple.cxx 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -8,9 +8,9 @@ #include <stdlib.h> #include <string.h> #include <stdio.h> -#include <ctype.h> #include <stdarg.h> #include <assert.h> +#include <ctype.h> #include <string> Modified: scintilla/lexlib/StyleContext.cxx 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -8,8 +8,8 @@ #include <stdlib.h> #include <string.h> #include <stdio.h> -#include <ctype.h> #include <assert.h> +#include <ctype.h> #include "ILexer.h" Modified: scintilla/lexlib/StyleContext.h 4 lines changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -66,7 +66,7 @@ class StyleContext { int widthNext; StyleContext(unsigned int startPos, unsigned int length, - int initStyle, LexAccessor &styler_, char chMask=31) : + int initStyle, LexAccessor &styler_, char chMask='\377') : styler(styler_), multiByteAccess(0), endPos(startPos + length), @@ -86,7 +86,7 @@ class StyleContext { if (styler.Encoding() != enc8bit) { multiByteAccess = styler.MultiByteAccess(); } - styler.StartAt(startPos, chMask); + styler.StartAt(startPos /*, chMask*/); styler.StartSegment(startPos); currentLine = styler.GetLine(startPos); lineStartNext = styler.LineStart(currentLine+1); Modified: scintilla/lexlib/WordList.cxx 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -8,8 +8,8 @@ #include <stdlib.h> #include <string.h> #include <stdio.h> -#include <ctype.h> #include <stdarg.h> +#include <ctype.h> #include <algorithm> Modified: scintilla/src/CaseFolder.cxx 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -8,9 +8,9 @@ #include <vector> #include <algorithm> +#include "CaseFolder.h" #include "CaseConvert.h" #include "UniConversion.h" -#include "CaseFolder.h" #ifdef SCI_NAMESPACE using namespace Scintilla; Modified: scintilla/src/Catalogue.cxx 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -8,9 +8,9 @@ #include <stdlib.h> #include <string.h> #include <stdio.h> -#include <ctype.h> #include <stdarg.h> #include <assert.h> +#include <ctype.h> #include <vector> Modified: scintilla/src/CellBuffer.cxx 13 lines changed, 6 insertions(+), 7 deletions(-) =================================================================== @@ -413,25 +413,24 @@ const char *CellBuffer::InsertString(int position, const char *s, int insertLeng return data; } -bool CellBuffer::SetStyleAt(int position, char styleValue, char mask) { - styleValue &= mask; +bool CellBuffer::SetStyleAt(int position, char styleValue) { char curVal = style.ValueAt(position); - if ((curVal & mask) != styleValue) { - style.SetValueAt(position, static_cast<char>((curVal & ~mask) | styleValue)); + if (curVal != styleValue) { + style.SetValueAt(position, styleValue); return true; } else { return false; } } -bool CellBuffer::SetStyleFor(int position, int lengthStyle, char styleValue, char mask) { +bool CellBuffer::SetStyleFor(int position, int lengthStyle, char styleValue) { bool changed = false; PLATFORM_ASSERT(lengthStyle == 0 || (lengthStyle > 0 && lengthStyle + position <= style.Length())); while (lengthStyle--) { char curVal = style.ValueAt(position); - if ((curVal & mask) != styleValue) { - style.SetValueAt(position, static_cast<char>((curVal & ~mask) | styleValue)); + if (curVal != styleValue) { + style.SetValueAt(position, styleValue); changed = true; } position++; Modified: scintilla/src/CellBuffer.h 4 lines changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -180,8 +180,8 @@ class CellBuffer { /// Setting styles for positions outside the range of the buffer is safe and has no effect. /// @return true if the style of a character is changed. - bool SetStyleAt(int position, char styleValue, char mask='\377'); - bool SetStyleFor(int position, int length, char styleValue, char mask); + bool SetStyleAt(int position, char styleValue); + bool SetStyleFor(int position, int length, char styleValue); const char *DeleteChars(int position, int deleteLength, bool &startSequence); Modified: scintilla/src/Document.cxx 26 lines changed, 8 insertions(+), 18 deletions(-) =================================================================== @@ -8,8 +8,8 @@ #include <stdlib.h> #include <string.h> #include <stdio.h> -#include <ctype.h> #include <assert.h> +#include <ctype.h> #include <string> #include <vector> @@ -20,13 +20,13 @@ #include "ILexer.h" #include "Scintilla.h" +#include "CharacterSet.h" #include "SplitVector.h" #include "Partitioning.h" #include "RunStyles.h" #include "CellBuffer.h" #include "PerLine.h" #include "CharClassify.h" -#include "CharacterSet.h" #include "Decoration.h" #include "CaseFolder.h" #include "Document.h" @@ -58,7 +58,7 @@ void LexInterface::Colourise(int start, int end) { int styleStart = 0; if (start > 0) - styleStart = pdoc->StyleAt(start - 1) & pdoc->stylingBitsMask; + styleStart = pdoc->StyleAt(start - 1); if (len > 0) { instance->Lex(start, len, styleStart, pdoc); @@ -90,9 +90,6 @@ Document::Document() { #endif dbcsCodePage = 0; lineEndBitSet = SC_LINE_END_TYPE_DEFAULT; - stylingBits = 5; - stylingBitsMask = 0x1F; - stylingMask = 0; endStyled = 0; styleClock = 0; enteredModification = 0; @@ -1712,13 +1709,7 @@ int Document::GetCharsOfClass(CharClassify::cc characterClass, unsigned char *bu return charClass.GetCharsOfClass(characterClass, buffer); } -void Document::SetStylingBits(int bits) { - stylingBits = bits; - stylingBitsMask = (1 << stylingBits) - 1; -} - -void SCI_METHOD Document::StartStyling(int position, char mask) { - stylingMask = mask; +void SCI_METHOD Document::StartStyling(int position, char) { endStyled = position; } @@ -1727,9 +1718,8 @@ bool SCI_METHOD Document::SetStyleFor(int length, char style) { return false; } else { enteredStyling++; - style &= stylingMask; int prevEndStyled = endStyled; - if (cb.SetStyleFor(endStyled, length, style, stylingMask)) { + if (cb.SetStyleFor(endStyled, length, style)) { DocModification mh(SC_MOD_CHANGESTYLE | SC_PERFORMED_USER, prevEndStyled, length); NotifyModified(mh); @@ -1750,7 +1740,7 @@ bool SCI_METHOD Document::SetStyles(int length, const char *styles) { int endMod = 0; for (int iPos = 0; iPos < length; iPos++, endStyled++) { PLATFORM_ASSERT(endStyled < Length()); - if (cb.SetStyleAt(endStyled, styles[iPos], stylingMask)) { + if (cb.SetStyleAt(endStyled, styles[iPos])) { if (!didChange) { startMod = endStyled; } @@ -2080,7 +2070,7 @@ int Document::BraceMatch(int position, int /*maxReStyle*/) { char chSeek = BraceOpposite(chBrace); if (chSeek == '\0') return - 1; - char styBrace = static_cast<char>(StyleAt(position) & stylingBitsMask); + char styBrace = static_cast<char>(StyleAt(position)); int direction = -1; if (chBrace == '(' || chBrace == '[' || chBrace == '{' || chBrace == '<') direction = 1; @@ -2088,7 +2078,7 @@ int Document::BraceMatch(int position, int /*maxReStyle*/) { position = NextPosition(position, direction); while ((position >= 0) && (position < Length())) { char chAtPos = CharAt(position); - char styAtPos = static_cast<char>(StyleAt(position) & stylingBitsMask); + char styAtPos = static_cast<char>(StyleAt(position)); if ((position > GetEndStyled()) || (styAtPos == styBrace)) { if (chAtPos == chBrace) depth++; Modified: scintilla/src/Document.h 9 lines changed, 4 insertions(+), 5 deletions(-) =================================================================== @@ -39,6 +39,10 @@ class Range { start(start_), end(end_) { } + bool operator==(const Range &other) const { + return (start == other.start) && (end == other.end); + } + bool Valid() const { return (start != invalidPosition) && (end != invalidPosition); } @@ -206,7 +210,6 @@ class Document : PerLine, public IDocumentWithLineEnd, public ILoader { CellBuffer cb; CharClassify charClass; CaseFolder *pcf; - char stylingMask; int endStyled; int styleClock; int enteredModification; @@ -229,9 +232,6 @@ class Document : PerLine, public IDocumentWithLineEnd, public ILoader { LexInterface *pli; - int stylingBits; - int stylingBitsMask; - int eolMode; /// Can also be SC_CP_UTF8 to enable UTF-8 mode int dbcsCodePage; @@ -369,7 +369,6 @@ class Document : PerLine, public IDocumentWithLineEnd, public ILoader { void SetDefaultCharClasses(bool includeWordClass); void SetCharClasses(const unsigned char *chars, CharClassify::cc newCharClass); int GetCharsOfClass(CharClassify::cc charClass, unsigned char *buffer); - void SetStylingBits(int bits); void SCI_METHOD StartStyling(int position, char mask); bool SCI_METHOD SetStyleFor(int length, char style); bool SCI_METHOD SetStyles(int length, const char *styles); Modified: scintilla/src/Editor.cxx 343 lines changed, 128 insertions(+), 215 deletions(-) =================================================================== @@ -8,9 +8,9 @@ #include <stdlib.h> #include <string.h> #include <stdio.h> -#include <ctype.h> #include <math.h> #include <assert.h> +#include <ctype.h> #include <string> #include <vector> @@ -220,8 +220,7 @@ Editor::Editor() { convertPastes = true; - hsStart = -1; - hsEnd = -1; + hotspot = Range(invalidPosition); llc.SetLevel(LineLayoutCache::llcCaret); posCache.SetSize(0x400); @@ -885,9 +884,8 @@ bool Editor::RangeContainsProtected(int start, int end) const { start = end; end = t; } - int mask = pdoc->stylingBitsMask; for (int pos = start; pos < end; pos++) { - if (vs.styles[pdoc->StyleAt(pos) & mask].IsProtected()) + if (vs.styles[pdoc->StyleAt(pos)].IsProtected()) return true; } } @@ -916,17 +914,16 @@ SelectionPosition Editor::MovePositionOutsideChar(SelectionPosition pos, int mov if (posMoved != pos.Position()) pos.SetPosition(posMoved); if (vs.ProtectionActive()) { - int mask = pdoc->stylingBitsMask; if (moveDir > 0) { - if ((pos.Position() > 0) && vs.styles[pdoc->StyleAt(pos.Position() - 1) & mask].IsProtected()) { + if ((pos.Position() > 0) && vs.styles[pdoc->StyleAt(pos.Position() - 1)].IsProtected()) { while ((pos.Position() < pdoc->Length()) && - (vs.styles[pdoc->StyleAt(pos.Position()) & mask].IsProtected())) + (vs.styles[pdoc->StyleAt(pos.Position())].IsProtected())) pos.Add(1); } } else if (moveDir < 0) { - if (vs.styles[pdoc->StyleAt(pos.Position()) & mask].IsProtected()) { + if (vs.styles[pdoc->StyleAt(pos.Position())].IsProtected()) { while ((pos.Position() > 0) && - (vs.styles[pdoc->StyleAt(pos.Position() - 1) & mask].IsProtected())) + (vs.styles[pdoc->StyleAt(pos.Position() - 1)].IsProtected())) pos.Add(-1); } } @@ -1741,7 +1738,7 @@ int Editor::SubstituteMarkerIfEmpty(int markerCheck, int markerDefault) const { return markerCheck; } -bool ValidStyledText(ViewStyle &vs, size_t styleOffset, const StyledText &st) { +bool ValidStyledText(const ViewStyle &vs, size_t styleOffset, const StyledText &st) { if (st.multipleStyles) { for (size_t iStyle=0; iStyle<st.length; iStyle++) { if (!vs.ValidStyle(styleOffset + st.styles[iStyle])) @@ -1754,7 +1751,7 @@ bool ValidStyledText(ViewStyle &vs, size_t styleOffset, const StyledText &st) { return true; } -static int WidthStyledText(Surface *surface, ViewStyle &vs, int styleOffset, +static int WidthStyledText(Surface *surface, const ViewStyle &vs, int styleOffset, const char *text, const unsigned char *styles, size_t len) { int width = 0; size_t start = 0; @@ -1763,14 +1760,15 @@ static int WidthStyledText(Surface *surface, ViewStyle &vs, int styleOffset, size_t endSegment = start; while ((endSegment+1 < len) && (static_cast<size_t>(styles[endSegment+1]) == style)) endSegment++; - width += static_cast<int>(surface->WidthText(vs.styles[style + styleOffset].font, text + start, + FontAlias fontText = vs.styles[style + styleOffset].font; + width += static_cast<int>(surface->WidthText(fontText, text + start, static_cast<int>(endSegment - start + 1))); start = endSegment + 1; } return width; } -static int WidestLineWidth(Surface *surface, ViewStyle &vs, int styleOffset, const StyledText &st) { +static int WidestLineWidth(Surface *surface, const ViewStyle &vs, int styleOffset, const StyledText &st) { int widthMax = 0; size_t start = 0; while (start < st.length) { @@ -1779,7 +1777,8 @@ static int WidestLineWidth(Surface *surface, ViewStyle &vs, int styleOffset, con if (st.multipleStyles) { widthSubLine = WidthStyledText(surface, vs, styleOffset, st.text + start, st.styles + start, lenLine); } else { - widthSubLine = static_cast<int>(surface->WidthText(vs.styles[styleOffset + st.style].font, + FontAlias fontText = vs.styles[styleOffset + st.style].font; + widthSubLine = static_cast<int>(surface->WidthText(fontText, st.text + start, static_cast<int>(lenLine))); } if (widthSubLine > widthMax) @@ -1789,7 +1788,13 @@ static int WidestLineWidth(Surface *surface, ViewStyle &vs, int styleOffset, con return widthMax; } -void DrawStyledText(Surface *surface, ViewStyle &vs, int styleOffset, PRectangle rcText, int ascent, +static void DrawTextInStyle(Surface *surface, PRectangle rcText, const Style &style, XYPOSITION ybase, const char *s, size_t length) { + FontAlias fontText = style.font; + surface->DrawTextNoClip(rcText, fontText, ybase, s, static_cast<int>(length), + style.fore, style.back); +} + +static void DrawStyledText(Surface *surface, const ViewStyle &vs, int styleOffset, PRectangle rcText, const StyledText &st, size_t start, size_t length) { if (st.multipleStyles) { @@ -1797,30 +1802,25 @@ void DrawStyledText(Surface *surface, ViewStyle &vs, int styleOffset, PRectangle size_t i = 0; while (i < length) { size_t end = i; - int style = st.styles[i + start]; + size_t style = st.styles[i + start]; while (end < length-1 && st.styles[start+end+1] == style) end++; style += styleOffset; - int width = static_cast<int>(surface->WidthText(vs.styles[style].font, + FontAlias fontText = vs.styles[style].font; + const int width = static_cast<int>(surface->WidthText(fontText, st.text + start + i, static_cast<int>(end - i + 1))); PRectangle rcSegment = rcText; rcSegment.left = static_cast<XYPOSITION>(x); rcSegment.right = static_cast<XYPOSITION>(x + width + 1); - surface->DrawTextNoClip(rcSegment, vs.styles[style].font, - static_cast<XYPOSITION>(ascent), st.text + start + i, - static_cast<int>(end - i + 1), - vs.styles[style].fore, - vs.styles[style].back); + DrawTextInStyle(surface, rcSegment, vs.styles[style], rcText.top + vs.maxAscent, + st.text + start + i, end - i + 1); x += width; i = end + 1; } } else { - size_t style = st.style + styleOffset; - surface->DrawTextNoClip(rcText, vs.styles[style].font, - rcText.top + vs.maxAscent, st.text + start, - static_cast<int>(length), - vs.styles[style].fore, - vs.styles[style].back); + const size_t style = st.style + styleOffset; + DrawTextInStyle(surface, rcText, vs.styles[style], rcText.top + vs.maxAscent, + st.text + start, length); } } @@ -1832,6 +1832,13 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { RefreshStyleData(); RefreshPixMaps(surfWindow); + // On GTK+ with Ubuntu overlay scroll bars, the surface may have been finished + // at this point. The Initialised call checks for this case and sets the status + // to be bad which avoids crashes in following calls. + if (!surfWindow->Initialised()) { + return; + } + PRectangle rcMargin = GetClientRectangle(); Point ptOrigin = GetVisibleOriginInMain(); rcMargin.Move(0, -ptOrigin.y); @@ -2057,10 +2064,8 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { XYPOSITION width = surface->WidthText(vs.styles[STYLE_LINENUMBER].font, number, istrlen(number)); XYPOSITION xpos = rcNumber.right - width - vs.marginNumberPadding; rcNumber.left = xpos; - surface->DrawTextNoClip(rcNumber, vs.styles[STYLE_LINENUMBER].font, - rcNumber.top + vs.maxAscent, number, istrlen(number), - vs.styles[STYLE_LINENUMBER].fore, - vs.styles[STYLE_LINENUMBER].back); + DrawTextInStyle(surface, rcNumber, vs.styles[STYLE_LINENUMBER], + rcNumber.top + vs.maxAscent, number, strlen(number)); } else if (vs.wrapVisualFlags & SC_WRAPVISUALFLAG_MARGIN) { PRectangle rcWrapMarker = rcMarker; rcWrapMarker.right -= 3; @@ -2077,7 +2082,7 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { int width = WidestLineWidth(surface, vs, vs.marginStyleOffset, stMargin); rcMarker.left = rcMarker.right - width - 3; } - DrawStyledText(surface, vs, vs.marginStyleOffset, rcMarker, static_cast<int>(rcMarker.top) + vs.maxAscent, + DrawStyledText(surface, vs, vs.marginStyleOffset, rcMarker, stMargin, 0, stMargin.length); } } @@ -2157,8 +2162,7 @@ LineLayout *Editor::RetrieveLineLayout(int lineNumber) { * Copy the given @a line and its styles from the document into local arrays. * Also determine the x position at which each character starts. */ -void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll, int width) { -//void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll, int width, Document *pdoc, PositionCache &posCache, SpecialRepresentations &reprs) { +void Editor::LayoutLine(int line, Surface *surface, const ViewStyle &vstyle, LineLayout *ll, int width) { if (!ll) return; @@ -2178,7 +2182,6 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou if (lineLength == ll->numCharsInLine) { // See if chars, styles, indicators, are all the same bool allSame = true; - const int styleMask = pdoc->stylingBitsMask; // Check base line layout char styleByte = 0; int numCharsInLine = 0; @@ -2187,9 +2190,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou char chDoc = pdoc->CharAt(charInDoc); styleByte = pdoc->StyleAt(charInDoc); allSame = allSame && - (ll->styles[numCharsInLine] == static_cast<unsigned char>(styleByte & styleMask)); - allSame = allSame && - (ll->indicators[numCharsInLine] == static_cast<char>(styleByte & ~styleMask)); + (ll->styles[numCharsInLine] == static_cast<unsigned char>(styleByte)); if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseMixed) allSame = allSame && (ll->chars[numCharsInLine] == chDoc); @@ -2223,8 +2224,6 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou ll->edgeColumn = -1; } - const int styleMask = pdoc->stylingBitsMask; - ll->styleBitsSet = 0; // Fill base line layout const int lineLength = posLineEnd - posLineStart; pdoc->GetCharRange(ll->chars, posLineStart, lineLength); @@ -2233,11 +2232,9 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou const int numCharsInLine = (vstyle.viewEOL) ? lineLength : numCharsBeforeEOL; for (int styleInLine = 0; styleInLine < numCharsInLine; styleInLine++) { const unsigned char styleByte = ll->styles[styleInLine]; - ll->styleBitsSet |= styleByte; - ll->styles[styleInLine] = styleByte & styleMask; - ll->indicators[styleInLine] = static_cast<char>(styleByte & ~styleMask); + ll->styles[styleInLine] = styleByte; } - const unsigned char styleByteLast = ((lineLength > 0) ? ll->styles[lineLength-1] : 0) & styleMask; + const unsigned char styleByteLast = (lineLength > 0) ? ll->styles[lineLength-1] : 0; if (vstyle.someStylesForceCase) { for (int charInLine = 0; charInLine<lineLength; charInLine++) { char chDoc = ll->chars[charInLine]; @@ -2251,14 +2248,13 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou // Extra element at the end of the line to hold end x position and act as ll->chars[numCharsInLine] = 0; // Also triggers processing in the loops as this is a control character ll->styles[numCharsInLine] = styleByteLast; // For eolFilled - ll->indicators[numCharsInLine] = 0; // Layout the line, determining the position of each character, // with an extra element at the end for the end of the line. ll->positions[0] = 0; bool lastSegItalics = false; - BreakFinder bfLayout(ll, 0, numCharsInLine, posLineStart, 0, false, pdoc, &reprs); + BreakFinder bfLayout(ll, NULL, 0, numCharsInLine, posLineStart, 0, false, pdoc, &reprs); while (bfLayout.More()) { const TextSegment ts = bfLayout.Next(); @@ -2390,14 +2386,14 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou } } -ColourDesired Editor::SelectionBackground(ViewStyle &vsDraw, bool main) const { +ColourDesired Editor::SelectionBackground(const ViewStyle &vsDraw, bool main) const { return main ? (primarySelection ? vsDraw.selColours.back : vsDraw.selBackground2) : vsDraw.selAdditionalBackground; } -ColourDesired Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground, - ColourDesired background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) const { +ColourDesired Editor::TextBackground(const ViewStyle &vsDraw, + ColourOptional background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) const { if (inSelection == 1) { if (vsDraw.selColours.back.isSet && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) { return SelectionBackground(vsDraw, true); @@ -2414,7 +2410,7 @@ ColourDesired Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground, if (inHotspot && vsDraw.hotspotColours.back.isSet) return vsDraw.hotspotColours.back; } - if (overrideBackground && (styleMain != STYLE_BRACELIGHT) && (styleMain != STYLE_BRACEBAD)) { + if (background.isSet && (styleMain != STYLE_BRACELIGHT) && (styleMain != STYLE_BRACEBAD)) { return background; } else { return vsDraw.styles[styleMain].back; @@ -2478,12 +2474,12 @@ static void SimpleAlphaRectangle(Surface *surface, PRectangle rc, ColourDesired } } -void DrawTextBlob(Surface *surface, ViewStyle &vsDraw, PRectangle rcSegment, +void DrawTextBlob(Surface *surface, const ViewStyle &vsDraw, PRectangle rcSegment, const char *s, ColourDesired textBack, ColourDesired textFore, bool twoPhaseDraw) { if (!twoPhaseDraw) { surface->FillRectangle(rcSegment, textBack); } - Font &ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; + FontAlias ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; int normalCharHeight = static_cast<int>(surface->Ascent(ctrlCharsFont) - surface->InternalLeading(ctrlCharsFont)); PRectangle rcCChar = rcSegment; @@ -2502,13 +2498,11 @@ void DrawTextBlob(Surface *surface, ViewStyle &vsDraw, PRectangle rcSegment, textBack, textFore); } -void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll, +void Editor::DrawEOL(Surface *surface, const ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll, int line, int lineEnd, int xStart, int subLine, XYACCUMULATOR subLineStart, - bool overrideBackground, ColourDesired background, - bool drawWrapMarkEnd, ColourDesired wrapColour) { + ColourOptional background) { const int posLineStart = pdoc->LineStart(line); - const int styleMask = pdoc->stylingBitsMask; PRectangle rcSegment = rcLine; const bool lastSubLine = subLine == (ll->lines - 1); @@ -2523,7 +2517,7 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin if (virtualSpace) { rcSegment.left = xEol + xStart; rcSegment.right = xEol + xStart + virtualSpace; - surface->FillRectangle(rcSegment, overrideBackground ? background : vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back); + surface->FillRectangle(rcSegment, background.isSet ? background : vsDraw.styles[ll->styles[ll->numCharsInLine]].back); if (!hideSelection && ((vsDraw.selAlpha == SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA))) { SelectionSegment virtualSpaceRange(SelectionPosition(pdoc->LineEnd(line)), SelectionPosition(pdoc->LineEnd(line), sel.VirtualSpaceFor(pdoc->LineEnd(line)))); for (size_t r=0; r<sel.Count(); r++) { @@ -2564,11 +2558,11 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin const char *ctrlChar; unsigned char chEOL = ll->chars[eolPos]; int styleMain = ll->styles[eolPos]; - ColourDesired textBack = TextBackground(vsDraw, overrideBackground, background, eolInSelection, false, styleMain, eolPos, ll); + ColourDesired textBack = TextBackground(vsDraw, background, eolInSelection, false, styleMain, eolPos, ll); if (UTF8IsAscii(chEOL)) { ctrlChar = ControlCharacterString(chEOL); } else { - Representation *repr = reprs.RepresentationFromCharacter(ll->chars + eolPos, ll->numCharsInLine - eolPos); + const Representation *repr = reprs.RepresentationFromCharacter(ll->chars + eolPos, ll->numCharsInLine - eolPos); if (repr) { ctrlChar = repr->stringRep.c_str(); eolPos = ll->numCharsInLine; @@ -2604,12 +2598,12 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin if (eolInSelection && vsDraw.selColours.back.isSet && (line < pdoc->LinesTotal() - 1) && (alpha == SC_ALPHA_NOALPHA)) { surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, eolInSelection == 1)); } else { - if (overrideBackground) { + if (background.isSet) { surface->FillRectangle(rcSegment, background); } else if (line < pdoc->LinesTotal() - 1) { - surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back); - } else if (vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].eolFilled) { - surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back); + surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine]].back); + } else if (vsDraw.styles[ll->styles[ll->numCharsInLine]].eolFilled) { + surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine]].back); } else { surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back); } @@ -2627,10 +2621,10 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin if (eolInSelection && vsDraw.selEOLFilled && vsDraw.selColours.back.isSet && (line < pdoc->LinesTotal() - 1) && (alpha == SC_ALPHA_NOALPHA)) { surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, eolInSelection == 1)); } else { - if (overrideBackground) { + if (background.isSet) { surface->FillRectangle(rcSegment, background); - } else if (vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].eolFilled) { - surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back); + } else if (vsDraw.styles[ll->styles[ll->numCharsInLine]].eolFilled) { + surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine]].back); } else { surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back); } @@ -2639,6 +2633,14 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin } } + bool drawWrapMarkEnd = false; + + if (vsDraw.wrapVisualFlags & SC_WRAPVISUALFLAG_END) { + if (subLine + 1 < ll->lines) { + drawWrapMarkEnd = ll->LineStart(subLine + 1) != 0; + } + } + if (drawWrapMarkEnd) { PRectangle rcPlace = rcSegment; @@ -2650,11 +2652,11 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin rcPlace.right = rcLine.right; rcPlace.left = rcPlace.right - vsDraw.aveCharWidth; } - DrawWrapMarker(surface, rcPlace, true, wrapColour); + DrawWrapMarker(surface, rcPlace, true, vsDraw.WrapColour()); } } -void Editor::DrawIndicator(int indicNum, int startPos, int endPos, Surface *surface, ViewStyle &vsDraw, +void Editor::DrawIndicator(int indicNum, int startPos, int endPos, Surface *surface, const ViewStyle &vsDraw, int xStart, PRectangle rcLine, LineLayout *ll, int subLine) { const XYPOSITION subLineStart = ll->positions[ll->LineStart(subLine)]; PRectangle rcIndic( @@ -2665,45 +2667,13 @@ void Editor::DrawIndicator(int indicNum, int startPos, int endPos, Surface *surf vsDraw.indicators[indicNum].Draw(surface, rcIndic, rcLine); } -void Editor::DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int xStart, +void Editor::DrawIndicators(Surface *surface, const ViewStyle &vsDraw, int line, int xStart, PRectangle rcLine, LineLayout *ll, int subLine, int lineEnd, bool under) { // Draw decorators const int posLineStart = pdoc->LineStart(line); const int lineStart = ll->LineStart(subLine); const int posLineEnd = posLineStart + lineEnd; - if (!under) { - // Draw indicators - // foreach indicator... - for (int indicnum = 0, mask = 1 << pdoc->stylingBits; mask < 0x100; indicnum++) { - if (!(mask & ll->styleBitsSet)) { - mask <<= 1; - continue; - } - int startPos = -1; - // foreach style pos in line... - for (int indicPos = lineStart; indicPos <= lineEnd; indicPos++) { - // look for starts... - if (startPos < 0) { - // NOT in indicator run, looking for START - if (indicPos < lineEnd && (ll->indicators[indicPos] & mask)) - startPos = indicPos; - } - // ... or ends - if (startPos >= 0) { - // IN indicator run, looking for END - if (indicPos >= lineEnd || !(ll->indicators[indicPos] & mask)) { - // AT end of indicator run, DRAW it! - DrawIndicator(indicnum, startPos, indicPos, surface, vsDraw, xStart, rcLine, ll, subLine); - // RESET control var - startPos = -1; - } - } - } - mask <<= 1; - } - } - for (Decoration *deco = pdoc->decorations.root; deco; deco = deco->next) { if (under == vsDraw.indicators[deco->indicator].under) { int startPos = posLineStart + lineStart; @@ -2725,9 +2695,9 @@ void Editor::DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int x } // Use indicators to highlight matching braces - if ((vs.braceHighlightIndicatorSet && (bracesMatchStyle == STYLE_BRACELIGHT)) || - (vs.braceBadLightIndicatorSet && (bracesMatchStyle == STYLE_BRACEBAD))) { - int braceIndicator = (bracesMatchStyle == STYLE_BRACELIGHT) ? vs.braceHighlightIndicator : vs.braceBadLightIndicator; + if ((vsDraw.braceHighlightIndicatorSet && (bracesMatchStyle == STYLE_BRACELIGHT)) || + (vsDraw.braceBadLightIndicatorSet && (bracesMatchStyle == STYLE_BRACEBAD))) { + int braceIndicator = (bracesMatchStyle == STYLE_BRACELIGHT) ? vsDraw.braceHighlightIndicator : vsDraw.braceBadLightIndicator; if (under == vsDraw.indicators[braceIndicator].under) { Range rangeLine(posLineStart + lineStart, posLineEnd); if (rangeLine.ContainsCharacter(braces[0])) { @@ -2746,7 +2716,7 @@ void Editor::DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int x } } -void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int xStart, +void Editor::DrawAnnotation(Surface *surface, const ViewStyle &vsDraw, int line, int xStart, PRectangle rcLine, LineLayout *ll, int subLine) { int indent = static_cast<int>(pdoc->GetLineIndentation(line) * vsDraw.spaceWidth); PRectangle rcSegment = rcLine; @@ -2755,15 +2725,15 @@ void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int x if (stAnnotation.text && ValidStyledText(vsDraw, vsDraw.annotationStyleOffset, stAnnotation)) { surface->FillRectangle(rcSegment, vsDraw.styles[0].back); rcSegment.left = static_cast<XYPOSITION>(xStart); - if (trackLineWidth || (vs.annotationVisible == ANNOTATION_BOXED)) { + if (trackLineWidth || (vsDraw.annotationVisible == ANNOTATION_BOXED)) { // Only care about calculating width if tracking or need to draw box int widthAnnotation = WidestLineWidth(surface, vsDraw, vsDraw.annotationStyleOffset, stAnnotation); - if (vs.annotationVisible == ANNOTATION_BOXED) { + if (vsDraw.annotationVisible == ANNOTATION_BOXED) { widthAnnotation += static_cast<int>(vsDraw.spaceWidth * 2); // Margins } if (widthAnnotation > lineWidthMaxSeen) lineWidthMaxSeen = widthAnnotation; - if (vs.annotationVisible == ANNOTATION_BOXED) { + if (vsDraw.annotationVisible == ANNOTATION_BOXED) { rcSegment.left = static_cast<XYPOSITION>(xStart + indent); rcSegment.right = rcSegment.left + widthAnnotation; } @@ -2778,14 +2748,14 @@ void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int x lineInAnnotation++; } PRectangle rcText = rcSegment; - if (vs.annotationVisible == ANNOTATION_BOXED) { + if (vsDraw.annotationVisible == ANNOTATION_BOXED) { surface->FillRectangle(rcText, vsDraw.styles[stAnnotation.StyleAt(start) + vsDraw.annotationStyleOffset].back); rcText.left += vsDraw.spaceWidth; } - DrawStyledText(surface, vsDraw, vsDraw.annotationStyleOffset, rcText, static_cast<int>(rcText.top + vsDraw.maxAscent), + DrawStyledText(surface, vsDraw, vsDraw.annotationStyleOffset, rcText, stAnnotation, start, lengthAnnotation); - if (vs.annotationVisible == ANNOTATION_BOXED) { + if (vsDraw.annotationVisible == ANNOTATION_BOXED) { surface->PenColour(vsDraw.styles[vsDraw.annotationStyleOffset].fore); surface->MoveTo(static_cast<int>(rcSegment.left), static_cast<int>(rcSegment.top)); surface->LineTo(static_cast<int>(rcSegment.left), static_cast<int>(rcSegment.bottom)); @@ -2803,7 +2773,7 @@ void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int x } } -void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart, +void Editor::DrawLine(Surface *surface, const ViewStyle &vsDraw, int line, int lineVisible, int xStart, PRectangle rcLine, LineLayout *ll, int subLine) { if (subLine >= ll->lines) { @@ -2816,49 +2786,13 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis // Using one font for all control characters so it can be controlled independently to ensure // the box goes around the characters tightly. Seems to be no way to work out what height // is taken by an individual character - internal leading gives varying results. - Font &ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; - - // See if something overrides the line background color: Either if caret is on the line - // and background color is set for that, or if a marker is defined that forces its background - // color onto the line, or if a marker is defined but has no selection margin in which to - // display itself (as long as it's not an SC_MARK_EMPTY marker). These are checked in order - // with the earlier taking precedence. When multiple markers cause background override, - // the color for the highest numbered one is used. - bool overrideBackground = false; - ColourDesired background; - if ((caret.active || vsDraw.alwaysShowCaretLineBackground) && vsDraw.showCaretLineBackground && (vsDraw.caretLineAlpha == SC_ALPHA_NOALPHA) && ll->containsCaret) { - overrideBackground = true; - background = vsDraw.caretLineBackground; - } - if (!overrideBackground) { - int marks = pdoc->GetMark(line); - for (int markBit = 0; (markBit < 32) && marks; markBit++) { - if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND) && - (vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) { - background = vsDraw.markers[markBit].back; - overrideBackground = true; - } - marks >>= 1; - } - } - if (!overrideBackground) { - if (vsDraw.maskInLine) { - int marksMasked = pdoc->GetMark(line) & vsDraw.maskInLine; - if (marksMasked) { - for (int markBit = 0; (markBit < 32) && marksMasked; markBit++) { - if ((marksMasked & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY) && - (vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) { - overrideBackground = true; - background = vsDraw.markers[markBit].back; - } - marksMasked >>= 1; - } - } - } - } + FontAlias ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; + + // See if something overrides the line background color. + const ColourOptional background = vsDraw.Background(pdoc->GetMark(line), caret.active, ll->containsCaret); const bool drawWhitespaceBackground = (vsDraw.viewWhitespace != wsInvisible) && - (!overrideBackground) && (vsDraw.whitespaceColours.back.isSet); + (!background.isSet) && (vsDraw.whitespaceColours.back.isSet); bool inIndentation = subLine == 0; // Do not handle indentation except on first subline. const XYPOSITION indentWidth = pdoc->IndentSize() * vsDraw.spaceWidth; @@ -2878,16 +2812,6 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis } } - const ColourDesired wrapColour = vsDraw.WrapColour(); - - bool drawWrapMarkEnd = false; - - if (vsDraw.wrapVisualFlags & SC_WRAPVISUALFLAG_END) { - if (subLine + 1 < ll->lines) { - drawWrapMarkEnd = ll->LineStart(subLine + 1) != 0; - } - } - if (ll->wrapIndent != 0) { bool continuedWrapLine = false; @@ -2903,7 +2827,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis rcPlace.right = rcPlace.left + ll->wrapIndent; // default bgnd here.. - surface->FillRectangle(rcSegment, overrideBackground ? background : + surface->FillRectangle(rcSegment, background.isSet ? background : vsDraw.styles[STYLE_DEFAULT].back); // main line style would be below but this would be inconsistent with end markers @@ -2918,7 +2842,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis else rcPlace.right = rcPlace.left + vsDraw.aveCharWidth; - DrawWrapMarker(surface, rcPlace, false, wrapColour); + DrawWrapMarker(surface, rcPlace, false, vsDraw.WrapColour()); } xStart += static_cast<int>(ll->wrapIndent); @@ -2931,10 +2855,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis // Does not take margin into account but not significant const int xStartVisible = static_cast<int>(subLineStart) - xStart; - ll->psel = &sel; - if (twoPhaseDraw) { - BreakFinder bfBack(ll, lineStart, lineEnd, posLineStart, xStartVisible, selBackDrawn, pdoc, &reprs); + BreakFinder bfBack(ll, &sel, lineStart, lineEnd, posLineStart, xStartVisible, selBackDrawn, pdoc, &reprs); // Background drawing loop while (bfBack.More()) { @@ -2955,8 +2877,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis rcSegment.right = rcLine.right; const int inSelection = hideSelection ? 0 : sel.CharacterInSelection(iDoc); - const bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd); - ColourDesired textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, + const bool inHotspot = (ll->hotspot.Valid()) && ll->hotspot.ContainsCharacter(iDoc); + ColourDesired textBack = TextBackground(vsDraw, background, inSelection, inHotspot, ll->styles[i], i, ll); if (ts.representation) { if (ll->chars[i] == '\t') { @@ -2997,8 +2919,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis } DrawEOL(surface, vsDraw, rcLine, ll, line, lineEnd, - xStart, subLine, subLineStart, overrideBackground, background, - drawWrapMarkEnd, wrapColour); + xStart, subLine, subLineStart, background); } DrawIndicators(surface, vsDraw, line, xStart, rcLine, ll, subLine, lineEnd, true); @@ -3027,7 +2948,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis inIndentation = subLine == 0; // Do not handle indentation except on first subline. // Foreground drawing loop - BreakFinder bfFore(ll, lineStart, lineEnd, posLineStart, xStartVisible, + BreakFinder bfFore(ll, &sel, lineStart, lineEnd, posLineStart, xStartVisible, ((!twoPhaseDraw && selBackDrawn) || vsDraw.selColours.fore.isSet), pdoc, &reprs); while (bfFore.More()) { @@ -3043,9 +2964,10 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis if (rcSegment.Intersects(rcLine)) { int styleMain = ll->styles[i]; ColourDesired textFore = vsDraw.styles[styleMain].fore; - Font &textFont = vsDraw.styles[styleMain].font; + FontAlias textFont = vsDraw.styles[styleMain].font; //hotspot foreground - if (ll->hsStart != -1 && iDoc >= ll->hsStart && iDoc < hsEnd) { + const bool inHotspot = (ll->hotspot.Valid()) && ll->hotspot.ContainsCharacter(iDoc); + if (inHotspot) { if (vsDraw.hotspotColours.fore.isSet) textFore = vsDraw.hotspotColours.fore; } @@ -3053,8 +2975,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis if (inSelection && (vsDraw.selColours.fore.isSet)) { textFore = (inSelection == 1) ? vsDraw.selColours.fore : vsDraw.selAdditionalForeground; } - const bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd); - ColourDesired textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, i, ll); + ColourDesired textBack = TextBackground(vsDraw, background, inSelection, inHotspot, styleMain, i, ll); if (ts.representation) { if (ll->chars[i] == '\t') { // Tab display @@ -3130,8 +3051,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis } PRectangle rcDot(xmid + xStart - static_cast<XYPOSITION>(subLineStart), rcSegment.top + vsDraw.lineHeight / 2, 0.0f, 0.0f); - rcDot.right = rcDot.left + vs.whitespaceSize; - rcDot.bottom = rcDot.top + vs.whitespaceSize; + rcDot.right = rcDot.left + vsDraw.whitespaceSize; + rcDot.bottom = rcDot.top + vsDraw.whitespaceSize; surface->FillRectangle(rcDot, textFore); } } @@ -3152,7 +3073,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis } } } - if (ll->hsStart != -1 && vsDraw.hotspotUnderline && iDoc >= ll->hsStart && iDoc < ll->hsEnd) { + if (ll->hotspot.Valid() && vsDraw.hotspotUnderline && ll->hotspot.ContainsCharacter(iDoc)) { PRectangle rcUL = rcSegment; rcUL.top = rcUL.top + vsDraw.maxAscent + 1; rcUL.bottom = rcUL.top + 1; @@ -3225,8 +3146,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis // End of the drawing of the current line if (!twoPhaseDraw) { DrawEOL(surface, vsDraw, rcLine, ll, line, lineEnd, - xStart, subLine, subLineStart, overrideBackground, background, - drawWrapMarkEnd, wrapColour); + xStart, subLine, subLineStart, background); } if (!hideSelection && ((vsDraw.selAlpha != SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha != SC_ALPHA_NOALPHA))) { // For each selection draw @@ -3289,8 +3209,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis } } -void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine, - int xStart, int offset, int posCaret, PRectangle rcCaret, ColourDesired caretColour) { +void Editor::DrawBlockCaret(Surface *surface, const ViewStyle &vsDraw, LineLayout *ll, int subLine, + int xStart, int offset, int posCaret, PRectangle rcCaret, ColourDesired caretColour) const { int lineStart = ll->LineStart(subLine); int posBefore = posCaret; @@ -3348,7 +3268,8 @@ void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, // This character is where the caret block is, we override the colours // (inversed) for drawing the caret here. int styleMain = ll->styles[offsetFirstChar]; - surface->DrawTextClipped(rcCaret, vsDraw.styles[styleMain].font, + FontAlias fontText = vsDraw.styles[styleMain].font; + surface->DrawTextClipped(rcCaret, fontText, rcCaret.top + vsDraw.maxAscent, ll->chars + offsetFirstChar, numCharsToDraw, vsDraw.styles[styleMain].back, caretColour); @@ -3422,7 +3343,7 @@ void Editor::RefreshPixMaps(Surface *surfaceWindow) { } } -void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xStart, +void Editor::DrawCarets(Surface *surface, const ViewStyle &vsDraw, int lineDoc, int xStart, PRectangle rcLine, LineLayout *ll, int subLine) { // When drag is active it is the only caret drawn bool drawDrag = posDrag.IsValid(); @@ -3654,7 +3575,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { ll->containsCaret = false; } - GetHotSpotRange(ll->hsStart, ll->hsEnd); + ll->hotspot = GetHotSpotRange(); PRectangle rcLine = rcTextArea; rcLine.top = static_cast<XYPOSITION>(ypos); @@ -6536,7 +6457,7 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b } bool Editor::PositionIsHotspot(int position) const { - return vs.styles[pdoc->StyleAt(position) & pdoc->stylingBitsMask].hotspot; + return vs.styles[pdoc->StyleAt(position)].hotspot; } bool Editor::PointIsHotspot(Point pt) { @@ -6553,35 +6474,28 @@ void Editor::SetHotSpotRange(Point *pt) { // If we don't limit this to word characters then the // range can encompass more than the run range and then // the underline will not be drawn properly. - int hsStart_ = pdoc->ExtendStyleRange(pos, -1, vs.hotspotSingleLine); - int hsEnd_ = pdoc->ExtendStyleRange(pos, 1, vs.hotspotSingleLine); + Range hsNew; + hsNew.start = pdoc->ExtendStyleRange(pos, -1, vs.hotspotSingleLine); + hsNew.end = pdoc->ExtendStyleRange(pos, 1, vs.hotspotSingleLine); // Only invalidate the range if the hotspot range has changed... - if (hsStart_ != hsStart || hsEnd_ != hsEnd) { - if (hsStart != -1) { - InvalidateRange(hsStart, hsEnd); + if (!(hsNew == hotspot)) { + if (hotspot.Valid()) { + InvalidateRange(hotspot.start, hotspot.end); } - hsStart = hsStart_; - hsEnd = hsEnd_; - InvalidateRange(hsStart, hsEnd); + hotspot = hsNew; + InvalidateRange(hotspot.start, hotspot.end); } } else { - if (hsStart != -1) { - int hsStart_ = hsStart; - int hsEnd_ = hsEnd; - hsStart = -1; - hsEnd = -1; - InvalidateRange(hsStart_, hsEnd_); - } else { - hsStart = -1; - hsEnd = -1; + if (hotspot.Valid()) { + InvalidateRange(hotspot.start, hotspot.end); } + hotspot = Range(invalidPosition); } } -void Editor::GetHotSpotRange(int &hsStart_, int &hsEnd_) const { - hsStart_ = hsStart; - hsEnd_ = hsEnd; +Range Editor::GetHotSpotRange() const { + return hotspot; } void Editor::ButtonMoveWithModifiers(Point pt, int modifiers) { @@ -6668,7 +6582,7 @@ void Editor::ButtonMoveWithModifiers(Point pt, int modifiers) { } EnsureCaretVisible(false, false, true); - if (hsStart != -1 && !PointIsHotspot(pt)) + if (hotspot.Valid() && !PointIsHotspot(pt)) SetHotSpotRange(NULL); if (hotSpotClickPos != INVALID_POSITION && PositionFromLocation(pt,true,true) != hotSpotClickPos) { @@ -8647,12 +8561,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { InvalidateStyleRedraw(); break; case SCI_SETSTYLEBITS: - vs.EnsureStyle((1 << wParam) - 1); - pdoc->SetStylingBits(static_cast<int>(wParam)); + vs.EnsureStyle(0xff); break; case SCI_GETSTYLEBITS: - return pdoc->stylingBits; + return 8; case SCI_SETLINESTATE: return pdoc->SetLineState(static_cast<int>(wParam), static_cast<int>(lParam)); @@ -9293,7 +9206,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_GETREPRESENTATION: { - Representation *repr = reprs.RepresentationFromCharacter( + const Representation *repr = reprs.RepresentationFromCharacter( reinterpret_cast<const char *>(wParam), UTF8MaxBytes); if (repr) { return StringResult(lParam, repr->stringRep.c_str()); Modified: scintilla/src/Editor.h 30 lines changed, 14 insertions(+), 16 deletions(-) =================================================================== @@ -309,8 +309,7 @@ class Editor : public DocWatcher { ContractionState cs; // Hotspot support - int hsStart; - int hsEnd; + Range hotspot; // Wrapping support int wrapWidth; @@ -435,27 +434,26 @@ class Editor : public DocWatcher { int SubstituteMarkerIfEmpty(int markerCheck, int markerDefault) const; void PaintSelMargin(Surface *surface, PRectangle &rc); LineLayout *RetrieveLineLayout(int lineNumber); - void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll, + void LayoutLine(int line, Surface *surface, const ViewStyle &vstyle, LineLayout *ll, int width=LineLayout::wrapWidthInfinite); - ColourDesired SelectionBackground(ViewStyle &vsDraw, bool main) const; - ColourDesired TextBackground(ViewStyle &vsDraw, bool overrideBackground, ColourDesired background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) const; + ColourDesired SelectionBackground(const ViewStyle &vsDraw, bool main) const; + ColourDesired TextBackground(const ViewStyle &vsDraw, ColourOptional background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) const; void DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, int start, PRectangle rcSegment, bool highlight); static void DrawWrapMarker(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourDesired wrapColour); - void DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll, + void DrawEOL(Surface *surface, const ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll, int line, int lineEnd, int xStart, int subLine, XYACCUMULATOR subLineStart, - bool overrideBackground, ColourDesired background, - bool drawWrapMark, ColourDesired wrapColour); - static void DrawIndicator(int indicNum, int startPos, int endPos, Surface *surface, ViewStyle &vsDraw, + ColourOptional background); + static void DrawIndicator(int indicNum, int startPos, int endPos, Surface *surface, const ViewStyle &vsDraw, int xStart, PRectangle rcLine, LineLayout *ll, int subLine); - void DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int xStart, + void DrawIndicators(Surface *surface, const ViewStyle &vsDraw, int line, int xStart, PRectangle rcLine, LineLayout *ll, int subLine, int lineEnd, bool under); - void DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int xStart, + void DrawAnnotation(Surface *surface, const ViewStyle &vsDraw, int line, int xStart, PRectangle rcLine, LineLayout *ll, int subLine); - void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart, + void DrawLine(Surface *surface, const ViewStyle &vsDraw, int line, int lineVisible, int xStart, PRectangle rcLine, LineLayout *ll, int subLine); - void DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine, - int xStart, int offset, int posCaret, PRectangle rcCaret, ColourDesired caretColour); - void DrawCarets(Surface *surface, ViewStyle &vsDraw, int line, int xStart, + void DrawBlockCaret(Surface *surface, const ViewStyle &vsDraw, LineLayout *ll, int subLine, + int xStart, int offset, int posCaret, PRectangle rcCaret, ColourDesired caretColour) const; + void DrawCarets(Surface *surface, const ViewStyle &vsDraw, int line, int xStart, PRectangle rcLine, LineLayout *ll, int subLine); void RefreshPixMaps(Surface *surfaceWindow); void Paint(Surface *surfaceWindow, PRectangle rcArea); @@ -623,7 +621,7 @@ class Editor : public DocWatcher { bool PositionIsHotspot(int position) const; bool PointIsHotspot(Point pt); void SetHotSpotRange(Point *pt); - void GetHotSpotRange(int &hsStart, int &hsEnd) const; + Range GetHotSpotRange() const; int CodePage() const; virtual bool ValidCodePage(int /* codePage */) const { return true; } Modified: scintilla/src/ExternalLexer.cxx 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -8,8 +8,8 @@ #include <stdlib.h> #include <string.h> #include <stdio.h> -#include <ctype.h> #include <assert.h> +#include <ctype.h> #include <string> Modified: scintilla/src/Indicator.cxx 4 lines changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -11,8 +11,8 @@ #include "Platform.h" #include "Scintilla.h" -#include "XPM.h" #include "Indicator.h" +#include "XPM.h" #ifdef SCI_NAMESPACE using namespace Scintilla; @@ -23,7 +23,7 @@ static PRectangle PixelGridAlign(const PRectangle &rc) { return PRectangle::FromInts(int(rc.left + 0.5), int(rc.top), int(rc.right + 0.5), int(rc.bottom)); } -void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine) { +void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine) const { surface->PenColour(fore); int ymid = static_cast<int>(rc.bottom + rc.top) / 2; if (style == INDIC_SQUIGGLE) { Modified: scintilla/src/Indicator.h 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -23,7 +23,7 @@ class Indicator { int outlineAlpha; Indicator() : style(INDIC_PLAIN), under(false), fore(ColourDesired(0,0,0)), fillAlpha(30), outlineAlpha(50) { } - void Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine); + void Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine) const; }; #ifdef SCI_NAMESPACE Modified: scintilla/src/LineMarker.cxx 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -71,7 +71,7 @@ static void DrawMinus(Surface *surface, int centreX, int centreY, int armSize, C surface->FillRectangle(rcH, fore); } -void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharacter, typeOfFold tFold, int marginStyle) { +void LineMarker::Draw(Surface *surface, PRectangle &rcWhole, Font &fontForCharacter, typeOfFold tFold, int marginStyle) const { ColourDesired head = back; ColourDesired body = back; ColourDesired tail = back; Modified: scintilla/src/LineMarker.h 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -66,7 +66,7 @@ class LineMarker { void SetXPM(const char *textForm); void SetXPM(const char *const *linesForm); void SetRGBAImage(Point sizeRGBAImage, float scale, const unsigned char *pixelsRGBAImage); - void Draw(Surface *surface, PRectangle &rc, Font &fontForCharacter, typeOfFold tFold, int marginStyle); + void Draw(Surface *surface, PRectangle &rc, Font &fontForCharacter, typeOfFold tFold, int marginStyle) const; }; #ifdef SCI_NAMESPACE Modified: scintilla/src/PositionCache.cxx 41 lines changed, 18 insertions(+), 23 deletions(-) =================================================================== @@ -17,6 +17,7 @@ #include "Platform.h" +#include "ILexer.h" #include "Scintilla.h" #include "SplitVector.h" @@ -32,7 +33,6 @@ #include "ViewStyle.h" #include "CharClassify.h" #include "Decoration.h" -#include "ILexer.h" #include "CaseFolder.h" #include "Document.h" #include "UniConversion.h" @@ -54,16 +54,12 @@ LineLayout::LineLayout(int maxLineLength_) : validity(llInvalid), xHighlightGuide(0), highlightColumn(0), - psel(NULL), containsCaret(false), edgeColumn(0), chars(0), styles(0), - styleBitsSet(0), - indicators(0), positions(0), - hsStart(0), - hsEnd(0), + hotspot(0,0), widthLine(wrapWidthInfinite), lines(1), wrapIndent(0) { @@ -81,7 +77,6 @@ void LineLayout::Resize(int maxLineLength_) { Free(); chars = new char[maxLineLength_ + 1]; styles = new unsigned char[maxLineLength_ + 1]; - indicators = new char[maxLineLength_ + 1]; // Extra position allocated as sometimes the Windows // GetTextExtentExPoint API writes an extra element. positions = new XYPOSITION[maxLineLength_ + 1 + 1]; @@ -94,8 +89,6 @@ void LineLayout::Free() { chars = 0; delete []styles; styles = 0; - delete []indicators; - indicators = 0; delete []positions; positions = 0; delete []lineStarts; @@ -153,7 +146,7 @@ void LineLayout::SetLineStart(int line, int start) { lineStarts[line] = start; } -void LineLayout::SetBracesHighlight(Range rangeLine, Position braces[], +void LineLayout::SetBracesHighlight(Range rangeLine, const Position braces[], char bracesMatchStyle, int xHighlight, bool ignoreStyle) { if (!ignoreStyle && rangeLine.ContainsCharacter(braces[0])) { int braceOffset = braces[0] - rangeLine.start; @@ -175,7 +168,7 @@ void LineLayout::SetBracesHighlight(Range rangeLine, Position braces[], } } -void LineLayout::RestoreBracesHighlight(Range rangeLine, Position braces[], bool ignoreStyle) { +void LineLayout::RestoreBracesHighlight(Range rangeLine, const Position braces[], bool ignoreStyle) { if (!ignoreStyle && rangeLine.ContainsCharacter(braces[0])) { int braceOffset = braces[0] - rangeLine.start; if (braceOffset < numCharsInLine) { @@ -410,11 +403,11 @@ void SpecialRepresentations::ClearRepresentation(const char *charBytes) { } } -Representation *SpecialRepresentations::RepresentationFromCharacter(const char *charBytes, size_t len) { +const Representation *SpecialRepresentations::RepresentationFromCharacter(const char *charBytes, size_t len) const { PLATFORM_ASSERT(len <= 4); if (!startByteHasReprs[static_cast<unsigned char>(charBytes[0])]) return 0; - MapRepresentation::iterator it = mapReprs.find(KeyFromString(charBytes, len)); + MapRepresentation::const_iterator it = mapReprs.find(KeyFromString(charBytes, len)); if (it != mapReprs.end()) { return &(it->second); } @@ -445,8 +438,8 @@ void BreakFinder::Insert(int val) { } } -BreakFinder::BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posLineStart_, - int xStart, bool breakForSelection, Document *pdoc_, SpecialRepresentations *preprs_) : +BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, int lineStart_, int lineEnd_, int posLineStart_, + int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_) : ll(ll_), lineStart(lineStart_), lineEnd(lineEnd_), @@ -472,8 +465,8 @@ BreakFinder::BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posL SelectionPosition posStart(posLineStart); SelectionPosition posEnd(posLineStart + lineEnd); SelectionSegment segmentLine(posStart, posEnd); - for (size_t r=0; r<ll->psel->Count(); r++) { - SelectionSegment portion = ll->psel->Range(r).Intersect(segmentLine); + for (size_t r=0; r<psel->Count(); r++) { + SelectionSegment portion = psel->Range(r).Intersect(segmentLine); if (!(portion.start == portion.end)) { if (portion.start.IsValid()) Insert(portion.start.Position() - posLineStart); @@ -500,7 +493,7 @@ TextSegment BreakFinder::Next() { charWidth = UTF8DrawBytes(reinterpret_cast<unsigned char *>(ll->chars) + nextBreak, lineEnd - nextBreak); else if (encodingFamily == efDBCS) charWidth = pdoc->IsDBCSLeadByte(ll->chars[nextBreak]) ? 2 : 1; - Representation *repr = preprs->RepresentationFromCharacter(ll->chars + nextBreak, charWidth); + const Representation *repr = preprs->RepresentationFromCharacter(ll->chars + nextBreak, charWidth); if (((nextBreak > 0) && (ll->styles[nextBreak] != ll->styles[nextBreak - 1])) || repr || (nextBreak == saeNext)) { @@ -565,7 +558,7 @@ void PositionCacheEntry::Set(unsigned int styleNumber_, const char *s_, for (unsigned int i=0; i<len; i++) { positions[i] = positions_[i]; } - memcpy(reinterpret_cast<char *>(positions + len), s_, len); + memcpy(reinterpret_cast<char *>(reinterpret_cast<void *>(positions + len)), s_, len); } } @@ -584,7 +577,7 @@ void PositionCacheEntry::Clear() { bool PositionCacheEntry::Retrieve(unsigned int styleNumber_, const char *s_, unsigned int len_, XYPOSITION *positions_) const { if ((styleNumber == styleNumber_) && (len == len_) && - (memcmp(reinterpret_cast<char *>(positions + len), s_, len)== 0)) { + (memcmp(reinterpret_cast<char *>(reinterpret_cast<void *>(positions + len)), s_, len)== 0)) { for (unsigned int i=0; i<len; i++) { positions_[i] = positions[i]; } @@ -642,7 +635,7 @@ void PositionCache::SetSize(size_t size_) { pces.resize(size_); } -void PositionCache::MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned int styleNumber, +void PositionCache::MeasureWidths(Surface *surface, const ViewStyle &vstyle, unsigned int styleNumber, const char *s, unsigned int len, XYPOSITION *positions, Document *pdoc) { allClear = false; @@ -672,7 +665,8 @@ void PositionCache::MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned XYPOSITION xStartSegment = 0; while (startSegment < len) { unsigned int lenSegment = pdoc->SafeSegment(s + startSegment, len - startSegment, BreakFinder::lengthEachSubdivision); - surface->MeasureWidths(vstyle.styles[styleNumber].font, s + startSegment, lenSegment, positions + startSegment); + FontAlias fontStyle = vstyle.styles[styleNumber].font; + surface->MeasureWidths(fontStyle, s + startSegment, lenSegment, positions + startSegment); for (unsigned int inSeg = 0; inSeg < lenSegment; inSeg++) { positions[startSegment + inSeg] += xStartSegment; } @@ -680,7 +674,8 @@ void PositionCache::MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned startSegment += lenSegment; } } else { - surface->MeasureWidths(vstyle.styles[styleNumber].font, s, len, positions); + FontAlias fontStyle = vstyle.styles[styleNumber].font; + surface->MeasureWidths(fontStyle, s, len, positions); } if (probe < pces.size()) { // Store into cache Modified: scintilla/src/PositionCache.h 28 lines changed, 12 insertions(+), 16 deletions(-) =================================================================== @@ -34,19 +34,15 @@ class LineLayout { enum validLevel { llInvalid, llCheckTextAndStyle, llPositions, llLines } validity; int xHighlightGuide; bool highlightColumn; - Selection *psel; bool containsCaret; int edgeColumn; char *chars; unsigned char *styles; - int styleBitsSet; - char *indicators; XYPOSITION *positions; char bracePreviousStyles[2]; // Hotspot support - int hsStart; - int hsEnd; + Range hotspot; // Wrapped line support int widthLine; @@ -63,9 +59,9 @@ class LineLayout { Range SubLineRange(int line) const; bool InLine(int offset, int line) const; void SetLineStart(int line, int start); - void SetBracesHighlight(Range rangeLine, Position braces[], + void SetBracesHighlight(Range rangeLine, const Position braces[], char bracesMatchStyle, int xHighlight, bool ignoreStyle); - void RestoreBracesHighlight(Range rangeLine, Position braces[], bool ignoreStyle); + void RestoreBracesHighlight(Range rangeLine, const Position braces[], bool ignoreStyle); int FindBefore(XYPOSITION x, int lower, int upper) const; int FindPositionFromX(XYPOSITION x, Range range, bool charPosition) const; Point PointFromPosition(int posInLine, int lineHeight) const; @@ -132,7 +128,7 @@ class SpecialRepresentations { SpecialRepresentations(); void SetRepresentation(const char *charBytes, const char *value); void ClearRepresentation(const char *charBytes); - Representation *RepresentationFromCharacter(const char *charBytes, size_t len); + const Representation *RepresentationFromCharacter(const char *charBytes, size_t len) const; bool Contains(const char *charBytes, size_t len) const; void Clear(); }; @@ -140,8 +136,8 @@ class SpecialRepresentations { struct TextSegment { int start; int length; - Representation *representation; - TextSegment(int start_=0, int length_=0, Representation *representation_=0) : + const Representation *representation; + TextSegment(int start_=0, int length_=0, const Representation *representation_=0) : start(start_), length(length_), representation(representation_) { } int end() const { @@ -151,7 +147,7 @@ struct TextSegment { // Class to break a line of text into shorter runs at sensible places. class BreakFinder { - LineLayout *ll; + const LineLayout *ll; int lineStart; int lineEnd; int posLineStart; @@ -160,9 +156,9 @@ class BreakFinder { unsigned int saeCurrentPos; int saeNext; int subBreak; - Document *pdoc; + const Document *pdoc; EncodingFamily encodingFamily; - SpecialRepresentations *preprs; + const SpecialRepresentations *preprs; void Insert(int val); // Private so BreakFinder objects can not be copied BreakFinder(const BreakFinder &); @@ -172,8 +168,8 @@ class BreakFinder { enum { lengthStartSubdivision = 300 }; // Try to make each subdivided run lengthEachSubdivision or shorter. enum { lengthEachSubdivision = 100 }; - BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posLineStart_, - int xStart, bool breakForSelection, Document *pdoc_, SpecialRepresentations *preprs_); + BreakFinder(const LineLayout *ll_, const Selection *psel, int lineStart_, int lineEnd_, int posLineStart_, + int xStart, bool breakForSelection, const Document *pdoc_, const SpecialRepresentations *preprs_); ~BreakFinder(); TextSegment Next(); bool More() const; @@ -191,7 +187,7 @@ class PositionCache { void Clear(); void SetSize(size_t size_); size_t GetSize() const { return pces.size(); } - void MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned int styleNumber, + void MeasureWidths(Surface *surface, const ViewStyle &vstyle, unsigned int styleNumber, const char *s, unsigned int len, XYPOSITION *positions, Document *pdoc); }; Modified: scintilla/src/ScintillaBase.cxx 56 lines changed, 42 insertions(+), 14 deletions(-) =================================================================== @@ -8,8 +8,8 @@ #include <stdlib.h> #include <string.h> #include <stdio.h> -#include <ctype.h> #include <assert.h> +#include <ctype.h> #include <string> #include <vector> @@ -21,12 +21,17 @@ #include "ILexer.h" #include "Scintilla.h" -#include "PropSetSimple.h" #ifdef SCI_LEXER #include "SciLexer.h" +#endif + +#include "PropSetSimple.h" + +#ifdef SCI_LEXER #include "LexerModule.h" #include "Catalogue.h" #endif + #include "SplitVector.h" #include "Partitioning.h" #include "RunStyles.h" @@ -39,7 +44,6 @@ #include "LineMarker.h" #include "Style.h" #include "ViewStyle.h" -#include "AutoComplete.h" #include "CharClassify.h" #include "Decoration.h" #include "CaseFolder.h" @@ -47,6 +51,7 @@ #include "Selection.h" #include "PositionCache.h" #include "Editor.h" +#include "AutoComplete.h" #include "ScintillaBase.h" #ifdef SCI_NAMESPACE @@ -57,6 +62,7 @@ ScintillaBase::ScintillaBase() { displayPopupMenu = true; listType = 0; maxListWidth = 0; + multiAutoCMode = SC_MULTIAUTOC_ONCE; } ScintillaBase::~ScintillaBase() { @@ -197,9 +203,30 @@ void ScintillaBase::AutoCompleteDoubleClick(void *p) { void ScintillaBase::AutoCompleteInsert(Position startPos, int removeLen, const char *text, int textLen) { UndoGroup ug(pdoc); - pdoc->DeleteChars(startPos, removeLen); - const int lengthInserted = pdoc->InsertString(startPos, text, textLen); - SetEmptySelection(startPos + lengthInserted); + if (multiAutoCMode == SC_MULTIAUTOC_ONCE) { + pdoc->DeleteChars(startPos, removeLen); + const int lengthInserted = pdoc->InsertString(startPos, text, textLen); + SetEmptySelection(startPos + lengthInserted); + } else { + // SC_MULTIAUTOC_EACH + for (size_t r=0; r<sel.Count(); r++) { + if (!RangeContainsProtected(sel.Range(r).Start().Position(), + sel.Range(r).End().Position())) { + int positionInsert = sel.Range(r).Start().Position(); + positionInsert = InsertSpace(positionInsert, sel.Range(r).caret.VirtualSpace()); + if (positionInsert - removeLen >= 0) { + positionInsert -= removeLen; + pdoc->DeleteChars(positionInsert, removeLen); + } + const int lengthInserted = pdoc->InsertString(positionInsert, text, textLen); + if (lengthInserted > 0) { + sel.Range(r).caret.SetPosition(positionInsert + lengthInserted); + sel.Range(r).anchor.SetPosition(positionInsert + lengthInserted); + } + sel.Range(r).ClearVirtualSpace(); + } + } + } } void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) { @@ -492,7 +519,6 @@ class LexState : public LexInterface { void SetLexerLanguage(const char *languageName); const char *DescribeWordListSets(); void SetWordList(int n, const char *wl); - int GetStyleBitsNeeded() const; const char *GetName() const; void *PrivateCall(int operation, void *pointer); const char *PropertyNames(); @@ -594,10 +620,6 @@ void LexState::SetWordList(int n, const char *wl) { } } -int LexState::GetStyleBitsNeeded() const { - return lexCurrent ? lexCurrent->GetStyleBitsNeeded() : 5; -} - const char *LexState::GetName() const { return lexCurrent ? lexCurrent->languageName : ""; } @@ -740,8 +762,7 @@ void ScintillaBase::NotifyStyleToNeeded(int endStyleNeeded) { void ScintillaBase::NotifyLexerChanged(Document *, void *) { #ifdef SCI_LEXER - int bits = DocumentLexState()->GetStyleBitsNeeded(); - vs.EnsureStyle((1 << bits) - 1); + vs.EnsureStyle(0xff); #endif } @@ -819,6 +840,13 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara case SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR: return ac.ignoreCaseBehaviour; + case SCI_AUTOCSETMULTI: + multiAutoCMode = static_cast<int>(wParam); + break; + + case SCI_AUTOCGETMULTI: + return multiAutoCMode; + case SCI_AUTOCSETORDER: ac.autoSort = static_cast<int>(wParam); break; @@ -982,7 +1010,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara DocumentLexState()->PrivateCall(wParam, reinterpret_cast<void *>(lParam))); case SCI_GETSTYLEBITSNEEDED: - return DocumentLexState()->GetStyleBitsNeeded(); + return 8; case SCI_PROPERTYNAMES: return StringResult(lParam, DocumentLexState()->PropertyNames()); Modified: scintilla/src/ScintillaBase.h 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -46,6 +46,7 @@ class ScintillaBase : public Editor { int listType; ///< 0 is an autocomplete list int maxListWidth; /// Maximum width of list, in average character widths + int multiAutoCMode; /// Mode for autocompleting when multiple selections are present #ifdef SCI_LEXER LexState *DocumentLexState(); Modified: scintilla/src/Selection.cxx 8 lines changed, 8 insertions(+), 0 deletions(-) =================================================================== @@ -226,10 +226,18 @@ SelectionRange &Selection::Range(size_t r) { return ranges[r]; } +const SelectionRange &Selection::Range(size_t r) const { + return ranges[r]; +} + SelectionRange &Selection::RangeMain() { return ranges[mainRange]; } +const SelectionRange &Selection::RangeMain() const { + return ranges[mainRange]; +} + SelectionPosition Selection::Start() const { if (IsRectangular()) { return rangeRectangular.Start(); Modified: scintilla/src/Selection.h 2 lines changed, 2 insertions(+), 0 deletions(-) =================================================================== @@ -156,7 +156,9 @@ class Selection { size_t Main() const; void SetMain(size_t r); SelectionRange &Range(size_t r); + const SelectionRange &Range(size_t r) const; SelectionRange &RangeMain(); + const SelectionRange &RangeMain() const; SelectionPosition Start() const; bool MoveExtends() const; void SetMoveExtends(bool moveExtends_); Modified: scintilla/src/Style.cxx 4 lines changed, 4 insertions(+), 0 deletions(-) =================================================================== @@ -19,6 +19,10 @@ using namespace Scintilla; FontAlias::FontAlias() { } +FontAlias::FontAlias(const FontAlias &other) : Font() { + SetID(other.fid); +} + FontAlias::~FontAlias() { SetID(0); // ~Font will not release the actual font resource since it is now 0 Modified: scintilla/src/Style.h 4 lines changed, 2 insertions(+), 2 deletions(-) =================================================================== @@ -33,11 +33,11 @@ struct FontSpecification { // Just like Font but only has a copy of the FontID so should not delete it class FontAlias : public Font { - // Private so FontAlias objects can not be copied - FontAlias(const FontAlias &); + // Private so FontAlias objects can not be assigned except for intiialization FontAlias &operator=(const FontAlias &); public: FontAlias(); + FontAlias(const FontAlias &); virtual ~FontAlias(); void MakeAlias(Font &fontOrigin); void ClearFont(); Modified: scintilla/src/ViewStyle.cxx 37 lines changed, 37 insertions(+), 0 deletions(-) =================================================================== @@ -434,6 +434,43 @@ void ViewStyle::CalcLargestMarkerHeight() { } } +// See if something overrides the line background color: Either if caret is on the line +// and background color is set for that, or if a marker is defined that forces its background +// color onto the line, or if a marker is defined but has no selection margin in which to +// display itself (as long as it's not an SC_MARK_EMPTY marker). These are checked in order +// with the earlier taking precedence. When multiple markers cause background override, +// the color for the highest numbered one is used. +ColourOptional ViewStyle::Background(int marksOfLine, bool caretActive, bool lineContainsCaret) const { + ColourOptional background; + if ((caretActive || alwaysShowCaretLineBackground) && showCaretLineBackground && (caretLineAlpha == SC_ALPHA_NOALPHA) && lineContainsCaret) { + background = ColourOptional(caretLineBackground, true); + } + if (!background.isSet && marksOfLine) { + int marks = marksOfLine; + for (int markBit = 0; (markBit < 32) && marks; markBit++) { + if ((marks & 1) && (markers[markBit].markType == SC_MARK_BACKGROUND) && + (markers[markBit].alpha == SC_ALPHA_NOALPHA)) { + background = ColourOptional(markers[markBit].back, true); + } + marks >>= 1; + } + } + if (!background.isSet && maskInLine) { + int marksMasked = marksOfLine & maskInLine; + if (marksMasked) { + for (int markBit = 0; (markBit < 32) && marksMasked; markBit++) { + if ((marksMasked & 1) && (markers[markBit].markType != SC_MARK_EMPTY) && + (markers[markBit].alpha == SC_ALPHA_NOALPHA)) { + background = ColourOptional(markers[markBit].back, true); + } + marksMasked >>= 1; + } + } + } + return background; +} + + ColourDesired ViewStyle::WrapColour() const { if (whitespaceColours.fore.isSet) return whitespaceColours.fore; Modified: scintilla/src/ViewStyle.h 3 lines changed, 2 insertions(+), 1 deletions(-) =================================================================== @@ -157,7 +157,7 @@ class ViewStyle { ViewStyle(); ViewStyle(const ViewStyle &source); ~ViewStyle(); - void Init(size_t stylesSize_=64); + void Init(size_t stylesSize_=256); void Refresh(Surface &surface, int tabInChars); void ReleaseAllExtendedStyles(); int AllocateExtendedStyles(int numberStyles); @@ -169,6 +169,7 @@ class ViewStyle { int ExternalMarginWidth() const; bool ValidStyle(size_t styleIndex) const; void CalcLargestMarkerHeight(); + ColourOptional Background(int marksOfLine, bool caretActive, bool lineContainsCaret) const; ColourDesired WrapColour() const; bool SetWrapState(int wrapState_); bool SetWrapVisualFlags(int wrapVisualFlags_); Modified: scintilla/version.txt 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -1 +1 @@ -342 +344 -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
[geany/geany] db9041: main: Refactor quit functions
by Thomas Martitz
03 Jul '14
03 Jul '14
Branch: refs/heads/master Author: Thomas Martitz <kugel(a)rockbox.org> Committer: Thomas Martitz <kugel(a)rockbox.org> Date: Thu, 03 Jul 2014 20:33:26 UTC Commit: db90411b0e7684fb5d7868309e1fc96a93df664b
https://github.com/geany/geany/commit/db90411b0e7684fb5d7868309e1fc96a93df6…
Log Message: ----------- main: Refactor quit functions Move quit-related functions to main.c and make them static. main_quit() now does all the heavy work and can be called from signal handlers. Modified Paths: -------------- src/callbacks.c src/keybindings.c src/main.c src/main.h Modified: src/callbacks.c 54 lines changed, 2 insertions(+), 52 deletions(-) =================================================================== @@ -157,61 +157,11 @@ G_MODULE_EXPORT void on_clone1_activate(GtkMenuItem *menuitem, gpointer user_dat /*static gboolean switch_tv_notebook_page = FALSE; */ -static gboolean check_no_unsaved(void) -{ - guint i; - - for (i = 0; i < documents_array->len; i++) - { - if (documents[i]->is_valid && documents[i]->changed) - { - return FALSE; - } - } - return TRUE; /* no unsaved edits */ -} - - -/* should only be called from on_window_delete_event */ -static void quit_app(void) -{ - configuration_save(); - - if (app->project != NULL) - project_close(FALSE); /* save project session files */ - - document_close_all(); - - main_status.quitting = TRUE; - - main_quit(); -} - /* wrapper function to abort exit process if cancel button is pressed */ G_MODULE_EXPORT gboolean on_window_delete_event(GtkWidget *widget, GdkEvent *event, gpointer gdata) { - main_status.quitting = TRUE; - - if (! check_no_unsaved()) - { - if (document_account_for_unsaved()) - { - quit_app(); - return FALSE; - } - } - else - if (! prefs.confirm_exit || - dialogs_show_question_full(NULL, GTK_STOCK_QUIT, GTK_STOCK_CANCEL, NULL, - _("Do you really want to quit?"))) - { - quit_app(); - return FALSE; - } - - main_status.quitting = FALSE; - return TRUE; + return !main_quit(); } @@ -296,7 +246,7 @@ G_MODULE_EXPORT void on_close1_activate(GtkMenuItem *menuitem, gpointer user_dat G_MODULE_EXPORT void on_quit1_activate(GtkMenuItem *menuitem, gpointer user_data) { - on_window_delete_event(NULL, NULL, NULL); + main_quit(); } Modified: src/keybindings.c 3 lines changed, 2 insertions(+), 1 deletions(-) =================================================================== @@ -39,6 +39,7 @@ #include "documentprivate.h" #include "filetypes.h" #include "keybindingsprivate.h" +#include "main.h" #include "msgwindow.h" #include "navqueue.h" #include "notebook.h" @@ -1364,7 +1365,7 @@ static gboolean cb_func_file_action(guint key_id) on_print1_activate(NULL, NULL); break; case GEANY_KEYS_FILE_QUIT: - on_quit1_activate(NULL, NULL); + main_quit(); break; } return TRUE; Modified: src/main.c 56 lines changed, 53 insertions(+), 3 deletions(-) =================================================================== @@ -788,13 +788,13 @@ static gint setup_config_dir(void) return mkdir_result; } -/* Signal handling removed since on_quit1_activate() uses functions that are +/* Signal handling removed since main_quit() uses functions that are * illegal in signal handlers static void signal_cb(gint sig) { if (sig == SIGTERM) { - on_quit1_activate(NULL, NULL); + main_quit(); } } */ @@ -1247,10 +1247,19 @@ static void queue_free(GQueue *queue) } -void main_quit(void) +static void do_main_quit(void) { geany_debug("Quitting..."); + configuration_save(); + + if (app->project != NULL) + project_close(FALSE); /* save project session files */ + + document_close_all(); + + main_status.quitting = TRUE; + #ifdef HAVE_SOCKET socket_finalize(); #endif @@ -1343,6 +1352,47 @@ void main_quit(void) } +static gboolean check_no_unsaved(void) +{ + guint i; + + for (i = 0; i < documents_array->len; i++) + { + if (documents[i]->is_valid && documents[i]->changed) + { + return FALSE; + } + } + return TRUE; /* no unsaved edits */ +} + + +/* Returns false when quitting is aborted due to user cancellation */ +gboolean main_quit(void) +{ + main_status.quitting = TRUE; + + if (! check_no_unsaved()) + { + if (document_account_for_unsaved()) + { + do_main_quit(); + return TRUE; + } + } + else + if (! prefs.confirm_exit || + dialogs_show_question_full(NULL, GTK_STOCK_QUIT, GTK_STOCK_CANCEL, NULL, + _("Do you really want to quit?"))) + { + do_main_quit(); + return TRUE; + } + + main_status.quitting = FALSE; + return FALSE; +} + /** * Reloads most of Geany's configuration files without restarting. Currently the following * files are reloaded: all template files, also new file templates and the 'New (with template)' Modified: src/main.h 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -60,7 +60,7 @@ const gchar *main_get_version_string(void); gchar *main_get_argv_filename(const gchar *filename); -void main_quit(void); +gboolean main_quit(void); gboolean main_handle_filename(const gchar *locale_filename); -------------- This E-Mail was brought to you by github_commit_mail.py (Source:
https://github.com/geany/infrastructure
).
1
0
0
0
← Newer
1
2
3
Older →
Jump to page:
1
2
3
Results per page:
10
25
50
100
200