Revision: 5808 http://geany.svn.sourceforge.net/geany/?rev=5808&view=rev Author: statc Date: 2011-05-21 08:58:07 +0000 (Sat, 21 May 2011)
Log Message: ----------- Merge trunk (revisions 5681..5700)
Modified Paths: -------------- branches/sm/ChangeLog branches/sm/data/filetypes.Genie.conf branches/sm/data/filetypes.Scala.conf branches/sm/data/filetypes.c branches/sm/data/filetypes.vala branches/sm/geany.glade branches/sm/makefile.win32 branches/sm/scintilla/Makefile.am branches/sm/scintilla/gtk/PlatGTK.cxx branches/sm/scintilla/gtk/ScintillaGTK.cxx branches/sm/scintilla/gtk/scintilla-marshal.c branches/sm/scintilla/include/Platform.h branches/sm/scintilla/include/SciLexer.h branches/sm/scintilla/include/Scintilla.h branches/sm/scintilla/include/Scintilla.iface branches/sm/scintilla/lexers/LexAda.cxx branches/sm/scintilla/lexers/LexAsm.cxx branches/sm/scintilla/lexers/LexBash.cxx branches/sm/scintilla/lexers/LexCOBOL.cxx branches/sm/scintilla/lexers/LexCPP.cxx branches/sm/scintilla/lexers/LexCSS.cxx branches/sm/scintilla/lexers/LexCmake.cxx branches/sm/scintilla/lexers/LexD.cxx branches/sm/scintilla/lexers/LexErlang.cxx branches/sm/scintilla/lexers/LexForth.cxx branches/sm/scintilla/lexers/LexFortran.cxx branches/sm/scintilla/lexers/LexHTML.cxx branches/sm/scintilla/lexers/LexLisp.cxx branches/sm/scintilla/lexers/LexLua.cxx branches/sm/scintilla/lexers/LexMarkdown.cxx branches/sm/scintilla/lexers/LexMatlab.cxx branches/sm/scintilla/lexers/LexNsis.cxx branches/sm/scintilla/lexers/LexOthers.cxx branches/sm/scintilla/lexers/LexPascal.cxx branches/sm/scintilla/lexers/LexPerl.cxx branches/sm/scintilla/lexers/LexPython.cxx branches/sm/scintilla/lexers/LexR.cxx branches/sm/scintilla/lexers/LexSQL.cxx branches/sm/scintilla/lexers/LexTCL.cxx branches/sm/scintilla/lexers/LexTxt2tags.cxx branches/sm/scintilla/lexers/LexVHDL.cxx branches/sm/scintilla/lexers/LexVerilog.cxx branches/sm/scintilla/lexers/LexYAML.cxx branches/sm/scintilla/lexlib/CharacterSet.h branches/sm/scintilla/lexlib/LexerBase.h branches/sm/scintilla/lexlib/OptionSet.h branches/sm/scintilla/lexlib/WordList.cxx branches/sm/scintilla/makefile.win32 branches/sm/scintilla/scintilla_changes.patch branches/sm/scintilla/src/AutoComplete.cxx branches/sm/scintilla/src/CallTip.cxx branches/sm/scintilla/src/Document.cxx branches/sm/scintilla/src/Document.h branches/sm/scintilla/src/Editor.cxx branches/sm/scintilla/src/Editor.h branches/sm/scintilla/src/ExternalLexer.cxx branches/sm/scintilla/src/ExternalLexer.h branches/sm/scintilla/src/Partitioning.h branches/sm/scintilla/src/PositionCache.cxx branches/sm/scintilla/src/RunStyles.cxx branches/sm/scintilla/src/Selection.cxx branches/sm/scintilla/src/Selection.h branches/sm/scintilla/src/SplitVector.h branches/sm/scintilla/src/ViewStyle.cxx branches/sm/scintilla/src/ViewStyle.h branches/sm/src/editor.c branches/sm/src/highlighting.c branches/sm/src/interface.c branches/sm/src/prefs.c branches/sm/src/search.c branches/sm/src/templates.c branches/sm/src/tools.c branches/sm/src/win32.c branches/sm/tagmanager/makefile.win32
Added Paths: ----------- branches/sm/scintilla/lexlib/SparseState.h branches/sm/scintilla/version.txt
Modified: branches/sm/ChangeLog =================================================================== --- branches/sm/ChangeLog 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/ChangeLog 2011-05-21 08:58:07 UTC (rev 5808) @@ -1,3 +1,64 @@ +2011-04-08 Colomban Wendling <colomban(at)geany(dot)org> + + * scintilla/lexers/LexCPP.cxx: + Make hightlighting of triple-quoted verbatim an option (Backport + from Scintilla HG 3602:5536ed81a85b). + * src/highlighting.c: + Add highlight for triple-quoted verbatims. + * data/filetypes.c, data/filetypes.vala, data/filetypes.Genie.conf, + data/filetypes.Scala.conf: + Highlight triple-quoted verbatims in Vala, Genie and Scala filtypes. + * data/filetypes.Genie.conf: + Copy C styling rather than redefining the styles. + * src/editor.c: + Don't set font twice for line numbers and braces. + + +2011-04-05 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> + + * src/templates.c: + Remove TEMPLATES_GET_FILENAME() macro. + * src/search.c: + Don't auto-enable case-sensitive option when enabling regex in + Find/Replace dialogs. + + +2011-04-04 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de> + + * scintilla/gtk/ScintillaGTK.cxx: + Fix X PRIMARY selection issue when Scintilla widget is + unrealized/re-realized (Backport from Scintilla HG, + original patch by Matthew Brush). + Reset cursors when Scintilla widget is realized (Backport from + Scintilla HG, original patch by Matthew Brush). + + +2011-04-04 Colomban Wendling <colomban(at)geany(dot)org> + + * scintilla/gtk/PlatGTK.cxx: + Fix font rendering in Scintilla when using Cairo. + + +2011-04-04 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> + + * src/interface.c, geany.glade: + Make Project->Properties the last menu item so it's faster to use. + + +2011-04-03 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de> + + * scintilla/*: + Update Scintilla to version 2.25. + * version.txt, Makefile.am: + Add Scintilla's version.txt file. + * scintilla/makefile.win32, tagmanager/makefile.win32, makefile.win32: + Replace escape character '' by slash '/' in paths in the + Windows Makefiles (patch by Matthew Brush, thanks). + * src/tools.c: + Reflect the existence of the entered command in `Set Custom Commands` + dialog as well using the yes/no icon. + + 2011-04-03 Colomban Wendling <colomban(at)geany(dot)org>
* src/main.c, src/prefs.c, src/tools.c: @@ -2,2 +63,6 @@ Fix loading and updating menu accelerators for custom commands. + * src/prefs.c: + Don't allow editing keybinding column of group rows. + * src/tools.c: + Fix ID of newly added commands in the `Set Custom Commands` dialog.
Modified: branches/sm/data/filetypes.Genie.conf =================================================================== --- branches/sm/data/filetypes.Genie.conf 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/data/filetypes.Genie.conf 2011-05-21 08:58:07 UTC (rev 5808) @@ -1,28 +1,5 @@ # For complete documentation of this file, please see Geany's main documentation -[styling] -# foreground;background;bold;italic -default=default -comment=comment -commentline=comment -commentdoc=commentdoc -number=number -word=keyword -word2=keyword2 -string=string -character=string -uuid=extra -preprocessor=preprocessor -operator=operator -identifier=default -stringeol=stringeol -# @"verbatim" -verbatim=extra -# (/regex/) -regex=extra -commentlinedoc=commentdoc,bold -commentdockeyword=commentdoc,bold,italic -commentdockeyworderror=commentdoc -globalclass=type +[styling=C]
[keywords] # all items must be in one line @@ -31,6 +8,9 @@ # these are some doxygen keywords (incomplete) docComment=attention author brief bug class code date def enum example exception file fn namespace note param remarks return see since struct throw todo typedef var version warning union
+[lexer_properties] +lexer.cpp.triplequoted.strings=1 + [settings] # Vala uses the C lexer lexer_filetype=C
Modified: branches/sm/data/filetypes.Scala.conf =================================================================== --- branches/sm/data/filetypes.Scala.conf 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/data/filetypes.Scala.conf 2011-05-21 08:58:07 UTC (rev 5808) @@ -5,11 +5,13 @@ [keywords] # all items must be in one line primary=abstract case catch class def do else extends false final finally for forSome if implicit import lazy match new object override package private protected requires return sealed throw trait true try type val var with while yield @ => - secondary=null super this AllRef Any AnyRef Array Attribute Elem Iterable List Option Some Stack String Unit Console Nil None Predef # these are some doxygen keywords (incomplete) docComment=attention author brief bug class code date def enum example exception file fn namespace note param remarks return see since struct throw todo typedef var version warning union
+[lexer_properties] +lexer.cpp.triplequoted.strings=1 + [settings] lexer_filetype=C
Modified: branches/sm/data/filetypes.c =================================================================== --- branches/sm/data/filetypes.c 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/data/filetypes.c 2011-05-21 08:58:07 UTC (rev 5808) @@ -15,7 +15,7 @@ operator=operator identifier=default stringeol=stringeol -# @"verbatim" +# @"verbatim" and """multi-line verbatim""" verbatim=extra # (/regex/) regex=extra
Modified: branches/sm/data/filetypes.vala =================================================================== --- branches/sm/data/filetypes.vala 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/data/filetypes.vala 2011-05-21 08:58:07 UTC (rev 5808) @@ -38,6 +38,7 @@ preprocessor.start.$(file.patterns.cpp)=if preprocessor.middle.$(file.patterns.cpp)=else elif preprocessor.end.$(file.patterns.cpp)=endif +lexer.cpp.triplequoted.strings=1
[settings] lexer_filetype=C
Modified: branches/sm/geany.glade =================================================================== --- branches/sm/geany.glade 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/geany.glade 2011-05-21 08:58:07 UTC (rev 5808) @@ -67,7 +67,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image4011"> + <widget class="GtkImage" id="image4056"> <property name="visible">True</property> <property name="stock">gtk-new</property> <property name="icon_size">1</property> @@ -144,7 +144,7 @@ <signal name="activate" handler="on_save_all1_activate" last_modification_time="Thu, 02 Jun 2005 14:15:30 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image4012"> + <widget class="GtkImage" id="image4057"> <property name="visible">True</property> <property name="stock">gtk-save</property> <property name="icon_size">1</property> @@ -165,7 +165,7 @@ <signal name="activate" handler="on_toolbutton_reload_clicked" last_modification_time="Mon, 01 Sep 2008 16:57:06 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image4013"> + <widget class="GtkImage" id="image4058"> <property name="visible">True</property> <property name="stock">gtk-revert-to-saved</property> <property name="icon_size">1</property> @@ -185,7 +185,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image4014"> + <widget class="GtkImage" id="image4059"> <property name="visible">True</property> <property name="stock">gtk-revert-to-saved</property> <property name="icon_size">1</property> @@ -272,7 +272,7 @@ <signal name="activate" handler="on_close_other_documents1_activate" last_modification_time="Fri, 27 Jun 2008 15:19:28 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image4015"> + <widget class="GtkImage" id="image4060"> <property name="visible">True</property> <property name="stock">gtk-close</property> <property name="icon_size">1</property> @@ -293,7 +293,7 @@ <signal name="activate" handler="on_close_all1_activate" last_modification_time="Thu, 02 Jun 2005 14:15:30 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image4016"> + <widget class="GtkImage" id="image4061"> <property name="visible">True</property> <property name="stock">gtk-close</property> <property name="icon_size">1</property> @@ -433,7 +433,7 @@ <signal name="activate" handler="on_cut_current_line(s)1_activate" last_modification_time="Mon, 26 Oct 2009 17:34:30 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image4017"> + <widget class="GtkImage" id="image4062"> <property name="visible">True</property> <property name="stock">gtk-cut</property> <property name="icon_size">1</property> @@ -454,7 +454,7 @@ <signal name="activate" handler="on_copy_current_line(s)1_activate" last_modification_time="Mon, 26 Oct 2009 17:34:30 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image4018"> + <widget class="GtkImage" id="image4063"> <property name="visible">True</property> <property name="stock">gtk-copy</property> <property name="icon_size">1</property> @@ -611,7 +611,7 @@ <signal name="activate" handler="on_menu_increase_indent1_activate" last_modification_time="Tue, 01 Aug 2006 10:28:54 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image4019"> + <widget class="GtkImage" id="image4064"> <property name="visible">True</property> <property name="stock">gtk-indent</property> <property name="icon_size">1</property> @@ -632,7 +632,7 @@ <signal name="activate" handler="on_menu_decrease_indent1_activate" last_modification_time="Tue, 01 Aug 2006 10:28:54 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image4020"> + <widget class="GtkImage" id="image4065"> <property name="visible">True</property> <property name="stock">gtk-unindent</property> <property name="icon_size">1</property> @@ -697,7 +697,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image4021"> + <widget class="GtkImage" id="image4066"> <property name="visible">True</property> <property name="stock">gtk-add</property> <property name="icon_size">1</property> @@ -782,7 +782,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image4022"> + <widget class="GtkImage" id="image4067"> <property name="visible">True</property> <property name="stock">gtk-add</property> <property name="icon_size">1</property> @@ -814,7 +814,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image4023"> + <widget class="GtkImage" id="image4068"> <property name="visible">True</property> <property name="stock">gtk-add</property> <property name="icon_size">1</property> @@ -862,7 +862,7 @@ <signal name="activate" handler="on_preferences1_activate" last_modification_time="Wed, 08 Jun 2005 11:35:19 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image4024"> + <widget class="GtkImage" id="image4069"> <property name="visible">True</property> <property name="stock">gtk-preferences</property> <property name="icon_size">1</property> @@ -883,7 +883,7 @@ <signal name="activate" handler="on_plugin_preferences1_activate" last_modification_time="Wed, 28 Oct 2009 17:17:31 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image4025"> + <widget class="GtkImage" id="image4070"> <property name="visible">True</property> <property name="stock">gtk-preferences</property> <property name="icon_size">1</property> @@ -951,7 +951,7 @@ <signal name="activate" handler="on_find_in_files1_activate" last_modification_time="Thu, 06 Jul 2006 11:31:09 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image4026"> + <widget class="GtkImage" id="image4071"> <property name="visible">True</property> <property name="stock">gtk-find</property> <property name="icon_size">1</property> @@ -972,7 +972,7 @@ <signal name="activate" handler="on_replace1_activate" last_modification_time="Sun, 23 Oct 2005 13:22:36 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image4027"> + <widget class="GtkImage" id="image4072"> <property name="visible">True</property> <property name="stock">gtk-find-and-replace</property> <property name="icon_size">1</property> @@ -999,7 +999,7 @@ <signal name="activate" handler="on_next_message1_activate" last_modification_time="Tue, 05 Dec 2006 11:15:02 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image4028"> + <widget class="GtkImage" id="image4073"> <property name="visible">True</property> <property name="stock">gtk-go-down</property> <property name="icon_size">1</property> @@ -1020,7 +1020,7 @@ <signal name="activate" handler="on_previous_message1_activate" last_modification_time="Wed, 25 Jun 2008 12:10:04 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image4029"> + <widget class="GtkImage" id="image4074"> <property name="visible">True</property> <property name="stock">gtk-go-up</property> <property name="icon_size">1</property> @@ -1071,7 +1071,7 @@ <signal name="activate" handler="on_go_to_line_activate" last_modification_time="Sat, 06 Dec 2008 17:41:21 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image4030"> + <widget class="GtkImage" id="image4075"> <property name="visible">True</property> <property name="stock">gtk-jump-to</property> <property name="icon_size">1</property> @@ -1199,7 +1199,7 @@ <signal name="activate" handler="on_change_font1_activate" last_modification_time="Fri, 22 Apr 2005 18:58:45 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image4031"> + <widget class="GtkImage" id="image4076"> <property name="visible">True</property> <property name="stock">gtk-select-font</property> <property name="icon_size">1</property> @@ -1771,7 +1771,7 @@ <signal name="activate" handler="on_project_new1_activate" last_modification_time="Thu, 18 Jan 2007 22:16:24 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image4032"> + <widget class="GtkImage" id="image4077"> <property name="visible">True</property> <property name="stock">gtk-new</property> <property name="icon_size">1</property> @@ -1792,7 +1792,7 @@ <signal name="activate" handler="on_project_open1_activate" last_modification_time="Mon, 15 Jan 2007 17:34:17 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image4033"> + <widget class="GtkImage" id="image4078"> <property name="visible">True</property> <property name="stock">gtk-open</property> <property name="icon_size">1</property> @@ -1821,7 +1821,7 @@ <signal name="activate" handler="on_project_close1_activate" last_modification_time="Mon, 15 Jan 2007 17:34:17 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image4034"> + <widget class="GtkImage" id="image4079"> <property name="visible">True</property> <property name="stock">gtk-close</property> <property name="icon_size">1</property> @@ -1841,11 +1841,12 @@ </child>
<child> - <widget class="GtkImageMenuItem" id="project_properties1"> + <widget class="GtkMenuItem" id="reset_indentation1"> <property name="visible">True</property> - <property name="label">gtk-properties</property> - <property name="use_stock">True</property> - <signal name="activate" handler="on_project_properties1_activate" last_modification_time="Mon, 15 Jan 2007 17:34:17 GMT"/> + <property name="tooltip" translatable="yes">Apply the default indentation settings to all documents</property> + <property name="label" translatable="yes">_Apply Default Indentation</property> + <property name="use_underline">True</property> + <signal name="activate" handler="on_reset_indentation1_activate" last_modification_time="Mon, 08 Nov 2010 15:30:43 GMT"/> </widget> </child>
@@ -1856,12 +1857,11 @@ </child>
<child> - <widget class="GtkMenuItem" id="reset_indentation1"> + <widget class="GtkImageMenuItem" id="project_properties1"> <property name="visible">True</property> - <property name="tooltip" translatable="yes">Apply the default indentation settings to all documents</property> - <property name="label" translatable="yes">_Apply Default Indentation</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_reset_indentation1_activate" last_modification_time="Mon, 08 Nov 2010 15:30:43 GMT"/> + <property name="label">gtk-properties</property> + <property name="use_stock">True</property> + <signal name="activate" handler="on_project_properties1_activate" last_modification_time="Mon, 15 Jan 2007 17:34:17 GMT"/> </widget> </child> </widget> @@ -1894,7 +1894,7 @@ <signal name="activate" handler="on_menu_reload_configuration1_activate" last_modification_time="Mon, 30 Jun 2008 16:19:40 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image4035"> + <widget class="GtkImage" id="image4080"> <property name="visible">True</property> <property name="stock">gtk-refresh</property> <property name="icon_size">1</property> @@ -1914,7 +1914,7 @@ <property name="use_underline">True</property>
<child internal-child="image"> - <widget class="GtkImage" id="image4036"> + <widget class="GtkImage" id="image4081"> <property name="visible">True</property> <property name="stock">gtk-file</property> <property name="icon_size">1</property> @@ -1941,7 +1941,7 @@ <signal name="activate" handler="on_show_color_chooser1_activate" last_modification_time="Wed, 22 Jun 2005 18:10:21 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image4037"> + <widget class="GtkImage" id="image4082"> <property name="visible">True</property> <property name="stock">gtk-select-color</property> <property name="icon_size">1</property> @@ -1993,7 +1993,7 @@ <signal name="activate" handler="on_help1_activate" last_modification_time="Sun, 24 Jul 2005 15:23:11 GMT"/>
<child internal-child="image"> - <widget class="GtkImage" id="image4038"> + <widget class="GtkImage" id="image4083"> <property name="visible">True</property> <property name="stock">gtk-help</property> <property name="icon_size">1</property>
Modified: branches/sm/makefile.win32 =================================================================== --- branches/sm/makefile.win32 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/makefile.win32 2011-05-21 08:58:07 UTC (rev 5808) @@ -22,7 +22,7 @@ # Note: && is needed after cd because each line is executed in a different # shell. (cd .. is just for clarity). all: check-tools config.h - cd tagmanager\mio && $(MAKE) -f makefile.win32 && cd .... + cd tagmanager/mio && $(MAKE) -f makefile.win32 && cd ../.. cd tagmanager && $(MAKE) -f makefile.win32 && cd .. cd scintilla && $(MAKE) -f makefile.win32 && cd .. cd plugins && $(MAKE) -f makefile.win32 && cd .. @@ -38,14 +38,14 @@ $(CP) $< $@
deps: - -$(RM) tagmanager\mio\deps.mak tagmanager\deps.mak scintilla\deps.mak plugins\deps.mak src\deps.mak + -$(RM) tagmanager/mio/deps.mak tagmanager/deps.mak scintilla/deps.mak plugins/deps.mak src/deps.mak
# used by src/makefile.win32 to avoid del ../file which is an error clean-local: -$(RM) geany_private.res geany.exe
clean: deps - cd tagmanager\mio && $(MAKE) -f makefile.win32 clean && cd .... + cd tagmanager/mio && $(MAKE) -f makefile.win32 clean && cd ../.. cd tagmanager && $(MAKE) -f makefile.win32 clean && cd .. cd scintilla && $(MAKE) -f makefile.win32 clean && cd .. cd plugins && $(MAKE) -f makefile.win32 clean && cd ..
Modified: branches/sm/scintilla/Makefile.am =================================================================== --- branches/sm/scintilla/Makefile.am 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/Makefile.am 2011-05-21 08:58:07 UTC (rev 5808) @@ -61,6 +61,7 @@ lexlib/OptionSet.h \ lexlib/PropSetSimple.cxx \ lexlib/PropSetSimple.h \ +lexlib/SparseState.h \ lexlib/StyleContext.cxx \ lexlib/StyleContext.h \ lexlib/WordList.cxx \ @@ -125,4 +126,4 @@ glib-genmarshal --prefix scintilla_marshal gtk/scintilla-marshal.list --header > gtk/scintilla-marshal.h glib-genmarshal --prefix scintilla_marshal gtk/scintilla-marshal.list --body > gtk/scintilla-marshal.c
-EXTRA_DIST=gtk/scintilla-marshal.list License.txt README +EXTRA_DIST=gtk/scintilla-marshal.list License.txt README version.txt
Modified: branches/sm/scintilla/gtk/PlatGTK.cxx =================================================================== --- branches/sm/scintilla/gtk/PlatGTK.cxx 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/gtk/PlatGTK.cxx 2011-05-21 08:58:07 UTC (rev 5808) @@ -7,6 +7,7 @@ #include <stdio.h> #include <stdlib.h> #include <stddef.h> +#include <math.h>
#include <glib.h> #include <gmodule.h> @@ -39,6 +40,14 @@ #define IS_WIDGET_FOCUSSED(w) (GTK_WIDGET_HAS_FOCUS(w)) #endif
+#if GTK_CHECK_VERSION(2,22,0) +#define USE_CAIRO 1 +#endif + +#ifdef USE_CAIRO +#define DISABLE_GDK_FONT 1 +#endif + #ifdef _MSC_VER // Ignore unreferenced local functions in GTK+ headers #pragma warning(disable: 4505) @@ -688,9 +697,14 @@ #endif class SurfaceImpl : public Surface { encodingType et; +#ifdef USE_CAIRO + cairo_t *context; + cairo_surface_t *psurf; +#else GdkDrawable *drawable; GdkGC *gc; GdkPixmap *ppixmap; +#endif int x; int y; bool inited; @@ -806,7 +820,15 @@ } }
-SurfaceImpl::SurfaceImpl() : et(singleByte), drawable(0), gc(0), ppixmap(0), +SurfaceImpl::SurfaceImpl() : et(singleByte), +#ifdef USE_CAIRO +context(0), +psurf(0), +#else +drawable(0), +gc(0), +ppixmap(0), +#endif x(0), y(0), inited(false), createdGC(false) , pcontext(0), layout(0), characterSet(-1) { } @@ -817,15 +839,28 @@
void SurfaceImpl::Release() { et = singleByte; +#ifndef USE_CAIRO drawable = 0; +#endif if (createdGC) { createdGC = false; +#ifdef USE_CAIRO + cairo_destroy(context); +#else g_object_unref(gc); +#endif } +#ifdef USE_CAIRO + context = 0; + if (psurf) + cairo_surface_destroy(psurf); + psurf = 0; +#else gc = 0; if (ppixmap) g_object_unref(ppixmap); ppixmap = 0; +#endif if (layout) g_object_unref(layout); layout = 0; @@ -847,6 +882,19 @@ void SurfaceImpl::Init(WindowID wid) { Release(); PLATFORM_ASSERT(wid); +#ifdef USE_CAIRO + GdkDrawable *drawable_ = GDK_DRAWABLE(PWidget(wid)->window); + 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; +#endif pcontext = gtk_widget_create_pango_context(PWidget(wid)); PLATFORM_ASSERT(pcontext); layout = pango_layout_new(pcontext); @@ -859,12 +907,20 @@ GdkDrawable *drawable_ = reinterpret_cast<GdkDrawable *>(sid); Release(); PLATFORM_ASSERT(wid); +#ifdef USE_CAIRO + context = gdk_cairo_create(drawable_); +#else + gc = gdk_gc_new(drawable_); + drawable = drawable_; +#endif pcontext = gtk_widget_create_pango_context(PWidget(wid)); layout = pango_layout_new(pcontext); - drawable = drawable_; - gc = gdk_gc_new(drawable_); +#ifdef USE_CAIRO + cairo_set_line_width(context, 1); +#else // Ask for lines that do not paint the last pixel so is like Win32 gdk_gc_set_line_attributes(gc, 0, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER); +#endif createdGC = true; inited = true; } @@ -873,28 +929,62 @@ PLATFORM_ASSERT(surface_); Release(); SurfaceImpl *surfImpl = static_cast<SurfaceImpl *>(surface_); + PLATFORM_ASSERT(wid); +#ifdef USE_CAIRO + context = cairo_reference(surfImpl->context); +#else PLATFORM_ASSERT(surfImpl->drawable); - PLATFORM_ASSERT(wid); + gc = gdk_gc_new(surfImpl->drawable); +#endif pcontext = gtk_widget_create_pango_context(PWidget(wid)); PLATFORM_ASSERT(pcontext); layout = pango_layout_new(pcontext); PLATFORM_ASSERT(layout); +#ifdef USE_CAIRO if (height > 0 && width > 0) + psurf = gdk_window_create_similar_surface( + gtk_widget_get_window(PWidget(wid)), + CAIRO_CONTENT_COLOR_ALPHA, width, height); +#else + if (height > 0 && width > 0) ppixmap = gdk_pixmap_new(surfImpl->drawable, width, height, -1); drawable = ppixmap; - gc = gdk_gc_new(surfImpl->drawable); +#endif +#ifdef USE_CAIRO + cairo_destroy(context); + context = cairo_create(psurf); + cairo_rectangle(context, 0, 0, width, height); + cairo_set_source_rgb(context, 1.0, 0, 0); + cairo_fill(context); + // This produces sharp drawing more similar to GDK: + //cairo_set_antialias(context, CAIRO_ANTIALIAS_NONE); +#endif +#ifdef USE_CAIRO + cairo_set_line_width(context, 1); +#else // Ask for lines that do not paint the last pixel so is like Win32 gdk_gc_set_line_attributes(gc, 0, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER); +#endif createdGC = true; inited = true; }
void SurfaceImpl::PenColour(ColourAllocated fore) { +#ifdef USE_CAIRO + if (context) { + ColourDesired cdFore(fore.AsLong()); + cairo_set_source_rgb(context, + cdFore.GetBlue() / 255.0, + cdFore.GetGreen() / 255.0, + cdFore.GetRed() / 255.0); + } +#else if (gc) { GdkColor co; co.pixel = fore.AsLong(); gdk_gc_set_foreground(gc, &co); } +#endif }
int SurfaceImpl::LogPixelsY() { @@ -911,18 +1001,71 @@ y = y_; }
+#ifdef USE_CAIRO +static int Delta(int difference) { + if (difference < 0) + return -1; + else if (difference > 0) + return 1; + else + return 0; +} +#endif + void SurfaceImpl::LineTo(int x_, int y_) { +#ifdef USE_CAIRO + // cairo_line_to draws the end position, unlike Win32 or GDK with GDK_CAP_NOT_LAST. + // For simple cases, move back one pixel from end. + if (context) { + int xDiff = x_ - x; + int xDelta = Delta(xDiff); + int yDiff = y_ - y; + int yDelta = Delta(yDiff); + if ((xDiff == 0) || (yDiff == 0)) { + // Horizontal or vertical lines can be more precisely drawn as a filled rectangle + int xEnd = x_ - xDelta; + int left = Platform::Minimum(x, xEnd); + int width = abs(x - xEnd) + 1; + int yEnd = y_ - yDelta; + int top = Platform::Minimum(y, yEnd); + int height = abs(y - yEnd) + 1; + cairo_rectangle(context, left, top, width, height); + cairo_fill(context); + } else if ((abs(xDiff) == abs(yDiff))) { + // 45 degree slope + cairo_move_to(context, x + 0.5, y + 0.5); + cairo_line_to(context, x_ + 0.5 - xDelta, y_ + 0.5 - yDelta); + } else { + // Line has a different slope so difficult to avoid last pixel + cairo_move_to(context, x + 0.5, y + 0.5); + cairo_line_to(context, x_ + 0.5, y_ + 0.5); + } + cairo_stroke(context); + } +#else if (drawable && gc) { gdk_draw_line(drawable, gc, x, y, x_, y_); } +#endif x = x_; y = y_; }
void SurfaceImpl::Polygon(Point *pts, int npts, ColourAllocated fore, ColourAllocated back) { +#ifdef USE_CAIRO + PenColour(back); + cairo_move_to(context, pts[0].x + 0.5, pts[0].y + 0.5); + for (int i = 1;i < npts;i++) { + cairo_line_to(context, pts[i].x + 0.5, pts[i].y + 0.5); + } + cairo_close_path(context); + cairo_fill_preserve(context); + PenColour(fore); + cairo_stroke(context); +#else GdkPoint gpts[20]; if (npts < static_cast<int>((sizeof(gpts) / sizeof(gpts[0])))) { for (int i = 0;i < npts;i++) { @@ -934,35 +1077,62 @@ PenColour(fore); gdk_draw_polygon(drawable, gc, 0, gpts, npts); } +#endif }
void SurfaceImpl::RectangleDraw(PRectangle rc, ColourAllocated fore, ColourAllocated back) { +#ifdef USE_CAIRO + if (context) { +#else if (gc && drawable) { +#endif +#ifdef USE_CAIRO + cairo_rectangle(context, rc.left + 0.5, rc.top + 0.5, + rc.right - rc.left - 1, rc.bottom - rc.top - 1); PenColour(back); + cairo_fill_preserve(context); + PenColour(fore); + cairo_stroke(context); +#else + PenColour(back); gdk_draw_rectangle(drawable, gc, 1, rc.left + 1, rc.top + 1, rc.right - rc.left - 2, rc.bottom - rc.top - 2); - PenColour(fore); // The subtraction of 1 off the width and height here shouldn't be needed but // otherwise a different rectangle is drawn than would be done if the fill parameter == 1 gdk_draw_rectangle(drawable, gc, 0, rc.left, rc.top, rc.right - rc.left - 1, rc.bottom - rc.top - 1); +#endif } }
void SurfaceImpl::FillRectangle(PRectangle rc, ColourAllocated back) { PenColour(back); +#ifdef USE_CAIRO + if (context && (rc.left < maxCoordinate)) { // Protect against out of range + cairo_rectangle(context, rc.left, rc.top, + rc.right - rc.left, rc.bottom - rc.top); + cairo_fill(context); + } +#else if (drawable && (rc.left < maxCoordinate)) { // Protect against out of range gdk_draw_rectangle(drawable, gc, 1, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top); } +#endif }
void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) { - if (static_cast<SurfaceImpl &>(surfacePattern).drawable) { + SurfaceImpl &surfi = static_cast<SurfaceImpl &>(surfacePattern); +#ifdef USE_CAIRO + bool canDraw = surfi.psurf; +#else + bool canDraw = surfi.drawable; +#endif + if (canDraw) { // Tile pattern over rectangle // Currently assumes 8x8 pattern int widthPat = 8; @@ -971,12 +1141,18 @@ int widthx = (xTile + widthPat > rc.right) ? rc.right - xTile : widthPat; for (int yTile = rc.top; yTile < rc.bottom; yTile += heightPat) { int heighty = (yTile + heightPat > rc.bottom) ? rc.bottom - yTile : heightPat; +#ifdef USE_CAIRO + cairo_set_source_surface(context, surfi.psurf, xTile, yTile); + cairo_rectangle(context, xTile, yTile, widthx, heighty); + cairo_fill(context); +#else gdk_draw_drawable(drawable, gc, static_cast<SurfaceImpl &>(surfacePattern).drawable, 0, 0, xTile, yTile, widthx, heighty); +#endif } } } else { @@ -1005,6 +1181,21 @@ } }
+#ifdef USE_CAIRO + +static void PathRoundRectangle(cairo_t *context, double left, double top, double width, double height, int radius) { + double degrees = M_PI / 180.0; + + cairo_new_sub_path(context); + cairo_arc(context, left + width - radius, top + radius, radius, -90 * degrees, 0 * degrees); + cairo_arc(context, left + width - radius, top + height - radius, radius, 0 * degrees, 90 * degrees); + cairo_arc(context, left + radius, top + height - radius, radius, 90 * degrees, 180 * degrees); + cairo_arc(context, left + radius, top + radius, radius, 180 * degrees, 270 * degrees); + cairo_close_path(context); +} + +#else + // Plot a point into a guint32 buffer symetrically to all 4 qudrants static void AllFour(guint32 *pixels, int stride, int width, int height, int x, int y, guint32 val) { pixels[y*stride+x] = val; @@ -1013,6 +1204,20 @@ pixels[(height-1-y)*stride+width-1-x] = val; }
+static guint32 u32FromRGBA(guint8 r, guint8 g, guint8 b, guint8 a) { + union { + guint8 pixVal[4]; + guint32 val; + } converter; + converter.pixVal[0] = r; + converter.pixVal[1] = g; + converter.pixVal[2] = b; + converter.pixVal[3] = a; + return converter.val; +} + +#endif + static unsigned int GetRValue(unsigned int co) { return (co >> 16) & 0xff; } @@ -1025,20 +1230,27 @@ return co & 0xff; }
-static guint32 u32FromRGBA(guint8 r, guint8 g, guint8 b, guint8 a) { - union { - guint8 pixVal[4]; - guint32 val; - } converter; - converter.pixVal[0] = r; - converter.pixVal[1] = g; - converter.pixVal[2] = b; - converter.pixVal[3] = a; - return converter.val; -} - void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill, ColourAllocated outline, int alphaOutline, int flags) { +#ifdef USE_CAIRO + if (context && rc.Width() > 0) { + cairo_set_source_rgba(context, + GetRValue(fill.AsLong()) / 255.0, + GetGValue(fill.AsLong()) / 255.0, + GetBValue(fill.AsLong()) / 255.0, + alphaFill / 255.0); + PathRoundRectangle(context, rc.left + 1.0, rc.top+1.0, rc.right - rc.left - 2.0, rc.bottom - rc.top - 2.0, cornerSize); + cairo_fill(context); + + cairo_set_source_rgba(context, + GetRValue(outline.AsLong()) / 255.0, + GetGValue(outline.AsLong()) / 255.0, + GetBValue(outline.AsLong()) / 255.0, + alphaOutline / 255.0); + PathRoundRectangle(context, rc.left +0.5, rc.top+0.5, rc.right - rc.left - 1, rc.bottom - rc.top - 1, cornerSize); + cairo_stroke(context); + } +#else if (gc && drawable && rc.Width() > 0) { int width = rc.Width(); int height = rc.Height(); @@ -1078,10 +1290,18 @@
g_object_unref(pixalpha); } +#endif }
void SurfaceImpl::Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated back) { PenColour(back); +#ifdef USE_CAIRO + cairo_arc(context, (rc.left + rc.right) / 2 + 0.5, (rc.top + rc.bottom) / 2 + 0.5, + Platform::Minimum(rc.Width(), rc.Height()) / 2, 0, 2*M_PI); + cairo_fill_preserve(context); + PenColour(fore); + cairo_stroke(context); +#else gdk_draw_arc(drawable, gc, 1, rc.left + 1, rc.top + 1, rc.right - rc.left - 2, rc.bottom - rc.top - 2, @@ -1093,16 +1313,30 @@ rc.left, rc.top, rc.right - rc.left - 1, rc.bottom - rc.top - 1, 0, 32767); +#endif }
void SurfaceImpl::Copy(PRectangle rc, Point from, Surface &surfaceSource) { - if (static_cast<SurfaceImpl &>(surfaceSource).drawable) { + SurfaceImpl &surfi = static_cast<SurfaceImpl &>(surfaceSource); +#ifdef USE_CAIRO + bool canDraw = surfi.psurf; +#else + bool canDraw = surfi.drawable; +#endif + if (canDraw) { +#ifdef USE_CAIRO + cairo_set_source_surface(context, surfi.psurf, + rc.left - from.x, rc.top - from.y); + cairo_rectangle(context, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top); + cairo_fill(context); +#else gdk_draw_drawable(drawable, gc, static_cast<SurfaceImpl &>(surfaceSource).drawable, from.x, from.y, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top); +#endif } }
@@ -1232,7 +1466,11 @@ void SurfaceImpl::DrawTextBase(PRectangle rc, Font &font_, int ybase, const char *s, int len, ColourAllocated fore) { PenColour(fore); +#ifdef USE_CAIRO + if (context) { +#else if (gc && drawable) { +#endif int xText = rc.left; if (PFont(font_)->pfd) { char *utfForm = 0; @@ -1256,12 +1494,20 @@ pango_layout_set_text(layout, utfForm, len); } pango_layout_set_font_description(layout, PFont(font_)->pfd); +#ifdef USE_CAIRO + pango_cairo_update_layout(context, layout); +#endif #ifdef PANGO_VERSION PangoLayoutLine *pll = pango_layout_get_line_readonly(layout,0); #else PangoLayoutLine *pll = pango_layout_get_line(layout,0); #endif +#ifdef USE_CAIRO + cairo_move_to(context, xText, ybase); + pango_cairo_show_layout_line(context, pll); +#else gdk_draw_layout_line(drawable, gc, xText, ybase, pll); +#endif if (useGFree) { g_free(utfForm); } else { @@ -1717,9 +1963,14 @@ }
void SurfaceImpl::SetClip(PRectangle rc) { +#ifdef USE_CAIRO + cairo_rectangle(context, rc.left, rc.top, rc.right, rc.bottom); + cairo_clip(context); +#else GdkRectangle area = {rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top}; gdk_gc_set_clip_rectangle(gc, &area); +#endif }
void SurfaceImpl::FlushCachedState() {} @@ -1875,7 +2126,6 @@ gdk window coordinates */ PRectangle Window::GetMonitorRect(Point pt) { gint x_offset, y_offset; - pt = pt;
gdk_window_get_origin(PWidget(wid)->window, &x_offset, &y_offset);
@@ -1894,6 +2144,7 @@ return PRectangle(rect.x, rect.y, rect.x + rect.width, rect.y + rect.height); } #else + pt = pt; return PRectangle(-x_offset, -y_offset, (-x_offset) + gdk_screen_width(), (-y_offset) + gdk_screen_height()); #endif @@ -1936,7 +2187,7 @@ CallBackAction doubleClickAction; void *doubleClickActionData;
- ListBoxX() : list(0), pixhash(NULL), pixbuf_renderer(0), + ListBoxX() : list(0), scroller(0), pixhash(NULL), pixbuf_renderer(0), desiredVisibleRows(5), maxItemCharacters(0), aveCharWidth(1), doubleClickAction(NULL), doubleClickActionData(NULL) { }
Modified: branches/sm/scintilla/gtk/ScintillaGTK.cxx =================================================================== --- branches/sm/scintilla/gtk/ScintillaGTK.cxx 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/gtk/ScintillaGTK.cxx 2011-05-21 08:58:07 UTC (rev 5808) @@ -75,6 +75,10 @@ #define IS_WIDGET_VISIBLE(w) (GTK_WIDGET_VISIBLE(w)) #endif
+#if GTK_CHECK_VERSION(2,22,0) +#define USE_CAIRO 1 +#endif + #ifdef _MSC_VER // Constant conditional expressions are because of GTK+ headers #pragma warning(disable: 4127) @@ -416,6 +420,26 @@ gtk_widget_realize(widtxt); gtk_widget_realize(PWidget(scrollbarv)); gtk_widget_realize(PWidget(scrollbarh)); + + cursor = gdk_cursor_new(GDK_XTERM); + gdk_window_set_cursor(PWidget(wText)->window, cursor); + gdk_cursor_unref(cursor); + + cursor = gdk_cursor_new(GDK_LEFT_PTR); + gdk_window_set_cursor(PWidget(scrollbarv)->window, cursor); + gdk_cursor_unref(cursor); + + cursor = gdk_cursor_new(GDK_LEFT_PTR); + gdk_window_set_cursor(PWidget(scrollbarh)->window, cursor); + gdk_cursor_unref(cursor); + + gtk_selection_add_targets(widget, GDK_SELECTION_PRIMARY, + clipboardCopyTargets, nClipboardCopyTargets); + +#ifndef USE_GTK_CLIPBOARD + gtk_selection_add_targets(widget, atomClipboard, + clipboardPasteTargets, nClipboardPasteTargets); +#endif }
void ScintillaGTK::Realize(GtkWidget *widget) { @@ -425,6 +449,14 @@
void ScintillaGTK::UnRealizeThis(GtkWidget *widget) { try { + + gtk_selection_clear_targets(widget, GDK_SELECTION_PRIMARY); + +#ifndef USE_GTK_CLIPBOARD + gtk_selection_clear_targets(widget, atomClipboard); +#endif + + if (IS_WIDGET_MAPPED(widget)) { gtk_widget_unmap(widget); } @@ -531,7 +563,6 @@
gint ScintillaGTK::FocusInThis(GtkWidget *widget) { try { - GTK_WIDGET_SET_FLAGS(widget, GTK_HAS_FOCUS); SetFocusState(true); if (im_context != NULL) { gchar *str = NULL; @@ -562,7 +593,6 @@
gint ScintillaGTK::FocusOutThis(GtkWidget *widget) { try { - GTK_WIDGET_UNSET_FLAGS(widget, GTK_HAS_FOCUS); SetFocusState(false);
if (PWidget(wPreedit) != NULL) @@ -668,14 +698,6 @@
gtk_widget_grab_focus(PWidget(wMain));
- gtk_selection_add_targets(GTK_WIDGET(PWidget(wMain)), GDK_SELECTION_PRIMARY, - clipboardCopyTargets, nClipboardCopyTargets); - -#ifndef USE_GTK_CLIPBOARD - gtk_selection_add_targets(GTK_WIDGET(PWidget(wMain)), atomClipboard, - clipboardPasteTargets, nClipboardPasteTargets); -#endif - gtk_drag_dest_set(GTK_WIDGET(PWidget(wMain)), GTK_DEST_DEFAULT_ALL, clipboardPasteTargets, nClipboardPasteTargets, static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_MOVE)); @@ -1422,7 +1444,7 @@
UndoGroup ug(pdoc); if (selection_data->selection != GDK_SELECTION_PRIMARY) { - ClearSelection(); + ClearSelection(multiPasteMode == SC_MULTIPASTE_EACH); } SelectionPosition selStart = sel.IsRectangular() ? sel.Rectangular().Start() : @@ -1983,6 +2005,7 @@ PangoLayout *layout = gtk_widget_create_pango_layout(PWidget(wText), str); pango_layout_set_attributes(layout, attrs);
+#ifndef USE_CAIRO GdkGC *gc = gdk_gc_new(widget->window); GdkColor color[2] = { {0, 0x0000, 0x0000, 0x0000}, {0, 0xffff, 0xffff, 0xffff} @@ -1997,8 +2020,8 @@ gdk_gc_set_foreground(gc, color); gdk_gc_set_background(gc, color + 1); gdk_draw_layout(widget->window, gc, 0, 0, layout); - g_object_unref(gc); +#endif g_free(str); pango_attr_list_unref(attrs); g_object_unref(layout);
Modified: branches/sm/scintilla/gtk/scintilla-marshal.c =================================================================== --- branches/sm/scintilla/gtk/scintilla-marshal.c 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/gtk/scintilla-marshal.c 2011-05-21 08:58:07 UTC (rev 5808) @@ -35,8 +35,8 @@ #define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong #define g_marshal_value_peek_int64(v) (v)->data[0].v_int64 #define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64 -#define g_marshal_value_peek_enum(v) (v)->data[0].v_int -#define g_marshal_value_peek_flags(v) (v)->data[0].v_uint +#define g_marshal_value_peek_enum(v) (v)->data[0].v_long +#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong #define g_marshal_value_peek_float(v) (v)->data[0].v_float #define g_marshal_value_peek_double(v) (v)->data[0].v_double #define g_marshal_value_peek_string(v) (v)->data[0].v_pointer @@ -50,10 +50,10 @@ /* NONE:INT,POINTER (scintilla-marshal.list:1) */ void scintilla_marshal_VOID__INT_POINTER (GClosure *closure, - GValue *return_value, + GValue *return_value G_GNUC_UNUSED, guint n_param_values, const GValue *param_values, - gpointer invocation_hint, + gpointer invocation_hint G_GNUC_UNUSED, gpointer marshal_data) { typedef void (*GMarshalFunc_VOID__INT_POINTER) (gpointer data1,
Modified: branches/sm/scintilla/include/Platform.h =================================================================== --- branches/sm/scintilla/include/Platform.h 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/include/Platform.h 2011-05-21 08:58:07 UTC (rev 5808) @@ -255,8 +255,8 @@ int allocatedLen; #endif // Private so Palette objects can not be copied - Palette(const Palette &) {} - Palette &operator=(const Palette &) { return *this; } + Palette(const Palette &); + Palette &operator=(const Palette &); public: #if PLAT_WIN void *hpal; @@ -288,8 +288,8 @@ int ascent; #endif // Private so Font objects can not be copied - Font(const Font &) {} - Font &operator=(const Font &) { fid=0; return *this; } + Font(const Font &); + Font &operator=(const Font &); public: Font(); virtual ~Font();
Modified: branches/sm/scintilla/include/SciLexer.h =================================================================== --- branches/sm/scintilla/include/SciLexer.h 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/include/SciLexer.h 2011-05-21 08:58:07 UTC (rev 5808) @@ -112,6 +112,8 @@ #define SCLEX_SML 97 #define SCLEX_MARKDOWN 98 #define SCLEX_TXT2TAGS 99 +#define SCLEX_A68K 100 +#define SCLEX_MODULA 101 #define SCLEX_AUTOMATIC 1000 #define SCE_P_DEFAULT 0 #define SCE_P_COMMENTLINE 1 @@ -149,6 +151,8 @@ #define SCE_C_COMMENTDOCKEYWORD 17 #define SCE_C_COMMENTDOCKEYWORDERROR 18 #define SCE_C_GLOBALCLASS 19 +#define SCE_C_STRINGRAW 20 +#define SCE_C_TRIPLEVERBATIM 21 #define SCE_D_DEFAULT 0 #define SCE_D_COMMENT 1 #define SCE_D_COMMENTLINE 2 @@ -601,6 +605,7 @@ #define SCE_ASM_CHARACTER 12 #define SCE_ASM_STRINGEOL 13 #define SCE_ASM_EXTINSTRUCTION 14 +#define SCE_ASM_COMMENTDIRECTIVE 15 #define SCE_F_DEFAULT 0 #define SCE_F_COMMENT 1 #define SCE_F_NUMBER 2 @@ -1415,6 +1420,43 @@ #define SCE_TXT2TAGS_OPTION 23 #define SCE_TXT2TAGS_PREPROC 24 #define SCE_TXT2TAGS_POSTPROC 25 +#define SCE_A68K_DEFAULT 0 +#define SCE_A68K_COMMENT 1 +#define SCE_A68K_NUMBER_DEC 2 +#define SCE_A68K_NUMBER_BIN 3 +#define SCE_A68K_NUMBER_HEX 4 +#define SCE_A68K_STRING1 5 +#define SCE_A68K_OPERATOR 6 +#define SCE_A68K_CPUINSTRUCTION 7 +#define SCE_A68K_EXTINSTRUCTION 8 +#define SCE_A68K_REGISTER 9 +#define SCE_A68K_DIRECTIVE 10 +#define SCE_A68K_MACRO_ARG 11 +#define SCE_A68K_LABEL 12 +#define SCE_A68K_STRING2 13 +#define SCE_A68K_IDENTIFIER 14 +#define SCE_A68K_MACRO_DECLARATION 15 +#define SCE_A68K_COMMENT_WORD 16 +#define SCE_A68K_COMMENT_SPECIAL 17 +#define SCE_A68K_COMMENT_DOXYGEN 18 +#define SCE_MODULA_DEFAULT 0 +#define SCE_MODULA_COMMENT 1 +#define SCE_MODULA_DOXYCOMM 2 +#define SCE_MODULA_DOXYKEY 3 +#define SCE_MODULA_KEYWORD 4 +#define SCE_MODULA_RESERVED 5 +#define SCE_MODULA_NUMBER 6 +#define SCE_MODULA_BASENUM 7 +#define SCE_MODULA_FLOAT 8 +#define SCE_MODULA_STRING 9 +#define SCE_MODULA_STRSPEC 10 +#define SCE_MODULA_CHAR 11 +#define SCE_MODULA_CHARSPEC 12 +#define SCE_MODULA_PROC 13 +#define SCE_MODULA_PRAGMA 14 +#define SCE_MODULA_PRGKEY 15 +#define SCE_MODULA_OPERATOR 16 +#define SCE_MODULA_BADSTR 17 /* --Autogenerated -- end of section automatically generated from Scintilla.iface */
#endif
Modified: branches/sm/scintilla/include/Scintilla.h =================================================================== --- branches/sm/scintilla/include/Scintilla.h 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/include/Scintilla.h 2011-05-21 08:58:07 UTC (rev 5808) @@ -159,6 +159,8 @@ #define SCI_GETMARGINMASKN 2245 #define SCI_SETMARGINSENSITIVEN 2246 #define SCI_GETMARGINSENSITIVEN 2247 +#define SCI_SETMARGINCURSORN 2248 +#define SCI_GETMARGINCURSORN 2249 #define STYLE_DEFAULT 32 #define STYLE_LINENUMBER 33 #define STYLE_BRACELIGHT 34 @@ -590,7 +592,9 @@ #define SCI_SETMOUSEDOWNCAPTURES 2384 #define SCI_GETMOUSEDOWNCAPTURES 2385 #define SC_CURSORNORMAL -1 +#define SC_CURSORARROW 2 #define SC_CURSORWAIT 4 +#define SC_CURSORREVERSEARROW 7 #define SCI_SETCURSOR 2386 #define SCI_GETCURSOR 2387 #define SCI_SETCONTROLCHARSYMBOL 2388 @@ -832,6 +836,10 @@ #define SC_MOD_CONTAINER 0x40000 #define SC_MOD_LEXERSTATE 0x80000 #define SC_MODEVENTMASKALL 0xFFFFF +#define SC_UPDATE_CONTENT 0x1 +#define SC_UPDATE_SELECTION 0x2 +#define SC_UPDATE_V_SCROLL 0x4 +#define SC_UPDATE_H_SCROLL 0x8 #define SCEN_CHANGE 768 #define SCEN_SETFOCUS 512 #define SCEN_KILLFOCUS 256 @@ -971,6 +979,7 @@ int y; /* SCN_DWELLSTART, SCN_DWELLEND */ int token; /* SCN_MODIFIED with SC_MOD_CONTAINER */ int annotationLinesAdded; /* SC_MOD_CHANGEANNOTATION */ + int updated; /* SCN_UPDATEUI */ };
#ifdef SCI_NAMESPACE
Modified: branches/sm/scintilla/include/Scintilla.iface =================================================================== --- branches/sm/scintilla/include/Scintilla.iface 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/include/Scintilla.iface 2011-05-21 08:58:07 UTC (rev 5808) @@ -352,6 +352,12 @@ # Retrieve the mouse click sensitivity of a margin. get bool GetMarginSensitiveN=2247(int margin,)
+# Set the cursor shown when the mouse is inside a margin. +set void SetMarginCursorN=2248(int margin, int cursor) + +# Retrieve the cursor shown in a margin. +get int GetMarginCursorN=2249(int margin,) + # Styles in range 32..38 are predefined for parts of the UI and are not used as normal styles. # Style 39 is for future use. enu StylesCommon=STYLE_ @@ -1540,7 +1546,9 @@
enu CursorShape=SC_CURSOR val SC_CURSORNORMAL=-1 +val SC_CURSORARROW=2 val SC_CURSORWAIT=4 +val SC_CURSORREVERSEARROW=7 # Sets the cursor to one of the SC_CURSOR* values. set void SetCursor=2386(int cursorType,) # Get cursor type. @@ -2193,6 +2201,12 @@ val SC_MOD_LEXERSTATE=0x80000 val SC_MODEVENTMASKALL=0xFFFFF
+enu Update=SC_UPDATE_ +val SC_UPDATE_CONTENT=0x1 +val SC_UPDATE_SELECTION=0x2 +val SC_UPDATE_V_SCROLL=0x4 +val SC_UPDATE_H_SCROLL=0x8 + # For compatibility, these go through the COMMAND notification rather than NOTIFY # and should have had exactly the same values as the EN_* constants. # Unfortunately the SETFOCUS and KILLFOCUS are flipped over from EN_* @@ -2335,6 +2349,8 @@ val SCLEX_SML=97 val SCLEX_MARKDOWN=98 val SCLEX_TXT2TAGS=99 +val SCLEX_A68K=100 +val SCLEX_MODULA=101
# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a # value assigned in sequence from SCLEX_AUTOMATIC+1. @@ -2381,6 +2397,8 @@ val SCE_C_COMMENTDOCKEYWORD=17 val SCE_C_COMMENTDOCKEYWORDERROR=18 val SCE_C_GLOBALCLASS=19 +val SCE_C_STRINGRAW=20 +val SCE_C_TRIPLEVERBATIM=21 # Lexical states for SCLEX_D lex D=SCLEX_D SCE_D_ val SCE_D_DEFAULT=0 @@ -2900,6 +2918,7 @@ val SCE_ASM_CHARACTER=12 val SCE_ASM_STRINGEOL=13 val SCE_ASM_EXTINSTRUCTION=14 +val SCE_ASM_COMMENTDIRECTIVE=15 # Lexical states for SCLEX_FORTRAN lex Fortran=SCLEX_FORTRAN SCE_F_ lex F77=SCLEX_F77 SCE_F_ @@ -3819,6 +3838,47 @@ val SCE_TXT2TAGS_OPTION=23 val SCE_TXT2TAGS_PREPROC=24 val SCE_TXT2TAGS_POSTPROC=25 +# Lexical states for SCLEX_A68K +lex A68k=SCLEX_A68K SCE_A68K_ +val SCE_A68K_DEFAULT=0 +val SCE_A68K_COMMENT=1 +val SCE_A68K_NUMBER_DEC=2 +val SCE_A68K_NUMBER_BIN=3 +val SCE_A68K_NUMBER_HEX=4 +val SCE_A68K_STRING1=5 +val SCE_A68K_OPERATOR=6 +val SCE_A68K_CPUINSTRUCTION=7 +val SCE_A68K_EXTINSTRUCTION=8 +val SCE_A68K_REGISTER=9 +val SCE_A68K_DIRECTIVE=10 +val SCE_A68K_MACRO_ARG=11 +val SCE_A68K_LABEL=12 +val SCE_A68K_STRING2=13 +val SCE_A68K_IDENTIFIER=14 +val SCE_A68K_MACRO_DECLARATION=15 +val SCE_A68K_COMMENT_WORD=16 +val SCE_A68K_COMMENT_SPECIAL=17 +val SCE_A68K_COMMENT_DOXYGEN=18 +# Lexical states for SCLEX_MODULA +lex Modula=SCLEX_MODULA SCE_MODULA_ +val SCE_MODULA_DEFAULT=0 +val SCE_MODULA_COMMENT=1 +val SCE_MODULA_DOXYCOMM=2 +val SCE_MODULA_DOXYKEY=3 +val SCE_MODULA_KEYWORD=4 +val SCE_MODULA_RESERVED=5 +val SCE_MODULA_NUMBER=6 +val SCE_MODULA_BASENUM=7 +val SCE_MODULA_FLOAT=8 +val SCE_MODULA_STRING=9 +val SCE_MODULA_STRSPEC=10 +val SCE_MODULA_CHAR=11 +val SCE_MODULA_CHARSPEC=12 +val SCE_MODULA_PROC=13 +val SCE_MODULA_PRAGMA=14 +val SCE_MODULA_PRGKEY=15 +val SCE_MODULA_OPERATOR=16 +val SCE_MODULA_BADSTR=17
# Events
Modified: branches/sm/scintilla/lexers/LexAda.cxx =================================================================== --- branches/sm/scintilla/lexers/LexAda.cxx 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/lexers/LexAda.cxx 2011-05-21 08:58:07 UTC (rev 5808) @@ -17,7 +17,6 @@ #include "Scintilla.h" #include "SciLexer.h"
-#include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h"
Modified: branches/sm/scintilla/lexers/LexAsm.cxx =================================================================== --- branches/sm/scintilla/lexers/LexAsm.cxx 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/lexers/LexAsm.cxx 2011-05-21 08:58:07 UTC (rev 5808) @@ -4,6 +4,7 @@ ** Written by The Black Horus ** Enhancements and NASM stuff by Kein-Hong Man, 2003-10 ** SCE_ASM_COMMENTBLOCK and SCE_ASM_CHARACTER are for future GNU as colouring + ** Converted to lexer object and added further folding features/properties by "Udo Lechner" <dlchnr(at)gmx(dot)net> **/ // Copyright 1998-2003 by Neil Hodgson neilh@scintilla.org // The License.txt file describes the conditions under which this software may be distributed. @@ -15,17 +16,24 @@ #include <assert.h> #include <ctype.h>
+#ifdef _MSC_VER +#pragma warning(disable: 4786) +#endif + +#include <string> +#include <map> +#include <set> + #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h"
-#include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" -#include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" +#include "OptionSet.h"
#ifdef SCI_NAMESPACE using namespace Scintilla; @@ -54,16 +62,185 @@ return false; }
-static void ColouriseAsmDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], - Accessor &styler) { +static bool IsStreamCommentStyle(int style) { + return style == SCE_ASM_COMMENTDIRECTIVE || style == SCE_ASM_COMMENTBLOCK; +}
- WordList &cpuInstruction = *keywordlists[0]; - WordList &mathInstruction = *keywordlists[1]; - WordList ®isters = *keywordlists[2]; - WordList &directive = *keywordlists[3]; - WordList &directiveOperand = *keywordlists[4]; - WordList &extInstruction = *keywordlists[5]; +static inline int LowerCase(int c) { + if (c >= 'A' && c <= 'Z') + return 'a' + c - 'A'; + return c; +}
+// An individual named option for use in an OptionSet + +// Options used for LexerAsm +struct OptionsAsm { + std::string delimiter; + bool fold; + bool foldSyntaxBased; + bool foldCommentMultiline; + bool foldCommentExplicit; + std::string foldExplicitStart; + std::string foldExplicitEnd; + bool foldExplicitAnywhere; + bool foldCompact; + OptionsAsm() { + delimiter = ""; + fold = false; + foldSyntaxBased = true; + foldCommentMultiline = false; + foldCommentExplicit = false; + foldExplicitStart = ""; + foldExplicitEnd = ""; + foldExplicitAnywhere = false; + foldCompact = true; + } +}; + +static const char * const asmWordListDesc[] = { + "CPU instructions", + "FPU instructions", + "Registers", + "Directives", + "Directive operands", + "Extended instructions", + "Directives4Foldstart", + "Directives4Foldend", + 0 +}; + +struct OptionSetAsm : public OptionSet<OptionsAsm> { + OptionSetAsm() { + DefineProperty("lexer.asm.comment.delimiter", &OptionsAsm::delimiter, + "Character used for COMMENT directive's delimiter, replacing the standard "~"."); + + DefineProperty("fold", &OptionsAsm::fold); + + DefineProperty("fold.asm.syntax.based", &OptionsAsm::foldSyntaxBased, + "Set this property to 0 to disable syntax based folding."); + + DefineProperty("fold.asm.comment.multiline", &OptionsAsm::foldCommentMultiline, + "Set this property to 1 to enable folding multi-line comments."); + + DefineProperty("fold.asm.comment.explicit", &OptionsAsm::foldCommentExplicit, + "This option enables folding explicit fold points when using the Asm lexer. " + "Explicit fold points allows adding extra folding by placing a ;{ comment at the start and a ;} " + "at the end of a section that should fold."); + + DefineProperty("fold.asm.explicit.start", &OptionsAsm::foldExplicitStart, + "The string to use for explicit fold start points, replacing the standard ;{."); + + DefineProperty("fold.asm.explicit.end", &OptionsAsm::foldExplicitEnd, + "The string to use for explicit fold end points, replacing the standard ;}."); + + DefineProperty("fold.asm.explicit.anywhere", &OptionsAsm::foldExplicitAnywhere, + "Set this property to 1 to enable explicit fold points anywhere, not just in line comments."); + + DefineProperty("fold.compact", &OptionsAsm::foldCompact); + + DefineWordListSets(asmWordListDesc); + } +}; + +class LexerAsm : public ILexer { + WordList cpuInstruction; + WordList mathInstruction; + WordList registers; + WordList directive; + WordList directiveOperand; + WordList extInstruction; + WordList directives4foldstart; + WordList directives4foldend; + OptionsAsm options; + OptionSetAsm osAsm; +public: + LexerAsm() { + } + ~LexerAsm() { + } + void SCI_METHOD Release() { + delete this; + } + int SCI_METHOD Version() const { + return lvOriginal; + } + const char * SCI_METHOD PropertyNames() { + return osAsm.PropertyNames(); + } + int SCI_METHOD PropertyType(const char *name) { + return osAsm.PropertyType(name); + } + const char * SCI_METHOD DescribeProperty(const char *name) { + return osAsm.DescribeProperty(name); + } + int SCI_METHOD PropertySet(const char *key, const char *val); + const char * SCI_METHOD DescribeWordListSets() { + return osAsm.DescribeWordListSets(); + } + int SCI_METHOD WordListSet(int n, const char *wl); + void SCI_METHOD Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess); + void SCI_METHOD Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess); + + void * SCI_METHOD PrivateCall(int, void *) { + return 0; + } + + static ILexer *LexerFactoryAsm() { + return new LexerAsm(); + } +}; + +int SCI_METHOD LexerAsm::PropertySet(const char *key, const char *val) { + if (osAsm.PropertySet(&options, key, val)) { + return 0; + } + return -1; +} + +int SCI_METHOD LexerAsm::WordListSet(int n, const char *wl) { + WordList *wordListN = 0; + switch (n) { + case 0: + wordListN = &cpuInstruction; + break; + case 1: + wordListN = &mathInstruction; + break; + case 2: + wordListN = ®isters; + break; + case 3: + wordListN = &directive; + break; + case 4: + wordListN = &directiveOperand; + break; + case 5: + wordListN = &extInstruction; + break; + case 6: + wordListN = &directives4foldstart; + break; + case 7: + wordListN = &directives4foldend; + break; + } + int firstModification = -1; + if (wordListN) { + WordList wlNew; + wlNew.Set(wl); + if (*wordListN != wlNew) { + wordListN->Set(wl); + firstModification = 0; + } + } + return firstModification; +} + +void SCI_METHOD LexerAsm::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess) { + LexAccessor styler(pAccess); + // Do not leak onto next line if (initStyle == SCE_ASM_STRINGEOL) initStyle = SCE_ASM_DEFAULT; @@ -96,7 +273,7 @@ if (!IsAsmOperator(sc.ch)) { sc.SetState(SCE_ASM_DEFAULT); } - }else if (sc.state == SCE_ASM_NUMBER) { + } else if (sc.state == SCE_ASM_NUMBER) { if (!IsAWordChar(sc.ch)) { sc.SetState(SCE_ASM_DEFAULT); } @@ -104,6 +281,7 @@ if (!IsAWordChar(sc.ch) ) { char s[100]; sc.GetCurrentLowered(s, sizeof(s)); + bool IsDirective = false;
if (cpuInstruction.InList(s)) { sc.ChangeState(SCE_ASM_CPUINSTRUCTION); @@ -113,15 +291,32 @@ sc.ChangeState(SCE_ASM_REGISTER); } else if (directive.InList(s)) { sc.ChangeState(SCE_ASM_DIRECTIVE); + IsDirective = true; } else if (directiveOperand.InList(s)) { sc.ChangeState(SCE_ASM_DIRECTIVEOPERAND); } else if (extInstruction.InList(s)) { sc.ChangeState(SCE_ASM_EXTINSTRUCTION); } sc.SetState(SCE_ASM_DEFAULT); + if (IsDirective && !strcmp(s, "comment")) { + char delimiter = options.delimiter.empty() ? '~' : options.delimiter.c_str()[0]; + while (IsASpaceOrTab(sc.ch) && !sc.atLineEnd) { + sc.ForwardSetState(SCE_ASM_DEFAULT); + } + if (sc.ch == delimiter) { + sc.SetState(SCE_ASM_COMMENTDIRECTIVE); + } + } } - } - else if (sc.state == SCE_ASM_COMMENT ) { + } else if (sc.state == SCE_ASM_COMMENTDIRECTIVE) { + char delimiter = options.delimiter.empty() ? '~' : options.delimiter.c_str()[0]; + if (sc.ch == delimiter) { + while (!sc.atLineEnd) { + sc.Forward(); + } + sc.SetState(SCE_ASM_DEFAULT); + } + } else if (sc.state == SCE_ASM_COMMENT ) { if (sc.atLineEnd) { sc.SetState(SCE_ASM_DEFAULT); } @@ -170,15 +365,100 @@ sc.Complete(); }
-static const char * const asmWordListDesc[] = { - "CPU instructions", - "FPU instructions", - "Registers", - "Directives", - "Directive operands", - "Extended instructions", - 0 -}; +// Store both the current line's fold level and the next lines in the +// level store to make it easy to pick up with each increment +// and to make it possible to fiddle the current level for "else".
-LexerModule lmAsm(SCLEX_ASM, ColouriseAsmDoc, "asm", 0, asmWordListDesc); +void SCI_METHOD LexerAsm::Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess) {
+ if (!options.fold) + return; + + LexAccessor styler(pAccess); + + unsigned int endPos = startPos + length; + int visibleChars = 0; + int lineCurrent = styler.GetLine(startPos); + int levelCurrent = SC_FOLDLEVELBASE; + if (lineCurrent > 0) + levelCurrent = styler.LevelAt(lineCurrent-1) >> 16; + int levelNext = levelCurrent; + char chNext = styler[startPos]; + int styleNext = styler.StyleAt(startPos); + int style = initStyle; + char word[100]; + int wordlen = 0; + const bool userDefinedFoldMarkers = !options.foldExplicitStart.empty() && !options.foldExplicitEnd.empty(); + for (unsigned int i = startPos; i < endPos; i++) { + char ch = chNext; + chNext = styler.SafeGetCharAt(i + 1); + int stylePrev = style; + style = styleNext; + styleNext = styler.StyleAt(i + 1); + bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); + if (options.foldCommentMultiline && IsStreamCommentStyle(style)) { + if (!IsStreamCommentStyle(stylePrev)) { + levelNext++; + } else if (!IsStreamCommentStyle(styleNext) && !atEOL) { + // Comments don't end at end of line and the next character may be unstyled. + levelNext--; + } + } + if (options.foldCommentExplicit && ((style == SCE_ASM_COMMENT) || options.foldExplicitAnywhere)) { + if (userDefinedFoldMarkers) { + if (styler.Match(i, options.foldExplicitStart.c_str())) { + levelNext++; + } else if (styler.Match(i, options.foldExplicitEnd.c_str())) { + levelNext--; + } + } else { + if (ch == ';') { + if (chNext == '{') { + levelNext++; + } else if (chNext == '}') { + levelNext--; + } + } + } + } + if (options.foldSyntaxBased && (style == SCE_ASM_DIRECTIVE)) { + word[wordlen++] = static_cast<char>(LowerCase(ch)); + if (wordlen == 100) { // prevent overflow + word[0] = '\0'; + wordlen = 1; + } + if (styleNext != SCE_ASM_DIRECTIVE) { // reading directive ready + word[wordlen] = '\0'; + wordlen = 0; + if (directives4foldstart.InList(word)) { + levelNext++; + } else if (directives4foldend.InList(word)){ + levelNext--; + } + } + } + if (!IsASpace(ch)) + visibleChars++; + if (atEOL || (i == endPos-1)) { + int levelUse = levelCurrent; + int lev = levelUse | levelNext << 16; + if (visibleChars == 0 && options.foldCompact) + lev |= SC_FOLDLEVELWHITEFLAG; + if (levelUse < levelNext) + lev |= SC_FOLDLEVELHEADERFLAG; + if (lev != styler.LevelAt(lineCurrent)) { + styler.SetLevel(lineCurrent, lev); + } + lineCurrent++; + levelCurrent = levelNext; + if (atEOL && (i == static_cast<unsigned int>(styler.Length()-1))) { + // There is an empty line at end of file so give it same level and empty + styler.SetLevel(lineCurrent, (levelCurrent | levelCurrent << 16) | SC_FOLDLEVELWHITEFLAG); + } + visibleChars = 0; + } + } +} + +LexerModule lmAsm(SCLEX_ASM, LexerAsm::LexerFactoryAsm, "asm", asmWordListDesc); +
Modified: branches/sm/scintilla/lexers/LexBash.cxx =================================================================== --- branches/sm/scintilla/lexers/LexBash.cxx 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/lexers/LexBash.cxx 2011-05-21 08:58:07 UTC (rev 5808) @@ -16,7 +16,6 @@ #include "Scintilla.h" #include "SciLexer.h"
-#include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" @@ -640,6 +639,14 @@ levelCurrent--; } } + // Here Document folding + if (style == SCE_SH_HERE_DELIM) { + if (ch == '<' && chNext == '<') { + levelCurrent++; + } + } else if (style == SCE_SH_HERE_Q && styler.StyleAt(i+1) == SCE_PL_DEFAULT) { + levelCurrent--; + } if (atEOL) { int lev = levelPrev; if (visibleChars == 0 && foldCompact)
Modified: branches/sm/scintilla/lexers/LexCOBOL.cxx =================================================================== --- branches/sm/scintilla/lexers/LexCOBOL.cxx 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/lexers/LexCOBOL.cxx 2011-05-21 08:58:07 UTC (rev 5808) @@ -19,7 +19,6 @@ #include "Scintilla.h" #include "SciLexer.h"
-#include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h"
Modified: branches/sm/scintilla/lexers/LexCPP.cxx =================================================================== --- branches/sm/scintilla/lexers/LexCPP.cxx 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/lexers/LexCPP.cxx 2011-05-21 08:58:07 UTC (rev 5808) @@ -1,6 +1,7 @@ // Scintilla source code edit control /** @file LexCPP.cxx ** Lexer for C++, C, Java, and JavaScript. + ** Further folding features and configuration properties added by "Udo Lechner" <dlchnr(at)gmx(dot)net> **/ // Copyright 1998-2005 by Neil Hodgson neilh@scintilla.org // The License.txt file describes the conditions under which this software may be distributed. @@ -15,10 +16,6 @@ #ifdef _MSC_VER #pragma warning(disable: 4786) #endif -#ifdef __BORLANDC__ -// Borland C++ displays warnings in vector header without this -#pragma option -w-ccc -w-rch -#endif
#include <string> #include <vector> @@ -29,7 +26,6 @@ #include "Scintilla.h" #include "SciLexer.h"
-#include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" @@ -37,6 +33,7 @@ #include "CharacterSet.h" #include "LexerModule.h" #include "OptionSet.h" +#include "SparseState.h"
#ifdef SCI_NAMESPACE using namespace Scintilla; @@ -211,9 +208,15 @@ bool identifiersAllowDollars; bool trackPreprocessor; bool updatePreprocessor; + bool triplequotedStrings; bool fold; + bool foldSyntaxBased; bool foldComment; + bool foldCommentMultiline; bool foldCommentExplicit; + std::string foldExplicitStart; + std::string foldExplicitEnd; + bool foldExplicitAnywhere; bool foldPreprocessor; bool foldCompact; bool foldAtElse; @@ -222,9 +225,15 @@ identifiersAllowDollars = true; trackPreprocessor = true; updatePreprocessor = true; + triplequotedStrings = false; fold = false; + foldSyntaxBased = true; foldComment = false; + foldCommentMultiline = true; foldCommentExplicit = true; + foldExplicitStart = ""; + foldExplicitEnd = ""; + foldExplicitAnywhere = false; foldPreprocessor = false; foldCompact = false; foldAtElse = false; @@ -256,16 +265,34 @@ DefineProperty("lexer.cpp.update.preprocessor", &OptionsCPP::updatePreprocessor, "Set to 1 to update preprocessor definitions when #define found.");
+ DefineProperty("lexer.cpp.triplequoted.strings", &OptionsCPP::triplequotedStrings, + "Set to 1 to enable highlighting of triple-quoted strings."); + DefineProperty("fold", &OptionsCPP::fold);
+ DefineProperty("fold.cpp.syntax.based", &OptionsCPP::foldSyntaxBased, + "Set this property to 0 to disable syntax based folding."); + DefineProperty("fold.comment", &OptionsCPP::foldComment, "This option enables folding multi-line comments and explicit fold points when using the C++ lexer. " "Explicit fold points allows adding extra folding by placing a //{ comment at the start and a //} " "at the end of a section that should fold.");
+ DefineProperty("fold.cpp.comment.multiline", &OptionsCPP::foldCommentMultiline, + "Set this property to 0 to disable folding multi-line comments when fold.comment=1."); + DefineProperty("fold.cpp.comment.explicit", &OptionsCPP::foldCommentExplicit, "Set this property to 0 to disable folding explicit fold points when fold.comment=1.");
+ DefineProperty("fold.cpp.explicit.start", &OptionsCPP::foldExplicitStart, + "The string to use for explicit fold start points, replacing the standard //{."); + + DefineProperty("fold.cpp.explicit.end", &OptionsCPP::foldExplicitEnd, + "The string to use for explicit fold end points, replacing the standard //}."); + + DefineProperty("fold.cpp.explicit.anywhere", &OptionsCPP::foldExplicitAnywhere, + "Set this property to 1 to enable explicit fold points anywhere, not just in line comments."); + DefineProperty("fold.preprocessor", &OptionsCPP::foldPreprocessor, "This option enables folding preprocessor directives when using the C++ lexer. " "Includes C#'s explicit #region and #endregion folding directives."); @@ -288,7 +315,6 @@ CharacterSet setLogicalOp; PPStates vlls; std::vector<PPDefinition> ppDefineHistory; - PropSetSimple props; WordList keywords; WordList keywords2; WordList keywords3; @@ -297,6 +323,7 @@ std::map<std::string, std::string> preprocessorDefinitionsStart; OptionsCPP options; OptionSetCPP osCPP; + SparseStatestd::string rawStringTerminators; public: LexerCPP(bool caseSensitive_) : caseSensitive(caseSensitive_), @@ -419,7 +446,6 @@ CharacterSet setDoxygen(CharacterSet::setAlpha, "$@\&<>#{}[]");
CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true); - CharacterSet setWord(CharacterSet::setAlphaNum, "._", 0x80, true);
if (options.identifiersAllowDollars) { setWordStart.Add('$'); @@ -483,16 +509,18 @@ }
const int maskActivity = 0x3F; + std::string rawStringTerminator = rawStringTerminators.ValueAt(lineCurrent-1); + SparseStatestd::string rawSTNew(lineCurrent);
int activitySet = preproc.IsInactive() ? 0x40 : 0;
for (; sc.More(); sc.Forward()) {
if (sc.atLineStart) { - if (sc.state == SCE_C_STRING) { + if ((sc.state == SCE_C_STRING) || (sc.state == SCE_C_CHARACTER)) { // Prevent SCE_C_STRINGEOL from leaking back to previous line which // ends with a line continuation by locking in the state upto this position. - sc.SetState(SCE_C_STRING); + sc.SetState(sc.state); } // Reset states to begining of colourise so no surprises // if different sets of lines lexed. @@ -515,6 +543,9 @@ if (sc.atLineEnd) { lineCurrent++; vlls.Add(lineCurrent, preproc); + if (rawStringTerminator != "") { + rawSTNew.Set(lineCurrent-1, rawStringTerminator); + } }
// Handle line continuation generically. @@ -558,6 +589,23 @@ } else if (keywords4.InList(s)) { sc.ChangeState(SCE_C_GLOBALCLASS|activitySet); } + const bool literalString = sc.ch == '"'; + if (literalString || sc.ch == ''') { + size_t lenS = strlen(s); + const bool raw = literalString && sc.chPrev == 'R'; + if (raw) + s[lenS--] = '\0'; + bool valid = + (lenS == 0) || + ((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 + sc.ChangeState(SCE_C_CHARACTER|activitySet); + } + } sc.SetState(SCE_C_DEFAULT|activitySet); } break; @@ -642,6 +690,14 @@ sc.ForwardSetState(SCE_C_DEFAULT|activitySet); } break; + case SCE_C_STRINGRAW: + if (sc.Match(rawStringTerminator.c_str())) { + for (size_t termPos=rawStringTerminator.size(); termPos; termPos--) + sc.Forward(); + sc.SetState(SCE_C_DEFAULT|activitySet); + rawStringTerminator = ""; + } + break; case SCE_C_CHARACTER: if (sc.atLineEnd) { sc.ChangeState(SCE_C_STRINGEOL|activitySet); @@ -682,6 +738,14 @@ } } break; + case SCE_C_TRIPLEVERBATIM: + if (sc.Match (""""")) { + while (sc.Match('"')) { + sc.Forward(); + } + sc.SetState(SCE_C_DEFAULT|activitySet); + } + break; case SCE_C_UUID: if (sc.ch == '\r' || sc.ch == '\n' || sc.ch == ')') { sc.SetState(SCE_C_DEFAULT|activitySet); @@ -699,6 +763,9 @@ if (sc.Match('@', '"')) { sc.SetState(SCE_C_VERBATIM|activitySet); sc.Forward(); + } else if (options.triplequotedStrings && sc.Match(""""")) { + sc.SetState(SCE_C_TRIPLEVERBATIM|activitySet); + sc.Forward(2); } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { if (lastWordWasUUID) { sc.SetState(SCE_C_UUID|activitySet); @@ -733,7 +800,19 @@ || !FollowsPostfixOperator(sc, styler))) { sc.SetState(SCE_C_REGEX|activitySet); // JavaScript's RegEx } else if (sc.ch == '"') { - sc.SetState(SCE_C_STRING|activitySet); + if (sc.chPrev == 'R') { + sc.SetState(SCE_C_STRINGRAW|activitySet); + rawStringTerminator = ")"; + for (int termPos = sc.currentPos + 1;;termPos++) { + char chTerminator = styler.SafeGetCharAt(termPos, '('); + if (chTerminator == '(') + break; + rawStringTerminator += chTerminator; + } + rawStringTerminator += '"'; + } else { + sc.SetState(SCE_C_STRING|activitySet); + } isIncludePreprocessor = false; // ensure that '>' won't end the string } else if (isIncludePreprocessor && sc.ch == '<') { sc.SetState(SCE_C_STRING|activitySet); @@ -828,10 +907,10 @@ } continuationLine = false; } - if (definitionsChanged) + const bool rawStringsChanged = rawStringTerminators.Merge(rawSTNew, lineCurrent); + if (definitionsChanged || rawStringsChanged) styler.ChangeLexerState(startPos, startPos + length); sc.Complete(); - styler.Flush(); }
// Store both the current line's fold level and the next lines in the @@ -856,6 +935,7 @@ char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); int style = initStyle; + const bool userDefinedFoldMarkers = !options.foldExplicitStart.empty() && !options.foldExplicitEnd.empty(); for (unsigned int i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); @@ -863,7 +943,7 @@ style = styleNext; styleNext = styler.StyleAt(i + 1); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); - if (options.foldComment && IsStreamCommentStyle(style)) { + if (options.foldComment && options.foldCommentMultiline && IsStreamCommentStyle(style)) { if (!IsStreamCommentStyle(stylePrev) && (stylePrev != SCE_C_COMMENTLINEDOC)) { levelNext++; } else if (!IsStreamCommentStyle(styleNext) && (styleNext != SCE_C_COMMENTLINEDOC) && !atEOL) { @@ -871,14 +951,22 @@ levelNext--; } } - if (options.foldComment && options.foldCommentExplicit && (style == SCE_C_COMMENTLINE)) { - if ((ch == '/') && (chNext == '/')) { - char chNext2 = styler.SafeGetCharAt(i + 2); - if (chNext2 == '{') { + if (options.foldComment && options.foldCommentExplicit && ((style == SCE_C_COMMENTLINE) || options.foldExplicitAnywhere)) { + if (userDefinedFoldMarkers) { + if (styler.Match(i, options.foldExplicitStart.c_str())) { levelNext++; - } else if (chNext2 == '}') { + } else if (styler.Match(i, options.foldExplicitEnd.c_str())) { levelNext--; } + } else { + if ((ch == '/') && (chNext == '/')) { + char chNext2 = styler.SafeGetCharAt(i + 2); + if (chNext2 == '{') { + levelNext++; + } else if (chNext2 == '}') { + levelNext--; + } + } } } if (options.foldPreprocessor && (style == SCE_C_PREPROCESSOR)) { @@ -894,7 +982,7 @@ } } } - if (style == SCE_C_OPERATOR) { + if (options.foldSyntaxBased && (style == SCE_C_OPERATOR)) { if (ch == '{') { // Measure the minimum before a '{' to allow // folding on "} else {" @@ -910,7 +998,7 @@ visibleChars++; if (atEOL || (i == endPos-1)) { int levelUse = levelCurrent; - if (options.foldAtElse) { + if (options.foldSyntaxBased && options.foldAtElse) { levelUse = levelMinCurrent; } int lev = levelUse | levelNext << 16;
Modified: branches/sm/scintilla/lexers/LexCSS.cxx =================================================================== --- branches/sm/scintilla/lexers/LexCSS.cxx 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/lexers/LexCSS.cxx 2011-05-21 08:58:07 UTC (rev 5808) @@ -18,7 +18,6 @@ #include "Scintilla.h" #include "SciLexer.h"
-#include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h"
Modified: branches/sm/scintilla/lexers/LexCmake.cxx =================================================================== --- branches/sm/scintilla/lexers/LexCmake.cxx 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/lexers/LexCmake.cxx 2011-05-21 08:58:07 UTC (rev 5808) @@ -17,7 +17,6 @@ #include "Scintilla.h" #include "SciLexer.h"
-#include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h"
Modified: branches/sm/scintilla/lexers/LexD.cxx =================================================================== --- branches/sm/scintilla/lexers/LexD.cxx 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/lexers/LexD.cxx 2011-05-21 08:58:07 UTC (rev 5808) @@ -2,6 +2,7 @@ ** Lexer for D. ** ** Copyright (c) 2006 by Waldemar Augustyn waldemar@wdmsys.com + ** Converted to lexer object and added further folding features/properties by "Udo Lechner" <dlchnr(at)gmx(dot)net> **/ // Copyright 1998-2005 by Neil Hodgson neilh@scintilla.org // The License.txt file describes the conditions under which this software may be distributed. @@ -13,17 +14,23 @@ #include <assert.h> #include <ctype.h>
+#ifdef _MSC_VER +#pragma warning(disable: 4786) +#endif + +#include <string> +#include <map> + #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h"
-#include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" -#include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" +#include "OptionSet.h"
#ifdef SCI_NAMESPACE using namespace Scintilla; @@ -59,18 +66,188 @@ return ch == 'c' || ch == 'w' || ch == 'd'; }
+static bool IsStreamCommentStyle(int style) { + return style == SCE_D_COMMENT || + style == SCE_D_COMMENTDOC || + style == SCE_D_COMMENTDOCKEYWORD || + style == SCE_D_COMMENTDOCKEYWORDERROR; +}
-static void ColouriseDoc(unsigned int startPos, int length, int initStyle, - WordList *keywordlists[], Accessor &styler, bool caseSensitive) { +// An individual named option for use in an OptionSet
- WordList &keywords = *keywordlists[0]; - WordList &keywords2 = *keywordlists[1]; - WordList &keywords3 = *keywordlists[2]; //doxygen - WordList &keywords4 = *keywordlists[3]; - WordList &keywords5 = *keywordlists[4]; - WordList &keywords6 = *keywordlists[5]; - WordList &keywords7 = *keywordlists[6]; +// Options used for LexerD +struct OptionsD { + bool fold; + bool foldSyntaxBased; + bool foldComment; + bool foldCommentMultiline; + bool foldCommentExplicit; + std::string foldExplicitStart; + std::string foldExplicitEnd; + bool foldExplicitAnywhere; + bool foldCompact; + int foldAtElseInt; + bool foldAtElse; + OptionsD() { + fold = false; + foldSyntaxBased = true; + foldComment = false; + foldCommentMultiline = true; + foldCommentExplicit = true; + foldExplicitStart = ""; + foldExplicitEnd = ""; + foldExplicitAnywhere = false; + foldCompact = true; + foldAtElseInt = -1; + foldAtElse = false; + } +};
+static const char * const dWordLists[] = { + "Primary keywords and identifiers", + "Secondary keywords and identifiers", + "Documentation comment keywords", + "Type definitions and aliases", + "Keywords 5", + "Keywords 6", + "Keywords 7", + 0, + }; + +struct OptionSetD : public OptionSet<OptionsD> { + OptionSetD() { + DefineProperty("fold", &OptionsD::fold); + + DefineProperty("fold.d.syntax.based", &OptionsD::foldSyntaxBased, + "Set this property to 0 to disable syntax based folding."); + + DefineProperty("fold.comment", &OptionsD::foldComment); + + DefineProperty("fold.d.comment.multiline", &OptionsD::foldCommentMultiline, + "Set this property to 0 to disable folding multi-line comments when fold.comment=1."); + + DefineProperty("fold.d.comment.explicit", &OptionsD::foldCommentExplicit, + "Set this property to 0 to disable folding explicit fold points when fold.comment=1."); + + DefineProperty("fold.d.explicit.start", &OptionsD::foldExplicitStart, + "The string to use for explicit fold start points, replacing the standard //{."); + + DefineProperty("fold.d.explicit.end", &OptionsD::foldExplicitEnd, + "The string to use for explicit fold end points, replacing the standard //}."); + + DefineProperty("fold.d.explicit.anywhere", &OptionsD::foldExplicitAnywhere, + "Set this property to 1 to enable explicit fold points anywhere, not just in line comments."); + + DefineProperty("fold.compact", &OptionsD::foldCompact); + + DefineProperty("lexer.d.fold.at.else", &OptionsD::foldAtElseInt, + "This option enables D folding on a "} else {" line of an if statement."); + + DefineProperty("fold.at.else", &OptionsD::foldAtElse); + + DefineWordListSets(dWordLists); + } +}; + +class LexerD : public ILexer { + bool caseSensitive; + WordList keywords; + WordList keywords2; + WordList keywords3; + WordList keywords4; + WordList keywords5; + WordList keywords6; + WordList keywords7; + OptionsD options; + OptionSetD osD; +public: + LexerD(bool caseSensitive_) : + caseSensitive(caseSensitive_) { + } + ~LexerD() { + } + void SCI_METHOD Release() { + delete this; + } + int SCI_METHOD Version() const { + return lvOriginal; + } + const char * SCI_METHOD PropertyNames() { + return osD.PropertyNames(); + } + int SCI_METHOD PropertyType(const char *name) { + return osD.PropertyType(name); + } + const char * SCI_METHOD DescribeProperty(const char *name) { + return osD.DescribeProperty(name); + } + int SCI_METHOD PropertySet(const char *key, const char *val); + const char * SCI_METHOD DescribeWordListSets() { + return osD.DescribeWordListSets(); + } + int SCI_METHOD WordListSet(int n, const char *wl); + void SCI_METHOD Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess); + void SCI_METHOD Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess); + + void * SCI_METHOD PrivateCall(int, void *) { + return 0; + } + + static ILexer *LexerFactoryD() { + return new LexerD(true); + } + static ILexer *LexerFactoryDInsensitive() { + return new LexerD(false); + } +}; + +int SCI_METHOD LexerD::PropertySet(const char *key, const char *val) { + if (osD.PropertySet(&options, key, val)) { + return 0; + } + return -1; +} + +int SCI_METHOD LexerD::WordListSet(int n, const char *wl) { + WordList *wordListN = 0; + switch (n) { + case 0: + wordListN = &keywords; + break; + case 1: + wordListN = &keywords2; + break; + case 2: + wordListN = &keywords3; + break; + case 3: + wordListN = &keywords4; + break; + case 4: + wordListN = &keywords5; + break; + case 5: + wordListN = &keywords6; + break; + case 6: + wordListN = &keywords7; + break; + } + int firstModification = -1; + if (wordListN) { + WordList wlNew; + wlNew.Set(wl); + if (*wordListN != wlNew) { + wordListN->Set(wl); + firstModification = 0; + } + } + return firstModification; +} + +void SCI_METHOD LexerD::Lex(unsigned int startPos, int length, int initStyle, IDocument *pAccess) { + LexAccessor styler(pAccess); + int styleBeforeDCKeyword = SCE_D_DEFAULT;
StyleContext sc(startPos, length, initStyle, styler); @@ -294,24 +471,17 @@ sc.Complete(); }
-static bool IsStreamCommentStyle(int style) { - return style == SCE_D_COMMENT || - style == SCE_D_COMMENTDOC || - style == SCE_D_COMMENTDOCKEYWORD || - style == SCE_D_COMMENTDOCKEYWORDERROR; -} - // Store both the current line's fold level and the next lines in the // level store to make it easy to pick up with each increment // and to make it possible to fiddle the current level for "} else {". -static void FoldDoc(unsigned int startPos, int length, int initStyle, Accessor &styler) { - bool foldComment = styler.GetPropertyInt("fold.comment") != 0; - bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
- // property lexer.d.fold.at.else - // This option enables D folding on a "} else {" line of an if statement. - bool foldAtElse = styler.GetPropertyInt("lexer.d.fold.at.else", - styler.GetPropertyInt("fold.at.else", 0)) != 0; +void SCI_METHOD LexerD::Fold(unsigned int startPos, int length, int initStyle, IDocument *pAccess) { + + if (!options.fold) + return; + + LexAccessor styler(pAccess); + unsigned int endPos = startPos + length; int visibleChars = 0; int lineCurrent = styler.GetLine(startPos); @@ -323,6 +493,8 @@ char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); int style = initStyle; + bool foldAtElse = options.foldAtElseInt >= 0 ? options.foldAtElseInt != 0 : options.foldAtElse; + const bool userDefinedFoldMarkers = !options.foldExplicitStart.empty() && !options.foldExplicitEnd.empty(); for (unsigned int i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler.SafeGetCharAt(i + 1); @@ -330,7 +502,7 @@ style = styleNext; styleNext = styler.StyleAt(i + 1); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); - if (foldComment && IsStreamCommentStyle(style)) { + if (options.foldComment && options.foldCommentMultiline && IsStreamCommentStyle(style)) { if (!IsStreamCommentStyle(stylePrev)) { levelNext++; } else if (!IsStreamCommentStyle(styleNext) && !atEOL) { @@ -338,7 +510,25 @@ levelNext--; } } - if (style == SCE_D_OPERATOR) { + if (options.foldComment && options.foldCommentExplicit && ((style == SCE_D_COMMENTLINE) || options.foldExplicitAnywhere)) { + if (userDefinedFoldMarkers) { + if (styler.Match(i, options.foldExplicitStart.c_str())) { + levelNext++; + } else if (styler.Match(i, options.foldExplicitEnd.c_str())) { + levelNext--; + } + } else { + if ((ch == '/') && (chNext == '/')) { + char chNext2 = styler.SafeGetCharAt(i + 2); + if (chNext2 == '{') { + levelNext++; + } else if (chNext2 == '}') { + levelNext--; + } + } + } + } + if (options.foldSyntaxBased && (style == SCE_D_OPERATOR)) { if (ch == '{') { // Measure the minimum before a '{' to allow // folding on "} else {" @@ -350,19 +540,19 @@ levelNext--; } } - if (atEOL) { - if (foldComment) { // Handle nested comments + if (atEOL || (i == endPos-1)) { + if (options.foldComment && options.foldCommentMultiline) { // Handle nested comments int nc; nc = styler.GetLineState(lineCurrent); nc -= lineCurrent>0? styler.GetLineState(lineCurrent-1): 0; levelNext += nc; } int levelUse = levelCurrent; - if (foldAtElse) { + if (options.foldSyntaxBased && foldAtElse) { levelUse = levelMinCurrent; } int lev = levelUse | levelNext << 16; - if (visibleChars == 0 && foldCompact) + if (visibleChars == 0 && options.foldCompact) lev |= SC_FOLDLEVELWHITEFLAG; if (levelUse < levelNext) lev |= SC_FOLDLEVELHEADERFLAG; @@ -379,25 +569,4 @@ } }
-static void FoldDDoc(unsigned int startPos, int length, int initStyle, - WordList *[], Accessor &styler) { - FoldDoc(startPos, length, initStyle, styler); -} - -static const char * const dWordLists[] = { - "Primary keywords and identifiers", - "Secondary keywords and identifiers", - "Documentation comment keywords", - "Type definitions and aliases", - "Keywords 5", - "Keywords 6", - "Keywords 7", - 0, - }; - -static void ColouriseDDoc(unsigned int startPos, int length, - int initStyle, WordList *keywordlists[], Accessor &styler) { - ColouriseDoc(startPos, length, initStyle, keywordlists, styler, true); -} - -LexerModule lmD(SCLEX_D, ColouriseDDoc, "d", FoldDDoc, dWordLists); +LexerModule lmD(SCLEX_D, LexerD::LexerFactoryD, "d", dWordLists);
Modified: branches/sm/scintilla/lexers/LexErlang.cxx =================================================================== --- branches/sm/scintilla/lexers/LexErlang.cxx 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/lexers/LexErlang.cxx 2011-05-21 08:58:07 UTC (rev 5808) @@ -19,7 +19,6 @@ #include "Scintilla.h" #include "SciLexer.h"
-#include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h"
Modified: branches/sm/scintilla/lexers/LexForth.cxx =================================================================== --- branches/sm/scintilla/lexers/LexForth.cxx 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/lexers/LexForth.cxx 2011-05-21 08:58:07 UTC (rev 5808) @@ -16,7 +16,6 @@ #include "Scintilla.h" #include "SciLexer.h"
-#include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h"
Modified: branches/sm/scintilla/lexers/LexFortran.cxx =================================================================== --- branches/sm/scintilla/lexers/LexFortran.cxx 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/lexers/LexFortran.cxx 2011-05-21 08:58:07 UTC (rev 5808) @@ -17,7 +17,6 @@ #include "Scintilla.h" #include "SciLexer.h"
-#include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" @@ -267,7 +266,7 @@ || strcmp(s, "endmodule") == 0 || strcmp(s, "endprogram") == 0 || strcmp(s, "endsubroutine") == 0 || strcmp(s, "endtype") == 0 || strcmp(s, "endwhere") == 0 - || strcmp(s, "procedure") == 0 ) { // Take care of the module procedure statement + || (strcmp(s, "procedure") == 0 && strcmp(prevWord,"module")==0) ) { // Take care of the module procedure statement lev = -1; } else if (strcmp(prevWord, "end") == 0 && strcmp(s, "if") == 0){ // end if lev = 0;
Modified: branches/sm/scintilla/lexers/LexHTML.cxx =================================================================== --- branches/sm/scintilla/lexers/LexHTML.cxx 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/lexers/LexHTML.cxx 2011-05-21 08:58:07 UTC (rev 5808) @@ -16,7 +16,6 @@ #include "Scintilla.h" #include "SciLexer.h"
-#include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" @@ -745,8 +744,18 @@ if ((state != SCE_HPHP_COMMENT) && (state != SCE_HPHP_COMMENTLINE) && (state != SCE_HJ_COMMENT) && (state != SCE_HJ_COMMENTLINE) && (state != SCE_HJ_COMMENTDOC) && (!isStringState(state))) { //Platform::DebugPrintf("state=%d, StateToPrint=%d, initStyle=%d\n", state, StateToPrint, initStyle); //if ((state == SCE_HPHP_OPERATOR) || (state == SCE_HPHP_DEFAULT) || (state == SCE_HJ_SYMBOLS) || (state == SCE_HJ_START) || (state == SCE_HJ_DEFAULT)) { - if ((ch == '{') || (ch == '}') || (foldComment && (ch == '/') && (chNext == '*'))) { - levelCurrent += ((ch == '{') || (ch == '/')) ? 1 : -1; + if (ch == '#') { + int j = i + 1; + while ((j < lengthDoc) && IsASpaceOrTab(styler.SafeGetCharAt(j))) { + j++; + } + if (styler.Match(j, "region") || styler.Match(j, "if")) { + levelCurrent++; + } else if (styler.Match(j, "end")) { + levelCurrent--; + } + } else if ((ch == '{') || (ch == '}') || (foldComment && (ch == '/') && (chNext == '*')) ) { + levelCurrent += ((ch == '{') || (ch == '/') ) ? 1 : -1; } } else if (((state == SCE_HPHP_COMMENT) || (state == SCE_HJ_COMMENT)) && foldComment && (ch == '*') && (chNext == '/')) { levelCurrent--;
Modified: branches/sm/scintilla/lexers/LexLisp.cxx =================================================================== --- branches/sm/scintilla/lexers/LexLisp.cxx 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/lexers/LexLisp.cxx 2011-05-21 08:58:07 UTC (rev 5808) @@ -17,7 +17,6 @@ #include "Scintilla.h" #include "SciLexer.h"
-#include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h"
Modified: branches/sm/scintilla/lexers/LexLua.cxx =================================================================== --- branches/sm/scintilla/lexers/LexLua.cxx 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/lexers/LexLua.cxx 2011-05-21 08:58:07 UTC (rev 5808) @@ -18,7 +18,6 @@ #include "Scintilla.h" #include "SciLexer.h"
-#include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h"
Modified: branches/sm/scintilla/lexers/LexMarkdown.cxx =================================================================== --- branches/sm/scintilla/lexers/LexMarkdown.cxx 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/lexers/LexMarkdown.cxx 2011-05-21 08:58:07 UTC (rev 5808) @@ -44,7 +44,6 @@ #include "Scintilla.h" #include "SciLexer.h"
-#include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h"
Modified: branches/sm/scintilla/lexers/LexMatlab.cxx =================================================================== --- branches/sm/scintilla/lexers/LexMatlab.cxx 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/lexers/LexMatlab.cxx 2011-05-21 08:58:07 UTC (rev 5808) @@ -21,7 +21,6 @@ #include "Scintilla.h" #include "SciLexer.h"
-#include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h"
Modified: branches/sm/scintilla/lexers/LexNsis.cxx =================================================================== --- branches/sm/scintilla/lexers/LexNsis.cxx 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/lexers/LexNsis.cxx 2011-05-21 08:58:07 UTC (rev 5808) @@ -17,7 +17,6 @@ #include "Scintilla.h" #include "SciLexer.h"
-#include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h"
Modified: branches/sm/scintilla/lexers/LexOthers.cxx =================================================================== --- branches/sm/scintilla/lexers/LexOthers.cxx 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/lexers/LexOthers.cxx 2011-05-21 08:58:07 UTC (rev 5808) @@ -17,7 +17,6 @@ #include "Scintilla.h" #include "SciLexer.h"
-#include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" @@ -510,7 +509,7 @@ styler.ColourTo(endLine, SCE_DIFF_COMMAND); } else if (0 == strncmp(lineBuffer, "Index: ", 7)) { // For subversion's diff styler.ColourTo(endLine, SCE_DIFF_COMMAND); - } else if (0 == strncmp(lineBuffer, "---", 3)) { + } else if (0 == strncmp(lineBuffer, "---", 3) && lineBuffer[3] != '-') { // In a context diff, --- appears in both the header and the position markers if (lineBuffer[3] == ' ' && atoi(lineBuffer + 4) && !strchr(lineBuffer, '/')) styler.ColourTo(endLine, SCE_DIFF_POSITION); @@ -930,8 +929,8 @@ // Command or return status return SCE_ERR_CMD; } else if (lineBuffer[0] == '<') { - // Diff removal, but not interested. Trapped to avoid hitting CTAG cases. - return SCE_ERR_DEFAULT; + // Diff removal. + return SCE_ERR_DIFF_DELETION; } else if (lineBuffer[0] == '!') { return SCE_ERR_DIFF_CHANGED; } else if (lineBuffer[0] == '+') {
Modified: branches/sm/scintilla/lexers/LexPascal.cxx =================================================================== --- branches/sm/scintilla/lexers/LexPascal.cxx 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/lexers/LexPascal.cxx 2011-05-21 08:58:07 UTC (rev 5808) @@ -118,7 +118,6 @@ #include "Scintilla.h" #include "SciLexer.h"
-#include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h"
Modified: branches/sm/scintilla/lexers/LexPerl.cxx =================================================================== --- branches/sm/scintilla/lexers/LexPerl.cxx 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/lexers/LexPerl.cxx 2011-05-21 08:58:07 UTC (rev 5808) @@ -17,7 +17,6 @@ #include "Scintilla.h" #include "SciLexer.h"
-#include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h"
Modified: branches/sm/scintilla/lexers/LexPython.cxx =================================================================== --- branches/sm/scintilla/lexers/LexPython.cxx 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/lexers/LexPython.cxx 2011-05-21 08:58:07 UTC (rev 5808) @@ -16,7 +16,6 @@ #include "Scintilla.h" #include "SciLexer.h"
-#include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h"
Modified: branches/sm/scintilla/lexers/LexR.cxx =================================================================== --- branches/sm/scintilla/lexers/LexR.cxx 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/lexers/LexR.cxx 2011-05-21 08:58:07 UTC (rev 5808) @@ -17,7 +17,6 @@ #include "Scintilla.h" #include "SciLexer.h"
-#include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h"
Modified: branches/sm/scintilla/lexers/LexSQL.cxx =================================================================== --- branches/sm/scintilla/lexers/LexSQL.cxx 2011-05-21 08:54:44 UTC (rev 5807) +++ branches/sm/scintilla/lexers/LexSQL.cxx 2011-05-21 08:58:07 UTC (rev 5808) @@ -2,7 +2,7 @@ /** @file LexSQL.cxx ** Lexer for SQL, including PL/SQL and SQL*Plus. **/ -// Copyright 1998-2005 by Neil Hodgson neilh@scintilla.org +// Copyright 1998-2011 by Neil Hodgson neilh@scintilla.org // The License.txt file describes the conditions under which this software may be distributed.
#include <stdlib.h> @@ -12,24 +12,36 @@ #include <assert.h> #include <ctype.h>
+#ifdef _MSC_VER +#pragma warning(disable: 4786) +#endif + +#include <string> +#include <vector> +#include <map> +#include <algorithm> + #include "ILexer.h" #include "Scintilla.h" #include "SciLexer.h"
-#include "PropSetSimple.h" #include "WordList.h" #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" #include "CharacterSet.h" #include "LexerModule.h" +#include "OptionSet.h"
#ifdef SCI_NAMESPACE using namespace Scintilla; #endif
-static inline bool IsAWordChar(int ch) { - return (ch < 0x80) && (isalnum(ch) || ch == '_'); +static inline bool IsAWordChar(int ch, bool sqlAllowDottedWord) { + if (!sqlAllowDottedWord) + return (ch < 0x80) && (isalnum(ch) || ch == '_'); + else + return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '.'); }
static inline bool IsAWordStart(int ch) { @@ -47,31 +59,289 @@ // Not exactly following number definition (several dots are seen as OK, etc.) // but probably enough in most cases. return (ch < 0x80) && - (isdigit(ch) || toupper(ch) == 'E' || - ch == '.' || ch == '-' || ch == '+'); + (isdigit(ch) || toupper(ch) == 'E' || + ch == '.' || ch == '-' || ch == '+'); }
-static void ColouriseSQLDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], - Accessor &styler) {
- WordList &keywords1 = *keywordlists[0]; - WordList &keywords2 = *keywordlists[1]; - WordList &kw_pldoc = *keywordlists[2]; - WordList &kw_sqlplus = *keywordlists[3]; - WordList &kw_user1 = *keywordlists[4]; - WordList &kw_user2 = *keywordlists[5]; - WordList &kw_user3 = *keywordlists[6]; - WordList &kw_user4 = *keywordlists[7]; +class SQLStates { +public : + void Set(int lineNumber, unsigned short int sqlStatesLine) { + if (!sqlStatement.size() == 0 || !sqlStatesLine == 0) { + sqlStatement.resize(lineNumber + 1, 0); + sqlStatement[lineNumber] = sqlStatesLine; + } + }
- StyleContext sc(startPos, length, initStyle, styler); + unsigned short int IgnoreWhen (unsigned short int sqlStatesLine, bool enable) { + if (enable) + sqlStatesLine |= MASK_IGNORE_WHEN; + else + sqlStatesLine &= ~MASK_IGNORE_WHEN;
- // property sql.backslash.escapes - // Enables backslash as an escape character in SQL. - bool sqlBackslashEscapes = styler.GetPropertyInt("sql.backslash.escapes", 0) != 0; + return sqlStatesLine; + }
- bool sqlBackticksIdentifier = styler.GetPropertyInt("lexer.sql.backticks.identifier", 0) != 0; + unsigned short int IntoCondition (unsigned short int sqlStatesLine, bool enable) { + if (enable) + sqlStatesLine |= MASK_INTO_CONDITION; + else + sqlStatesLine &= ~MASK_INTO_CONDITION; + + return sqlStatesLine; + } + + unsigned short int IntoExceptionBlock (unsigned short int sqlStatesLine, bool enable) { + if (enable) + sqlStatesLine |= MASK_INTO_EXCEPTION; + else + sqlStatesLine &= ~MASK_INTO_EXCEPTION; + + return sqlStatesLine; + } + + unsigned short int IntoDeclareBlock (unsigned short int sqlStatesLine, bool enable) { + if (enable) + sqlStatesLine |= MASK_INTO_DECLARE; + else + sqlStatesLine &= ~MASK_INTO_DECLARE; + + return sqlStatesLine; + } + + unsigned short int BeginCaseBlock (unsigned short int sqlStatesLine) { + if ((sqlStatesLine & MASK_NESTED_CASES) < MASK_NESTED_CASES) { + sqlStatesLine++; + } + return sqlStatesLine; + } + + unsigned short int EndCaseBlock (unsigned short int sqlStatesLine) { + if ((sqlStatesLine & MASK_NESTED_CASES) > 0) { + sqlStatesLine--; + } + return sqlStatesLine; + } + + bool IsIgnoreWhen (unsigned short int sqlStatesLine) { + return (sqlStatesLine & MASK_IGNORE_WHEN) != 0; + } + + bool IsIntoCondition (unsigned short int sqlStatesLine) { + return (sqlStatesLine & MASK_INTO_CONDITION) != 0; + } + + bool IsIntoCaseBlock (unsigned short int sqlStatesLine) { + return (sqlStatesLine & MASK_NESTED_CASES) != 0; + } + + bool IsIntoExceptionBlock (unsigned short int sqlStatesLine) { + return (sqlStatesLine & MASK_INTO_EXCEPTION) != 0; + } + + bool IsIntoDeclareBlock (unsigned short int sqlStatesLine) { + return (sqlStatesLine & MASK_INTO_DECLARE) != 0; + } + + unsigned short int ForLine(int lineNumber) { + if ((lineNumber > 0) && (sqlStatement.size() > static_cast<size_t>(lineNumber))) { + return sqlStatement[lineNumber]; + } else { + return 0; + } + } + + SQLStates() {} + +private : + std::vector <unsigned short int> sqlStatement; + enum { + MASK_INTO_DECLARE = 0x1000, + MASK_INTO_EXCEPTION = 0x2000, + MASK_INTO_CONDITION = 0x4000, + MASK_IGNORE_WHEN = 0x8000, + MASK_NESTED_CASES = 0x0FFF + }; +}; + +// Options used for LexerSQL +struct OptionsSQL { + bool fold; + bool foldAtElse; + bool foldComment; + bool foldCompact; + bool foldOnlyBegin; + bool sqlBackticksIdentifier; + bool sqlNumbersignComment; + bool sqlBackslashEscapes; + bool sqlAllowDottedWord; + OptionsSQL() { + fold = false; + foldAtElse = false; + foldComment = false; + foldCompact = false; + foldOnlyBegin = false; + sqlBackticksIdentifier = false; + sqlNumbersignComment = false;
@@ Diff output truncated at 100000 characters. @@
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.