From 9e96e16fe0bc7af32d329c965ad110a3e5be5ad8 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 30 Mar 2010 03:50:06 +0000 Subject: [PATCH] Apply patch (plus some additional changes) upgrading Scintilla to version 2.03. Closes #11765, #11748, #11346 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63792 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- Makefile.in | 58 +- build/bakefiles/scintilla.bkl | 14 + build/msw/makefile.bcc | 58 +- build/msw/makefile.gcc | 58 +- build/msw/makefile.vc | 58 +- build/msw/makefile.wat | 58 +- build/msw/wx_vc7_wxscintilla.vcproj | 42 + build/msw/wx_vc8_wxscintilla.vcproj | 56 + build/msw/wx_vc9_wxscintilla.vcproj | 56 + build/msw/wx_wxscintilla.dsp | 56 + include/wx/stc/stc.h | 482 ++- interface/wx/stc/stc.h | 401 ++- samples/stc/edit.cpp | 6 + samples/stc/edit.h | 1 + src/common/wincmn.cpp | 2 +- src/stc/Makefile.in | 8 + src/stc/PlatWX.cpp | 122 +- src/stc/ScintillaWX.cpp | 31 +- src/stc/ScintillaWX.h | 23 +- src/stc/gen_iface.py | 92 +- src/stc/scintilla/README.txt | 8 +- src/stc/scintilla/include/KeyWords.h | 23 + src/stc/scintilla/include/Platform.h | 37 +- src/stc/scintilla/include/PropSet.h | 90 +- src/stc/scintilla/include/SciLexer.h | 195 +- src/stc/scintilla/include/Scintilla.h | 257 +- src/stc/scintilla/include/Scintilla.iface | 526 +++- src/stc/scintilla/include/ScintillaWidget.h | 6 +- src/stc/scintilla/include/WindowAccessor.h | 5 +- src/stc/scintilla/src/Array.cpp | 380 +++ src/stc/scintilla/src/Array.h | 209 ++ src/stc/scintilla/src/AutoComplete.cxx | 2 +- src/stc/scintilla/src/CallTip.cxx | 8 +- src/stc/scintilla/src/CallTip.h | 4 +- src/stc/scintilla/src/CellBuffer.cxx | 371 +-- src/stc/scintilla/src/CellBuffer.h | 81 +- src/stc/scintilla/src/CharClassify.cxx | 35 + src/stc/scintilla/src/CharClassify.h | 14 +- src/stc/scintilla/src/Document.cxx | 661 ++-- src/stc/scintilla/src/Document.h | 127 +- src/stc/scintilla/src/DocumentAccessor.h | 9 +- src/stc/scintilla/src/Editor.cxx | 3105 ++++++++++++------- src/stc/scintilla/src/Editor.h | 129 +- src/stc/scintilla/src/ExternalLexer.cxx | 10 +- src/stc/scintilla/src/ExternalLexer.h | 3 +- src/stc/scintilla/src/FontQuality.h | 12 + src/stc/scintilla/src/Indicator.cxx | 2 +- src/stc/scintilla/src/Indicator.h | 3 +- src/stc/scintilla/src/KeyWords.cxx | 200 +- src/stc/scintilla/src/LexAU3.cxx | 3 +- src/stc/scintilla/src/LexAbaqus.cxx | 657 +++- src/stc/scintilla/src/LexAda.cxx | 21 +- src/stc/scintilla/src/LexAsm.cxx | 10 +- src/stc/scintilla/src/LexBash.cxx | 757 ++--- src/stc/scintilla/src/LexCOBOL.cxx | 368 +++ src/stc/scintilla/src/LexCPP.cxx | 44 +- src/stc/scintilla/src/LexCSS.cxx | 144 +- src/stc/scintilla/src/LexCaml.cxx | 156 +- src/stc/scintilla/src/LexCmake.cxx | 1 + src/stc/scintilla/src/LexD.cxx | 607 ++-- src/stc/scintilla/src/LexErlang.cxx | 993 +++--- src/stc/scintilla/src/LexForth.cxx | 440 +-- src/stc/scintilla/src/LexFortran.cxx | 17 +- src/stc/scintilla/src/LexGen.py | 288 ++ src/stc/scintilla/src/LexHTML.cxx | 742 +++-- src/stc/scintilla/src/LexHaskell.cxx | 6 +- src/stc/scintilla/src/LexInno.cxx | 121 +- src/stc/scintilla/src/LexLisp.cxx | 9 +- src/stc/scintilla/src/LexLua.cxx | 92 +- src/stc/scintilla/src/LexMPT.cxx | 16 +- src/stc/scintilla/src/LexMagik.cxx | 445 +++ src/stc/scintilla/src/LexMarkdown.cxx | 412 +++ src/stc/scintilla/src/LexMatlab.cxx | 4 +- src/stc/scintilla/src/LexMySQL.cxx | 518 ++++ src/stc/scintilla/src/LexNimrod.cxx | 430 +++ src/stc/scintilla/src/LexNsis.cxx | 13 +- src/stc/scintilla/src/LexOthers.cxx | 232 +- src/stc/scintilla/src/LexPascal.cxx | 699 +++-- src/stc/scintilla/src/LexPerl.cxx | 2102 ++++++------- src/stc/scintilla/src/LexPowerPro.cxx | 600 ++++ src/stc/scintilla/src/LexPowerShell.cxx | 175 ++ src/stc/scintilla/src/LexProgress.cxx | 52 +- src/stc/scintilla/src/LexPython.cxx | 164 +- src/stc/scintilla/src/LexRuby.cxx | 7 +- src/stc/scintilla/src/LexSML.cxx | 223 ++ src/stc/scintilla/src/LexSQL.cxx | 17 +- src/stc/scintilla/src/LexSorcus.cxx | 205 ++ src/stc/scintilla/src/LexSpice.cxx | 7 +- src/stc/scintilla/src/LexTACL.cxx | 397 +++ src/stc/scintilla/src/LexTADS3.cxx | 2 +- src/stc/scintilla/src/LexTAL.cxx | 396 +++ src/stc/scintilla/src/LexTeX.cxx | 9 +- src/stc/scintilla/src/LexVB.cxx | 34 + src/stc/scintilla/src/LexVerilog.cxx | 34 +- src/stc/scintilla/src/LexYAML.cxx | 4 +- src/stc/scintilla/src/LineMarker.cxx | 7 +- src/stc/scintilla/src/LineMarker.h | 16 +- src/stc/scintilla/src/Partitioning.h | 2 +- src/stc/scintilla/src/PerLine.cxx | 486 +++ src/stc/scintilla/src/PerLine.h | 120 + src/stc/scintilla/src/PositionCache.cxx | 58 +- src/stc/scintilla/src/PositionCache.h | 10 +- src/stc/scintilla/src/PropSet.cxx | 713 +---- src/stc/scintilla/src/PropSetSimple.h | 33 + src/stc/scintilla/src/RESearch.cxx | 30 +- src/stc/scintilla/src/RESearch.h | 4 +- src/stc/scintilla/src/RunStyles.cxx | 4 +- src/stc/scintilla/src/RunStyles.h | 9 +- src/stc/scintilla/src/SVector.h | 123 + src/stc/scintilla/src/ScintillaBase.cxx | 129 +- src/stc/scintilla/src/ScintillaBase.h | 11 +- src/stc/scintilla/src/Selection.cxx | 366 +++ src/stc/scintilla/src/Selection.h | 191 ++ src/stc/scintilla/src/SplitVector.h | 8 +- src/stc/scintilla/src/Style.cxx | 2 +- src/stc/scintilla/src/Style.h | 2 +- src/stc/scintilla/src/StyleContext.h | 4 +- src/stc/scintilla/src/UniConversion.cxx | 2 +- src/stc/scintilla/src/ViewStyle.cxx | 34 +- src/stc/scintilla/src/ViewStyle.h | 13 +- src/stc/scintilla/src/WindowAccessor.cxx | 2 +- src/stc/scintilla/src/XPM.h | 6 +- src/stc/stc.cpp | 531 +++- src/stc/stc.cpp.in | 10 + src/stc/stc.h.in | 8 +- 125 files changed, 17100 insertions(+), 6701 deletions(-) create mode 100644 src/stc/scintilla/src/Array.cpp create mode 100644 src/stc/scintilla/src/Array.h create mode 100644 src/stc/scintilla/src/FontQuality.h create mode 100644 src/stc/scintilla/src/LexCOBOL.cxx create mode 100644 src/stc/scintilla/src/LexGen.py create mode 100644 src/stc/scintilla/src/LexMagik.cxx create mode 100644 src/stc/scintilla/src/LexMarkdown.cxx create mode 100644 src/stc/scintilla/src/LexMySQL.cxx create mode 100644 src/stc/scintilla/src/LexNimrod.cxx create mode 100644 src/stc/scintilla/src/LexPowerPro.cxx create mode 100644 src/stc/scintilla/src/LexPowerShell.cxx create mode 100644 src/stc/scintilla/src/LexSML.cxx create mode 100644 src/stc/scintilla/src/LexSorcus.cxx create mode 100644 src/stc/scintilla/src/LexTACL.cxx create mode 100644 src/stc/scintilla/src/LexTAL.cxx create mode 100644 src/stc/scintilla/src/PerLine.cxx create mode 100644 src/stc/scintilla/src/PerLine.h create mode 100644 src/stc/scintilla/src/PropSetSimple.h create mode 100644 src/stc/scintilla/src/Selection.cxx create mode 100644 src/stc/scintilla/src/Selection.h diff --git a/Makefile.in b/Makefile.in index f6de013fdc..c7bf50e854 100644 --- a/Makefile.in +++ b/Makefile.in @@ -246,6 +246,7 @@ WXSCINTILLA_OBJECTS = \ wxscintilla_LexCSS.o \ wxscintilla_LexCaml.o \ wxscintilla_LexCsound.o \ + wxscintilla_LexCOBOL.o \ wxscintilla_LexConf.o \ wxscintilla_LexCrontab.o \ wxscintilla_LexD.o \ @@ -264,11 +265,14 @@ WXSCINTILLA_OBJECTS = \ wxscintilla_LexLisp.o \ wxscintilla_LexLout.o \ wxscintilla_LexLua.o \ + wxscintilla_LexMagik.o \ wxscintilla_LexMMIXAL.o \ wxscintilla_LexMPT.o \ wxscintilla_LexMSSQL.o \ wxscintilla_LexMatlab.o \ wxscintilla_LexMetapost.o \ + wxscintilla_LexMySQL.o \ + wxscintilla_LexNimrod.o \ wxscintilla_LexNsis.o \ wxscintilla_LexOpal.o \ wxscintilla_LexOthers.o \ @@ -279,16 +283,22 @@ WXSCINTILLA_OBJECTS = \ wxscintilla_LexPS.o \ wxscintilla_LexPascal.o \ wxscintilla_LexPerl.o \ + wxscintilla_LexPowerPro.o \ + wxscintilla_LexPowerShell.o \ wxscintilla_LexPython.o \ wxscintilla_LexR.o \ wxscintilla_LexRebol.o \ wxscintilla_LexRuby.o \ wxscintilla_LexSQL.o \ + wxscintilla_LexSML.o \ wxscintilla_LexSmalltalk.o \ wxscintilla_LexTADS3.o \ wxscintilla_LexScriptol.o \ wxscintilla_LexSpecman.o \ + wxscintilla_LexSorcus.o \ wxscintilla_LexSpice.o \ + wxscintilla_LexTAL.o \ + wxscintilla_LexTACL.o \ wxscintilla_LexTCL.o \ wxscintilla_LexTeX.o \ wxscintilla_LexVB.o \ @@ -296,17 +306,21 @@ WXSCINTILLA_OBJECTS = \ wxscintilla_LexVerilog.o \ wxscintilla_LexYAML.o \ wxscintilla_LineMarker.o \ + wxscintilla_PerLine.o \ wxscintilla_PositionCache.o \ wxscintilla_PropSet.o \ wxscintilla_RESearch.o \ wxscintilla_RunStyles.o \ + wxscintilla_Selection.o \ wxscintilla_ScintillaBase.o \ wxscintilla_Style.o \ wxscintilla_StyleContext.o \ wxscintilla_UniConversion.o \ wxscintilla_ViewStyle.o \ wxscintilla_WindowAccessor.o \ - wxscintilla_XPM.o + wxscintilla_XPM.o \ + wxscintilla_LexMarkdown.o \ + wxscintilla_Array.o PLUGINS_INST_DIR = $(libdir)/wx/$(PLUGIN_VERSION0) ALL_BASE_HEADERS = \ wx/afterstd.h \ @@ -14501,6 +14515,9 @@ wxscintilla_LexCaml.o: $(srcdir)/src/stc/scintilla/src/LexCaml.cxx wxscintilla_LexCsound.o: $(srcdir)/src/stc/scintilla/src/LexCsound.cxx $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexCsound.cxx +wxscintilla_LexCOBOL.o: $(srcdir)/src/stc/scintilla/src/LexCOBOL.cxx + $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexCOBOL.cxx + wxscintilla_LexConf.o: $(srcdir)/src/stc/scintilla/src/LexConf.cxx $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexConf.cxx @@ -14555,6 +14572,9 @@ wxscintilla_LexLout.o: $(srcdir)/src/stc/scintilla/src/LexLout.cxx wxscintilla_LexLua.o: $(srcdir)/src/stc/scintilla/src/LexLua.cxx $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexLua.cxx +wxscintilla_LexMagik.o: $(srcdir)/src/stc/scintilla/src/LexMagik.cxx + $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexMagik.cxx + wxscintilla_LexMMIXAL.o: $(srcdir)/src/stc/scintilla/src/LexMMIXAL.cxx $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexMMIXAL.cxx @@ -14570,6 +14590,12 @@ wxscintilla_LexMatlab.o: $(srcdir)/src/stc/scintilla/src/LexMatlab.cxx wxscintilla_LexMetapost.o: $(srcdir)/src/stc/scintilla/src/LexMetapost.cxx $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexMetapost.cxx +wxscintilla_LexMySQL.o: $(srcdir)/src/stc/scintilla/src/LexMySQL.cxx + $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexMySQL.cxx + +wxscintilla_LexNimrod.o: $(srcdir)/src/stc/scintilla/src/LexNimrod.cxx + $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexNimrod.cxx + wxscintilla_LexNsis.o: $(srcdir)/src/stc/scintilla/src/LexNsis.cxx $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexNsis.cxx @@ -14600,6 +14626,12 @@ wxscintilla_LexPascal.o: $(srcdir)/src/stc/scintilla/src/LexPascal.cxx wxscintilla_LexPerl.o: $(srcdir)/src/stc/scintilla/src/LexPerl.cxx $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexPerl.cxx +wxscintilla_LexPowerPro.o: $(srcdir)/src/stc/scintilla/src/LexPowerPro.cxx + $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexPowerPro.cxx + +wxscintilla_LexPowerShell.o: $(srcdir)/src/stc/scintilla/src/LexPowerShell.cxx + $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexPowerShell.cxx + wxscintilla_LexPython.o: $(srcdir)/src/stc/scintilla/src/LexPython.cxx $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexPython.cxx @@ -14615,6 +14647,9 @@ wxscintilla_LexRuby.o: $(srcdir)/src/stc/scintilla/src/LexRuby.cxx wxscintilla_LexSQL.o: $(srcdir)/src/stc/scintilla/src/LexSQL.cxx $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexSQL.cxx +wxscintilla_LexSML.o: $(srcdir)/src/stc/scintilla/src/LexSML.cxx + $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexSML.cxx + wxscintilla_LexSmalltalk.o: $(srcdir)/src/stc/scintilla/src/LexSmalltalk.cxx $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexSmalltalk.cxx @@ -14627,9 +14662,18 @@ wxscintilla_LexScriptol.o: $(srcdir)/src/stc/scintilla/src/LexScriptol.cxx wxscintilla_LexSpecman.o: $(srcdir)/src/stc/scintilla/src/LexSpecman.cxx $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexSpecman.cxx +wxscintilla_LexSorcus.o: $(srcdir)/src/stc/scintilla/src/LexSorcus.cxx + $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexSorcus.cxx + wxscintilla_LexSpice.o: $(srcdir)/src/stc/scintilla/src/LexSpice.cxx $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexSpice.cxx +wxscintilla_LexTAL.o: $(srcdir)/src/stc/scintilla/src/LexTAL.cxx + $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexTAL.cxx + +wxscintilla_LexTACL.o: $(srcdir)/src/stc/scintilla/src/LexTACL.cxx + $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexTACL.cxx + wxscintilla_LexTCL.o: $(srcdir)/src/stc/scintilla/src/LexTCL.cxx $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexTCL.cxx @@ -14651,6 +14695,9 @@ wxscintilla_LexYAML.o: $(srcdir)/src/stc/scintilla/src/LexYAML.cxx wxscintilla_LineMarker.o: $(srcdir)/src/stc/scintilla/src/LineMarker.cxx $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LineMarker.cxx +wxscintilla_PerLine.o: $(srcdir)/src/stc/scintilla/src/PerLine.cxx + $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/PerLine.cxx + wxscintilla_PositionCache.o: $(srcdir)/src/stc/scintilla/src/PositionCache.cxx $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/PositionCache.cxx @@ -14663,6 +14710,9 @@ wxscintilla_RESearch.o: $(srcdir)/src/stc/scintilla/src/RESearch.cxx wxscintilla_RunStyles.o: $(srcdir)/src/stc/scintilla/src/RunStyles.cxx $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/RunStyles.cxx +wxscintilla_Selection.o: $(srcdir)/src/stc/scintilla/src/Selection.cxx + $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/Selection.cxx + wxscintilla_ScintillaBase.o: $(srcdir)/src/stc/scintilla/src/ScintillaBase.cxx $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/ScintillaBase.cxx @@ -14684,6 +14734,12 @@ wxscintilla_WindowAccessor.o: $(srcdir)/src/stc/scintilla/src/WindowAccessor.cxx wxscintilla_XPM.o: $(srcdir)/src/stc/scintilla/src/XPM.cxx $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/XPM.cxx +wxscintilla_LexMarkdown.o: $(srcdir)/src/stc/scintilla/src/LexMarkdown.cxx + $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexMarkdown.cxx + +wxscintilla_Array.o: $(srcdir)/src/stc/scintilla/src/Array.cpp + $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/Array.cpp + monodll_any.o: $(srcdir)/src/common/any.cpp $(MONODLL_ODEP) $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/common/any.cpp diff --git a/build/bakefiles/scintilla.bkl b/build/bakefiles/scintilla.bkl index 45d244e1d6..d79cb7aab7 100644 --- a/build/bakefiles/scintilla.bkl +++ b/build/bakefiles/scintilla.bkl @@ -69,6 +69,7 @@ src/stc/scintilla/src/LexCSS.cxx src/stc/scintilla/src/LexCaml.cxx src/stc/scintilla/src/LexCsound.cxx + src/stc/scintilla/src/LexCOBOL.cxx src/stc/scintilla/src/LexConf.cxx src/stc/scintilla/src/LexCrontab.cxx src/stc/scintilla/src/LexD.cxx @@ -87,11 +88,14 @@ src/stc/scintilla/src/LexLisp.cxx src/stc/scintilla/src/LexLout.cxx src/stc/scintilla/src/LexLua.cxx + src/stc/scintilla/src/LexMagik.cxx src/stc/scintilla/src/LexMMIXAL.cxx src/stc/scintilla/src/LexMPT.cxx src/stc/scintilla/src/LexMSSQL.cxx src/stc/scintilla/src/LexMatlab.cxx src/stc/scintilla/src/LexMetapost.cxx + src/stc/scintilla/src/LexMySQL.cxx + src/stc/scintilla/src/LexNimrod.cxx src/stc/scintilla/src/LexNsis.cxx src/stc/scintilla/src/LexOpal.cxx src/stc/scintilla/src/LexOthers.cxx @@ -102,16 +106,22 @@ src/stc/scintilla/src/LexPS.cxx src/stc/scintilla/src/LexPascal.cxx src/stc/scintilla/src/LexPerl.cxx + src/stc/scintilla/src/LexPowerPro.cxx + src/stc/scintilla/src/LexPowerShell.cxx src/stc/scintilla/src/LexPython.cxx src/stc/scintilla/src/LexR.cxx src/stc/scintilla/src/LexRebol.cxx src/stc/scintilla/src/LexRuby.cxx src/stc/scintilla/src/LexSQL.cxx + src/stc/scintilla/src/LexSML.cxx src/stc/scintilla/src/LexSmalltalk.cxx src/stc/scintilla/src/LexTADS3.cxx src/stc/scintilla/src/LexScriptol.cxx src/stc/scintilla/src/LexSpecman.cxx + src/stc/scintilla/src/LexSorcus.cxx src/stc/scintilla/src/LexSpice.cxx + src/stc/scintilla/src/LexTAL.cxx + src/stc/scintilla/src/LexTACL.cxx src/stc/scintilla/src/LexTCL.cxx src/stc/scintilla/src/LexTeX.cxx src/stc/scintilla/src/LexVB.cxx @@ -119,10 +129,12 @@ src/stc/scintilla/src/LexVerilog.cxx src/stc/scintilla/src/LexYAML.cxx src/stc/scintilla/src/LineMarker.cxx + src/stc/scintilla/src/PerLine.cxx src/stc/scintilla/src/PositionCache.cxx src/stc/scintilla/src/PropSet.cxx src/stc/scintilla/src/RESearch.cxx src/stc/scintilla/src/RunStyles.cxx + src/stc/scintilla/src/Selection.cxx src/stc/scintilla/src/ScintillaBase.cxx src/stc/scintilla/src/Style.cxx src/stc/scintilla/src/StyleContext.cxx @@ -130,6 +142,8 @@ src/stc/scintilla/src/ViewStyle.cxx src/stc/scintilla/src/WindowAccessor.cxx src/stc/scintilla/src/XPM.cxx + src/stc/scintilla/src/LexMarkdown.cxx + src/stc/scintilla/src/Array.cpp diff --git a/build/msw/makefile.bcc b/build/msw/makefile.bcc index 5e1184ba3a..d03bfbc61f 100644 --- a/build/msw/makefile.bcc +++ b/build/msw/makefile.bcc @@ -227,6 +227,7 @@ WXSCINTILLA_OBJECTS = \ $(OBJS)\wxscintilla_LexCSS.obj \ $(OBJS)\wxscintilla_LexCaml.obj \ $(OBJS)\wxscintilla_LexCsound.obj \ + $(OBJS)\wxscintilla_LexCOBOL.obj \ $(OBJS)\wxscintilla_LexConf.obj \ $(OBJS)\wxscintilla_LexCrontab.obj \ $(OBJS)\wxscintilla_LexD.obj \ @@ -245,11 +246,14 @@ WXSCINTILLA_OBJECTS = \ $(OBJS)\wxscintilla_LexLisp.obj \ $(OBJS)\wxscintilla_LexLout.obj \ $(OBJS)\wxscintilla_LexLua.obj \ + $(OBJS)\wxscintilla_LexMagik.obj \ $(OBJS)\wxscintilla_LexMMIXAL.obj \ $(OBJS)\wxscintilla_LexMPT.obj \ $(OBJS)\wxscintilla_LexMSSQL.obj \ $(OBJS)\wxscintilla_LexMatlab.obj \ $(OBJS)\wxscintilla_LexMetapost.obj \ + $(OBJS)\wxscintilla_LexMySQL.obj \ + $(OBJS)\wxscintilla_LexNimrod.obj \ $(OBJS)\wxscintilla_LexNsis.obj \ $(OBJS)\wxscintilla_LexOpal.obj \ $(OBJS)\wxscintilla_LexOthers.obj \ @@ -260,16 +264,22 @@ WXSCINTILLA_OBJECTS = \ $(OBJS)\wxscintilla_LexPS.obj \ $(OBJS)\wxscintilla_LexPascal.obj \ $(OBJS)\wxscintilla_LexPerl.obj \ + $(OBJS)\wxscintilla_LexPowerPro.obj \ + $(OBJS)\wxscintilla_LexPowerShell.obj \ $(OBJS)\wxscintilla_LexPython.obj \ $(OBJS)\wxscintilla_LexR.obj \ $(OBJS)\wxscintilla_LexRebol.obj \ $(OBJS)\wxscintilla_LexRuby.obj \ $(OBJS)\wxscintilla_LexSQL.obj \ + $(OBJS)\wxscintilla_LexSML.obj \ $(OBJS)\wxscintilla_LexSmalltalk.obj \ $(OBJS)\wxscintilla_LexTADS3.obj \ $(OBJS)\wxscintilla_LexScriptol.obj \ $(OBJS)\wxscintilla_LexSpecman.obj \ + $(OBJS)\wxscintilla_LexSorcus.obj \ $(OBJS)\wxscintilla_LexSpice.obj \ + $(OBJS)\wxscintilla_LexTAL.obj \ + $(OBJS)\wxscintilla_LexTACL.obj \ $(OBJS)\wxscintilla_LexTCL.obj \ $(OBJS)\wxscintilla_LexTeX.obj \ $(OBJS)\wxscintilla_LexVB.obj \ @@ -277,17 +287,21 @@ WXSCINTILLA_OBJECTS = \ $(OBJS)\wxscintilla_LexVerilog.obj \ $(OBJS)\wxscintilla_LexYAML.obj \ $(OBJS)\wxscintilla_LineMarker.obj \ + $(OBJS)\wxscintilla_PerLine.obj \ $(OBJS)\wxscintilla_PositionCache.obj \ $(OBJS)\wxscintilla_PropSet.obj \ $(OBJS)\wxscintilla_RESearch.obj \ $(OBJS)\wxscintilla_RunStyles.obj \ + $(OBJS)\wxscintilla_Selection.obj \ $(OBJS)\wxscintilla_ScintillaBase.obj \ $(OBJS)\wxscintilla_Style.obj \ $(OBJS)\wxscintilla_StyleContext.obj \ $(OBJS)\wxscintilla_UniConversion.obj \ $(OBJS)\wxscintilla_ViewStyle.obj \ $(OBJS)\wxscintilla_WindowAccessor.obj \ - $(OBJS)\wxscintilla_XPM.obj + $(OBJS)\wxscintilla_XPM.obj \ + $(OBJS)\wxscintilla_LexMarkdown.obj \ + $(OBJS)\wxscintilla_Array.obj MONODLL_CFLAGS = $(__RUNTIME_LIBS) -I$(BCCDIR)\include $(__DEBUGINFO) \ $(__OPTIMIZEFLAG) $(__THREADSFLAG) -D__WXMSW__ $(__WXUNIV_DEFINE_p) \ $(__DEBUG_DEFINE_p) $(__NDEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) \ @@ -5434,6 +5448,9 @@ $(OBJS)\wxscintilla_LexCaml.obj: ..\..\src\stc\scintilla\src\LexCaml.cxx $(OBJS)\wxscintilla_LexCsound.obj: ..\..\src\stc\scintilla\src\LexCsound.cxx $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexCsound.cxx +$(OBJS)\wxscintilla_LexCOBOL.obj: ..\..\src\stc\scintilla\src\LexCOBOL.cxx + $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexCOBOL.cxx + $(OBJS)\wxscintilla_LexConf.obj: ..\..\src\stc\scintilla\src\LexConf.cxx $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexConf.cxx @@ -5488,6 +5505,9 @@ $(OBJS)\wxscintilla_LexLout.obj: ..\..\src\stc\scintilla\src\LexLout.cxx $(OBJS)\wxscintilla_LexLua.obj: ..\..\src\stc\scintilla\src\LexLua.cxx $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexLua.cxx +$(OBJS)\wxscintilla_LexMagik.obj: ..\..\src\stc\scintilla\src\LexMagik.cxx + $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexMagik.cxx + $(OBJS)\wxscintilla_LexMMIXAL.obj: ..\..\src\stc\scintilla\src\LexMMIXAL.cxx $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexMMIXAL.cxx @@ -5503,6 +5523,12 @@ $(OBJS)\wxscintilla_LexMatlab.obj: ..\..\src\stc\scintilla\src\LexMatlab.cxx $(OBJS)\wxscintilla_LexMetapost.obj: ..\..\src\stc\scintilla\src\LexMetapost.cxx $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexMetapost.cxx +$(OBJS)\wxscintilla_LexMySQL.obj: ..\..\src\stc\scintilla\src\LexMySQL.cxx + $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexMySQL.cxx + +$(OBJS)\wxscintilla_LexNimrod.obj: ..\..\src\stc\scintilla\src\LexNimrod.cxx + $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexNimrod.cxx + $(OBJS)\wxscintilla_LexNsis.obj: ..\..\src\stc\scintilla\src\LexNsis.cxx $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexNsis.cxx @@ -5533,6 +5559,12 @@ $(OBJS)\wxscintilla_LexPascal.obj: ..\..\src\stc\scintilla\src\LexPascal.cxx $(OBJS)\wxscintilla_LexPerl.obj: ..\..\src\stc\scintilla\src\LexPerl.cxx $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexPerl.cxx +$(OBJS)\wxscintilla_LexPowerPro.obj: ..\..\src\stc\scintilla\src\LexPowerPro.cxx + $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexPowerPro.cxx + +$(OBJS)\wxscintilla_LexPowerShell.obj: ..\..\src\stc\scintilla\src\LexPowerShell.cxx + $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexPowerShell.cxx + $(OBJS)\wxscintilla_LexPython.obj: ..\..\src\stc\scintilla\src\LexPython.cxx $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexPython.cxx @@ -5548,6 +5580,9 @@ $(OBJS)\wxscintilla_LexRuby.obj: ..\..\src\stc\scintilla\src\LexRuby.cxx $(OBJS)\wxscintilla_LexSQL.obj: ..\..\src\stc\scintilla\src\LexSQL.cxx $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexSQL.cxx +$(OBJS)\wxscintilla_LexSML.obj: ..\..\src\stc\scintilla\src\LexSML.cxx + $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexSML.cxx + $(OBJS)\wxscintilla_LexSmalltalk.obj: ..\..\src\stc\scintilla\src\LexSmalltalk.cxx $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexSmalltalk.cxx @@ -5560,9 +5595,18 @@ $(OBJS)\wxscintilla_LexScriptol.obj: ..\..\src\stc\scintilla\src\LexScriptol.cxx $(OBJS)\wxscintilla_LexSpecman.obj: ..\..\src\stc\scintilla\src\LexSpecman.cxx $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexSpecman.cxx +$(OBJS)\wxscintilla_LexSorcus.obj: ..\..\src\stc\scintilla\src\LexSorcus.cxx + $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexSorcus.cxx + $(OBJS)\wxscintilla_LexSpice.obj: ..\..\src\stc\scintilla\src\LexSpice.cxx $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexSpice.cxx +$(OBJS)\wxscintilla_LexTAL.obj: ..\..\src\stc\scintilla\src\LexTAL.cxx + $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexTAL.cxx + +$(OBJS)\wxscintilla_LexTACL.obj: ..\..\src\stc\scintilla\src\LexTACL.cxx + $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexTACL.cxx + $(OBJS)\wxscintilla_LexTCL.obj: ..\..\src\stc\scintilla\src\LexTCL.cxx $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexTCL.cxx @@ -5584,6 +5628,9 @@ $(OBJS)\wxscintilla_LexYAML.obj: ..\..\src\stc\scintilla\src\LexYAML.cxx $(OBJS)\wxscintilla_LineMarker.obj: ..\..\src\stc\scintilla\src\LineMarker.cxx $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LineMarker.cxx +$(OBJS)\wxscintilla_PerLine.obj: ..\..\src\stc\scintilla\src\PerLine.cxx + $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\PerLine.cxx + $(OBJS)\wxscintilla_PositionCache.obj: ..\..\src\stc\scintilla\src\PositionCache.cxx $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\PositionCache.cxx @@ -5596,6 +5643,9 @@ $(OBJS)\wxscintilla_RESearch.obj: ..\..\src\stc\scintilla\src\RESearch.cxx $(OBJS)\wxscintilla_RunStyles.obj: ..\..\src\stc\scintilla\src\RunStyles.cxx $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\RunStyles.cxx +$(OBJS)\wxscintilla_Selection.obj: ..\..\src\stc\scintilla\src\Selection.cxx + $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\Selection.cxx + $(OBJS)\wxscintilla_ScintillaBase.obj: ..\..\src\stc\scintilla\src\ScintillaBase.cxx $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\ScintillaBase.cxx @@ -5617,6 +5667,12 @@ $(OBJS)\wxscintilla_WindowAccessor.obj: ..\..\src\stc\scintilla\src\WindowAccess $(OBJS)\wxscintilla_XPM.obj: ..\..\src\stc\scintilla\src\XPM.cxx $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\XPM.cxx +$(OBJS)\wxscintilla_LexMarkdown.obj: ..\..\src\stc\scintilla\src\LexMarkdown.cxx + $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexMarkdown.cxx + +$(OBJS)\wxscintilla_Array.obj: ..\..\src\stc\scintilla\src\Array.cpp + $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\Array.cpp + $(OBJS)\monodll_dummy.obj: ..\..\src\common\dummy.cpp $(CXX) -q -c -P -o$@ $(MONODLL_CXXFLAGS) -H ..\..\src\common\dummy.cpp diff --git a/build/msw/makefile.gcc b/build/msw/makefile.gcc index 671f502096..02f15af326 100644 --- a/build/msw/makefile.gcc +++ b/build/msw/makefile.gcc @@ -214,6 +214,7 @@ WXSCINTILLA_OBJECTS = \ $(OBJS)\wxscintilla_LexCSS.o \ $(OBJS)\wxscintilla_LexCaml.o \ $(OBJS)\wxscintilla_LexCsound.o \ + $(OBJS)\wxscintilla_LexCOBOL.o \ $(OBJS)\wxscintilla_LexConf.o \ $(OBJS)\wxscintilla_LexCrontab.o \ $(OBJS)\wxscintilla_LexD.o \ @@ -232,11 +233,14 @@ WXSCINTILLA_OBJECTS = \ $(OBJS)\wxscintilla_LexLisp.o \ $(OBJS)\wxscintilla_LexLout.o \ $(OBJS)\wxscintilla_LexLua.o \ + $(OBJS)\wxscintilla_LexMagik.o \ $(OBJS)\wxscintilla_LexMMIXAL.o \ $(OBJS)\wxscintilla_LexMPT.o \ $(OBJS)\wxscintilla_LexMSSQL.o \ $(OBJS)\wxscintilla_LexMatlab.o \ $(OBJS)\wxscintilla_LexMetapost.o \ + $(OBJS)\wxscintilla_LexMySQL.o \ + $(OBJS)\wxscintilla_LexNimrod.o \ $(OBJS)\wxscintilla_LexNsis.o \ $(OBJS)\wxscintilla_LexOpal.o \ $(OBJS)\wxscintilla_LexOthers.o \ @@ -247,16 +251,22 @@ WXSCINTILLA_OBJECTS = \ $(OBJS)\wxscintilla_LexPS.o \ $(OBJS)\wxscintilla_LexPascal.o \ $(OBJS)\wxscintilla_LexPerl.o \ + $(OBJS)\wxscintilla_LexPowerPro.o \ + $(OBJS)\wxscintilla_LexPowerShell.o \ $(OBJS)\wxscintilla_LexPython.o \ $(OBJS)\wxscintilla_LexR.o \ $(OBJS)\wxscintilla_LexRebol.o \ $(OBJS)\wxscintilla_LexRuby.o \ $(OBJS)\wxscintilla_LexSQL.o \ + $(OBJS)\wxscintilla_LexSML.o \ $(OBJS)\wxscintilla_LexSmalltalk.o \ $(OBJS)\wxscintilla_LexTADS3.o \ $(OBJS)\wxscintilla_LexScriptol.o \ $(OBJS)\wxscintilla_LexSpecman.o \ + $(OBJS)\wxscintilla_LexSorcus.o \ $(OBJS)\wxscintilla_LexSpice.o \ + $(OBJS)\wxscintilla_LexTAL.o \ + $(OBJS)\wxscintilla_LexTACL.o \ $(OBJS)\wxscintilla_LexTCL.o \ $(OBJS)\wxscintilla_LexTeX.o \ $(OBJS)\wxscintilla_LexVB.o \ @@ -264,17 +274,21 @@ WXSCINTILLA_OBJECTS = \ $(OBJS)\wxscintilla_LexVerilog.o \ $(OBJS)\wxscintilla_LexYAML.o \ $(OBJS)\wxscintilla_LineMarker.o \ + $(OBJS)\wxscintilla_PerLine.o \ $(OBJS)\wxscintilla_PositionCache.o \ $(OBJS)\wxscintilla_PropSet.o \ $(OBJS)\wxscintilla_RESearch.o \ $(OBJS)\wxscintilla_RunStyles.o \ + $(OBJS)\wxscintilla_Selection.o \ $(OBJS)\wxscintilla_ScintillaBase.o \ $(OBJS)\wxscintilla_Style.o \ $(OBJS)\wxscintilla_StyleContext.o \ $(OBJS)\wxscintilla_UniConversion.o \ $(OBJS)\wxscintilla_ViewStyle.o \ $(OBJS)\wxscintilla_WindowAccessor.o \ - $(OBJS)\wxscintilla_XPM.o + $(OBJS)\wxscintilla_XPM.o \ + $(OBJS)\wxscintilla_LexMarkdown.o \ + $(OBJS)\wxscintilla_Array.o MONODLL_CFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) $(GCCFLAGS) \ -DHAVE_W32API_H -D__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) \ $(__NDEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \ @@ -5600,6 +5614,9 @@ $(OBJS)\wxscintilla_LexCaml.o: ../../src/stc/scintilla/src/LexCaml.cxx $(OBJS)\wxscintilla_LexCsound.o: ../../src/stc/scintilla/src/LexCsound.cxx $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\wxscintilla_LexCOBOL.o: ../../src/stc/scintilla/src/LexCOBOL.cxx + $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\wxscintilla_LexConf.o: ../../src/stc/scintilla/src/LexConf.cxx $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< @@ -5654,6 +5671,9 @@ $(OBJS)\wxscintilla_LexLout.o: ../../src/stc/scintilla/src/LexLout.cxx $(OBJS)\wxscintilla_LexLua.o: ../../src/stc/scintilla/src/LexLua.cxx $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\wxscintilla_LexMagik.o: ../../src/stc/scintilla/src/LexMagik.cxx + $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\wxscintilla_LexMMIXAL.o: ../../src/stc/scintilla/src/LexMMIXAL.cxx $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< @@ -5669,6 +5689,12 @@ $(OBJS)\wxscintilla_LexMatlab.o: ../../src/stc/scintilla/src/LexMatlab.cxx $(OBJS)\wxscintilla_LexMetapost.o: ../../src/stc/scintilla/src/LexMetapost.cxx $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\wxscintilla_LexMySQL.o: ../../src/stc/scintilla/src/LexMySQL.cxx + $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\wxscintilla_LexNimrod.o: ../../src/stc/scintilla/src/LexNimrod.cxx + $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\wxscintilla_LexNsis.o: ../../src/stc/scintilla/src/LexNsis.cxx $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< @@ -5699,6 +5725,12 @@ $(OBJS)\wxscintilla_LexPascal.o: ../../src/stc/scintilla/src/LexPascal.cxx $(OBJS)\wxscintilla_LexPerl.o: ../../src/stc/scintilla/src/LexPerl.cxx $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\wxscintilla_LexPowerPro.o: ../../src/stc/scintilla/src/LexPowerPro.cxx + $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\wxscintilla_LexPowerShell.o: ../../src/stc/scintilla/src/LexPowerShell.cxx + $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\wxscintilla_LexPython.o: ../../src/stc/scintilla/src/LexPython.cxx $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< @@ -5714,6 +5746,9 @@ $(OBJS)\wxscintilla_LexRuby.o: ../../src/stc/scintilla/src/LexRuby.cxx $(OBJS)\wxscintilla_LexSQL.o: ../../src/stc/scintilla/src/LexSQL.cxx $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\wxscintilla_LexSML.o: ../../src/stc/scintilla/src/LexSML.cxx + $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\wxscintilla_LexSmalltalk.o: ../../src/stc/scintilla/src/LexSmalltalk.cxx $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< @@ -5726,9 +5761,18 @@ $(OBJS)\wxscintilla_LexScriptol.o: ../../src/stc/scintilla/src/LexScriptol.cxx $(OBJS)\wxscintilla_LexSpecman.o: ../../src/stc/scintilla/src/LexSpecman.cxx $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\wxscintilla_LexSorcus.o: ../../src/stc/scintilla/src/LexSorcus.cxx + $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\wxscintilla_LexSpice.o: ../../src/stc/scintilla/src/LexSpice.cxx $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\wxscintilla_LexTAL.o: ../../src/stc/scintilla/src/LexTAL.cxx + $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\wxscintilla_LexTACL.o: ../../src/stc/scintilla/src/LexTACL.cxx + $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\wxscintilla_LexTCL.o: ../../src/stc/scintilla/src/LexTCL.cxx $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< @@ -5750,6 +5794,9 @@ $(OBJS)\wxscintilla_LexYAML.o: ../../src/stc/scintilla/src/LexYAML.cxx $(OBJS)\wxscintilla_LineMarker.o: ../../src/stc/scintilla/src/LineMarker.cxx $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\wxscintilla_PerLine.o: ../../src/stc/scintilla/src/PerLine.cxx + $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\wxscintilla_PositionCache.o: ../../src/stc/scintilla/src/PositionCache.cxx $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< @@ -5762,6 +5809,9 @@ $(OBJS)\wxscintilla_RESearch.o: ../../src/stc/scintilla/src/RESearch.cxx $(OBJS)\wxscintilla_RunStyles.o: ../../src/stc/scintilla/src/RunStyles.cxx $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\wxscintilla_Selection.o: ../../src/stc/scintilla/src/Selection.cxx + $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\wxscintilla_ScintillaBase.o: ../../src/stc/scintilla/src/ScintillaBase.cxx $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< @@ -5783,6 +5833,12 @@ $(OBJS)\wxscintilla_WindowAccessor.o: ../../src/stc/scintilla/src/WindowAccessor $(OBJS)\wxscintilla_XPM.o: ../../src/stc/scintilla/src/XPM.cxx $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\wxscintilla_LexMarkdown.o: ../../src/stc/scintilla/src/LexMarkdown.cxx + $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< + +$(OBJS)\wxscintilla_Array.o: ../../src/stc/scintilla/src/Array.cpp + $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\monodll_dummy.o: ../../src/common/dummy.cpp $(CXX) -c -o $@ $(MONODLL_CXXFLAGS) $(CPPDEPS) $< diff --git a/build/msw/makefile.vc b/build/msw/makefile.vc index d1da00996b..17e5c2b855 100644 --- a/build/msw/makefile.vc +++ b/build/msw/makefile.vc @@ -227,6 +227,7 @@ WXSCINTILLA_OBJECTS = \ $(OBJS)\wxscintilla_LexCSS.obj \ $(OBJS)\wxscintilla_LexCaml.obj \ $(OBJS)\wxscintilla_LexCsound.obj \ + $(OBJS)\wxscintilla_LexCOBOL.obj \ $(OBJS)\wxscintilla_LexConf.obj \ $(OBJS)\wxscintilla_LexCrontab.obj \ $(OBJS)\wxscintilla_LexD.obj \ @@ -245,11 +246,14 @@ WXSCINTILLA_OBJECTS = \ $(OBJS)\wxscintilla_LexLisp.obj \ $(OBJS)\wxscintilla_LexLout.obj \ $(OBJS)\wxscintilla_LexLua.obj \ + $(OBJS)\wxscintilla_LexMagik.obj \ $(OBJS)\wxscintilla_LexMMIXAL.obj \ $(OBJS)\wxscintilla_LexMPT.obj \ $(OBJS)\wxscintilla_LexMSSQL.obj \ $(OBJS)\wxscintilla_LexMatlab.obj \ $(OBJS)\wxscintilla_LexMetapost.obj \ + $(OBJS)\wxscintilla_LexMySQL.obj \ + $(OBJS)\wxscintilla_LexNimrod.obj \ $(OBJS)\wxscintilla_LexNsis.obj \ $(OBJS)\wxscintilla_LexOpal.obj \ $(OBJS)\wxscintilla_LexOthers.obj \ @@ -260,16 +264,22 @@ WXSCINTILLA_OBJECTS = \ $(OBJS)\wxscintilla_LexPS.obj \ $(OBJS)\wxscintilla_LexPascal.obj \ $(OBJS)\wxscintilla_LexPerl.obj \ + $(OBJS)\wxscintilla_LexPowerPro.obj \ + $(OBJS)\wxscintilla_LexPowerShell.obj \ $(OBJS)\wxscintilla_LexPython.obj \ $(OBJS)\wxscintilla_LexR.obj \ $(OBJS)\wxscintilla_LexRebol.obj \ $(OBJS)\wxscintilla_LexRuby.obj \ $(OBJS)\wxscintilla_LexSQL.obj \ + $(OBJS)\wxscintilla_LexSML.obj \ $(OBJS)\wxscintilla_LexSmalltalk.obj \ $(OBJS)\wxscintilla_LexTADS3.obj \ $(OBJS)\wxscintilla_LexScriptol.obj \ $(OBJS)\wxscintilla_LexSpecman.obj \ + $(OBJS)\wxscintilla_LexSorcus.obj \ $(OBJS)\wxscintilla_LexSpice.obj \ + $(OBJS)\wxscintilla_LexTAL.obj \ + $(OBJS)\wxscintilla_LexTACL.obj \ $(OBJS)\wxscintilla_LexTCL.obj \ $(OBJS)\wxscintilla_LexTeX.obj \ $(OBJS)\wxscintilla_LexVB.obj \ @@ -277,17 +287,21 @@ WXSCINTILLA_OBJECTS = \ $(OBJS)\wxscintilla_LexVerilog.obj \ $(OBJS)\wxscintilla_LexYAML.obj \ $(OBJS)\wxscintilla_LineMarker.obj \ + $(OBJS)\wxscintilla_PerLine.obj \ $(OBJS)\wxscintilla_PositionCache.obj \ $(OBJS)\wxscintilla_PropSet.obj \ $(OBJS)\wxscintilla_RESearch.obj \ $(OBJS)\wxscintilla_RunStyles.obj \ + $(OBJS)\wxscintilla_Selection.obj \ $(OBJS)\wxscintilla_ScintillaBase.obj \ $(OBJS)\wxscintilla_Style.obj \ $(OBJS)\wxscintilla_StyleContext.obj \ $(OBJS)\wxscintilla_UniConversion.obj \ $(OBJS)\wxscintilla_ViewStyle.obj \ $(OBJS)\wxscintilla_WindowAccessor.obj \ - $(OBJS)\wxscintilla_XPM.obj + $(OBJS)\wxscintilla_XPM.obj \ + $(OBJS)\wxscintilla_LexMarkdown.obj \ + $(OBJS)\wxscintilla_Array.obj MONODLL_CFLAGS = /M$(__RUNTIME_LIBS_116)$(__DEBUGRUNTIME) /DWIN32 \ $(__DEBUGINFO) \ /Fd$(LIBDIRNAME)\wx$(PORTNAME)$(WXUNIVNAME)$(WX_VERSION_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_vc$(VENDORTAG).pdb \ @@ -6031,6 +6045,9 @@ $(OBJS)\wxscintilla_LexCaml.obj: ..\..\src\stc\scintilla\src\LexCaml.cxx $(OBJS)\wxscintilla_LexCsound.obj: ..\..\src\stc\scintilla\src\LexCsound.cxx $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexCsound.cxx +$(OBJS)\wxscintilla_LexCOBOL.obj: ..\..\src\stc\scintilla\src\LexCOBOL.cxx + $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexCOBOL.cxx + $(OBJS)\wxscintilla_LexConf.obj: ..\..\src\stc\scintilla\src\LexConf.cxx $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexConf.cxx @@ -6085,6 +6102,9 @@ $(OBJS)\wxscintilla_LexLout.obj: ..\..\src\stc\scintilla\src\LexLout.cxx $(OBJS)\wxscintilla_LexLua.obj: ..\..\src\stc\scintilla\src\LexLua.cxx $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexLua.cxx +$(OBJS)\wxscintilla_LexMagik.obj: ..\..\src\stc\scintilla\src\LexMagik.cxx + $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexMagik.cxx + $(OBJS)\wxscintilla_LexMMIXAL.obj: ..\..\src\stc\scintilla\src\LexMMIXAL.cxx $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexMMIXAL.cxx @@ -6100,6 +6120,12 @@ $(OBJS)\wxscintilla_LexMatlab.obj: ..\..\src\stc\scintilla\src\LexMatlab.cxx $(OBJS)\wxscintilla_LexMetapost.obj: ..\..\src\stc\scintilla\src\LexMetapost.cxx $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexMetapost.cxx +$(OBJS)\wxscintilla_LexMySQL.obj: ..\..\src\stc\scintilla\src\LexMySQL.cxx + $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexMySQL.cxx + +$(OBJS)\wxscintilla_LexNimrod.obj: ..\..\src\stc\scintilla\src\LexNimrod.cxx + $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexNimrod.cxx + $(OBJS)\wxscintilla_LexNsis.obj: ..\..\src\stc\scintilla\src\LexNsis.cxx $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexNsis.cxx @@ -6130,6 +6156,12 @@ $(OBJS)\wxscintilla_LexPascal.obj: ..\..\src\stc\scintilla\src\LexPascal.cxx $(OBJS)\wxscintilla_LexPerl.obj: ..\..\src\stc\scintilla\src\LexPerl.cxx $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexPerl.cxx +$(OBJS)\wxscintilla_LexPowerPro.obj: ..\..\src\stc\scintilla\src\LexPowerPro.cxx + $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexPowerPro.cxx + +$(OBJS)\wxscintilla_LexPowerShell.obj: ..\..\src\stc\scintilla\src\LexPowerShell.cxx + $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexPowerShell.cxx + $(OBJS)\wxscintilla_LexPython.obj: ..\..\src\stc\scintilla\src\LexPython.cxx $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexPython.cxx @@ -6145,6 +6177,9 @@ $(OBJS)\wxscintilla_LexRuby.obj: ..\..\src\stc\scintilla\src\LexRuby.cxx $(OBJS)\wxscintilla_LexSQL.obj: ..\..\src\stc\scintilla\src\LexSQL.cxx $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexSQL.cxx +$(OBJS)\wxscintilla_LexSML.obj: ..\..\src\stc\scintilla\src\LexSML.cxx + $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexSML.cxx + $(OBJS)\wxscintilla_LexSmalltalk.obj: ..\..\src\stc\scintilla\src\LexSmalltalk.cxx $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexSmalltalk.cxx @@ -6157,9 +6192,18 @@ $(OBJS)\wxscintilla_LexScriptol.obj: ..\..\src\stc\scintilla\src\LexScriptol.cxx $(OBJS)\wxscintilla_LexSpecman.obj: ..\..\src\stc\scintilla\src\LexSpecman.cxx $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexSpecman.cxx +$(OBJS)\wxscintilla_LexSorcus.obj: ..\..\src\stc\scintilla\src\LexSorcus.cxx + $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexSorcus.cxx + $(OBJS)\wxscintilla_LexSpice.obj: ..\..\src\stc\scintilla\src\LexSpice.cxx $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexSpice.cxx +$(OBJS)\wxscintilla_LexTAL.obj: ..\..\src\stc\scintilla\src\LexTAL.cxx + $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexTAL.cxx + +$(OBJS)\wxscintilla_LexTACL.obj: ..\..\src\stc\scintilla\src\LexTACL.cxx + $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexTACL.cxx + $(OBJS)\wxscintilla_LexTCL.obj: ..\..\src\stc\scintilla\src\LexTCL.cxx $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexTCL.cxx @@ -6181,6 +6225,9 @@ $(OBJS)\wxscintilla_LexYAML.obj: ..\..\src\stc\scintilla\src\LexYAML.cxx $(OBJS)\wxscintilla_LineMarker.obj: ..\..\src\stc\scintilla\src\LineMarker.cxx $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LineMarker.cxx +$(OBJS)\wxscintilla_PerLine.obj: ..\..\src\stc\scintilla\src\PerLine.cxx + $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\PerLine.cxx + $(OBJS)\wxscintilla_PositionCache.obj: ..\..\src\stc\scintilla\src\PositionCache.cxx $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\PositionCache.cxx @@ -6193,6 +6240,9 @@ $(OBJS)\wxscintilla_RESearch.obj: ..\..\src\stc\scintilla\src\RESearch.cxx $(OBJS)\wxscintilla_RunStyles.obj: ..\..\src\stc\scintilla\src\RunStyles.cxx $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\RunStyles.cxx +$(OBJS)\wxscintilla_Selection.obj: ..\..\src\stc\scintilla\src\Selection.cxx + $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\Selection.cxx + $(OBJS)\wxscintilla_ScintillaBase.obj: ..\..\src\stc\scintilla\src\ScintillaBase.cxx $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\ScintillaBase.cxx @@ -6214,6 +6264,12 @@ $(OBJS)\wxscintilla_WindowAccessor.obj: ..\..\src\stc\scintilla\src\WindowAccess $(OBJS)\wxscintilla_XPM.obj: ..\..\src\stc\scintilla\src\XPM.cxx $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\XPM.cxx +$(OBJS)\wxscintilla_LexMarkdown.obj: ..\..\src\stc\scintilla\src\LexMarkdown.cxx + $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\LexMarkdown.cxx + +$(OBJS)\wxscintilla_Array.obj: ..\..\src\stc\scintilla\src\Array.cpp + $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) ..\..\src\stc\scintilla\src\Array.cpp + $(OBJS)\monodll_dummy.obj: ..\..\src\common\dummy.cpp $(CXX) /c /nologo /TP /Fo$@ $(MONODLL_CXXFLAGS) /Ycwx/wxprec.h ..\..\src\common\dummy.cpp diff --git a/build/msw/makefile.wat b/build/msw/makefile.wat index 61cc8599a4..497fae7286 100644 --- a/build/msw/makefile.wat +++ b/build/msw/makefile.wat @@ -3430,6 +3430,7 @@ WXSCINTILLA_OBJECTS = & $(OBJS)\wxscintilla_LexCSS.obj & $(OBJS)\wxscintilla_LexCaml.obj & $(OBJS)\wxscintilla_LexCsound.obj & + $(OBJS)\wxscintilla_LexCOBOL.obj & $(OBJS)\wxscintilla_LexConf.obj & $(OBJS)\wxscintilla_LexCrontab.obj & $(OBJS)\wxscintilla_LexD.obj & @@ -3448,11 +3449,14 @@ WXSCINTILLA_OBJECTS = & $(OBJS)\wxscintilla_LexLisp.obj & $(OBJS)\wxscintilla_LexLout.obj & $(OBJS)\wxscintilla_LexLua.obj & + $(OBJS)\wxscintilla_LexMagik.obj & $(OBJS)\wxscintilla_LexMMIXAL.obj & $(OBJS)\wxscintilla_LexMPT.obj & $(OBJS)\wxscintilla_LexMSSQL.obj & $(OBJS)\wxscintilla_LexMatlab.obj & $(OBJS)\wxscintilla_LexMetapost.obj & + $(OBJS)\wxscintilla_LexMySQL.obj & + $(OBJS)\wxscintilla_LexNimrod.obj & $(OBJS)\wxscintilla_LexNsis.obj & $(OBJS)\wxscintilla_LexOpal.obj & $(OBJS)\wxscintilla_LexOthers.obj & @@ -3463,16 +3467,22 @@ WXSCINTILLA_OBJECTS = & $(OBJS)\wxscintilla_LexPS.obj & $(OBJS)\wxscintilla_LexPascal.obj & $(OBJS)\wxscintilla_LexPerl.obj & + $(OBJS)\wxscintilla_LexPowerPro.obj & + $(OBJS)\wxscintilla_LexPowerShell.obj & $(OBJS)\wxscintilla_LexPython.obj & $(OBJS)\wxscintilla_LexR.obj & $(OBJS)\wxscintilla_LexRebol.obj & $(OBJS)\wxscintilla_LexRuby.obj & $(OBJS)\wxscintilla_LexSQL.obj & + $(OBJS)\wxscintilla_LexSML.obj & $(OBJS)\wxscintilla_LexSmalltalk.obj & $(OBJS)\wxscintilla_LexTADS3.obj & $(OBJS)\wxscintilla_LexScriptol.obj & $(OBJS)\wxscintilla_LexSpecman.obj & + $(OBJS)\wxscintilla_LexSorcus.obj & $(OBJS)\wxscintilla_LexSpice.obj & + $(OBJS)\wxscintilla_LexTAL.obj & + $(OBJS)\wxscintilla_LexTACL.obj & $(OBJS)\wxscintilla_LexTCL.obj & $(OBJS)\wxscintilla_LexTeX.obj & $(OBJS)\wxscintilla_LexVB.obj & @@ -3480,17 +3490,21 @@ WXSCINTILLA_OBJECTS = & $(OBJS)\wxscintilla_LexVerilog.obj & $(OBJS)\wxscintilla_LexYAML.obj & $(OBJS)\wxscintilla_LineMarker.obj & + $(OBJS)\wxscintilla_PerLine.obj & $(OBJS)\wxscintilla_PositionCache.obj & $(OBJS)\wxscintilla_PropSet.obj & $(OBJS)\wxscintilla_RESearch.obj & $(OBJS)\wxscintilla_RunStyles.obj & + $(OBJS)\wxscintilla_Selection.obj & $(OBJS)\wxscintilla_ScintillaBase.obj & $(OBJS)\wxscintilla_Style.obj & $(OBJS)\wxscintilla_StyleContext.obj & $(OBJS)\wxscintilla_UniConversion.obj & $(OBJS)\wxscintilla_ViewStyle.obj & $(OBJS)\wxscintilla_WindowAccessor.obj & - $(OBJS)\wxscintilla_XPM.obj + $(OBJS)\wxscintilla_XPM.obj & + $(OBJS)\wxscintilla_LexMarkdown.obj & + $(OBJS)\wxscintilla_Array.obj MONODLL_CFLAGS = -bd $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) & $(__RUNTIME_LIBS) -d__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) & $(__NDEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) & @@ -5859,6 +5873,9 @@ $(OBJS)\wxscintilla_LexCaml.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexCa $(OBJS)\wxscintilla_LexCsound.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexCsound.cxx $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< +$(OBJS)\wxscintilla_LexCOBOL.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexCOBOL.cxx + $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< + $(OBJS)\wxscintilla_LexConf.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexConf.cxx $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< @@ -5913,6 +5930,9 @@ $(OBJS)\wxscintilla_LexLout.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexLo $(OBJS)\wxscintilla_LexLua.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexLua.cxx $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< +$(OBJS)\wxscintilla_LexMagik.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexMagik.cxx + $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< + $(OBJS)\wxscintilla_LexMMIXAL.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexMMIXAL.cxx $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< @@ -5928,6 +5948,12 @@ $(OBJS)\wxscintilla_LexMatlab.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\Lex $(OBJS)\wxscintilla_LexMetapost.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexMetapost.cxx $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< +$(OBJS)\wxscintilla_LexMySQL.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexMySQL.cxx + $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< + +$(OBJS)\wxscintilla_LexNimrod.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexNimrod.cxx + $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< + $(OBJS)\wxscintilla_LexNsis.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexNsis.cxx $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< @@ -5958,6 +5984,12 @@ $(OBJS)\wxscintilla_LexPascal.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\Lex $(OBJS)\wxscintilla_LexPerl.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexPerl.cxx $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< +$(OBJS)\wxscintilla_LexPowerPro.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexPowerPro.cxx + $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< + +$(OBJS)\wxscintilla_LexPowerShell.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexPowerShell.cxx + $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< + $(OBJS)\wxscintilla_LexPython.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexPython.cxx $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< @@ -5973,6 +6005,9 @@ $(OBJS)\wxscintilla_LexRuby.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexRu $(OBJS)\wxscintilla_LexSQL.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexSQL.cxx $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< +$(OBJS)\wxscintilla_LexSML.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexSML.cxx + $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< + $(OBJS)\wxscintilla_LexSmalltalk.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexSmalltalk.cxx $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< @@ -5985,9 +6020,18 @@ $(OBJS)\wxscintilla_LexScriptol.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\L $(OBJS)\wxscintilla_LexSpecman.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexSpecman.cxx $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< +$(OBJS)\wxscintilla_LexSorcus.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexSorcus.cxx + $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< + $(OBJS)\wxscintilla_LexSpice.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexSpice.cxx $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< +$(OBJS)\wxscintilla_LexTAL.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexTAL.cxx + $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< + +$(OBJS)\wxscintilla_LexTACL.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexTACL.cxx + $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< + $(OBJS)\wxscintilla_LexTCL.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexTCL.cxx $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< @@ -6009,6 +6053,9 @@ $(OBJS)\wxscintilla_LexYAML.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexYA $(OBJS)\wxscintilla_LineMarker.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LineMarker.cxx $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< +$(OBJS)\wxscintilla_PerLine.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\PerLine.cxx + $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< + $(OBJS)\wxscintilla_PositionCache.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\PositionCache.cxx $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< @@ -6021,6 +6068,9 @@ $(OBJS)\wxscintilla_RESearch.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\RESe $(OBJS)\wxscintilla_RunStyles.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\RunStyles.cxx $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< +$(OBJS)\wxscintilla_Selection.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\Selection.cxx + $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< + $(OBJS)\wxscintilla_ScintillaBase.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\ScintillaBase.cxx $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< @@ -6042,6 +6092,12 @@ $(OBJS)\wxscintilla_WindowAccessor.obj : .AUTODEPEND ..\..\src\stc\scintilla\sr $(OBJS)\wxscintilla_XPM.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\XPM.cxx $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< +$(OBJS)\wxscintilla_LexMarkdown.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexMarkdown.cxx + $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< + +$(OBJS)\wxscintilla_Array.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\Array.cpp + $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $< + $(OBJS)\monodll_dummy.obj : .AUTODEPEND ..\..\src\common\dummy.cpp $(CXX) -bt=nt -zq -fo=$^@ $(MONODLL_CXXFLAGS) $< diff --git a/build/msw/wx_vc7_wxscintilla.vcproj b/build/msw/wx_vc7_wxscintilla.vcproj index df4e33ceb7..0928dab780 100644 --- a/build/msw/wx_vc7_wxscintilla.vcproj +++ b/build/msw/wx_vc7_wxscintilla.vcproj @@ -461,6 +461,9 @@ Name="Source Files" Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> + + @@ -539,6 +542,9 @@ + + @@ -617,12 +623,24 @@ + + + + + + + + @@ -650,6 +668,12 @@ + + + + @@ -665,6 +689,9 @@ + + @@ -674,15 +701,24 @@ + + + + + + @@ -704,6 +740,9 @@ + + @@ -719,6 +758,9 @@ + + diff --git a/build/msw/wx_vc8_wxscintilla.vcproj b/build/msw/wx_vc8_wxscintilla.vcproj index e6e782866e..50e3b123a2 100644 --- a/build/msw/wx_vc8_wxscintilla.vcproj +++ b/build/msw/wx_vc8_wxscintilla.vcproj @@ -667,6 +667,10 @@ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > + + @@ -771,6 +775,10 @@ RelativePath="..\..\src\stc\scintilla\src\LexCLW.cxx" > + + @@ -875,6 +883,14 @@ RelativePath="..\..\src\stc\scintilla\src\LexMSSQL.cxx" > + + + + @@ -883,6 +899,14 @@ RelativePath="..\..\src\stc\scintilla\src\LexMetapost.cxx" > + + + + @@ -919,6 +943,14 @@ RelativePath="..\..\src\stc\scintilla\src\LexPerl.cxx" > + + + + @@ -939,6 +971,10 @@ RelativePath="..\..\src\stc\scintilla\src\LexRuby.cxx" > + + @@ -951,6 +987,10 @@ RelativePath="..\..\src\stc\scintilla\src\LexSmalltalk.cxx" > + + @@ -959,10 +999,18 @@ RelativePath="..\..\src\stc\scintilla\src\LexSpice.cxx" > + + + + @@ -991,6 +1039,10 @@ RelativePath="..\..\src\stc\scintilla\src\LineMarker.cxx" > + + @@ -1011,6 +1063,10 @@ RelativePath="..\..\src\stc\scintilla\src\ScintillaBase.cxx" > + + diff --git a/build/msw/wx_vc9_wxscintilla.vcproj b/build/msw/wx_vc9_wxscintilla.vcproj index bc1eec7ebc..7592e89468 100644 --- a/build/msw/wx_vc9_wxscintilla.vcproj +++ b/build/msw/wx_vc9_wxscintilla.vcproj @@ -663,6 +663,10 @@ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > + + @@ -767,6 +771,10 @@ RelativePath="..\..\src\stc\scintilla\src\LexCLW.cxx" > + + @@ -871,6 +879,14 @@ RelativePath="..\..\src\stc\scintilla\src\LexMSSQL.cxx" > + + + + @@ -879,6 +895,14 @@ RelativePath="..\..\src\stc\scintilla\src\LexMetapost.cxx" > + + + + @@ -915,6 +939,14 @@ RelativePath="..\..\src\stc\scintilla\src\LexPerl.cxx" > + + + + @@ -935,6 +967,10 @@ RelativePath="..\..\src\stc\scintilla\src\LexRuby.cxx" > + + @@ -947,6 +983,10 @@ RelativePath="..\..\src\stc\scintilla\src\LexSmalltalk.cxx" > + + @@ -955,10 +995,18 @@ RelativePath="..\..\src\stc\scintilla\src\LexSpice.cxx" > + + + + @@ -987,6 +1035,10 @@ RelativePath="..\..\src\stc\scintilla\src\LineMarker.cxx" > + + @@ -1007,6 +1059,10 @@ RelativePath="..\..\src\stc\scintilla\src\ScintillaBase.cxx" > + + diff --git a/build/msw/wx_wxscintilla.dsp b/build/msw/wx_wxscintilla.dsp index 40018e90bc..60825df223 100644 --- a/build/msw/wx_wxscintilla.dsp +++ b/build/msw/wx_wxscintilla.dsp @@ -235,6 +235,10 @@ LIB32=link.exe -lib # PROP Default_Filter "" # Begin Source File +SOURCE=..\..\src\stc\scintilla\src\Array.cpp +# End Source File +# Begin Source File + SOURCE=..\..\src\stc\scintilla\src\AutoComplete.cxx # End Source File # Begin Source File @@ -339,6 +343,10 @@ SOURCE=..\..\src\stc\scintilla\src\LexCLW.cxx # End Source File # Begin Source File +SOURCE=..\..\src\stc\scintilla\src\LexCOBOL.cxx +# End Source File +# Begin Source File + SOURCE=..\..\src\stc\scintilla\src\LexCPP.cxx # End Source File # Begin Source File @@ -443,6 +451,14 @@ SOURCE=..\..\src\stc\scintilla\src\LexMSSQL.cxx # End Source File # Begin Source File +SOURCE=..\..\src\stc\scintilla\src\LexMagik.cxx +# End Source File +# Begin Source File + +SOURCE=..\..\src\stc\scintilla\src\LexMarkdown.cxx +# End Source File +# Begin Source File + SOURCE=..\..\src\stc\scintilla\src\LexMatlab.cxx # End Source File # Begin Source File @@ -451,6 +467,14 @@ SOURCE=..\..\src\stc\scintilla\src\LexMetapost.cxx # End Source File # Begin Source File +SOURCE=..\..\src\stc\scintilla\src\LexMySQL.cxx +# End Source File +# Begin Source File + +SOURCE=..\..\src\stc\scintilla\src\LexNimrod.cxx +# End Source File +# Begin Source File + SOURCE=..\..\src\stc\scintilla\src\LexNsis.cxx # End Source File # Begin Source File @@ -487,6 +511,14 @@ SOURCE=..\..\src\stc\scintilla\src\LexPerl.cxx # End Source File # Begin Source File +SOURCE=..\..\src\stc\scintilla\src\LexPowerPro.cxx +# End Source File +# Begin Source File + +SOURCE=..\..\src\stc\scintilla\src\LexPowerShell.cxx +# End Source File +# Begin Source File + SOURCE=..\..\src\stc\scintilla\src\LexProgress.cxx # End Source File # Begin Source File @@ -507,6 +539,10 @@ SOURCE=..\..\src\stc\scintilla\src\LexRuby.cxx # End Source File # Begin Source File +SOURCE=..\..\src\stc\scintilla\src\LexSML.cxx +# End Source File +# Begin Source File + SOURCE=..\..\src\stc\scintilla\src\LexSQL.cxx # End Source File # Begin Source File @@ -519,6 +555,10 @@ SOURCE=..\..\src\stc\scintilla\src\LexSmalltalk.cxx # End Source File # Begin Source File +SOURCE=..\..\src\stc\scintilla\src\LexSorcus.cxx +# End Source File +# Begin Source File + SOURCE=..\..\src\stc\scintilla\src\LexSpecman.cxx # End Source File # Begin Source File @@ -527,10 +567,18 @@ SOURCE=..\..\src\stc\scintilla\src\LexSpice.cxx # End Source File # Begin Source File +SOURCE=..\..\src\stc\scintilla\src\LexTACL.cxx +# End Source File +# Begin Source File + SOURCE=..\..\src\stc\scintilla\src\LexTADS3.cxx # End Source File # Begin Source File +SOURCE=..\..\src\stc\scintilla\src\LexTAL.cxx +# End Source File +# Begin Source File + SOURCE=..\..\src\stc\scintilla\src\LexTCL.cxx # End Source File # Begin Source File @@ -559,6 +607,10 @@ SOURCE=..\..\src\stc\scintilla\src\LineMarker.cxx # End Source File # Begin Source File +SOURCE=..\..\src\stc\scintilla\src\PerLine.cxx +# End Source File +# Begin Source File + SOURCE=..\..\src\stc\scintilla\src\PositionCache.cxx # End Source File # Begin Source File @@ -579,6 +631,10 @@ SOURCE=..\..\src\stc\scintilla\src\ScintillaBase.cxx # End Source File # Begin Source File +SOURCE=..\..\src\stc\scintilla\src\Selection.cxx +# End Source File +# Begin Source File + SOURCE=..\..\src\stc\scintilla\src\Style.cxx # End Source File # Begin Source File diff --git a/include/wx/stc/stc.h b/include/wx/stc/stc.h index ad0f3c16c1..be225a574c 100644 --- a/include/wx/stc/stc.h +++ b/include/wx/stc/stc.h @@ -111,6 +111,9 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #define wxSTC_MARK_ARROWS 24 #define wxSTC_MARK_PIXMAP 25 #define wxSTC_MARK_FULLRECT 26 +#define wxSTC_MARK_LEFTRECT 27 +#define wxSTC_MARK_AVAILABLE 28 +#define wxSTC_MARK_UNDERLINE 29 #define wxSTC_MARK_CHARACTER 10000 // Markers used for outlining column. @@ -126,6 +129,8 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #define wxSTC_MARGIN_NUMBER 1 #define wxSTC_MARGIN_BACK 2 #define wxSTC_MARGIN_FORE 3 +#define wxSTC_MARGIN_TEXT 4 +#define wxSTC_MARGIN_RTEXT 5 // 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. @@ -208,17 +213,12 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #define wxSTC_FOLDLEVELBASE 0x400 #define wxSTC_FOLDLEVELWHITEFLAG 0x1000 #define wxSTC_FOLDLEVELHEADERFLAG 0x2000 -#define wxSTC_FOLDLEVELBOXHEADERFLAG 0x4000 -#define wxSTC_FOLDLEVELBOXFOOTERFLAG 0x8000 -#define wxSTC_FOLDLEVELCONTRACTED 0x10000 -#define wxSTC_FOLDLEVELUNINDENT 0x20000 #define wxSTC_FOLDLEVELNUMBERMASK 0x0FFF #define wxSTC_FOLDFLAG_LINEBEFORE_EXPANDED 0x0002 #define wxSTC_FOLDFLAG_LINEBEFORE_CONTRACTED 0x0004 #define wxSTC_FOLDFLAG_LINEAFTER_EXPANDED 0x0008 #define wxSTC_FOLDFLAG_LINEAFTER_CONTRACTED 0x0010 #define wxSTC_FOLDFLAG_LEVELNUMBERS 0x0040 -#define wxSTC_FOLDFLAG_BOX 0x0001 #define wxSTC_TIME_FOREVER 10000000 #define wxSTC_WRAP_NONE 0 #define wxSTC_WRAP_WORD 1 @@ -229,13 +229,26 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #define wxSTC_WRAPVISUALFLAGLOC_DEFAULT 0x0000 #define wxSTC_WRAPVISUALFLAGLOC_END_BY_TEXT 0x0001 #define wxSTC_WRAPVISUALFLAGLOC_START_BY_TEXT 0x0002 +#define wxSTC_WRAPINDENT_FIXED 0 +#define wxSTC_WRAPINDENT_SAME 1 +#define wxSTC_WRAPINDENT_INDENT 2 #define wxSTC_CACHE_NONE 0 #define wxSTC_CACHE_CARET 1 #define wxSTC_CACHE_PAGE 2 #define wxSTC_CACHE_DOCUMENT 3 + +// Control font anti-aliasing. +#define wxSTC_EFF_QUALITY_MASK 0xF +#define wxSTC_EFF_QUALITY_DEFAULT 0 +#define wxSTC_EFF_QUALITY_NON_ANTIALIASED 1 +#define wxSTC_EFF_QUALITY_ANTIALIASED 2 +#define wxSTC_EFF_QUALITY_LCD_OPTIMIZED 3 #define wxSTC_EDGE_NONE 0 #define wxSTC_EDGE_LINE 1 #define wxSTC_EDGE_BACKGROUND 2 +#define wxSTC_STATUS_OK 0 +#define wxSTC_STATUS_FAILURE 1 +#define wxSTC_STATUS_BADALLOC 2 #define wxSTC_CURSORNORMAL -1 #define wxSTC_CURSORWAIT 4 @@ -268,19 +281,23 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; // This way, we favour the displaying of useful information: the begining of lines, // where most code reside, and the lines after the caret, eg. the body of a function. #define wxSTC_CARET_EVEN 0x08 - -// Selection Modes #define wxSTC_SEL_STREAM 0 #define wxSTC_SEL_RECTANGLE 1 #define wxSTC_SEL_LINES 2 +#define wxSTC_SEL_THIN 3 #define wxSTC_ALPHA_TRANSPARENT 0 #define wxSTC_ALPHA_OPAQUE 255 #define wxSTC_ALPHA_NOALPHA 256 - -// Caret Styles #define wxSTC_CARETSTYLE_INVISIBLE 0 #define wxSTC_CARETSTYLE_LINE 1 #define wxSTC_CARETSTYLE_BLOCK 2 +#define wxSTC_ANNOTATION_HIDDEN 0 +#define wxSTC_ANNOTATION_STANDARD 1 +#define wxSTC_ANNOTATION_BOXED 2 +#define wxSTC_UNDO_MAY_COALESCE 1 +#define wxSTC_SCVS_NONE 0 +#define wxSTC_SCVS_RECTANGULARSELECTION 1 +#define wxSTC_SCVS_USERACCESSIBLE 2 // Maximum value of keywordSet parameter of SetKeyWords. #define wxSTC_KEYWORDSET_MAX 8 @@ -305,7 +322,10 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #define wxSTC_STARTACTION 0x2000 #define wxSTC_MOD_CHANGEINDICATOR 0x4000 #define wxSTC_MOD_CHANGELINESTATE 0x8000 -#define wxSTC_MODEVENTMASKALL 0xFFFF +#define wxSTC_MOD_CHANGEMARGIN 0x10000 +#define wxSTC_MOD_CHANGEANNOTATION 0x20000 +#define wxSTC_MOD_CONTAINER 0x40000 +#define wxSTC_MODEVENTMASKALL 0x7FFFF // Symbolic key codes and modifier flags. // ASCII and other printable characters below 256. @@ -334,6 +354,7 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #define wxSTC_SCMOD_SHIFT 1 #define wxSTC_SCMOD_CTRL 2 #define wxSTC_SCMOD_ALT 4 +#define wxSTC_SCMOD_SUPER 8 // For SciLexer.h #define wxSTC_LEX_CONTAINER 0 @@ -421,6 +442,18 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #define wxSTC_LEX_ABAQUS 84 #define wxSTC_LEX_ASYMPTOTE 85 #define wxSTC_LEX_R 86 +#define wxSTC_LEX_MAGIK 87 +#define wxSTC_LEX_POWERSHELL 88 +#define wxSTC_LEX_MYSQL 89 +#define wxSTC_LEX_PO 90 +#define wxSTC_LEX_TAL 91 +#define wxSTC_LEX_COBOL 92 +#define wxSTC_LEX_TACL 93 +#define wxSTC_LEX_SORCUS 94 +#define wxSTC_LEX_POWERPRO 95 +#define wxSTC_LEX_NIMROD 96 +#define wxSTC_LEX_SML 97 +#define wxSTC_LEX_MARKDOWN 98 // When a lexer specifies its language as SCLEX_AUTOMATIC it receives a // value assigned in sequence from SCLEX_AUTOMATIC+1. @@ -485,6 +518,11 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #define wxSTC_D_COMMENTLINEDOC 15 #define wxSTC_D_COMMENTDOCKEYWORD 16 #define wxSTC_D_COMMENTDOCKEYWORDERROR 17 +#define wxSTC_D_STRINGB 18 +#define wxSTC_D_STRINGR 19 +#define wxSTC_D_WORD5 20 +#define wxSTC_D_WORD6 21 +#define wxSTC_D_WORD7 22 // Lexical states for SCLEX_TCL #define wxSTC_TCL_DEFAULT 0 @@ -829,6 +867,7 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #define wxSTC_DIFF_POSITION 4 #define wxSTC_DIFF_DELETED 5 #define wxSTC_DIFF_ADDED 6 +#define wxSTC_DIFF_CHANGED 7 // Lexical states for SCLEX_CONF (Apache Configuration Files Lexer) #define wxSTC_CONF_DEFAULT 0 @@ -1021,6 +1060,11 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #define wxSTC_CSS_SINGLESTRING 14 #define wxSTC_CSS_IDENTIFIER2 15 #define wxSTC_CSS_ATTRIBUTE 16 +#define wxSTC_CSS_IDENTIFIER3 17 +#define wxSTC_CSS_PSEUDOELEMENT 18 +#define wxSTC_CSS_EXTENDED_IDENTIFIER 19 +#define wxSTC_CSS_EXTENDED_PSEUDOCLASS 20 +#define wxSTC_CSS_EXTENDED_PSEUDOELEMENT 21 // Lexical states for SCLEX_POV #define wxSTC_POV_DEFAULT 0 @@ -1195,8 +1239,19 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #define wxSTC_ERLANG_CHARACTER 9 #define wxSTC_ERLANG_MACRO 10 #define wxSTC_ERLANG_RECORD 11 -#define wxSTC_ERLANG_SEPARATOR 12 +#define wxSTC_ERLANG_PREPROC 12 #define wxSTC_ERLANG_NODE_NAME 13 +#define wxSTC_ERLANG_COMMENT_FUNCTION 14 +#define wxSTC_ERLANG_COMMENT_MODULE 15 +#define wxSTC_ERLANG_COMMENT_DOC 16 +#define wxSTC_ERLANG_COMMENT_DOC_MACRO 17 +#define wxSTC_ERLANG_ATOM_QUOTED 18 +#define wxSTC_ERLANG_MACRO_QUOTED 19 +#define wxSTC_ERLANG_RECORD_QUOTED 20 +#define wxSTC_ERLANG_NODE_NAME_QUOTED 21 +#define wxSTC_ERLANG_BIFS 22 +#define wxSTC_ERLANG_MODULES 23 +#define wxSTC_ERLANG_MODULES_ATT 24 #define wxSTC_ERLANG_UNKNOWN 31 // Lexical states for SCLEX_OCTAVE are identical to MatLab @@ -1368,6 +1423,7 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #define wxSTC_CAML_OPERATOR 7 #define wxSTC_CAML_NUMBER 8 #define wxSTC_CAML_CHAR 9 +#define wxSTC_CAML_WHITE 10 #define wxSTC_CAML_STRING 11 #define wxSTC_CAML_COMMENT 12 #define wxSTC_CAML_COMMENT1 13 @@ -1541,7 +1597,7 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #define wxSTC_INNO_PARAMETER 3 #define wxSTC_INNO_SECTION 4 #define wxSTC_INNO_PREPROC 5 -#define wxSTC_INNO_PREPROC_INLINE 6 +#define wxSTC_INNO_INLINE_EXPANSION 6 #define wxSTC_INNO_COMMENT_PASCAL 7 #define wxSTC_INNO_KEYWORD_PASCAL 8 #define wxSTC_INNO_KEYWORD_USER 9 @@ -1690,6 +1746,162 @@ class WXDLLIMPEXP_FWD_CORE wxScrollBar; #define wxSTC_R_INFIX 10 #define wxSTC_R_INFIXEOL 11 +// Lexical state for SCLEX_MAGIKSF +#define wxSTC_MAGIK_DEFAULT 0 +#define wxSTC_MAGIK_COMMENT 1 +#define wxSTC_MAGIK_HYPER_COMMENT 16 +#define wxSTC_MAGIK_STRING 2 +#define wxSTC_MAGIK_CHARACTER 3 +#define wxSTC_MAGIK_NUMBER 4 +#define wxSTC_MAGIK_IDENTIFIER 5 +#define wxSTC_MAGIK_OPERATOR 6 +#define wxSTC_MAGIK_FLOW 7 +#define wxSTC_MAGIK_CONTAINER 8 +#define wxSTC_MAGIK_BRACKET_BLOCK 9 +#define wxSTC_MAGIK_BRACE_BLOCK 10 +#define wxSTC_MAGIK_SQBRACKET_BLOCK 11 +#define wxSTC_MAGIK_UNKNOWN_KEYWORD 12 +#define wxSTC_MAGIK_KEYWORD 13 +#define wxSTC_MAGIK_PRAGMA 14 +#define wxSTC_MAGIK_SYMBOL 15 + +// Lexical state for SCLEX_POWERSHELL +#define wxSTC_POWERSHELL_DEFAULT 0 +#define wxSTC_POWERSHELL_COMMENT 1 +#define wxSTC_POWERSHELL_STRING 2 +#define wxSTC_POWERSHELL_CHARACTER 3 +#define wxSTC_POWERSHELL_NUMBER 4 +#define wxSTC_POWERSHELL_VARIABLE 5 +#define wxSTC_POWERSHELL_OPERATOR 6 +#define wxSTC_POWERSHELL_IDENTIFIER 7 +#define wxSTC_POWERSHELL_KEYWORD 8 +#define wxSTC_POWERSHELL_CMDLET 9 +#define wxSTC_POWERSHELL_ALIAS 10 + +// Lexical state for SCLEX_MYSQL +#define wxSTC_MYSQL_DEFAULT 0 +#define wxSTC_MYSQL_COMMENT 1 +#define wxSTC_MYSQL_COMMENTLINE 2 +#define wxSTC_MYSQL_VARIABLE 3 +#define wxSTC_MYSQL_SYSTEMVARIABLE 4 +#define wxSTC_MYSQL_KNOWNSYSTEMVARIABLE 5 +#define wxSTC_MYSQL_NUMBER 6 +#define wxSTC_MYSQL_MAJORKEYWORD 7 +#define wxSTC_MYSQL_KEYWORD 8 +#define wxSTC_MYSQL_DATABASEOBJECT 9 +#define wxSTC_MYSQL_PROCEDUREKEYWORD 10 +#define wxSTC_MYSQL_STRING 11 +#define wxSTC_MYSQL_SQSTRING 12 +#define wxSTC_MYSQL_DQSTRING 13 +#define wxSTC_MYSQL_OPERATOR 14 +#define wxSTC_MYSQL_FUNCTION 15 +#define wxSTC_MYSQL_IDENTIFIER 16 +#define wxSTC_MYSQL_QUOTEDIDENTIFIER 17 +#define wxSTC_MYSQL_USER1 18 +#define wxSTC_MYSQL_USER2 19 +#define wxSTC_MYSQL_USER3 20 +#define wxSTC_MYSQL_HIDDENCOMMAND 21 + +// Lexical state for SCLEX_PO +#define wxSTC_PO_DEFAULT 0 +#define wxSTC_PO_COMMENT 1 +#define wxSTC_PO_MSGID 2 +#define wxSTC_PO_MSGID_TEXT 3 +#define wxSTC_PO_MSGSTR 4 +#define wxSTC_PO_MSGSTR_TEXT 5 +#define wxSTC_PO_MSGCTXT 6 +#define wxSTC_PO_MSGCTXT_TEXT 7 +#define wxSTC_PO_FUZZY 8 + +// Lexical states for SCLEX_PASCAL +#define wxSTC_PAS_DEFAULT 0 +#define wxSTC_PAS_IDENTIFIER 1 +#define wxSTC_PAS_COMMENT 2 +#define wxSTC_PAS_COMMENT2 3 +#define wxSTC_PAS_COMMENTLINE 4 +#define wxSTC_PAS_PREPROCESSOR 5 +#define wxSTC_PAS_PREPROCESSOR2 6 +#define wxSTC_PAS_NUMBER 7 +#define wxSTC_PAS_HEXNUMBER 8 +#define wxSTC_PAS_WORD 9 +#define wxSTC_PAS_STRING 10 +#define wxSTC_PAS_STRINGEOL 11 +#define wxSTC_PAS_CHARACTER 12 +#define wxSTC_PAS_OPERATOR 13 +#define wxSTC_PAS_ASM 14 + +// Lexical state for SCLEX_SORCUS +#define wxSTC_SORCUS_DEFAULT 0 +#define wxSTC_SORCUS_COMMAND 1 +#define wxSTC_SORCUS_PARAMETER 2 +#define wxSTC_SORCUS_COMMENTLINE 3 +#define wxSTC_SORCUS_STRING 4 +#define wxSTC_SORCUS_STRINGEOL 5 +#define wxSTC_SORCUS_IDENTIFIER 6 +#define wxSTC_SORCUS_OPERATOR 7 +#define wxSTC_SORCUS_NUMBER 8 +#define wxSTC_SORCUS_CONSTANT 9 + +// Lexical state for SCLEX_POWERPRO +#define wxSTC_POWERPRO_DEFAULT 0 +#define wxSTC_POWERPRO_COMMENTBLOCK 1 +#define wxSTC_POWERPRO_COMMENTLINE 2 +#define wxSTC_POWERPRO_NUMBER 3 +#define wxSTC_POWERPRO_WORD 4 +#define wxSTC_POWERPRO_WORD2 5 +#define wxSTC_POWERPRO_WORD3 6 +#define wxSTC_POWERPRO_WORD4 7 +#define wxSTC_POWERPRO_DOUBLEQUOTEDSTRING 8 +#define wxSTC_POWERPRO_SINGLEQUOTEDSTRING 9 +#define wxSTC_POWERPRO_LINECONTINUE 10 +#define wxSTC_POWERPRO_OPERATOR 11 +#define wxSTC_POWERPRO_IDENTIFIER 12 +#define wxSTC_POWERPRO_STRINGEOL 13 +#define wxSTC_POWERPRO_VERBATIM 14 +#define wxSTC_POWERPRO_ALTQUOTE 15 +#define wxSTC_POWERPRO_FUNCTION 16 + +// Lexical states for SCLEX_SML +#define wxSTC_SML_DEFAULT 0 +#define wxSTC_SML_IDENTIFIER 1 +#define wxSTC_SML_TAGNAME 2 +#define wxSTC_SML_KEYWORD 3 +#define wxSTC_SML_KEYWORD2 4 +#define wxSTC_SML_KEYWORD3 5 +#define wxSTC_SML_LINENUM 6 +#define wxSTC_SML_OPERATOR 7 +#define wxSTC_SML_NUMBER 8 +#define wxSTC_SML_CHAR 9 +#define wxSTC_SML_STRING 11 +#define wxSTC_SML_COMMENT 12 +#define wxSTC_SML_COMMENT1 13 +#define wxSTC_SML_COMMENT2 14 +#define wxSTC_SML_COMMENT3 15 + +// Lexical state for SCLEX_MARKDOWN +#define wxSTC_MARKDOWN_DEFAULT 0 +#define wxSTC_MARKDOWN_LINE_BEGIN 1 +#define wxSTC_MARKDOWN_STRONG1 2 +#define wxSTC_MARKDOWN_STRONG2 3 +#define wxSTC_MARKDOWN_EM1 4 +#define wxSTC_MARKDOWN_EM2 5 +#define wxSTC_MARKDOWN_HEADER1 6 +#define wxSTC_MARKDOWN_HEADER2 7 +#define wxSTC_MARKDOWN_HEADER3 8 +#define wxSTC_MARKDOWN_HEADER4 9 +#define wxSTC_MARKDOWN_HEADER5 10 +#define wxSTC_MARKDOWN_HEADER6 11 +#define wxSTC_MARKDOWN_PRECHAR 12 +#define wxSTC_MARKDOWN_ULIST_ITEM 13 +#define wxSTC_MARKDOWN_OLIST_ITEM 14 +#define wxSTC_MARKDOWN_BLOCKQUOTE 15 +#define wxSTC_MARKDOWN_STRIKEOUT 16 +#define wxSTC_MARKDOWN_HRULE 17 +#define wxSTC_MARKDOWN_LINK 18 +#define wxSTC_MARKDOWN_CODE 19 +#define wxSTC_MARKDOWN_CODE2 20 +#define wxSTC_MARKDOWN_CODEBK 21 + //}}} //---------------------------------------------------------------------- @@ -2039,7 +2251,7 @@ public: // Set all style bytes to 0, remove all folding information. void ClearDocumentStyle(); - // Returns the number of characters in the document. + // Returns the number of bytes in the document. int GetLength() const; // Returns the character byte at the position. @@ -2290,10 +2502,10 @@ public: // Set a style to be a hotspot or not. void StyleSetHotSpot(int style, bool hotspot); - // Set the foreground colour of the selection and whether to use this setting. + // Set the foreground colour of the main and additional selections and whether to use this setting. void SetSelForeground(bool useSetting, const wxColour& fore); - // Set the background colour of the selection and whether to use this setting. + // Set the background colour of the main and additional selections and whether to use this setting. void SetSelBackground(bool useSetting, const wxColour& back); // Get the alpha of the selection. @@ -2333,7 +2545,7 @@ public: void SetCaretPeriod(int periodMilliseconds); // Set the set of characters making up words for when moving or selecting by word. - // First sets deaults like SetCharsDefault. + // First sets defaults like SetCharsDefault. void SetWordChars(const wxString& characters); // Start a sequence of actions that is undone and redone as a unit. @@ -2367,6 +2579,12 @@ public: // Set the background colour of all whitespace and whether to use this setting. void SetWhitespaceBackground(bool useSetting, const wxColour& back); + // Set the size of the dots used to mark space characters. + void SetWhitespaceSize(int size); + + // Get the size of the dots used to mark space characters. + int GetWhitespaceSize() const; + // Divide each styling byte into lexical class bits (default: 5) and indicator // bits (default: 3). If a lexer requires more than 32 lexical states, then this // is used to expand the possible states. @@ -2852,6 +3070,12 @@ public: // Retrive the start indent for wrapped lines. int GetWrapStartIndent() const; + // Sets how wrapped sublines are placed. Default is fixed. + void SetWrapIndentMode(int mode); + + // Retrieve how wrapped sublines are placed. Default is fixed. + int GetWrapIndentMode() const; + // Sets the degree of caching of layout information. void SetLayoutCache(int mode); @@ -2903,6 +3127,9 @@ public: // and then the foreground. This avoids chopping off characters that overlap the next run. void SetTwoPhaseDraw(bool twoPhase); + // Scroll so that a display line is at the top of the display. + void SetFirstVisibleLine(int lineDisplay); + // Make the target range start and end be the same as the selection range start and end. void TargetFromSelection(); @@ -3093,7 +3320,7 @@ public: // Move the caret inside current view if it's not there already. void MoveCaretInsideView(); - // How many characters are on a line, not including end of line characters? + // How many characters are on a line, including end of line characters? int LineLength(int line) const; // Highlight the characters at two positions. @@ -3301,7 +3528,7 @@ public: // Copy argument text to the clipboard. void CopyText(int length, const wxString& text); - // Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or + // Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE/SC_SEL_THIN) or // by lines (SC_SEL_LINES). void SetSelectionMode(int mode); @@ -3450,6 +3677,217 @@ public: // How many entries are allocated to the position cache? int GetPositionCacheSize() const; + // Copy the selection, if selection empty copy the line with the caret + void CopyAllowLine(); + + // Compact the document buffer and return a read-only pointer to the + // characters in the document. + const char* GetCharacterPointer(); + + // Always interpret keyboard input as Unicode + void SetKeysUnicode(bool keysUnicode); + + // Are keys always interpreted as Unicode? + bool GetKeysUnicode() const; + + // Set the alpha fill colour of the given indicator. + void IndicatorSetAlpha(int indicator, int alpha); + + // Get the alpha fill colour of the given indicator. + int IndicatorGetAlpha(int indicator) const; + + // Set extra ascent for each line + void SetExtraAscent(int extraAscent); + + // Get extra ascent for each line + int GetExtraAscent() const; + + // Set extra descent for each line + void SetExtraDescent(int extraDescent); + + // Get extra descent for each line + int GetExtraDescent() const; + + // Which symbol was defined for markerNumber with MarkerDefine + int GetMarkerSymbolDefined(int markerNumber); + + // Set the text in the text margin for a line + void MarginSetText(int line, const wxString& text); + + // Get the text in the text margin for a line + wxString MarginGetText(int line) const; + + // Set the style number for the text margin for a line + void MarginSetStyle(int line, int style); + + // Get the style number for the text margin for a line + int MarginGetStyle(int line) const; + + // Set the style in the text margin for a line + void MarginSetStyles(int line, const wxString& styles); + + // Get the styles in the text margin for a line + wxString MarginGetStyles(int line) const; + + // Clear the margin text on all lines + void MarginTextClearAll(); + + // Get the start of the range of style numbers used for margin text + void MarginSetStyleOffset(int style); + + // Get the start of the range of style numbers used for margin text + int MarginGetStyleOffset() const; + + // Set the annotation text for a line + void AnnotationSetText(int line, const wxString& text); + + // Get the annotation text for a line + wxString AnnotationGetText(int line) const; + + // Set the style number for the annotations for a line + void AnnotationSetStyle(int line, int style); + + // Get the style number for the annotations for a line + int AnnotationGetStyle(int line) const; + + // Set the annotation styles for a line + void AnnotationSetStyles(int line, const wxString& styles); + + // Get the annotation styles for a line + wxString AnnotationGetStyles(int line) const; + + // Get the number of annotation lines for a line + int AnnotationGetLines(int line) const; + + // Clear the annotations from all lines + void AnnotationClearAll(); + + // Set the visibility for the annotations for a view + void AnnotationSetVisible(int visible); + + // Get the visibility for the annotations for a view + int AnnotationGetVisible() const; + + // Get the start of the range of style numbers used for annotations + void AnnotationSetStyleOffset(int style); + + // Get the start of the range of style numbers used for annotations + int AnnotationGetStyleOffset() const; + + // Add a container action to the undo stack + void AddUndoAction(int token, int flags); + + // Find the position of a character from a point within the window. + int CharPositionFromPoint(int x, int y); + + // Find the position of a character from a point within the window. + // Return INVALID_POSITION if not close to text. + int CharPositionFromPointClose(int x, int y); + + // Set whether multiple selections can be made + void SetMultipleSelection(bool multipleSelection); + + // Whether multiple selections can be made + bool GetMultipleSelection() const; + + // Set whether typing can be performed into multiple selections + void SetAdditionalSelectionTyping(bool additionalSelectionTyping); + + // Whether typing can be performed into multiple selections + bool GetAdditionalSelectionTyping() const; + + // Set whether additional carets will blink + void SetAdditionalCaretsBlink(bool additionalCaretsBlink); + + // Whether additional carets will blink + bool GetAdditionalCaretsBlink() const; + + // Set whether additional carets are visible + void SetAdditionalCaretsVisible(bool additionalCaretsBlink); + + // Whether additional carets are visible + bool GetAdditionalCaretsVisible() const; + + // How many selections are there? + int GetSelections() const; + + // Clear selections to a single empty stream selection + void ClearSelections(); + + // Add a selection + int AddSelection(int caret, int anchor); + + // Set the main selection + void SetMainSelection(int selection); + + // Which selection is the main selection + int GetMainSelection() const; + void SetSelectionNCaret(int selection, int pos); + int GetSelectionNCaret(int selection) const; + void SetSelectionNAnchor(int selection, int posAnchor); + int GetSelectionNAnchor(int selection) const; + void SetSelectionNCaretVirtualSpace(int selection, int space); + int GetSelectionNCaretVirtualSpace(int selection) const; + void SetSelectionNAnchorVirtualSpace(int selection, int space); + int GetSelectionNAnchorVirtualSpace(int selection) const; + + // Sets the position that starts the selection - this becomes the anchor. + void SetSelectionNStart(int selection, int pos); + + // Returns the position at the start of the selection. + int GetSelectionNStart(int selection) const; + + // Sets the position that ends the selection - this becomes the currentPosition. + void SetSelectionNEnd(int selection, int pos); + + // Returns the position at the end of the selection. + int GetSelectionNEnd(int selection) const; + void SetRectangularSelectionCaret(int pos); + int GetRectangularSelectionCaret() const; + void SetRectangularSelectionAnchor(int posAnchor); + int GetRectangularSelectionAnchor() const; + void SetRectangularSelectionCaretVirtualSpace(int space); + int GetRectangularSelectionCaretVirtualSpace() const; + void SetRectangularSelectionAnchorVirtualSpace(int space); + int GetRectangularSelectionAnchorVirtualSpace() const; + void SetVirtualSpaceOptions(int virtualSpaceOptions); + int GetVirtualSpaceOptions() const; + + // On GTK+, allow selecting the modifier key to use for mouse-based + // rectangular selection. Often the window manager requires Alt+Mouse Drag + // for moving windows. + // Valid values are SCMOD_CTRL(default), SCMOD_ALT, or SCMOD_SUPER. + void SetRectangularSelectionModifier(int modifier); + + // Get the modifier key used for rectangular selection. + int GetRectangularSelectionModifier() const; + + // Set the foreground colour of additional selections. + // Must have previously called SetSelFore with non-zero first argument for this to have an effect. + void SetAdditionalSelForeground(const wxColour& fore); + + // Set the background colour of additional selections. + // Must have previously called SetSelBack with non-zero first argument for this to have an effect. + void SetAdditionalSelBackground(const wxColour& back); + + // Set the alpha of the selection. + void SetAdditionalSelAlpha(int alpha); + + // Get the alpha of the selection. + int GetAdditionalSelAlpha() const; + + // Set the foreground colour of additional carets. + void SetAdditionalCaretForeground(const wxColour& fore); + + // Get the foreground colour of additional carets. + wxColour GetAdditionalCaretForeground() const; + + // Set the main selection to the next selection. + void RotateSelection(); + + // Swap that caret and anchor of the main selection. + void SwapMainAnchorCaret(); + // Start notifying the container of all key presses and commands. void StartRecord(); @@ -3988,6 +4426,8 @@ wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_CALLTIP_CLICK, wxStyledText wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_AUTOCOMP_SELECTION, wxStyledTextEvent ); wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_INDICATOR_CLICK, wxStyledTextEvent ); wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_INDICATOR_RELEASE, wxStyledTextEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_AUTOCOMP_CANCELLED, wxStyledTextEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_AUTOCOMP_CHAR_DELETED, wxStyledTextEvent ); #else enum { wxEVT_STC_CHANGE, @@ -4017,7 +4457,9 @@ wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_INDICATOR_RELEASE, wxStyled wxEVT_STC_CALLTIP_CLICK, wxEVT_STC_AUTOCOMP_SELECTION, wxEVT_STC_INDICATOR_CLICK, - wxEVT_STC_INDICATOR_RELEASE + wxEVT_STC_INDICATOR_RELEASE, + wxEVT_STC_AUTOCOMP_CANCELLED, + wxEVT_STC_AUTOCOMP_CHAR_DELETED }; #endif @@ -4057,6 +4499,8 @@ typedef void (wxEvtHandler::*wxStyledTextEventFunction)(wxStyledTextEvent&); #define EVT_STC_AUTOCOMP_SELECTION(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_AUTOCOMP_SELECTION, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), #define EVT_STC_INDICATOR_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_INDICATOR_CLICK, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), #define EVT_STC_INDICATOR_RELEASE(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_INDICATOR_RELEASE, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), +#define EVT_STC_AUTOCOMP_CANCELLED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_AUTOCOMP_CANCELLED, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), +#define EVT_STC_AUTOCOMP_CHAR_DELETED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_AUTOCOMP_CHAR_DELETED, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), #endif diff --git a/interface/wx/stc/stc.h b/interface/wx/stc/stc.h index ff4494dcf9..e1b0d08617 100644 --- a/interface/wx/stc/stc.h +++ b/interface/wx/stc/stc.h @@ -316,6 +316,14 @@ public: TOWRITE @event{EVT_STC_AUTOCOMP_SELECTION(id, fn)} TOWRITE + @event{EVT_STC_INDICATOR_CLICK(id, fn)} + TOWRITE + @event{EVT_STC_INDICATOR_RELEASE(id, fn)} + TOWRITE + @event{EVT_STC_AUTOCOMP_CANCELLED(id, fn)} + TOWRITE + @event{EVT_STC_AUTOCOMP_CHAR_DELETED(id, fn)} + TOWRITE @endEventTable @library{wxbase} @@ -1040,7 +1048,7 @@ public: int GetLayoutCache() const; /** - Returns the number of characters in the document. + Returns the number of bytes in the document. */ int GetLength() const; @@ -1568,7 +1576,7 @@ public: int LineFromPosition(int pos) const; /** - How many characters are on a line, not including end of line characters? + How many characters are on a line, including end of line characters? */ int LineLength(int line) const; @@ -2234,12 +2242,12 @@ public: void SetSelAlpha(int alpha); /** - Set the background colour of the selection and whether to use this setting. + Set the background colour of the main and additional selections and whether to use this setting. */ void SetSelBackground(bool useSetting, const wxColour& back); /** - Set the foreground colour of the selection and whether to use this setting. + Set the foreground colour of the main and additional selections and whether to use this setting. */ void SetSelForeground(bool useSetting, const wxColour& fore); @@ -2254,9 +2262,8 @@ public: void SetSelectionEnd(int pos); /** - Set the selection mode to stream (SC_SEL_STREAM) or rectangular - (SC_SEL_RECTANGLE) or - by lines (SC_SEL_LINES). + Set the selection mode to stream (wxSTC_SEL_STREAM) or rectangular + (wxSTC_SEL_RECTANGLE/wxSTC_SEL_THIN) or by lines (wxSTC_SEL_LINES). */ void SetSelectionMode(int mode); @@ -2398,9 +2405,20 @@ public: void SetWhitespaceForeground(bool useSetting, const wxColour& fore); + /** + Set the size of the dots used to mark space characters. + */ + void SetWhitespaceSize(int size); + + /** + Get the size of the dots used to mark space characters. + */ + int GetWhitespaceSize() const; + + /** Set the set of characters making up words for when moving or selecting by word. - First sets deaults like SetCharsDefault. + First sets defaults like SetCharsDefault. */ void SetWordChars(const wxString& characters); @@ -2780,5 +2798,372 @@ public: Make the displayed text smaller by decreasing the sizes by 1 point. */ void ZoomOut(); + + + + + /** + Set the size of the dots used to mark space characters. + */ + void SetWhitespaceSize(int size); + + /** + Get the size of the dots used to mark space characters. + */ + int GetWhitespaceSize() const; + + /** + Sets how wrapped sublines are placed. Default is fixed. + */ + void SetWrapIndentMode(int mode); + + /** + Retrieve how wrapped sublines are placed. Default is fixed. + */ + int GetWrapIndentMode() const; + + /** + Scroll so that a display line is at the top of the display. + */ + void SetFirstVisibleLine(int lineDisplay); + + + + /** + Copy the selection, if selection empty copy the line with the caret + */ + void CopyAllowLine(); + + /** + Compact the document buffer and return a read-only pointer to the + characters in the document. + */ + const char* GetCharacterPointer(); + + /** + Always interpret keyboard input as Unicode + */ + void SetKeysUnicode(bool keysUnicode); + + /** + Are keys always interpreted as Unicode? + */ + bool GetKeysUnicode() const; + + /** + Set the alpha fill colour of the given indicator. + */ + void IndicatorSetAlpha(int indicator, int alpha); + + /** + Get the alpha fill colour of the given indicator. + */ + int IndicatorGetAlpha(int indicator) const; + + /** + Set extra ascent for each line + */ + void SetExtraAscent(int extraAscent); + + /** + Get extra ascent for each line + */ + int GetExtraAscent() const; + + /** + Set extra descent for each line + */ + void SetExtraDescent(int extraDescent); + + /** + Get extra descent for each line + */ + int GetExtraDescent() const; + + /** + Which symbol was defined for markerNumber with MarkerDefine + */ + int GetMarkerSymbolDefined(int markerNumber); + + /** + Set the text in the text margin for a line + */ + void MarginSetText(int line, const wxString& text); + + /** + Get the text in the text margin for a line + */ + wxString MarginGetText(int line) const; + + /** + Set the style number for the text margin for a line + */ + void MarginSetStyle(int line, int style); + + /** + Get the style number for the text margin for a line + */ + int MarginGetStyle(int line) const; + + /** + Set the style in the text margin for a line + */ + void MarginSetStyles(int line, const wxString& styles); + + /** + Get the styles in the text margin for a line + */ + wxString MarginGetStyles(int line) const; + + /** + Clear the margin text on all lines + */ + void MarginTextClearAll(); + + /** + Get the start of the range of style numbers used for margin text + */ + void MarginSetStyleOffset(int style); + + /** + Get the start of the range of style numbers used for margin text + */ + int MarginGetStyleOffset() const; + + /** + Set the annotation text for a line + */ + void AnnotationSetText(int line, const wxString& text); + + /** + Get the annotation text for a line + */ + wxString AnnotationGetText(int line) const; + + /** + Set the style number for the annotations for a line + */ + void AnnotationSetStyle(int line, int style); + + /** + Get the style number for the annotations for a line + */ + int AnnotationGetStyle(int line) const; + + /** + Set the annotation styles for a line + */ + void AnnotationSetStyles(int line, const wxString& styles); + + /** + Get the annotation styles for a line + */ + wxString AnnotationGetStyles(int line) const; + + /** + Get the number of annotation lines for a line + */ + int AnnotationGetLines(int line) const; + + /** + Clear the annotations from all lines + */ + void AnnotationClearAll(); + + /** + Set the visibility for the annotations for a view + */ + void AnnotationSetVisible(int visible); + + /** + Get the visibility for the annotations for a view + */ + int AnnotationGetVisible() const; + + /** + Get the start of the range of style numbers used for annotations + */ + void AnnotationSetStyleOffset(int style); + + /** + Get the start of the range of style numbers used for annotations + */ + int AnnotationGetStyleOffset() const; + + /** + Add a container action to the undo stack + */ + void AddUndoAction(int token, int flags); + + /** + Find the position of a character from a point within the window. + */ + int CharPositionFromPoint(int x, int y); + + /** + Find the position of a character from a point within the window. + Return INVALID_POSITION if not close to text. + */ + int CharPositionFromPointClose(int x, int y); + + /** + Set whether multiple selections can be made + */ + void SetMultipleSelection(bool multipleSelection); + + /** + Whether multiple selections can be made + */ + bool GetMultipleSelection() const; + + /** + Set whether typing can be performed into multiple selections + */ + void SetAdditionalSelectionTyping(bool additionalSelectionTyping); + + /** + Whether typing can be performed into multiple selections + */ + bool GetAdditionalSelectionTyping() const; + + /** + Set whether additional carets will blink + */ + void SetAdditionalCaretsBlink(bool additionalCaretsBlink); + + /** + Whether additional carets will blink + */ + bool GetAdditionalCaretsBlink() const; + + /** + Set whether additional carets are visible + */ + void SetAdditionalCaretsVisible(bool additionalCaretsBlink); + + /** + Whether additional carets are visible + */ + bool GetAdditionalCaretsVisible() const; + + /** + How many selections are there? + */ + int GetSelections() const; + + /** + Clear selections to a single empty stream selection + */ + void ClearSelections(); + + /** + Add a selection + */ + int AddSelection(int caret, int anchor); + + /** + Set the main selection + */ + void SetMainSelection(int selection); + + /** + Which selection is the main selection + */ + int GetMainSelection() const; + + void SetSelectionNCaret(int selection, int pos); + int GetSelectionNCaret(int selection) const; + void SetSelectionNAnchor(int selection, int posAnchor); + int GetSelectionNAnchor(int selection) const; + void SetSelectionNCaretVirtualSpace(int selection, int space); + int GetSelectionNCaretVirtualSpace(int selection) const; + void SetSelectionNAnchorVirtualSpace(int selection, int space); + int GetSelectionNAnchorVirtualSpace(int selection) const; + + /** + Sets the position that starts the selection - this becomes the anchor. + */ + void SetSelectionNStart(int selection, int pos); + + /** + Returns the position at the start of the selection. + */ + int GetSelectionNStart(int selection) const; + + /** + Sets the position that ends the selection - this becomes the currentPosition. + */ + void SetSelectionNEnd(int selection, int pos); + + /** + Returns the position at the end of the selection. + */ + int GetSelectionNEnd(int selection) const; + + void SetRectangularSelectionCaret(int pos); + int GetRectangularSelectionCaret() const; + void SetRectangularSelectionAnchor(int posAnchor); + int GetRectangularSelectionAnchor() const; + void SetRectangularSelectionCaretVirtualSpace(int space); + int GetRectangularSelectionCaretVirtualSpace() const; + void SetRectangularSelectionAnchorVirtualSpace(int space); + int GetRectangularSelectionAnchorVirtualSpace() const; + void SetVirtualSpaceOptions(int virtualSpaceOptions); + int GetVirtualSpaceOptions() const; + + /** + Select the modifier key to use for mouse-based rectangular selection. + */ + void SetRectangularSelectionModifier(int modifier); + + /** + Get the modifier key used for rectangular selection. + */ + int GetRectangularSelectionModifier() const; + + /** + Set the foreground colour of additional selections. Must have + previously called SetSelFore with non-zero first argument for this to + have an effect. + */ + void SetAdditionalSelForeground(const wxColour& fore); + + /** + Set the background colour of additional selections. Must have + previously called SetSelBack with non-zero first argument for this to + have an effect. + */ + void SetAdditionalSelBackground(const wxColour& back); + + /** + Set the alpha of the selection. + */ + void SetAdditionalSelAlpha(int alpha); + + /** + Get the alpha of the selection. + */ + int GetAdditionalSelAlpha() const; + + /** + Set the foreground colour of additional carets. + */ + void SetAdditionalCaretForeground(const wxColour& fore); + + /** + Get the foreground colour of additional carets. + */ + wxColour GetAdditionalCaretForeground() const; + + /** + Set the main selection to the next selection. + */ + void RotateSelection(); + + /** + Swap that caret and anchor of the main selection. + */ + void SwapMainAnchorCaret(); + }; diff --git a/samples/stc/edit.cpp b/samples/stc/edit.cpp index df2fdf1530..777f190789 100644 --- a/samples/stc/edit.cpp +++ b/samples/stc/edit.cpp @@ -102,6 +102,7 @@ BEGIN_EVENT_TABLE (Edit, wxStyledTextCtrl) // stc EVT_STC_MARGINCLICK (wxID_ANY, Edit::OnMarginClick) EVT_STC_CHARADDED (wxID_ANY, Edit::OnCharAdded) + EVT_STC_KEY( wxID_ANY , Edit::OnKey ) END_EVENT_TABLE() Edit::Edit (wxWindow *parent, wxWindowID id, @@ -189,6 +190,11 @@ void Edit::OnEditClear (wxCommandEvent &WXUNUSED(event)) { Clear (); } +void Edit::OnKey (wxStyledTextEvent &event) +{ + wxMessageBox("OnKey"); +} + void Edit::OnEditCut (wxCommandEvent &WXUNUSED(event)) { if (GetReadOnly() || (GetSelectionEnd()-GetSelectionStart() <= 0)) return; Cut (); diff --git a/samples/stc/edit.h b/samples/stc/edit.h index 44e185ead9..780076d77a 100644 --- a/samples/stc/edit.h +++ b/samples/stc/edit.h @@ -97,6 +97,7 @@ public: // stc void OnMarginClick (wxStyledTextEvent &event); void OnCharAdded (wxStyledTextEvent &event); + void OnKey (wxStyledTextEvent &event); //! language/lexer wxString DeterminePrefs (const wxString &filename); diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index e67ee6a67b..fdeecde222 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -1275,7 +1275,7 @@ bool wxWindowBase::RemoveEventHandler(wxEvtHandler *handlerToRemove) // NOTE: the wxWindow event handler list is always terminated with "this" handler wxEvtHandler *handlerCur = GetEventHandler()->GetNextHandler(); - while ( handlerCur != this ) + while ( handlerCur != this && handlerCur ) { wxEvtHandler *handlerNext = handlerCur->GetNextHandler(); diff --git a/src/stc/Makefile.in b/src/stc/Makefile.in index 35a213e58d..74e7aa46f1 100644 --- a/src/stc/Makefile.in +++ b/src/stc/Makefile.in @@ -141,6 +141,7 @@ STCDLL_OBJECTS = \ stcdll_PropSet.o \ stcdll_RESearch.o \ stcdll_ScintillaBase.o \ + stcdll_Selection.o \ stcdll_Style.o \ stcdll_StyleContext.o \ stcdll_UniConversion.o \ @@ -231,6 +232,7 @@ STCLIB_OBJECTS = \ stclib_PropSet.o \ stclib_RESearch.o \ stclib_ScintillaBase.o \ + stcdll_Selection.o \ stclib_Style.o \ stclib_StyleContext.o \ stclib_UniConversion.o \ @@ -661,6 +663,9 @@ stcdll_RESearch.o: $(srcdir)/scintilla/src/RESearch.cxx stcdll_ScintillaBase.o: $(srcdir)/scintilla/src/ScintillaBase.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $(srcdir)/scintilla/src/ScintillaBase.cxx +stcdll_Selection.o: $(srcdir)/scintilla/src/Selction.cxx + $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $(srcdir)/scintilla/src/Selection.cxx + stcdll_Style.o: $(srcdir)/scintilla/src/Style.cxx $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $(srcdir)/scintilla/src/Style.cxx @@ -913,6 +918,9 @@ stclib_RESearch.o: $(srcdir)/scintilla/src/RESearch.cxx stclib_ScintillaBase.o: $(srcdir)/scintilla/src/ScintillaBase.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $(srcdir)/scintilla/src/ScintillaBase.cxx +stclib_Selection.o: $(srcdir)/scintilla/src/Selection.cxx + $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $(srcdir)/scintilla/src/Selection.cxx + stclib_Style.o: $(srcdir)/scintilla/src/Style.cxx $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $(srcdir)/scintilla/src/Style.cxx diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index ac4c035126..fbc9ce00a3 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -45,7 +45,6 @@ #include "wx/stc/private.h" - Point Point::FromLong(long lpoint) { return Point(lpoint & 0xFFFF, lpoint >> 16); } @@ -142,7 +141,7 @@ void Palette::Allocate(Window &) { //---------------------------------------------------------------------- Font::Font() { - id = 0; + fid = 0; ascent = 0; } @@ -151,7 +150,7 @@ Font::~Font() { void Font::Create(const char *faceName, int characterSet, int size, bool bold, bool italic, - bool WXUNUSED(extraFontFlag)) { + int WXUNUSED(extraFontFlag)) { Release(); // The minus one is done because since Scintilla uses SC_SHARSET_DEFAULT @@ -171,14 +170,14 @@ void Font::Create(const char *faceName, int characterSet, false, stc2wx(faceName), encoding); - id = font; + fid = font; } void Font::Release() { - if (id) - delete (wxFont*)id; - id = 0; + if (fid) + delete (wxFont*)fid; + fid = 0; } //---------------------------------------------------------------------- @@ -648,26 +647,26 @@ Window::~Window() { } void Window::Destroy() { - if (id) { + if (wid) { Show(false); - GETWIN(id)->Destroy(); + GETWIN(wid)->Destroy(); } - id = 0; + wid = 0; } bool Window::HasFocus() { - return wxWindow::FindFocus() == GETWIN(id); + return wxWindow::FindFocus() == GETWIN(wid); } PRectangle Window::GetPosition() { - if (! id) return PRectangle(); - wxRect rc(GETWIN(id)->GetPosition(), GETWIN(id)->GetSize()); + if (! wid) return PRectangle(); + wxRect rc(GETWIN(wid)->GetPosition(), GETWIN(wid)->GetSize()); return PRectangleFromwxRect(rc); } void Window::SetPosition(PRectangle rc) { wxRect r = wxRectFromPRectangle(rc); - GETWIN(id)->SetSize(r); + GETWIN(wid)->SetSize(r); } void Window::SetPositionRelative(PRectangle rc, Window) { @@ -675,26 +674,26 @@ void Window::SetPositionRelative(PRectangle rc, Window) { } PRectangle Window::GetClientPosition() { - if (! id) return PRectangle(); - wxSize sz = GETWIN(id)->GetClientSize(); + if (! wid) return PRectangle(); + wxSize sz = GETWIN(wid)->GetClientSize(); return PRectangle(0, 0, sz.x, sz.y); } void Window::Show(bool show) { - GETWIN(id)->Show(show); + GETWIN(wid)->Show(show); } void Window::InvalidateAll() { - GETWIN(id)->Refresh(false); + GETWIN(wid)->Refresh(false); } void Window::InvalidateRectangle(PRectangle rc) { wxRect r = wxRectFromPRectangle(rc); - GETWIN(id)->Refresh(false, &r); + GETWIN(wid)->Refresh(false, &r); } void Window::SetFont(Font &font) { - GETWIN(id)->SetFont(*((wxFont*)font.GetID())); + GETWIN(wid)->SetFont(*((wxFont*)font.GetID())); } void Window::SetCursor(Cursor curs) { @@ -733,21 +732,21 @@ void Window::SetCursor(Cursor curs) { wxCursor wc = wxCursor(cursorId); if(curs != cursorLast) { - GETWIN(id)->SetCursor(wc); + GETWIN(wid)->SetCursor(wc); cursorLast = curs; } } void Window::SetTitle(const char *s) { - GETWIN(id)->SetLabel(stc2wx(s)); + GETWIN(wid)->SetLabel(stc2wx(s)); } // Returns rectangle of monitor pt is on PRectangle Window::GetMonitorRect(Point pt) { wxRect rect; - if (! id) return PRectangle(); + if (! wid) return PRectangle(); #if wxUSE_DISPLAY // Get the display the point is found on int n = wxDisplay::GetFromPoint(wxPoint(pt.x, pt.y)); @@ -823,15 +822,6 @@ END_EVENT_TABLE() #if wxUSE_POPUPWIN //----------------------------------- #include "wx/popupwin.h" - -// -// TODO: Refactor these two classes to have a common base (or a mix-in) to get -// rid of the code duplication. (Either that or convince somebody to -// implement wxPopupWindow for the Mac!!) -// -// In the meantime, be careful to duplicate any changes as needed... -// - // A popup window to place the wxSTCListBox upon class wxSTCListBoxWin : public wxPopupWindow { @@ -841,11 +831,9 @@ private: void* doubleClickActionData; public: wxSTCListBoxWin(wxWindow* parent, wxWindowID id, Point WXUNUSED(location)) : - wxPopupWindow(parent, wxBORDER_NONE) + wxPopupWindow(parent, wxBORDER_SIMPLE) { - SetBackgroundColour(*wxBLACK); // for our simple border - lv = new wxSTCListBox(parent, id, wxPoint(-50,-50), wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL | wxLC_NO_HEADER | wxBORDER_NONE); lv->SetCursor(wxCursor(wxCURSOR_ARROW)); @@ -919,11 +907,9 @@ public: } void OnSize(wxSizeEvent& event) { - // resize the child - wxSize sz = GetSize(); - sz.x -= 2; - sz.y -= 2; - lv->SetSize(1, 1, sz.x, sz.y); + // resize the child to fill the popup + wxSize sz = GetClientSize(); + lv->SetSize(0, 0, sz.x, sz.y); // reset the column widths lv->SetColumnWidth(0, IconWidth()+4); lv->SetColumnWidth(1, sz.x - 2 - lv->GetColumnWidth(0) - @@ -1170,7 +1156,7 @@ ListBoxImpl::~ListBoxImpl() { void ListBoxImpl::SetFont(Font &font) { - GETLB(id)->SetFont(*((wxFont*)font.GetID())); + GETLB(wid)->SetFont(*((wxFont*)font.GetID())); } @@ -1179,9 +1165,9 @@ void ListBoxImpl::Create(Window &parent, int ctrlID, Point location_, int lineHe lineHeight = lineHeight_; unicodeMode = unicodeMode_; maxStrWidth = 0; - id = new wxSTCListBoxWin(GETWIN(parent.GetID()), ctrlID, location); + wid = new wxSTCListBoxWin(GETWIN(parent.GetID()), ctrlID, location); if (imgList != NULL) - GETLB(id)->SetImageList(imgList, wxIMAGE_LIST_SMALL); + GETLB(wid)->SetImageList(imgList, wxIMAGE_LIST_SMALL); } @@ -1208,15 +1194,15 @@ PRectangle ListBoxImpl::GetDesiredRect() { // give it a default if there are no lines, and/or add a bit more if (maxw == 0) maxw = 100; maxw += aveCharWidth * 3 + - GETLBW(id)->IconWidth() + wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); + GETLBW(wid)->IconWidth() + wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); if (maxw > 350) maxw = 350; // estimate a desired height - int count = GETLB(id)->GetItemCount(); + int count = GETLB(wid)->GetItemCount(); if (count) { wxRect rect; - GETLB(id)->GetItemRect(0, rect); + GETLB(wid)->GetItemRect(0, rect); maxh = count * rect.GetHeight(); if (maxh > 140) // TODO: Use desiredVisibleRows?? maxh = 140; @@ -1238,12 +1224,12 @@ PRectangle ListBoxImpl::GetDesiredRect() { int ListBoxImpl::CaretFromEdge() { - return 4 + GETLBW(id)->IconWidth(); + return 4 + GETLBW(wid)->IconWidth(); } void ListBoxImpl::Clear() { - GETLB(id)->DeleteAllItems(); + GETLB(wid)->DeleteAllItems(); } @@ -1252,20 +1238,20 @@ void ListBoxImpl::Append(char *s, int type) { } void ListBoxImpl::Append(const wxString& text, int type) { - long count = GETLB(id)->GetItemCount(); - long itemID = GETLB(id)->InsertItem(count, wxEmptyString); + long count = GETLB(wid)->GetItemCount(); + long itemID = GETLB(wid)->InsertItem(count, wxEmptyString); long idx = -1; - GETLB(id)->SetItem(itemID, 1, text); + GETLB(wid)->SetItem(itemID, 1, text); maxStrWidth = wxMax(maxStrWidth, text.length()); if (type != -1) { wxCHECK_RET(imgTypeMap, wxT("Unexpected NULL imgTypeMap")); idx = imgTypeMap->Item(type); } - GETLB(id)->SetItemImage(itemID, idx, idx); + GETLB(wid)->SetItemImage(itemID, idx, idx); } void ListBoxImpl::SetList(const char* list, char separator, char typesep) { - GETLB(id)->Freeze(); + GETLB(wid)->Freeze(); Clear(); wxStringTokenizer tkzr(stc2wx(list), (wxChar)separator); while ( tkzr.HasMoreTokens() ) { @@ -1278,12 +1264,12 @@ void ListBoxImpl::SetList(const char* list, char separator, char typesep) { } Append(token, (int)type); } - GETLB(id)->Thaw(); + GETLB(wid)->Thaw(); } int ListBoxImpl::Length() { - return GETLB(id)->GetItemCount(); + return GETLB(wid)->GetItemCount(); } @@ -1293,13 +1279,13 @@ void ListBoxImpl::Select(int n) { n = 0; select = false; } - GETLB(id)->EnsureVisible(n); - GETLB(id)->Select(n, select); + GETLB(wid)->EnsureVisible(n); + GETLB(wid)->Select(n, select); } int ListBoxImpl::GetSelection() { - return GETLB(id)->GetFirstSelected(); + return GETLB(wid)->GetFirstSelected(); } @@ -1314,7 +1300,7 @@ void ListBoxImpl::GetValue(int n, char *value, int len) { item.SetId(n); item.SetColumn(1); item.SetMask(wxLIST_MASK_TEXT); - GETLB(id)->GetItem(item); + GETLB(wid)->GetItem(item); strncpy(value, wx2stc(item.GetText()), len); value[len-1] = '\0'; } @@ -1351,13 +1337,13 @@ void ListBoxImpl::ClearRegisteredImages() { delete imgTypeMap; imgTypeMap = NULL; } - if (id) - GETLB(id)->SetImageList(NULL, wxIMAGE_LIST_SMALL); + if (wid) + GETLB(wid)->SetImageList(NULL, wxIMAGE_LIST_SMALL); } void ListBoxImpl::SetDoubleClickAction(CallBackAction action, void *data) { - GETLBW(id)->SetDoubleClickAction(action, data); + GETLBW(wid)->SetDoubleClickAction(action, data); } @@ -1373,22 +1359,22 @@ ListBox *ListBox::Allocate() { //---------------------------------------------------------------------- -Menu::Menu() : id(0) { +Menu::Menu() : mid(0) { } void Menu::CreatePopUp() { Destroy(); - id = new wxMenu(); + mid = new wxMenu(); } void Menu::Destroy() { - if (id) - delete (wxMenu*)id; - id = 0; + if (mid) + delete (wxMenu*)mid; + mid = 0; } void Menu::Show(Point pt, Window &w) { - GETWIN(w.GetID())->PopupMenu((wxMenu*)id, pt.x - 4, pt.y); + GETWIN(w.GetID())->PopupMenu((wxMenu*)mid, pt.x - 4, pt.y); Destroy(); } diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index 0f9a5281ab..0850bcbced 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -301,7 +301,7 @@ void ScintillaWX::StartDrag() { if (result == wxDragMove && dropWentOutside) ClearSelection(); inDragDrop = ddNone; - SetDragPosition(invalidPosition); + SetDragPosition(SelectionPosition(invalidPosition)); } #endif // wxUSE_DRAG_AND_DROP } @@ -472,7 +472,7 @@ void ScintillaWX::CancelModes() { void ScintillaWX::Copy() { - if (currentPos != anchor) { + if (!sel.Empty()) { SelectionText st; CopySelectionRange(&st); CopyToClipboard(st); @@ -504,8 +504,9 @@ void ScintillaWX::Paste() { text = wxEmptyString; #endif int len = strlen(buf); - pdoc->InsertString(currentPos, buf, len); - SetEmptySelection(currentPos + len); + int caretMain = sel.MainCaret(); + pdoc->InsertString(caretMain, buf, len); + SetEmptySelection(caretMain + len); } #endif // wxUSE_DATAOBJ @@ -580,7 +581,7 @@ void ScintillaWX::AddToPopUp(const char *label, int cmd, bool enabled) { void ScintillaWX::ClaimSelection() { #ifdef __WXGTK__ // Put the selected text in the PRIMARY selection - if (currentPos != anchor) { + if (!sel.Empty()) { SelectionText st; CopySelectionRange(&st); wxTheClipboard->UsePrimarySelection(true); @@ -602,7 +603,7 @@ void ScintillaWX::UpdateSystemCaret() { DestroySystemCaret(); CreateSystemCaret(); } - Point pos = LocationFromPosition(currentPos); + Point pos = PointMainCaret(); ::SetCaretPos(pos.x, pos.y); } #endif @@ -679,7 +680,8 @@ sptr_t ScintillaWX::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { ct.SetForeBack(vs.styles[STYLE_CALLTIP].fore, vs.styles[STYLE_CALLTIP].back); } - PRectangle rc = ct.CallTipStart(currentPos, pt, + int caretMain = sel.MainCaret(); + PRectangle rc = ct.CallTipStart(caretMain, pt, defn, vs.styles[ctStyle].fontName, vs.styles[ctStyle].sizeZoomed, @@ -862,7 +864,7 @@ void ScintillaWX::DoMiddleButtonUp(Point pt) { // Set the current position to the mouse click point and // then paste in the PRIMARY selection, if any. wxGTK only. int newPos = PositionFromLocation(pt); - MovePositionTo(newPos, noSel, true); + MovePositionTo(newPos, Selection::noSel, true); pdoc->BeginUndoAction(); wxTextDataObject data; @@ -878,8 +880,9 @@ void ScintillaWX::DoMiddleButtonUp(Point pt) { wxConvertEOLMode(pdoc->eolMode)); wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); int len = strlen(buf); - pdoc->InsertString(currentPos, buf, len); - SetEmptySelection(currentPos + len); + int caretMain = sel.MainCaret(); + pdoc->InsertString(caretMain, buf, len); + SetEmptySelection(caretMain + len); } pdoc->EndUndoAction(); NotifyChange(); @@ -1007,7 +1010,7 @@ void ScintillaWX::DoOnIdle(wxIdleEvent& evt) { #if wxUSE_DRAG_AND_DROP bool ScintillaWX::DoDropText(long x, long y, const wxString& data) { - SetDragPosition(invalidPosition); + SetDragPosition(SelectionPosition(invalidPosition)); wxString text = wxTextBuffer::Translate(data, wxConvertEOLMode(pdoc->eolMode)); @@ -1024,7 +1027,7 @@ bool ScintillaWX::DoDropText(long x, long y, const wxString& data) { dragResult = evt.GetDragResult(); if (dragResult == wxDragMove || dragResult == wxDragCopy) { - DropAt(evt.GetPosition(), + DropAt(SelectionPosition(evt.GetPosition()), wx2stc(evt.GetDragText()), dragResult == wxDragMove, false); // TODO: rectangular? @@ -1041,7 +1044,7 @@ wxDragResult ScintillaWX::DoDragEnter(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxDragResult ScintillaWX::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) { - SetDragPosition(PositionFromLocation(Point(x, y))); + SetDragPosition(SelectionPosition(PositionFromLocation(Point(x, y)))); // Send an event to allow the drag result to be changed wxStyledTextEvent evt(wxEVT_STC_DRAG_OVER, stc->GetId()); @@ -1058,7 +1061,7 @@ wxDragResult ScintillaWX::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) { void ScintillaWX::DoDragLeave() { - SetDragPosition(invalidPosition); + SetDragPosition(SelectionPosition(invalidPosition)); } #endif // wxUSE_DRAG_AND_DROP //---------------------------------------------------------------------- diff --git a/src/stc/ScintillaWX.h b/src/stc/ScintillaWX.h index d74ea4a0d7..ae27a5d500 100644 --- a/src/stc/ScintillaWX.h +++ b/src/stc/ScintillaWX.h @@ -26,32 +26,35 @@ #include #include "Platform.h" -#include "PropSet.h" -#include "Accessor.h" -#include "KeyWords.h" - +#include "SplitVector.h" +#include "Partitioning.h" +#include "RunStyles.h" #include "Scintilla.h" -#include "CharClassify.h" -#include "XPM.h" +#include "ScintillaWidget.h" #ifdef SCI_LEXER #include "SciLexer.h" +#include "PropSet.h" +#include "Accessor.h" +#include "KeyWords.h" #endif -#include "SplitVector.h" -#include "Partitioning.h" -#include "RunStyles.h" #include "ContractionState.h" +#include "SVector.h" #include "CellBuffer.h" #include "CallTip.h" #include "KeyMap.h" #include "Indicator.h" +#include "XPM.h" #include "LineMarker.h" #include "Style.h" -#include "ViewStyle.h" #include "AutoComplete.h" +#include "ViewStyle.h" +#include "CharClassify.h" #include "Decoration.h" #include "Document.h" +#include "Selection.h" #include "PositionCache.h" #include "Editor.h" +#include "PropSetSimple.h" #include "ScintillaBase.h" #ifdef __WXMSW__ diff --git a/src/stc/gen_iface.py b/src/stc/gen_iface.py index 54efef00db..8fddb97722 100755 --- a/src/stc/gen_iface.py +++ b/src/stc/gen_iface.py @@ -21,7 +21,10 @@ H_TEMPLATE = os.path.abspath('./stc.h.in') CPP_TEMPLATE = os.path.abspath('./stc.cpp.in') H_DEST = os.path.abspath('../../include/wx/stc/stc.h') CPP_DEST = os.path.abspath('./stc.cpp') -DOCSTR_DEST = '/dev/null' #os.path.abspath('../../../wxPython/contrib/stc/_stc_gendocs.i') +if len(sys.argv) > 1 and sys.argv[1] == '--wxpython': + DOCSTR_DEST = os.path.abspath('../../../wxPython/src/_stc_gendocs.i') +else: + DOCSTR_DEST = '/dev/null' # Value prefixes to convert @@ -29,6 +32,7 @@ valPrefixes = [('SCI_', ''), ('SC_', ''), ('SCN_', None), # just toss these out... ('SCEN_', None), + ('SC_EFF', None), ('SCE_', ''), ('SCLEX_', 'LEX_'), ('SCK_', 'KEY_'), @@ -177,6 +181,8 @@ methodOverrideMap = { 'MarkerSetFore' : ('MarkerSetForeground', 0, 0, 0), 'MarkerSetBack' : ('MarkerSetBackground', 0, 0, 0), + 'MarkerSymbolDefined' : ('GetMarkerSymbolDefined', 0, 0, 0), + 'MarkerDefine' : (0, '''void %s(int markerNumber, int markerSymbol, @@ -226,6 +232,74 @@ methodOverrideMap = { 'SetMarginSensitiveN' : ('SetMarginSensitive', 0, 0, 0), 'GetMarginSensitiveN' : ('GetMarginSensitive', 0, 0, 0), + 'MarginGetText' : + (0, + 'wxString %s(int line) const;', + + '''wxString %s(int line) const { + long msg = %s; + long len = SendMsg(msg, line, 0); + + wxMemoryBuffer mbuf(len+1); + char* buf = (char*)mbuf.GetWriteBuf(len+1); + SendMsg(msg, line, (sptr_t)buf); + mbuf.UngetWriteBuf(len); + mbuf.AppendByte(0); + return stc2wx(buf);''', + 0), + + 'MarginGetStyles' : + (0, + 'wxString %s(int line) const;', + + '''wxString %s(int line) const { + long msg = %s; + long len = SendMsg(msg, line, 0); + + wxMemoryBuffer mbuf(len+1); + char* buf = (char*)mbuf.GetWriteBuf(len+1); + SendMsg(msg, line, (sptr_t)buf); + mbuf.UngetWriteBuf(len); + mbuf.AppendByte(0); + return stc2wx(buf);''', + 0), + + 'SetAdditionalSelFore' : ('SetAdditionalSelForeground', 0, 0, 0), + 'SetAdditionalSelBack' : ('SetAdditionalSelBackground', 0, 0, 0), + 'SetAdditionalCaretFore' : ('SetAdditionalCaretForeground', 0, 0, 0), + 'GetAdditionalCaretFore' : ('GetAdditionalCaretForeground', 0, 0, 0), + + 'AnnotationGetText' : + (0, + 'wxString %s(int line) const;', + + '''wxString %s(int line) const { + long msg = %s; + long len = SendMsg(msg, line, 0); + + wxMemoryBuffer mbuf(len+1); + char* buf = (char*)mbuf.GetWriteBuf(len+1); + SendMsg(msg, line, (sptr_t)buf); + mbuf.UngetWriteBuf(len); + mbuf.AppendByte(0); + return stc2wx(buf);''', + 0), + + 'AnnotationGetStyles' : + (0, + 'wxString %s(int line) const;', + + '''wxString %s(int line) const { + long msg = %s; + long len = SendMsg(msg, line, 0); + + wxMemoryBuffer mbuf(len+1); + char* buf = (char*)mbuf.GetWriteBuf(len+1); + SendMsg(msg, line, (sptr_t)buf); + mbuf.UngetWriteBuf(len); + mbuf.AppendByte(0); + return stc2wx(buf);''', + 0), 'StyleGetFore' : ('StyleGetForeground', 0, 0, 0), 'StyleGetBack' : ('StyleGetBackground', 0, 0, 0), @@ -279,6 +353,8 @@ methodOverrideMap = { 0), + 'IndicSetAlpha' : ('IndicatorSetAlpha', 0, 0, 0), + 'IndicGetAlpha' : ('IndicatorGetAlpha', 0, 0, 0), 'IndicSetStyle' : ('IndicatorSetStyle', 0, 0, 0), 'IndicGetStyle' : ('IndicatorGetStyle', 0, 0, 0), 'IndicSetFore' : ('IndicatorSetForeground', 0, 0, 0), @@ -312,6 +388,7 @@ methodOverrideMap = { 'AutoCGetTypeSeparator' : ('AutoCompGetTypeSeparator', 0, 0, 0), 'AutoCSetTypeSeparator' : ('AutoCompSetTypeSeparator', 0, 0, 0), 'AutoCGetCurrent' : ('AutoCompGetCurrent', 0, 0, 0), + 'AutoCGetCurrentText' : (None, 0, 0, 0), 'AutoCSetMaxWidth' : ('AutoCompSetMaxWidth', 0, 0, 0), 'AutoCGetMaxWidth' : ('AutoCompGetMaxWidth', 0, 0, 0), 'AutoCSetMaxHeight' : ('AutoCompSetMaxHeight', 0, 0, 0), @@ -650,6 +727,17 @@ methodOverrideMap = { 'SetPositionCache' : ('SetPositionCacheSize', 0, 0, 0), 'GetPositionCache' : ('GetPositionCacheSize', 0, 0, 0), + 'GetLexerLanguage' : (None, 0, 0, 0), + 'SetFontQuality' : (None, 0, 0, 0), + 'GetFontQuality' : (None, 0, 0, 0), + 'SetSelection' : (None, 0, 0, 0), + + 'GetCharacterPointer' : (0, + 'const char* %s();', + 'const char* %s() {\n' + ' return (const char*)SendMsg(%s, 0, 0);', + 0), + '' : ('', 0, 0, 0), @@ -889,7 +977,7 @@ funregex = re.compile(r'\s*([a-zA-Z0-9_]+)' # return type '\s+([a-zA-Z0-9_]+)=' # name= '([0-9]+)' # number '\(([ a-zA-Z0-9_]*),' # (param, - '([ a-zA-Z0-9_]*)\)') # param) + '([ a-zA-Z0-9_]*),*\)') # param) def parseFun(line, methods, docs, values, is_const): def parseParam(param): diff --git a/src/stc/scintilla/README.txt b/src/stc/scintilla/README.txt index 13390ddda6..27a2157fef 100644 --- a/src/stc/scintilla/README.txt +++ b/src/stc/scintilla/README.txt @@ -1,7 +1,7 @@ This directory contains copies of the scintilla/src and -scintilla/include directories from the Scintilla/SCiTE source -distribution. All other code needed to implement Scintilla on top of -wxWindows is located in the directory above this one. +scintilla/include directories from the Scintilla source distribution. +All other code needed to implement Scintilla on top of wxWidgets is +located in the directory above this one. -The current version of the Scintilla code is 1.75 +The current version of the Scintilla code is 2.03 diff --git a/src/stc/scintilla/include/KeyWords.h b/src/stc/scintilla/include/KeyWords.h index 6abae59453..5593b7d091 100644 --- a/src/stc/scintilla/include/KeyWords.h +++ b/src/stc/scintilla/include/KeyWords.h @@ -9,6 +9,29 @@ namespace Scintilla { #endif +/** + */ +class WordList { +public: + // Each word contains at least one character - a empty word acts as sentinel at the end. + char **words; + char *list; + int len; + bool onlyLineEnds; ///< Delimited by any white space or only line ends + bool sorted; + int starts[256]; + WordList(bool onlyLineEnds_ = false) : + words(0), list(0), len(0), onlyLineEnds(onlyLineEnds_), + sorted(false) + {} + ~WordList() { Clear(); } + operator bool() { return len ? true : false; } + void Clear(); + void Set(const char *s); + bool InList(const char *s); + bool InListAbbreviated(const char *s, const char marker); +}; + typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyle, WordList *keywordlists[], Accessor &styler); diff --git a/src/stc/scintilla/include/Platform.h b/src/stc/scintilla/include/Platform.h index 79be33f6ba..b5d6d9bf8d 100644 --- a/src/stc/scintilla/include/Platform.h +++ b/src/stc/scintilla/include/Platform.h @@ -3,7 +3,7 @@ ** Interface to platform facilities. Also includes some basic utilities. ** Implemented in PlatGTK.cxx for GTK+/Linux, PlatWin.cxx for Windows, and PlatWX.cxx for wxWindows. **/ -// Copyright 1998-2003 by Neil Hodgson +// Copyright 1998-2009 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #ifndef PLATFORM_H @@ -33,12 +33,13 @@ #undef PLAT_GTK #define PLAT_GTK 1 -#ifdef _MSC_VER +#if defined(__WIN32__) || defined(_MSC_VER) #undef PLAT_GTK_WIN32 #define PLAT_GTK_WIN32 1 #endif -#elif defined(MACOSX) +#elif defined(__APPLE__) + #undef PLAT_MACOSX #define PLAT_MACOSX 1 @@ -122,7 +123,7 @@ public: } int Width() { return right - left; } int Height() { return bottom - top; } - bool Empty() { + bool Empty() { return (Height() <= 0) || (Width() <= 0); } }; @@ -282,24 +283,24 @@ public: */ class Font { protected: - FontID id; + FontID fid; #if PLAT_WX int ascent; #endif // Private so Font objects can not be copied Font(const Font &) {} - Font &operator=(const Font &) { id=0; return *this; } + Font &operator=(const Font &) { fid=0; return *this; } public: Font(); virtual ~Font(); virtual void Create(const char *faceName, int characterSet, int size, - bool bold, bool italic, bool extraFontFlag=false); + bool bold, bool italic, int extraFontFlag=0); virtual void Release(); - FontID GetID() { return id; } + FontID GetID() { return fid; } // Alias another font - caller guarantees not to Release - void SetID(FontID id_) { id = id_; } + void SetID(FontID fid_) { fid = fid_; } friend class Surface; friend class SurfaceImpl; }; @@ -370,31 +371,31 @@ typedef void (*CallBackAction)(void*); */ class Window { protected: - WindowID id; + WindowID wid; #if PLAT_MACOSX void *windowRef; void *control; #endif public: - Window() : id(0), cursorLast(cursorInvalid) { + Window() : wid(0), cursorLast(cursorInvalid) { #if PLAT_MACOSX windowRef = 0; control = 0; #endif } - Window(const Window &source) : id(source.id), cursorLast(cursorInvalid) { + Window(const Window &source) : wid(source.wid), cursorLast(cursorInvalid) { #if PLAT_MACOSX windowRef = 0; control = 0; #endif } virtual ~Window(); - Window &operator=(WindowID id_) { - id = id_; + Window &operator=(WindowID wid_) { + wid = wid_; return *this; } - WindowID GetID() const { return id; } - bool Created() const { return id != 0; } + WindowID GetID() const { return wid; } + bool Created() const { return wid != 0; } void Destroy(); bool HasFocus(); PRectangle GetPosition(); @@ -451,10 +452,10 @@ public: * Menu management. */ class Menu { - MenuID id; + MenuID mid; public: Menu(); - MenuID GetID() { return id; } + MenuID GetID() { return mid; } void CreatePopUp(); void Destroy(); void Show(Point pt, Window &w); diff --git a/src/stc/scintilla/include/PropSet.h b/src/stc/scintilla/include/PropSet.h index 91bc7072ba..c95202174f 100644 --- a/src/stc/scintilla/include/PropSet.h +++ b/src/stc/scintilla/include/PropSet.h @@ -1,104 +1,26 @@ // Scintilla source code edit control /** @file PropSet.h - ** A Java style properties file module. + ** An interface to the methods needed for access to property sets inside lexers. **/ -// Copyright 1998-2002 by Neil Hodgson +// Copyright 1998-2009 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #ifndef PROPSET_H #define PROPSET_H -#include "SString.h" - -bool EqualCaseInsensitive(const char *a, const char *b); - -bool isprefix(const char *target, const char *prefix); #ifdef SCI_NAMESPACE namespace Scintilla { #endif -struct Property { - unsigned int hash; - char *key; - char *val; - Property *next; - Property() : hash(0), key(0), val(0), next(0) {} -}; - -/** - */ -class PropSet { -protected: - enum { hashRoots=31 }; - Property *props[hashRoots]; - Property *enumnext; - int enumhash; - static unsigned int HashString(const char *s, size_t len) { - unsigned int ret = 0; - while (len--) { - ret <<= 4; - ret ^= *s; - s++; - } - return ret; - } - +class PropertyGet { public: - PropSet *superPS; - PropSet(); - ~PropSet(); - void Set(const char *key, const char *val, int lenKey=-1, int lenVal=-1); - void Set(const char *keyVal); - void Unset(const char *key, int lenKey=-1); - void SetMultiple(const char *s); - SString Get(const char *key) const; - SString GetExpanded(const char *key) const; - SString Expand(const char *withVars, int maxExpands=100) const; - int GetInt(const char *key, int defaultValue=0) const; - void Clear(); - char *ToString() const; // Caller must delete[] the return value - -private: - // copy-value semantics not implemented - PropSet(const PropSet ©); - void operator=(const PropSet &assign); + virtual char *ToString() const=0; // Caller must delete[] the return value + virtual int GetInt(const char *key, int defaultValue=0) const=0; + virtual ~PropertyGet() {} }; -/** - */ -class WordList { -public: - // Each word contains at least one character - a empty word acts as sentinel at the end. - char **words; - char *list; - int len; - bool onlyLineEnds; ///< Delimited by any white space or only line ends - bool sorted; - int starts[256]; - WordList(bool onlyLineEnds_ = false) : - words(0), list(0), len(0), onlyLineEnds(onlyLineEnds_), - sorted(false) - {} - ~WordList() { Clear(); } - operator bool() { return len ? true : false; } - void Clear(); - void Set(const char *s); - bool InList(const char *s); - bool InListAbbreviated(const char *s, const char marker); -}; - -inline bool IsAlphabetic(unsigned int ch) { - return ((ch >= 'A') && (ch <= 'Z')) || ((ch >= 'a') && (ch <= 'z')); -} - #ifdef SCI_NAMESPACE } #endif -#ifdef _MSC_VER -// Visual C++ doesn't like the private copy idiom for disabling -// the default copy constructor and operator=, but it's fine. -#pragma warning(disable: 4511 4512) -#endif - #endif diff --git a/src/stc/scintilla/include/SciLexer.h b/src/stc/scintilla/include/SciLexer.h index 2354aa8765..ced86f4339 100644 --- a/src/stc/scintilla/include/SciLexer.h +++ b/src/stc/scintilla/include/SciLexer.h @@ -1,19 +1,19 @@ -// Scintilla source code edit control +/* Scintilla source code edit control */ /** @file SciLexer.h ** Interface to the added lexer functions in the SciLexer version of the edit control. **/ -// Copyright 1998-2002 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. +/* Copyright 1998-2002 by Neil Hodgson + * The License.txt file describes the conditions under which this software may be distributed. */ -// Most of this file is automatically generated from the Scintilla.iface interface definition -// file which contains any comments about the definitions. HFacer.py does the generation. +/* Most of this file is automatically generated from the Scintilla.iface interface definition + * file which contains any comments about the definitions. HFacer.py does the generation. */ #ifndef SCILEXER_H #define SCILEXER_H -// SciLexer features - not in standard Scintilla +/* SciLexer features - not in standard Scintilla */ -//++Autogenerated -- start of section automatically generated from Scintilla.iface +/* ++Autogenerated -- start of section automatically generated from Scintilla.iface */ #define SCLEX_CONTAINER 0 #define SCLEX_NULL 1 #define SCLEX_PYTHON 2 @@ -99,6 +99,18 @@ #define SCLEX_ABAQUS 84 #define SCLEX_ASYMPTOTE 85 #define SCLEX_R 86 +#define SCLEX_MAGIK 87 +#define SCLEX_POWERSHELL 88 +#define SCLEX_MYSQL 89 +#define SCLEX_PO 90 +#define SCLEX_TAL 91 +#define SCLEX_COBOL 92 +#define SCLEX_TACL 93 +#define SCLEX_SORCUS 94 +#define SCLEX_POWERPRO 95 +#define SCLEX_NIMROD 96 +#define SCLEX_SML 97 +#define SCLEX_MARKDOWN 98 #define SCLEX_AUTOMATIC 1000 #define SCE_P_DEFAULT 0 #define SCE_P_COMMENTLINE 1 @@ -154,6 +166,11 @@ #define SCE_D_COMMENTLINEDOC 15 #define SCE_D_COMMENTDOCKEYWORD 16 #define SCE_D_COMMENTDOCKEYWORDERROR 17 +#define SCE_D_STRINGB 18 +#define SCE_D_STRINGR 19 +#define SCE_D_WORD5 20 +#define SCE_D_WORD6 21 +#define SCE_D_WORD7 22 #define SCE_TCL_DEFAULT 0 #define SCE_TCL_COMMENT 1 #define SCE_TCL_COMMENTLINE 2 @@ -450,6 +467,7 @@ #define SCE_DIFF_POSITION 4 #define SCE_DIFF_DELETED 5 #define SCE_DIFF_ADDED 6 +#define SCE_DIFF_CHANGED 7 #define SCE_CONF_DEFAULT 0 #define SCE_CONF_COMMENT 1 #define SCE_CONF_NUMBER 2 @@ -614,6 +632,11 @@ #define SCE_CSS_SINGLESTRING 14 #define SCE_CSS_IDENTIFIER2 15 #define SCE_CSS_ATTRIBUTE 16 +#define SCE_CSS_IDENTIFIER3 17 +#define SCE_CSS_PSEUDOELEMENT 18 +#define SCE_CSS_EXTENDED_IDENTIFIER 19 +#define SCE_CSS_EXTENDED_PSEUDOCLASS 20 +#define SCE_CSS_EXTENDED_PSEUDOELEMENT 21 #define SCE_POV_DEFAULT 0 #define SCE_POV_COMMENT 1 #define SCE_POV_COMMENTLINE 2 @@ -766,8 +789,19 @@ #define SCE_ERLANG_CHARACTER 9 #define SCE_ERLANG_MACRO 10 #define SCE_ERLANG_RECORD 11 -#define SCE_ERLANG_SEPARATOR 12 +#define SCE_ERLANG_PREPROC 12 #define SCE_ERLANG_NODE_NAME 13 +#define SCE_ERLANG_COMMENT_FUNCTION 14 +#define SCE_ERLANG_COMMENT_MODULE 15 +#define SCE_ERLANG_COMMENT_DOC 16 +#define SCE_ERLANG_COMMENT_DOC_MACRO 17 +#define SCE_ERLANG_ATOM_QUOTED 18 +#define SCE_ERLANG_MACRO_QUOTED 19 +#define SCE_ERLANG_RECORD_QUOTED 20 +#define SCE_ERLANG_NODE_NAME_QUOTED 21 +#define SCE_ERLANG_BIFS 22 +#define SCE_ERLANG_MODULES 23 +#define SCE_ERLANG_MODULES_ATT 24 #define SCE_ERLANG_UNKNOWN 31 #define SCE_MSSQL_DEFAULT 0 #define SCE_MSSQL_COMMENT 1 @@ -916,6 +950,7 @@ #define SCE_CAML_OPERATOR 7 #define SCE_CAML_NUMBER 8 #define SCE_CAML_CHAR 9 +#define SCE_CAML_WHITE 10 #define SCE_CAML_STRING 11 #define SCE_CAML_COMMENT 12 #define SCE_CAML_COMMENT1 13 @@ -1073,7 +1108,7 @@ #define SCE_INNO_PARAMETER 3 #define SCE_INNO_SECTION 4 #define SCE_INNO_PREPROC 5 -#define SCE_INNO_PREPROC_INLINE 6 +#define SCE_INNO_INLINE_EXPANSION 6 #define SCE_INNO_COMMENT_PASCAL 7 #define SCE_INNO_KEYWORD_PASCAL 8 #define SCE_INNO_KEYWORD_USER 9 @@ -1203,8 +1238,144 @@ #define SCE_R_IDENTIFIER 9 #define SCE_R_INFIX 10 #define SCE_R_INFIXEOL 11 -#define SCLEX_ASP 29 -#define SCLEX_PHP 30 -//--Autogenerated -- end of section automatically generated from Scintilla.iface +#define SCE_MAGIK_DEFAULT 0 +#define SCE_MAGIK_COMMENT 1 +#define SCE_MAGIK_HYPER_COMMENT 16 +#define SCE_MAGIK_STRING 2 +#define SCE_MAGIK_CHARACTER 3 +#define SCE_MAGIK_NUMBER 4 +#define SCE_MAGIK_IDENTIFIER 5 +#define SCE_MAGIK_OPERATOR 6 +#define SCE_MAGIK_FLOW 7 +#define SCE_MAGIK_CONTAINER 8 +#define SCE_MAGIK_BRACKET_BLOCK 9 +#define SCE_MAGIK_BRACE_BLOCK 10 +#define SCE_MAGIK_SQBRACKET_BLOCK 11 +#define SCE_MAGIK_UNKNOWN_KEYWORD 12 +#define SCE_MAGIK_KEYWORD 13 +#define SCE_MAGIK_PRAGMA 14 +#define SCE_MAGIK_SYMBOL 15 +#define SCE_POWERSHELL_DEFAULT 0 +#define SCE_POWERSHELL_COMMENT 1 +#define SCE_POWERSHELL_STRING 2 +#define SCE_POWERSHELL_CHARACTER 3 +#define SCE_POWERSHELL_NUMBER 4 +#define SCE_POWERSHELL_VARIABLE 5 +#define SCE_POWERSHELL_OPERATOR 6 +#define SCE_POWERSHELL_IDENTIFIER 7 +#define SCE_POWERSHELL_KEYWORD 8 +#define SCE_POWERSHELL_CMDLET 9 +#define SCE_POWERSHELL_ALIAS 10 +#define SCE_MYSQL_DEFAULT 0 +#define SCE_MYSQL_COMMENT 1 +#define SCE_MYSQL_COMMENTLINE 2 +#define SCE_MYSQL_VARIABLE 3 +#define SCE_MYSQL_SYSTEMVARIABLE 4 +#define SCE_MYSQL_KNOWNSYSTEMVARIABLE 5 +#define SCE_MYSQL_NUMBER 6 +#define SCE_MYSQL_MAJORKEYWORD 7 +#define SCE_MYSQL_KEYWORD 8 +#define SCE_MYSQL_DATABASEOBJECT 9 +#define SCE_MYSQL_PROCEDUREKEYWORD 10 +#define SCE_MYSQL_STRING 11 +#define SCE_MYSQL_SQSTRING 12 +#define SCE_MYSQL_DQSTRING 13 +#define SCE_MYSQL_OPERATOR 14 +#define SCE_MYSQL_FUNCTION 15 +#define SCE_MYSQL_IDENTIFIER 16 +#define SCE_MYSQL_QUOTEDIDENTIFIER 17 +#define SCE_MYSQL_USER1 18 +#define SCE_MYSQL_USER2 19 +#define SCE_MYSQL_USER3 20 +#define SCE_MYSQL_HIDDENCOMMAND 21 +#define SCE_PO_DEFAULT 0 +#define SCE_PO_COMMENT 1 +#define SCE_PO_MSGID 2 +#define SCE_PO_MSGID_TEXT 3 +#define SCE_PO_MSGSTR 4 +#define SCE_PO_MSGSTR_TEXT 5 +#define SCE_PO_MSGCTXT 6 +#define SCE_PO_MSGCTXT_TEXT 7 +#define SCE_PO_FUZZY 8 +#define SCE_PAS_DEFAULT 0 +#define SCE_PAS_IDENTIFIER 1 +#define SCE_PAS_COMMENT 2 +#define SCE_PAS_COMMENT2 3 +#define SCE_PAS_COMMENTLINE 4 +#define SCE_PAS_PREPROCESSOR 5 +#define SCE_PAS_PREPROCESSOR2 6 +#define SCE_PAS_NUMBER 7 +#define SCE_PAS_HEXNUMBER 8 +#define SCE_PAS_WORD 9 +#define SCE_PAS_STRING 10 +#define SCE_PAS_STRINGEOL 11 +#define SCE_PAS_CHARACTER 12 +#define SCE_PAS_OPERATOR 13 +#define SCE_PAS_ASM 14 +#define SCE_SORCUS_DEFAULT 0 +#define SCE_SORCUS_COMMAND 1 +#define SCE_SORCUS_PARAMETER 2 +#define SCE_SORCUS_COMMENTLINE 3 +#define SCE_SORCUS_STRING 4 +#define SCE_SORCUS_STRINGEOL 5 +#define SCE_SORCUS_IDENTIFIER 6 +#define SCE_SORCUS_OPERATOR 7 +#define SCE_SORCUS_NUMBER 8 +#define SCE_SORCUS_CONSTANT 9 +#define SCE_POWERPRO_DEFAULT 0 +#define SCE_POWERPRO_COMMENTBLOCK 1 +#define SCE_POWERPRO_COMMENTLINE 2 +#define SCE_POWERPRO_NUMBER 3 +#define SCE_POWERPRO_WORD 4 +#define SCE_POWERPRO_WORD2 5 +#define SCE_POWERPRO_WORD3 6 +#define SCE_POWERPRO_WORD4 7 +#define SCE_POWERPRO_DOUBLEQUOTEDSTRING 8 +#define SCE_POWERPRO_SINGLEQUOTEDSTRING 9 +#define SCE_POWERPRO_LINECONTINUE 10 +#define SCE_POWERPRO_OPERATOR 11 +#define SCE_POWERPRO_IDENTIFIER 12 +#define SCE_POWERPRO_STRINGEOL 13 +#define SCE_POWERPRO_VERBATIM 14 +#define SCE_POWERPRO_ALTQUOTE 15 +#define SCE_POWERPRO_FUNCTION 16 +#define SCE_SML_DEFAULT 0 +#define SCE_SML_IDENTIFIER 1 +#define SCE_SML_TAGNAME 2 +#define SCE_SML_KEYWORD 3 +#define SCE_SML_KEYWORD2 4 +#define SCE_SML_KEYWORD3 5 +#define SCE_SML_LINENUM 6 +#define SCE_SML_OPERATOR 7 +#define SCE_SML_NUMBER 8 +#define SCE_SML_CHAR 9 +#define SCE_SML_STRING 11 +#define SCE_SML_COMMENT 12 +#define SCE_SML_COMMENT1 13 +#define SCE_SML_COMMENT2 14 +#define SCE_SML_COMMENT3 15 +#define SCE_MARKDOWN_DEFAULT 0 +#define SCE_MARKDOWN_LINE_BEGIN 1 +#define SCE_MARKDOWN_STRONG1 2 +#define SCE_MARKDOWN_STRONG2 3 +#define SCE_MARKDOWN_EM1 4 +#define SCE_MARKDOWN_EM2 5 +#define SCE_MARKDOWN_HEADER1 6 +#define SCE_MARKDOWN_HEADER2 7 +#define SCE_MARKDOWN_HEADER3 8 +#define SCE_MARKDOWN_HEADER4 9 +#define SCE_MARKDOWN_HEADER5 10 +#define SCE_MARKDOWN_HEADER6 11 +#define SCE_MARKDOWN_PRECHAR 12 +#define SCE_MARKDOWN_ULIST_ITEM 13 +#define SCE_MARKDOWN_OLIST_ITEM 14 +#define SCE_MARKDOWN_BLOCKQUOTE 15 +#define SCE_MARKDOWN_STRIKEOUT 16 +#define SCE_MARKDOWN_HRULE 17 +#define SCE_MARKDOWN_LINK 18 +#define SCE_MARKDOWN_CODE 19 +#define SCE_MARKDOWN_CODE2 20 +#define SCE_MARKDOWN_CODEBK 21 +/* --Autogenerated -- end of section automatically generated from Scintilla.iface */ #endif diff --git a/src/stc/scintilla/include/Scintilla.h b/src/stc/scintilla/include/Scintilla.h index 36aed76b8e..0687c5df26 100644 --- a/src/stc/scintilla/include/Scintilla.h +++ b/src/stc/scintilla/include/Scintilla.h @@ -1,12 +1,12 @@ -// Scintilla source code edit control +/* Scintilla source code edit control */ /** @file Scintilla.h ** Interface to the edit control. **/ -// Copyright 1998-2003 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. +/* Copyright 1998-2003 by Neil Hodgson + * The License.txt file describes the conditions under which this software may be distributed. */ -// Most of this file is automatically generated from the Scintilla.iface interface definition -// file which contains any comments about the definitions. HFacer.py does the generation. +/* Most of this file is automatically generated from the Scintilla.iface interface definition + * file which contains any comments about the definitions. HFacer.py does the generation. */ #ifndef SCINTILLA_H #define SCINTILLA_H @@ -15,18 +15,26 @@ typedef BOOL bool; #endif +#ifdef __cplusplus +extern "C" { +#endif + #if PLAT_WIN -// Return false on failure: +/* Return false on failure: */ bool Scintilla_RegisterClasses(void *hInstance); bool Scintilla_ReleaseResources(); #endif int Scintilla_LinkLexers(); -// Here should be placed typedefs for uptr_t, an unsigned integer type large enough to -// hold a pointer and sptr_t, a signed integer large enough to hold a pointer. -// May need to be changed for 64 bit platforms. -#ifdef _WIN32 -#include +#ifdef __cplusplus +} +#endif + +/* Here should be placed typedefs for uptr_t, an unsigned integer type large enough to + * hold a pointer and sptr_t, a signed integer large enough to hold a pointer. + * May need to be changed for 64 bit platforms. */ +#if defined(_WIN32) +#include #endif #ifdef MAXULONG_PTR typedef ULONG_PTR uptr_t; @@ -38,7 +46,7 @@ typedef long sptr_t; typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, sptr_t lParam); -//++Autogenerated -- start of section automatically generated from Scintilla.iface +/* ++Autogenerated -- start of section automatically generated from Scintilla.iface */ #define INVALID_POSITION -1 #define SCI_START 2000 #define SCI_OPTIONAL_START 3000 @@ -118,6 +126,9 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_MARK_ARROWS 24 #define SC_MARK_PIXMAP 25 #define SC_MARK_FULLRECT 26 +#define SC_MARK_LEFTRECT 27 +#define SC_MARK_AVAILABLE 28 +#define SC_MARK_UNDERLINE 29 #define SC_MARK_CHARACTER 10000 #define SC_MARKNUM_FOLDEREND 25 #define SC_MARKNUM_FOLDEROPENMID 26 @@ -143,6 +154,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_MARGIN_NUMBER 1 #define SC_MARGIN_BACK 2 #define SC_MARGIN_FORE 3 +#define SC_MARGIN_TEXT 4 +#define SC_MARGIN_RTEXT 5 #define SCI_SETMARGINTYPEN 2240 #define SCI_GETMARGINTYPEN 2241 #define SCI_SETMARGINWIDTHN 2242 @@ -249,6 +262,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_INDICGETUNDER 2511 #define SCI_SETWHITESPACEFORE 2084 #define SCI_SETWHITESPACEBACK 2085 +#define SCI_SETWHITESPACESIZE 2086 +#define SCI_GETWHITESPACESIZE 2087 #define SCI_SETSTYLEBITS 2090 #define SCI_GETSTYLEBITS 2091 #define SCI_SETLINESTATE 2092 @@ -394,10 +409,6 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_FOLDLEVELBASE 0x400 #define SC_FOLDLEVELWHITEFLAG 0x1000 #define SC_FOLDLEVELHEADERFLAG 0x2000 -#define SC_FOLDLEVELBOXHEADERFLAG 0x4000 -#define SC_FOLDLEVELBOXFOOTERFLAG 0x8000 -#define SC_FOLDLEVELCONTRACTED 0x10000 -#define SC_FOLDLEVELUNINDENT 0x20000 #define SC_FOLDLEVELNUMBERMASK 0x0FFF #define SCI_SETFOLDLEVEL 2222 #define SCI_GETFOLDLEVEL 2223 @@ -415,7 +426,6 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_FOLDFLAG_LINEAFTER_EXPANDED 0x0008 #define SC_FOLDFLAG_LINEAFTER_CONTRACTED 0x0010 #define SC_FOLDFLAG_LEVELNUMBERS 0x0040 -#define SC_FOLDFLAG_BOX 0x0001 #define SCI_SETFOLDFLAGS 2233 #define SCI_ENSUREVISIBLEENFORCEPOLICY 2234 #define SCI_SETTABINDENTS 2260 @@ -444,6 +454,11 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETWRAPVISUALFLAGSLOCATION 2463 #define SCI_SETWRAPSTARTINDENT 2464 #define SCI_GETWRAPSTARTINDENT 2465 +#define SC_WRAPINDENT_FIXED 0 +#define SC_WRAPINDENT_SAME 1 +#define SC_WRAPINDENT_INDENT 2 +#define SCI_SETWRAPINDENTMODE 2472 +#define SCI_GETWRAPINDENTMODE 2473 #define SC_CACHE_NONE 0 #define SC_CACHE_CARET 1 #define SC_CACHE_PAGE 2 @@ -463,6 +478,14 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_APPENDTEXT 2282 #define SCI_GETTWOPHASEDRAW 2283 #define SCI_SETTWOPHASEDRAW 2284 +#define SC_EFF_QUALITY_MASK 0xF +#define SC_EFF_QUALITY_DEFAULT 0 +#define SC_EFF_QUALITY_NON_ANTIALIASED 1 +#define SC_EFF_QUALITY_ANTIALIASED 2 +#define SC_EFF_QUALITY_LCD_OPTIMIZED 3 +#define SCI_SETFONTQUALITY 2611 +#define SCI_GETFONTQUALITY 2612 +#define SCI_SETFIRSTVISIBLELINE 2613 #define SCI_TARGETFROMSELECTION 2287 #define SCI_LINESJOIN 2288 #define SCI_LINESSPLIT 2289 @@ -559,6 +582,9 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETMODEVENTMASK 2378 #define SCI_SETFOCUS 2380 #define SCI_GETFOCUS 2381 +#define SC_STATUS_OK 0 +#define SC_STATUS_FAILURE 1 +#define SC_STATUS_BADALLOC 2 #define SCI_SETSTATUS 2382 #define SCI_GETSTATUS 2383 #define SCI_SETMOUSEDOWNCAPTURES 2384 @@ -609,6 +635,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_SEL_STREAM 0 #define SC_SEL_RECTANGLE 1 #define SC_SEL_LINES 2 +#define SC_SEL_THIN 3 #define SCI_SETSELECTIONMODE 2422 #define SCI_GETSELECTIONMODE 2423 #define SCI_GETLINESELSTARTPOSITION 2424 @@ -633,6 +660,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_SETWHITESPACECHARS 2443 #define SCI_SETCHARSDEFAULT 2444 #define SCI_AUTOCGETCURRENT 2445 +#define SCI_AUTOCGETCURRENTTEXT 2610 #define SCI_ALLOCATE 2446 #define SCI_TARGETASUTF8 2447 #define SCI_SETLENGTHFORENCODE 2448 @@ -666,6 +694,94 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_INDICATOREND 2509 #define SCI_SETPOSITIONCACHE 2514 #define SCI_GETPOSITIONCACHE 2515 +#define SCI_COPYALLOWLINE 2519 +#define SCI_GETCHARACTERPOINTER 2520 +#define SCI_SETKEYSUNICODE 2521 +#define SCI_GETKEYSUNICODE 2522 +#define SCI_INDICSETALPHA 2523 +#define SCI_INDICGETALPHA 2524 +#define SCI_SETEXTRAASCENT 2525 +#define SCI_GETEXTRAASCENT 2526 +#define SCI_SETEXTRADESCENT 2527 +#define SCI_GETEXTRADESCENT 2528 +#define SCI_MARKERSYMBOLDEFINED 2529 +#define SCI_MARGINSETTEXT 2530 +#define SCI_MARGINGETTEXT 2531 +#define SCI_MARGINSETSTYLE 2532 +#define SCI_MARGINGETSTYLE 2533 +#define SCI_MARGINSETSTYLES 2534 +#define SCI_MARGINGETSTYLES 2535 +#define SCI_MARGINTEXTCLEARALL 2536 +#define SCI_MARGINSETSTYLEOFFSET 2537 +#define SCI_MARGINGETSTYLEOFFSET 2538 +#define SCI_ANNOTATIONSETTEXT 2540 +#define SCI_ANNOTATIONGETTEXT 2541 +#define SCI_ANNOTATIONSETSTYLE 2542 +#define SCI_ANNOTATIONGETSTYLE 2543 +#define SCI_ANNOTATIONSETSTYLES 2544 +#define SCI_ANNOTATIONGETSTYLES 2545 +#define SCI_ANNOTATIONGETLINES 2546 +#define SCI_ANNOTATIONCLEARALL 2547 +#define ANNOTATION_HIDDEN 0 +#define ANNOTATION_STANDARD 1 +#define ANNOTATION_BOXED 2 +#define SCI_ANNOTATIONSETVISIBLE 2548 +#define SCI_ANNOTATIONGETVISIBLE 2549 +#define SCI_ANNOTATIONSETSTYLEOFFSET 2550 +#define SCI_ANNOTATIONGETSTYLEOFFSET 2551 +#define UNDO_MAY_COALESCE 1 +#define SCI_ADDUNDOACTION 2560 +#define SCI_CHARPOSITIONFROMPOINT 2561 +#define SCI_CHARPOSITIONFROMPOINTCLOSE 2562 +#define SCI_SETMULTIPLESELECTION 2563 +#define SCI_GETMULTIPLESELECTION 2564 +#define SCI_SETADDITIONALSELECTIONTYPING 2565 +#define SCI_GETADDITIONALSELECTIONTYPING 2566 +#define SCI_SETADDITIONALCARETSBLINK 2567 +#define SCI_GETADDITIONALCARETSBLINK 2568 +#define SCI_SETADDITIONALCARETSVISIBLE 2608 +#define SCI_GETADDITIONALCARETSVISIBLE 2609 +#define SCI_GETSELECTIONS 2570 +#define SCI_CLEARSELECTIONS 2571 +#define SCI_SETSELECTION 2572 +#define SCI_ADDSELECTION 2573 +#define SCI_SETMAINSELECTION 2574 +#define SCI_GETMAINSELECTION 2575 +#define SCI_SETSELECTIONNCARET 2576 +#define SCI_GETSELECTIONNCARET 2577 +#define SCI_SETSELECTIONNANCHOR 2578 +#define SCI_GETSELECTIONNANCHOR 2579 +#define SCI_SETSELECTIONNCARETVIRTUALSPACE 2580 +#define SCI_GETSELECTIONNCARETVIRTUALSPACE 2581 +#define SCI_SETSELECTIONNANCHORVIRTUALSPACE 2582 +#define SCI_GETSELECTIONNANCHORVIRTUALSPACE 2583 +#define SCI_SETSELECTIONNSTART 2584 +#define SCI_GETSELECTIONNSTART 2585 +#define SCI_SETSELECTIONNEND 2586 +#define SCI_GETSELECTIONNEND 2587 +#define SCI_SETRECTANGULARSELECTIONCARET 2588 +#define SCI_GETRECTANGULARSELECTIONCARET 2589 +#define SCI_SETRECTANGULARSELECTIONANCHOR 2590 +#define SCI_GETRECTANGULARSELECTIONANCHOR 2591 +#define SCI_SETRECTANGULARSELECTIONCARETVIRTUALSPACE 2592 +#define SCI_GETRECTANGULARSELECTIONCARETVIRTUALSPACE 2593 +#define SCI_SETRECTANGULARSELECTIONANCHORVIRTUALSPACE 2594 +#define SCI_GETRECTANGULARSELECTIONANCHORVIRTUALSPACE 2595 +#define SCVS_NONE 0 +#define SCVS_RECTANGULARSELECTION 1 +#define SCVS_USERACCESSIBLE 2 +#define SCI_SETVIRTUALSPACEOPTIONS 2596 +#define SCI_GETVIRTUALSPACEOPTIONS 2597 +#define SCI_SETRECTANGULARSELECTIONMODIFIER 2598 +#define SCI_GETRECTANGULARSELECTIONMODIFIER 2599 +#define SCI_SETADDITIONALSELFORE 2600 +#define SCI_SETADDITIONALSELBACK 2601 +#define SCI_SETADDITIONALSELALPHA 2602 +#define SCI_GETADDITIONALSELALPHA 2603 +#define SCI_SETADDITIONALCARETFORE 2604 +#define SCI_GETADDITIONALCARETFORE 2605 +#define SCI_ROTATESELECTION 2606 +#define SCI_SWAPMAINANCHORCARET 2607 #define SCI_STARTRECORD 3001 #define SCI_STOPRECORD 3002 #define SCI_SETLEXER 4001 @@ -680,6 +796,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCI_GETPROPERTYEXPANDED 4009 #define SCI_GETPROPERTYINT 4010 #define SCI_GETSTYLEBITSNEEDED 4011 +#define SCI_GETLEXERLANGUAGE 4012 #define SC_MOD_INSERTTEXT 0x1 #define SC_MOD_DELETETEXT 0x2 #define SC_MOD_CHANGESTYLE 0x4 @@ -696,7 +813,10 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_STARTACTION 0x2000 #define SC_MOD_CHANGEINDICATOR 0x4000 #define SC_MOD_CHANGELINESTATE 0x8000 -#define SC_MODEVENTMASKALL 0xFFFF +#define SC_MOD_CHANGEMARGIN 0x10000 +#define SC_MOD_CHANGEANNOTATION 0x20000 +#define SC_MOD_CONTAINER 0x40000 +#define SC_MODEVENTMASKALL 0x7FFFF #define SCEN_CHANGE 768 #define SCEN_SETFOCUS 512 #define SCEN_KILLFOCUS 256 @@ -724,6 +844,7 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCMOD_SHIFT 1 #define SCMOD_CTRL 2 #define SCMOD_ALT 4 +#define SCMOD_SUPER 8 #define SCN_STYLENEEDED 2000 #define SCN_CHARADDED 2001 #define SCN_SAVEPOINTREACHED 2002 @@ -748,95 +869,91 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SCN_AUTOCSELECTION 2022 #define SCN_INDICATORCLICK 2023 #define SCN_INDICATORRELEASE 2024 -//--Autogenerated -- end of section automatically generated from Scintilla.iface +#define SCN_AUTOCCANCELLED 2025 +#define SCN_AUTOCCHARDELETED 2026 +/* --Autogenerated -- end of section automatically generated from Scintilla.iface */ -// These structures are defined to be exactly the same shape as the Win32 -// CHARRANGE, TEXTRANGE, FINDTEXTEX, FORMATRANGE, and NMHDR structs. -// So older code that treats Scintilla as a RichEdit will work. +/* These structures are defined to be exactly the same shape as the Win32 + * CHARRANGE, TEXTRANGE, FINDTEXTEX, FORMATRANGE, and NMHDR structs. + * So older code that treats Scintilla as a RichEdit will work. */ #ifdef SCI_NAMESPACE namespace Scintilla { #endif -struct CharacterRange { +struct Sci_CharacterRange { long cpMin; long cpMax; }; -struct TextRange { - struct CharacterRange chrg; +struct Sci_TextRange { + struct Sci_CharacterRange chrg; char *lpstrText; }; -struct TextToFind { - struct CharacterRange chrg; +struct Sci_TextToFind { + struct Sci_CharacterRange chrg; char *lpstrText; - struct CharacterRange chrgText; + struct Sci_CharacterRange chrgText; }; +#define CharacterRange Sci_CharacterRange +#define TextRange Sci_TextRange +#define TextToFind Sci_TextToFind + #ifdef PLATFORM_H -// This structure is used in printing and requires some of the graphics types -// from Platform.h. Not needed by most client code. +/* This structure is used in printing and requires some of the graphics types + * from Platform.h. Not needed by most client code. */ -struct RangeToFormat { +struct Sci_RangeToFormat { SurfaceID hdc; SurfaceID hdcTarget; PRectangle rc; PRectangle rcPage; - CharacterRange chrg; + Sci_CharacterRange chrg; }; +#define RangeToFormat Sci_RangeToFormat + #endif -struct NotifyHeader { - // Compatible with Windows NMHDR. - // hwndFrom is really an environment specific window handle or pointer - // but most clients of Scintilla.h do not have this type visible. +struct Sci_NotifyHeader { + /* Compatible with Windows NMHDR. + * hwndFrom is really an environment specific window handle or pointer + * but most clients of Scintilla.h do not have this type visible. */ void *hwndFrom; uptr_t idFrom; unsigned int code; }; +#define NotifyHeader Sci_NotifyHeader + struct SCNotification { - struct NotifyHeader nmhdr; - int position; // SCN_STYLENEEDED, SCN_MODIFIED, SCN_DWELLSTART, SCN_DWELLEND - int ch; // SCN_CHARADDED, SCN_KEY - int modifiers; // SCN_KEY - int modificationType; // SCN_MODIFIED - const char *text; // SCN_MODIFIED, SCN_USERLISTSELECTION, SCN_AUTOCSELECTION - int length; // SCN_MODIFIED - int linesAdded; // SCN_MODIFIED - int message; // SCN_MACRORECORD - uptr_t wParam; // SCN_MACRORECORD - sptr_t lParam; // SCN_MACRORECORD - int line; // SCN_MODIFIED - int foldLevelNow; // SCN_MODIFIED - int foldLevelPrev; // SCN_MODIFIED - int margin; // SCN_MARGINCLICK - int listType; // SCN_USERLISTSELECTION - int x; // SCN_DWELLSTART, SCN_DWELLEND - int y; // SCN_DWELLSTART, SCN_DWELLEND + struct Sci_NotifyHeader nmhdr; + int position; /* SCN_STYLENEEDED, SCN_MODIFIED, SCN_DWELLSTART, SCN_DWELLEND */ + int ch; /* SCN_CHARADDED, SCN_KEY */ + int modifiers; /* SCN_KEY */ + int modificationType; /* SCN_MODIFIED */ + const char *text; /* SCN_MODIFIED, SCN_USERLISTSELECTION, SCN_AUTOCSELECTION */ + int length; /* SCN_MODIFIED */ + int linesAdded; /* SCN_MODIFIED */ + int message; /* SCN_MACRORECORD */ + uptr_t wParam; /* SCN_MACRORECORD */ + sptr_t lParam; /* SCN_MACRORECORD */ + int line; /* SCN_MODIFIED */ + int foldLevelNow; /* SCN_MODIFIED */ + int foldLevelPrev; /* SCN_MODIFIED */ + int margin; /* SCN_MARGINCLICK */ + int listType; /* SCN_USERLISTSELECTION */ + int x; /* SCN_DWELLSTART, SCN_DWELLEND */ + int y; /* SCN_DWELLSTART, SCN_DWELLEND */ + int token; /* SCN_MODIFIED with SC_MOD_CONTAINER */ + int annotationLinesAdded; /* SC_MOD_CHANGEANNOTATION */ }; #ifdef SCI_NAMESPACE } #endif -// Deprecation section listing all API features that are deprecated and will -// will be removed completely in a future version. -// To enable these features define INCLUDE_DEPRECATED_FEATURES - -#ifdef INCLUDE_DEPRECATED_FEATURES - -#define SCI_SETCARETPOLICY 2369 -#define CARET_CENTER 0x02 -#define CARET_XEVEN 0x08 -#define CARET_XJUMPS 0x10 - -#define SCN_POSCHANGED 2012 -#define SCN_CHECKBRACE 2007 - -#endif - #endif diff --git a/src/stc/scintilla/include/Scintilla.iface b/src/stc/scintilla/include/Scintilla.iface index a6626d2335..f2810454d5 100644 --- a/src/stc/scintilla/include/Scintilla.iface +++ b/src/stc/scintilla/include/Scintilla.iface @@ -104,7 +104,7 @@ fun void ClearAll=2004(,) # Set all style bytes to 0, remove all folding information. fun void ClearDocumentStyle=2005(,) -# Returns the number of characters in the document. +# Returns the number of bytes in the document. get int GetLength=2006(,) # Returns the character byte at the position. @@ -268,6 +268,9 @@ val SC_MARK_DOTDOTDOT=23 val SC_MARK_ARROWS=24 val SC_MARK_PIXMAP=25 val SC_MARK_FULLRECT=26 +val SC_MARK_LEFTRECT=27 +val SC_MARK_AVAILABLE=28 +val SC_MARK_UNDERLINE=29 val SC_MARK_CHARACTER=10000 @@ -324,6 +327,8 @@ val SC_MARGIN_SYMBOL=0 val SC_MARGIN_NUMBER=1 val SC_MARGIN_BACK=2 val SC_MARGIN_FORE=3 +val SC_MARGIN_TEXT=4 +val SC_MARGIN_RTEXT=5 # Set a margin to be either numeric or symbolic. set void SetMarginTypeN=2240(int margin, int marginType) @@ -472,10 +477,10 @@ set void StyleSetCharacterSet=2066(int style, int characterSet) # Set a style to be a hotspot or not. set void StyleSetHotSpot=2409(int style, bool hotspot) -# Set the foreground colour of the selection and whether to use this setting. +# Set the foreground colour of the main and additional selections and whether to use this setting. fun void SetSelFore=2067(bool useSetting, colour fore) -# Set the background colour of the selection and whether to use this setting. +# Set the background colour of the main and additional selections and whether to use this setting. fun void SetSelBack=2068(bool useSetting, colour back) # Get the alpha of the selection. @@ -515,7 +520,7 @@ get int GetCaretPeriod=2075(,) set void SetCaretPeriod=2076(int periodMilliseconds,) # Set the set of characters making up words for when moving or selecting by word. -# First sets deaults like SetCharsDefault. +# First sets defaults like SetCharsDefault. set void SetWordChars=2077(, string characters) # Start a sequence of actions that is undone and redone as a unit. @@ -566,6 +571,12 @@ fun void SetWhitespaceFore=2084(bool useSetting, colour fore) # Set the background colour of all whitespace and whether to use this setting. fun void SetWhitespaceBack=2085(bool useSetting, colour back) +# Set the size of the dots used to mark space characters. +set void SetWhitespaceSize=2086(int size,) + +# Get the size of the dots used to mark space characters. +get int GetWhitespaceSize=2087(,) + # Divide each styling byte into lexical class bits (default: 5) and indicator # bits (default: 3). If a lexer requires more than 32 lexical states, then this # is used to expand the possible states. @@ -1010,10 +1021,6 @@ enu FoldLevel=SC_FOLDLEVEL val SC_FOLDLEVELBASE=0x400 val SC_FOLDLEVELWHITEFLAG=0x1000 val SC_FOLDLEVELHEADERFLAG=0x2000 -val SC_FOLDLEVELBOXHEADERFLAG=0x4000 -val SC_FOLDLEVELBOXFOOTERFLAG=0x8000 -val SC_FOLDLEVELCONTRACTED=0x10000 -val SC_FOLDLEVELUNINDENT=0x20000 val SC_FOLDLEVELNUMBERMASK=0x0FFF # Set the fold level of a line. @@ -1057,7 +1064,6 @@ val SC_FOLDFLAG_LINEBEFORE_CONTRACTED=0x0004 val SC_FOLDFLAG_LINEAFTER_EXPANDED=0x0008 val SC_FOLDFLAG_LINEAFTER_CONTRACTED=0x0010 val SC_FOLDFLAG_LEVELNUMBERS=0x0040 -val SC_FOLDFLAG_BOX=0x0001 # Set some style options for folding. fun void SetFoldFlags=2233(int flags,) @@ -1131,6 +1137,17 @@ set void SetWrapStartIndent=2464(int indent,) # Retrive the start indent for wrapped lines. get int GetWrapStartIndent=2465(,) +enu WrapIndentMode=SC_WRAPINDENT_ +val SC_WRAPINDENT_FIXED=0 +val SC_WRAPINDENT_SAME=1 +val SC_WRAPINDENT_INDENT=2 + +# Sets how wrapped sublines are placed. Default is fixed. +set void SetWrapIndentMode=2472(int mode,) + +# Retrieve how wrapped sublines are placed. Default is fixed. +get int GetWrapIndentMode=2473(,) + enu LineCache=SC_CACHE_ val SC_CACHE_NONE=0 val SC_CACHE_CARET=1 @@ -1188,6 +1205,24 @@ get bool GetTwoPhaseDraw=2283(,) # and then the foreground. This avoids chopping off characters that overlap the next run. set void SetTwoPhaseDraw=2284(bool twoPhase,) +# Control font anti-aliasing. + +enu FontQuality=SC_EFF_ +val SC_EFF_QUALITY_MASK=0xF +val SC_EFF_QUALITY_DEFAULT=0 +val SC_EFF_QUALITY_NON_ANTIALIASED=1 +val SC_EFF_QUALITY_ANTIALIASED=2 +val SC_EFF_QUALITY_LCD_OPTIMIZED=3 + +# Choose the quality level for text from the FontQuality enumeration. +set void SetFontQuality=2611(int fontQuality,) + +# Retrieve the quality level for text. +get int GetFontQuality=2612(,) + +# Scroll so that a display line is at the top of the display. +set void SetFirstVisibleLine=2613(int lineDisplay,) + # Make the target range start and end be the same as the selection range start and end. fun void TargetFromSelection=2287(,) @@ -1382,7 +1417,7 @@ fun void LineCopy=2455(,) # Move the caret inside current view if it's not there already. fun void MoveCaretInsideView=2401(,) -# How many characters are on a line, not including end of line characters? +# How many characters are on a line, including end of line characters? fun int LineLength=2350(int line,) # Highlight the characters at two positions. @@ -1477,6 +1512,11 @@ set void SetFocus=2380(bool focus,) # Get internal focus flag. get bool GetFocus=2381(,) +enu Status=SC_STATUS_ +val SC_STATUS_OK=0 +val SC_STATUS_FAILURE=1 +val SC_STATUS_BADALLOC=2 + # Change error status - 0 = OK. set void SetStatus=2382(int statusCode,) # Get error status. @@ -1535,7 +1575,7 @@ fun void ChooseCaretX=2399(,) # Set the focus to this Scintilla widget. fun void GrabFocus=2400(,) -enu CaretPolicy = CARET_ +enu CaretPolicy=CARET_ # Caret policy, used by SetXCaretPolicy and SetYCaretPolicy. # If CARET_SLOP is set, we can define a slop value: caretSlop. # This value defines an unwanted zone (UZ) where the caret is... unwanted. @@ -1617,13 +1657,13 @@ fun void CopyRange=2419(position start, position end) # Copy argument text to the clipboard. fun void CopyText=2420(int length, string text) -# Selection Modes enu SelectionMode=SC_SEL_ val SC_SEL_STREAM=0 val SC_SEL_RECTANGLE=1 val SC_SEL_LINES=2 +val SC_SEL_THIN=3 -# Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or +# Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE/SC_SEL_THIN) or # by lines (SC_SEL_LINES). set void SetSelectionMode=2422(int mode,) @@ -1702,6 +1742,10 @@ fun void SetCharsDefault=2444(,) # Get currently selected item position in the auto-completion list fun int AutoCGetCurrent=2445(,) +# Get currently selected item text in the auto-completion list +# Returns the length of the item text +fun int AutoCGetCurrentText=2610(, stringresult s) + # Enlarge the document to a particular size of text bytes. fun void Allocate=2446(int bytes,) @@ -1750,7 +1794,6 @@ set void SetCaretLineBackAlpha=2470(int alpha,) # Get the background alpha of the caret line. get int GetCaretLineBackAlpha=2471(,) -# Caret Styles enu CaretStyle=CARETSTYLE_ val CARETSTYLE_INVISIBLE=0 val CARETSTYLE_LINE=1 @@ -1798,6 +1841,236 @@ set void SetPositionCache=2514(int size,) # How many entries are allocated to the position cache? get int GetPositionCache=2515(,) +# Copy the selection, if selection empty copy the line with the caret +fun void CopyAllowLine=2519(,) + +# Compact the document buffer and return a read-only pointer to the +# characters in the document. +get int GetCharacterPointer=2520(,) + +# Always interpret keyboard input as Unicode +set void SetKeysUnicode=2521(bool keysUnicode,) + +# Are keys always interpreted as Unicode? +get bool GetKeysUnicode=2522(,) + +# Set the alpha fill colour of the given indicator. +set void IndicSetAlpha=2523(int indicator, int alpha) + +# Get the alpha fill colour of the given indicator. +get int IndicGetAlpha=2524(int indicator,) + +# Set extra ascent for each line +set void SetExtraAscent=2525(int extraAscent,) + +# Get extra ascent for each line +get int GetExtraAscent=2526(,) + +# Set extra descent for each line +set void SetExtraDescent=2527(int extraDescent,) + +# Get extra descent for each line +get int GetExtraDescent=2528(,) + +# Which symbol was defined for markerNumber with MarkerDefine +fun int MarkerSymbolDefined=2529(int markerNumber,) + +# Set the text in the text margin for a line +set void MarginSetText=2530(int line, string text) + +# Get the text in the text margin for a line +get int MarginGetText=2531(int line, stringresult text) + +# Set the style number for the text margin for a line +set void MarginSetStyle=2532(int line, int style) + +# Get the style number for the text margin for a line +get int MarginGetStyle=2533(int line,) + +# Set the style in the text margin for a line +set void MarginSetStyles=2534(int line, string styles) + +# Get the styles in the text margin for a line +get int MarginGetStyles=2535(int line, stringresult styles) + +# Clear the margin text on all lines +fun void MarginTextClearAll=2536(,) + +# Get the start of the range of style numbers used for margin text +set void MarginSetStyleOffset=2537(int style,) + +# Get the start of the range of style numbers used for margin text +get int MarginGetStyleOffset=2538(,) + +# Set the annotation text for a line +set void AnnotationSetText=2540(int line, string text) + +# Get the annotation text for a line +get int AnnotationGetText=2541(int line, stringresult text) + +# Set the style number for the annotations for a line +set void AnnotationSetStyle=2542(int line, int style) + +# Get the style number for the annotations for a line +get int AnnotationGetStyle=2543(int line,) + +# Set the annotation styles for a line +set void AnnotationSetStyles=2544(int line, string styles) + +# Get the annotation styles for a line +get int AnnotationGetStyles=2545(int line, stringresult styles) + +# Get the number of annotation lines for a line +get int AnnotationGetLines=2546(int line,) + +# Clear the annotations from all lines +fun void AnnotationClearAll=2547(,) + +enu AnnotationVisible=ANNOTATION_ +val ANNOTATION_HIDDEN=0 +val ANNOTATION_STANDARD=1 +val ANNOTATION_BOXED=2 + +# Set the visibility for the annotations for a view +set void AnnotationSetVisible=2548(int visible,) + +# Get the visibility for the annotations for a view +get int AnnotationGetVisible=2549(,) + +# Get the start of the range of style numbers used for annotations +set void AnnotationSetStyleOffset=2550(int style,) + +# Get the start of the range of style numbers used for annotations +get int AnnotationGetStyleOffset=2551(,) + +val UNDO_MAY_COALESCE=1 + +# Add a container action to the undo stack +fun void AddUndoAction=2560(int token, int flags) + +# Find the position of a character from a point within the window. +fun position CharPositionFromPoint=2561(int x, int y) + +# Find the position of a character from a point within the window. +# Return INVALID_POSITION if not close to text. +fun position CharPositionFromPointClose=2562(int x, int y) + +# Set whether multiple selections can be made +set void SetMultipleSelection=2563(bool multipleSelection,) + +# Whether multiple selections can be made +get bool GetMultipleSelection=2564(,) + +# Set whether typing can be performed into multiple selections +set void SetAdditionalSelectionTyping=2565(bool additionalSelectionTyping,) + +# Whether typing can be performed into multiple selections +get bool GetAdditionalSelectionTyping=2566(,) + +# Set whether additional carets will blink +set void SetAdditionalCaretsBlink=2567(bool additionalCaretsBlink,) + +# Whether additional carets will blink +get bool GetAdditionalCaretsBlink=2568(,) + +# Set whether additional carets are visible +set void SetAdditionalCaretsVisible=2608(bool additionalCaretsBlink,) + +# Whether additional carets are visible +get bool GetAdditionalCaretsVisible=2609(,) + +# How many selections are there? +get int GetSelections=2570(,) + +# Clear selections to a single empty stream selection +fun void ClearSelections=2571(,) + +# Set a simple selection +fun int SetSelection=2572(int caret,int anchor) + +# Add a selection +fun int AddSelection=2573(int caret,int anchor) + +# Set the main selection +set void SetMainSelection=2574(int selection,) + +# Which selection is the main selection +get int GetMainSelection=2575(,) + +set void SetSelectionNCaret=2576(int selection, position pos) +get position GetSelectionNCaret=2577(int selection,) +set void SetSelectionNAnchor=2578(int selection, position posAnchor) +get position GetSelectionNAnchor=2579(int selection,) +set void SetSelectionNCaretVirtualSpace=2580(int selection, int space) +get int GetSelectionNCaretVirtualSpace=2581(int selection,) +set void SetSelectionNAnchorVirtualSpace=2582(int selection, int space) +get int GetSelectionNAnchorVirtualSpace=2583(int selection,) + +# Sets the position that starts the selection - this becomes the anchor. +set void SetSelectionNStart=2584(int selection, position pos) + +# Returns the position at the start of the selection. +get position GetSelectionNStart=2585(int selection,) + +# Sets the position that ends the selection - this becomes the currentPosition. +set void SetSelectionNEnd=2586(int selection, position pos,) + +# Returns the position at the end of the selection. +get position GetSelectionNEnd=2587(int selection,) + +set void SetRectangularSelectionCaret=2588(position pos,) +get position GetRectangularSelectionCaret=2589(,) +set void SetRectangularSelectionAnchor=2590(position posAnchor,) +get position GetRectangularSelectionAnchor=2591(,) +set void SetRectangularSelectionCaretVirtualSpace=2592(int space,) +get int GetRectangularSelectionCaretVirtualSpace=2593(,) +set void SetRectangularSelectionAnchorVirtualSpace=2594(int space,) +get int GetRectangularSelectionAnchorVirtualSpace=2595(,) + +enu VirtualSpace=SCVS_ +val SCVS_NONE=0 +val SCVS_RECTANGULARSELECTION=1 +val SCVS_USERACCESSIBLE=2 + +set void SetVirtualSpaceOptions=2596(int virtualSpaceOptions,) +get int GetVirtualSpaceOptions=2597(,) + +# On GTK+, allow selecting the modifier key to use for mouse-based +# rectangular selection. Often the window manager requires Alt+Mouse Drag +# for moving windows. +# Valid values are SCMOD_CTRL(default), SCMOD_ALT, or SCMOD_SUPER. + +set void SetRectangularSelectionModifier=2598(int modifier,) + +# Get the modifier key used for rectangular selection. +get int GetRectangularSelectionModifier=2599(,) + +# Set the foreground colour of additional selections. +# Must have previously called SetSelFore with non-zero first argument for this to have an effect. +set void SetAdditionalSelFore=2600(colour fore,) + +# Set the background colour of additional selections. +# Must have previously called SetSelBack with non-zero first argument for this to have an effect. +set void SetAdditionalSelBack=2601(colour back,) + +# Set the alpha of the selection. +set void SetAdditionalSelAlpha=2602(int alpha,) + +# Get the alpha of the selection. +get int GetAdditionalSelAlpha=2603(,) + +# Set the foreground colour of additional carets. +set void SetAdditionalCaretFore=2604(colour fore,) + +# Get the foreground colour of additional carets. +get colour GetAdditionalCaretFore=2605(,) + +# Set the main selection to the next selection. +fun void RotateSelection=2606(,) + +# Swap that caret and anchor of the main selection. +fun void SwapMainAnchorCaret=2607(,) + # Start notifying the container of all key presses and commands. fun void StartRecord=3001(,) @@ -1842,6 +2115,10 @@ get int GetPropertyInt=4010(string key,) # Retrieve the number of bits the current lexer needs for styling. get int GetStyleBitsNeeded=4011(,) +# Retrieve the name of the lexer. +# Return the length of the text. +get int GetLexerLanguage=4012(, stringresult text) + # Notifications # Type of modification and the action which caused the modification. # These are defined as a bit mask to make it easy to specify which notifications are wanted. @@ -1863,7 +2140,10 @@ val SC_MULTILINEUNDOREDO=0x1000 val SC_STARTACTION=0x2000 val SC_MOD_CHANGEINDICATOR=0x4000 val SC_MOD_CHANGELINESTATE=0x8000 -val SC_MODEVENTMASKALL=0xFFFF +val SC_MOD_CHANGEMARGIN=0x10000 +val SC_MOD_CHANGEANNOTATION=0x20000 +val SC_MOD_CONTAINER=0x40000 +val SC_MODEVENTMASKALL=0x7FFFF # For compatibility, these go through the COMMAND notification rather than NOTIFY # and should have had exactly the same values as the EN_* constants. @@ -1904,6 +2184,7 @@ val SCMOD_NORM=0 val SCMOD_SHIFT=1 val SCMOD_CTRL=2 val SCMOD_ALT=4 +val SCMOD_SUPER=8 ################################################ # For SciLexer.h @@ -1993,12 +2274,25 @@ val SCLEX_PROGRESS=83 val SCLEX_ABAQUS=84 val SCLEX_ASYMPTOTE=85 val SCLEX_R=86 +val SCLEX_MAGIK=87 +val SCLEX_POWERSHELL=88 +val SCLEX_MYSQL=89 +val SCLEX_PO=90 +val SCLEX_TAL=91 +val SCLEX_COBOL=92 +val SCLEX_TACL=93 +val SCLEX_SORCUS=94 +val SCLEX_POWERPRO=95 +val SCLEX_NIMROD=96 +val SCLEX_SML=97 +val SCLEX_MARKDOWN=98 # When a lexer specifies its language as SCLEX_AUTOMATIC it receives a # value assigned in sequence from SCLEX_AUTOMATIC+1. val SCLEX_AUTOMATIC=1000 # Lexical states for SCLEX_PYTHON lex Python=SCLEX_PYTHON SCE_P_ +lex Nimrod=SCLEX_NIMROD SCE_P_ val SCE_P_DEFAULT=0 val SCE_P_COMMENTLINE=1 val SCE_P_NUMBER=2 @@ -2017,7 +2311,6 @@ val SCE_P_WORD2=14 val SCE_P_DECORATOR=15 # Lexical states for SCLEX_CPP lex Cpp=SCLEX_CPP SCE_C_ -lex Pascal=SCLEX_PASCAL SCE_C_ lex BullAnt=SCLEX_BULLANT SCE_C_ val SCE_C_DEFAULT=0 val SCE_C_COMMENT=1 @@ -2059,6 +2352,11 @@ val SCE_D_IDENTIFIER=14 val SCE_D_COMMENTLINEDOC=15 val SCE_D_COMMENTDOCKEYWORD=16 val SCE_D_COMMENTDOCKEYWORDERROR=17 +val SCE_D_STRINGB=18 +val SCE_D_STRINGR=19 +val SCE_D_WORD5=20 +val SCE_D_WORD6=21 +val SCE_D_WORD7=22 # Lexical states for SCLEX_TCL lex TCL=SCLEX_TCL SCE_TCL_ val SCE_TCL_DEFAULT=0 @@ -2396,6 +2694,7 @@ val SCE_DIFF_HEADER=3 val SCE_DIFF_POSITION=4 val SCE_DIFF_DELETED=5 val SCE_DIFF_ADDED=6 +val SCE_DIFF_CHANGED=7 # Lexical states for SCLEX_CONF (Apache Configuration Files Lexer) lex Conf=SCLEX_CONF SCE_CONF_ val SCE_CONF_DEFAULT=0 @@ -2589,6 +2888,11 @@ val SCE_CSS_DOUBLESTRING=13 val SCE_CSS_SINGLESTRING=14 val SCE_CSS_IDENTIFIER2=15 val SCE_CSS_ATTRIBUTE=16 +val SCE_CSS_IDENTIFIER3=17 +val SCE_CSS_PSEUDOELEMENT=18 +val SCE_CSS_EXTENDED_IDENTIFIER=19 +val SCE_CSS_EXTENDED_PSEUDOCLASS=20 +val SCE_CSS_EXTENDED_PSEUDOELEMENT=21 # Lexical states for SCLEX_POV lex POV=SCLEX_POV SCE_POV_ val SCE_POV_DEFAULT=0 @@ -2764,8 +3068,19 @@ val SCE_ERLANG_FUNCTION_NAME=8 val SCE_ERLANG_CHARACTER=9 val SCE_ERLANG_MACRO=10 val SCE_ERLANG_RECORD=11 -val SCE_ERLANG_SEPARATOR=12 +val SCE_ERLANG_PREPROC=12 val SCE_ERLANG_NODE_NAME=13 +val SCE_ERLANG_COMMENT_FUNCTION=14 +val SCE_ERLANG_COMMENT_MODULE=15 +val SCE_ERLANG_COMMENT_DOC=16 +val SCE_ERLANG_COMMENT_DOC_MACRO=17 +val SCE_ERLANG_ATOM_QUOTED=18 +val SCE_ERLANG_MACRO_QUOTED=19 +val SCE_ERLANG_RECORD_QUOTED=20 +val SCE_ERLANG_NODE_NAME_QUOTED=21 +val SCE_ERLANG_BIFS=22 +val SCE_ERLANG_MODULES=23 +val SCE_ERLANG_MODULES_ATT=24 val SCE_ERLANG_UNKNOWN=31 # Lexical states for SCLEX_OCTAVE are identical to MatLab lex Octave=SCLEX_OCTAVE SCE_MATLAB_ @@ -2937,6 +3252,7 @@ val SCE_CAML_LINENUM=6 val SCE_CAML_OPERATOR=7 val SCE_CAML_NUMBER=8 val SCE_CAML_CHAR=9 +val SCE_CAML_WHITE=10 val SCE_CAML_STRING=11 val SCE_CAML_COMMENT=12 val SCE_CAML_COMMENT1=13 @@ -3110,7 +3426,7 @@ val SCE_INNO_KEYWORD=2 val SCE_INNO_PARAMETER=3 val SCE_INNO_SECTION=4 val SCE_INNO_PREPROC=5 -val SCE_INNO_PREPROC_INLINE=6 +val SCE_INNO_INLINE_EXPANSION=6 val SCE_INNO_COMMENT_PASCAL=7 val SCE_INNO_KEYWORD_PASCAL=8 val SCE_INNO_KEYWORD_USER=9 @@ -3258,6 +3574,162 @@ val SCE_R_OPERATOR=8 val SCE_R_IDENTIFIER=9 val SCE_R_INFIX=10 val SCE_R_INFIXEOL=11 +# Lexical state for SCLEX_MAGIKSF +lex MagikSF=SCLEX_MAGIKSF SCE_MAGIK_ +val SCE_MAGIK_DEFAULT=0 +val SCE_MAGIK_COMMENT=1 +val SCE_MAGIK_HYPER_COMMENT=16 +val SCE_MAGIK_STRING=2 +val SCE_MAGIK_CHARACTER=3 +val SCE_MAGIK_NUMBER=4 +val SCE_MAGIK_IDENTIFIER=5 +val SCE_MAGIK_OPERATOR=6 +val SCE_MAGIK_FLOW=7 +val SCE_MAGIK_CONTAINER=8 +val SCE_MAGIK_BRACKET_BLOCK=9 +val SCE_MAGIK_BRACE_BLOCK=10 +val SCE_MAGIK_SQBRACKET_BLOCK=11 +val SCE_MAGIK_UNKNOWN_KEYWORD=12 +val SCE_MAGIK_KEYWORD=13 +val SCE_MAGIK_PRAGMA=14 +val SCE_MAGIK_SYMBOL=15 +# Lexical state for SCLEX_POWERSHELL +lex PowerShell=SCLEX_POWERSHELL SCE_POWERSHELL_ +val SCE_POWERSHELL_DEFAULT=0 +val SCE_POWERSHELL_COMMENT=1 +val SCE_POWERSHELL_STRING=2 +val SCE_POWERSHELL_CHARACTER=3 +val SCE_POWERSHELL_NUMBER=4 +val SCE_POWERSHELL_VARIABLE=5 +val SCE_POWERSHELL_OPERATOR=6 +val SCE_POWERSHELL_IDENTIFIER=7 +val SCE_POWERSHELL_KEYWORD=8 +val SCE_POWERSHELL_CMDLET=9 +val SCE_POWERSHELL_ALIAS=10 +# Lexical state for SCLEX_MYSQL +lex MySQL=SCLEX_MYSQL SCE_MYSQL_ +val SCE_MYSQL_DEFAULT=0 +val SCE_MYSQL_COMMENT=1 +val SCE_MYSQL_COMMENTLINE=2 +val SCE_MYSQL_VARIABLE=3 +val SCE_MYSQL_SYSTEMVARIABLE=4 +val SCE_MYSQL_KNOWNSYSTEMVARIABLE=5 +val SCE_MYSQL_NUMBER=6 +val SCE_MYSQL_MAJORKEYWORD=7 +val SCE_MYSQL_KEYWORD=8 +val SCE_MYSQL_DATABASEOBJECT=9 +val SCE_MYSQL_PROCEDUREKEYWORD=10 +val SCE_MYSQL_STRING=11 +val SCE_MYSQL_SQSTRING=12 +val SCE_MYSQL_DQSTRING=13 +val SCE_MYSQL_OPERATOR=14 +val SCE_MYSQL_FUNCTION=15 +val SCE_MYSQL_IDENTIFIER=16 +val SCE_MYSQL_QUOTEDIDENTIFIER=17 +val SCE_MYSQL_USER1=18 +val SCE_MYSQL_USER2=19 +val SCE_MYSQL_USER3=20 +val SCE_MYSQL_HIDDENCOMMAND=21 +# Lexical state for SCLEX_PO +lex Po=SCLEX_PO SCE_PO_ +val SCE_PO_DEFAULT=0 +val SCE_PO_COMMENT=1 +val SCE_PO_MSGID=2 +val SCE_PO_MSGID_TEXT=3 +val SCE_PO_MSGSTR=4 +val SCE_PO_MSGSTR_TEXT=5 +val SCE_PO_MSGCTXT=6 +val SCE_PO_MSGCTXT_TEXT=7 +val SCE_PO_FUZZY=8 +# Lexical states for SCLEX_PASCAL +lex Pascal=SCLEX_PASCAL SCE_PAS_ +val SCE_PAS_DEFAULT=0 +val SCE_PAS_IDENTIFIER=1 +val SCE_PAS_COMMENT=2 +val SCE_PAS_COMMENT2=3 +val SCE_PAS_COMMENTLINE=4 +val SCE_PAS_PREPROCESSOR=5 +val SCE_PAS_PREPROCESSOR2=6 +val SCE_PAS_NUMBER=7 +val SCE_PAS_HEXNUMBER=8 +val SCE_PAS_WORD=9 +val SCE_PAS_STRING=10 +val SCE_PAS_STRINGEOL=11 +val SCE_PAS_CHARACTER=12 +val SCE_PAS_OPERATOR=13 +val SCE_PAS_ASM=14 +# Lexical state for SCLEX_SORCUS +lex SORCUS=SCLEX_SORCUS SCE_SORCUS_ +val SCE_SORCUS_DEFAULT=0 +val SCE_SORCUS_COMMAND=1 +val SCE_SORCUS_PARAMETER=2 +val SCE_SORCUS_COMMENTLINE=3 +val SCE_SORCUS_STRING=4 +val SCE_SORCUS_STRINGEOL=5 +val SCE_SORCUS_IDENTIFIER=6 +val SCE_SORCUS_OPERATOR=7 +val SCE_SORCUS_NUMBER=8 +val SCE_SORCUS_CONSTANT=9 +# Lexical state for SCLEX_POWERPRO +lex PowerPro=SCLEX_POWERPRO SCE_POWERPRO_ +val SCE_POWERPRO_DEFAULT=0 +val SCE_POWERPRO_COMMENTBLOCK=1 +val SCE_POWERPRO_COMMENTLINE=2 +val SCE_POWERPRO_NUMBER=3 +val SCE_POWERPRO_WORD=4 +val SCE_POWERPRO_WORD2=5 +val SCE_POWERPRO_WORD3=6 +val SCE_POWERPRO_WORD4=7 +val SCE_POWERPRO_DOUBLEQUOTEDSTRING=8 +val SCE_POWERPRO_SINGLEQUOTEDSTRING=9 +val SCE_POWERPRO_LINECONTINUE=10 +val SCE_POWERPRO_OPERATOR=11 +val SCE_POWERPRO_IDENTIFIER=12 +val SCE_POWERPRO_STRINGEOL=13 +val SCE_POWERPRO_VERBATIM=14 +val SCE_POWERPRO_ALTQUOTE=15 +val SCE_POWERPRO_FUNCTION=16 +# Lexical states for SCLEX_SML +lex SML=SCLEX_SML SCE_SML_ +val SCE_SML_DEFAULT=0 +val SCE_SML_IDENTIFIER=1 +val SCE_SML_TAGNAME=2 +val SCE_SML_KEYWORD=3 +val SCE_SML_KEYWORD2=4 +val SCE_SML_KEYWORD3=5 +val SCE_SML_LINENUM=6 +val SCE_SML_OPERATOR=7 +val SCE_SML_NUMBER=8 +val SCE_SML_CHAR=9 +val SCE_SML_STRING=11 +val SCE_SML_COMMENT=12 +val SCE_SML_COMMENT1=13 +val SCE_SML_COMMENT2=14 +val SCE_SML_COMMENT3=15 +# Lexical state for SCLEX_MARKDOWN +lex Markdown=SCLEX_MARKDOWN SCE_MARKDOWN_ +val SCE_MARKDOWN_DEFAULT=0 +val SCE_MARKDOWN_LINE_BEGIN=1 +val SCE_MARKDOWN_STRONG1=2 +val SCE_MARKDOWN_STRONG2=3 +val SCE_MARKDOWN_EM1=4 +val SCE_MARKDOWN_EM2=5 +val SCE_MARKDOWN_HEADER1=6 +val SCE_MARKDOWN_HEADER2=7 +val SCE_MARKDOWN_HEADER3=8 +val SCE_MARKDOWN_HEADER4=9 +val SCE_MARKDOWN_HEADER5=10 +val SCE_MARKDOWN_HEADER6=11 +val SCE_MARKDOWN_PRECHAR=12 +val SCE_MARKDOWN_ULIST_ITEM=13 +val SCE_MARKDOWN_OLIST_ITEM=14 +val SCE_MARKDOWN_BLOCKQUOTE=15 +val SCE_MARKDOWN_STRIKEOUT=16 +val SCE_MARKDOWN_HRULE=17 +val SCE_MARKDOWN_LINK=18 +val SCE_MARKDOWN_CODE=19 +val SCE_MARKDOWN_CODE2=20 +val SCE_MARKDOWN_CODEBK=21 # Events @@ -3286,19 +3758,5 @@ evt void CallTipClick=2021(int position) evt void AutoCSelection=2022(string text) evt void IndicatorClick=2023(int modifiers, int position) evt void IndicatorRelease=2024(int modifiers, int position) - -cat Deprecated - -# CARET_POLICY changed in 1.47 -fun void SetCaretPolicy=2369(int caretPolicy, int caretSlop) -val CARET_CENTER=0x02 -val CARET_XEVEN=0x08 -val CARET_XJUMPS=0x10 - -# The old name for SCN_UPDATEUI -val SCN_CHECKBRACE=2007 -evt void PosChanged=2012(int position) - -# SCLEX_HTML should be used in preference to these. -val SCLEX_ASP=29 -val SCLEX_PHP=30 +evt void AutoCCancelled=2025(void) +evt void AutoCCharDeleted=2026(void) diff --git a/src/stc/scintilla/include/ScintillaWidget.h b/src/stc/scintilla/include/ScintillaWidget.h index 9d23ce2a91..c60c4a21b9 100644 --- a/src/stc/scintilla/include/ScintillaWidget.h +++ b/src/stc/scintilla/include/ScintillaWidget.h @@ -1,10 +1,10 @@ -// Scintilla source code edit control +/* Scintilla source code edit control */ /** @file ScintillaWidget.h ** Definition of Scintilla widget for GTK+. ** Only needed by GTK+ code but is harmless on other platforms. **/ -// Copyright 1998-2001 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. +/* Copyright 1998-2001 by Neil Hodgson + * The License.txt file describes the conditions under which this software may be distributed. */ #ifndef SCINTILLAWIDGET_H #define SCINTILLAWIDGET_H diff --git a/src/stc/scintilla/include/WindowAccessor.h b/src/stc/scintilla/include/WindowAccessor.h index e107a0659c..6f265f6580 100644 --- a/src/stc/scintilla/include/WindowAccessor.h +++ b/src/stc/scintilla/include/WindowAccessor.h @@ -12,13 +12,14 @@ namespace Scintilla { /** */ + class WindowAccessor : public Accessor { // Private so WindowAccessor objects can not be copied WindowAccessor(const WindowAccessor &source) : Accessor(), props(source.props) {} WindowAccessor &operator=(const WindowAccessor &) { return *this; } protected: WindowID id; - PropSet &props; + PropertyGet &props; int lenDoc; char styleBuf[bufferSize]; @@ -30,7 +31,7 @@ protected: bool InternalIsLeadByte(char ch); void Fill(int position); public: - WindowAccessor(WindowID id_, PropSet &props_) : + WindowAccessor(WindowID id_, PropertyGet &props_) : Accessor(), id(id_), props(props_), lenDoc(-1), validLen(0), chFlags(0), chWhile(0) { } diff --git a/src/stc/scintilla/src/Array.cpp b/src/stc/scintilla/src/Array.cpp new file mode 100644 index 0000000000..a2ec27b101 --- /dev/null +++ b/src/stc/scintilla/src/Array.cpp @@ -0,0 +1,380 @@ +/** file Array.cpp +* This file is defining a kind of tool for simulating std::vector +* for using wx on OS which are not supporting the STL +* @author foldink (foldink@gmail.com) +* @date 26-February-2010 +*/ + +#include + +#include "Platform.h" +#include "Scintilla.h" +#include "Selection.h" +#include "Array.h" + +SelectionRange& ArrayIterator::operator*() +{ + if ( m_idx >= m_parent->size() ) + throw "Error access out of bounds"; + + return (*m_parent)[m_idx]; +} + +ArrayIterator ArrayIterator::operator++(int) +{ + ArrayIterator ret(*this); + ret.m_idx++; + return ret; +} + +ArrayIterator& ArrayIterator::operator++() +{ + m_idx++; + return (*this); +} + +ArrayIterator ArrayIterator::operator--(int) +{ + if ( m_idx == 0 ) + throw "Error access out of bounds"; + + ArrayIterator ret(*this); + ret.m_idx--; + return ret; +} + +ArrayIterator& ArrayIterator::operator--() +{ + if ( m_idx == 0 ) + + + m_idx--; + return (*this); +} + +ArrayIterator ArrayIterator::operator+(size_t idx) +{ + ArrayIterator ret(*this); + ret.m_idx += idx; + return ret; +} + +ArrayIterator ArrayIterator::operator-(size_t idx) +{ + if ( idx > m_idx ) + throw "Error access out of bounds"; + + ArrayIterator ret(*this); + ret.m_idx -= idx; + return ret; +} + +ArrayIterator& ArrayIterator::operator+=(size_t idx) +{ + m_idx += idx; + return (*this); +} + +ArrayIterator& ArrayIterator::operator-=(size_t idx) +{ + if ( idx > m_idx ) + throw "Error access out of bounds"; + + m_idx -= idx; + return (*this); +} + +bool ArrayIterator::operator!=(const ArrayIterator& rhs) +{ + if ( m_parent == rhs.m_parent && m_idx == rhs.m_idx ) + return false; + + return true; +} + +bool ArrayIterator::operator==(const ArrayIterator& rhs) +{ + if ( m_parent == rhs.m_parent && m_idx == rhs.m_idx ) + return true; + + return false; +} + +Array::Array( size_t len ): + m_data(0L), + m_size(0) +{ + if ( len == 0 ) + return; + + m_data = new SelectionRange[len]; + m_size = len; +} + +Array::Array( size_t len , const SelectionRange& val ): + m_data(0L), + m_size(0) +{ + if ( len == 0 ) + return; + + m_data = new SelectionRange[len]; + m_size = len; + + for ( size_t i = 0; i < len ; ++i ) + *(m_data + i) = val; +} + +Array::Array( const Array& rhs ): + m_data(0L), + m_size(0) +{ + if ( rhs.m_size == 0 ) + return; + + m_data = new SelectionRange[rhs.m_size]; + m_size = rhs.m_size; + memcpy( m_data , rhs.m_data , m_size*sizeof(SelectionRange) ); +} + +Array::~Array() +{ + if ( m_data ) + delete m_data; +} + +Array& Array::operator=( const Array& rhs ) +{ + if ( m_data ) + delete m_data; + + m_data = 0L; + m_size = 0; + + if ( rhs.m_size == 0 ) + return (*this); + + m_data = new SelectionRange[rhs.m_size]; + m_size = rhs.m_size; + memcpy( m_data , rhs.m_data , m_size*sizeof(SelectionRange) ); + + return (*this); +} + +void Array::reserve( size_t len ) +{ + if ( len <= m_size || len == 0 ) + return; + + SelectionRange* data = 0L; + data = new SelectionRange[len]; + + if ( m_data ) { + memcpy( data , m_data , m_size*sizeof(SelectionRange) ); + delete m_data; + m_data = data; + } else + m_data = data; +} + +void Array::push_back( const SelectionRange& val ) +{ + if ( !m_data ) { + m_data = new SelectionRange[1]; + *m_data = val; + m_size = 1; + return; + } + + SelectionRange* data = 0L; + data = new SelectionRange[m_size+1]; + memcpy( data , m_data , m_size*sizeof(SelectionRange) ); + m_data = data; + *(m_data+m_size) = val; + m_size++; +} + +void Array::pop_back( ) +{ + if ( !m_data ) + throw "Error access out of bounds"; + + m_size--; + SelectionRange* data = 0L; + + if ( m_size > 0 ) { + data = new SelectionRange[m_size]; + memcpy( data , m_data , m_size*sizeof(SelectionRange) ); + } + + delete m_data; + m_data = data; +} + +void Array::insert( ArrayIterator it , SelectionRange& val ) +{ + size_t idx = it.GetIdx(); + SelectionRange* data = 0L; + if (!m_data) { + m_size = idx+1; + m_data = new SelectionRange[m_size]; + } else if ( idx >= m_size ) { + data = new SelectionRange[idx+1]; + memcpy( data , m_data , m_size*sizeof(SelectionRange) ); + m_size = idx+1; + delete m_data; + m_data = data; + } else if ( idx == 0 ) { + data = new SelectionRange[m_size+1]; + memcpy( data + 1 , m_data , m_size*sizeof(SelectionRange) ); + delete m_data; + m_size++; + m_data = data; + } else { + data = new SelectionRange[m_size+1]; + memcpy( data , m_data , idx*sizeof(SelectionRange) ); + memcpy( data + idx + 1 , m_data + idx , (m_size-idx)*sizeof(SelectionRange) ); + delete m_data; + m_size++; + m_data = data; + } + + *(m_data + idx) = val; +} + +void Array::erase( ArrayIterator it ) +{ + size_t idx = it.GetIdx(); + if (!m_data || idx >= m_size ) + throw "Error access out of bounds"; + + SelectionRange* data = 0L; + if ( m_size == 1 ) { + delete m_data; + m_data = 0L; + return; + } else if ( idx == 0) { + data = new SelectionRange[m_size-1]; + memcpy( data , m_data + 1 , (m_size-1)*sizeof(SelectionRange) ); + delete m_data; + m_size--; + m_data = data; + } else { + data = new SelectionRange[m_size-1]; + memcpy( data , m_data , (idx)*sizeof(SelectionRange) ); + memcpy( data + idx , m_data + idx + 1 , (m_size-idx-1)*sizeof(SelectionRange) ); + delete m_data; + m_size--; + m_data = data; + } +} + +void Array::clear( ) +{ + if ( !m_data ) + return; + + delete m_data; + m_data = 0L; + m_size = 0; +} + +void Array::resize( size_t n , SelectionRange val ) +{ + if ( (n == 0 && !m_data) || n <= m_size ) + return; + + if ( n == 0 ) { + delete m_data; + m_data = 0L; + m_size = 0; + } + + SelectionRange* data = 0L; + data = new SelectionRange[n]; + memcpy( data , m_data , m_size*sizeof(SelectionRange) ); + delete m_data; + m_data = data; + + for ( size_t i = m_size ; i < n ; ++i ) + *( m_data + i ) = val; + + m_size = n; +} + +bool Array::operator==(const Array& rhs) +{ + if ( m_size != rhs.m_size ) + return false; + + if ( m_size == 0 && rhs.m_size == 0 ) + return true; + + for ( size_t i = 0 ; i < m_size ; ++i ) + if ( ! ((*(m_data +i)) == (*(rhs.m_data+i))) ) + return false; + + return true; +} + +ArrayIterator Array::begin() +{ + ArrayIterator ret(this,0); + return ret; +} + +ArrayIterator Array::end() +{ + ArrayIterator ret(this,m_size); + return ret; +} + + +int partition(Array &array, int top, int bottom) +{ + SelectionRange x = array[top]; + int i = top - 1; + int j = bottom + 1; + SelectionRange temp; + do { + do { + j--; + } while (x < array[j]); + + do { + i++; + } while (array[j] < x); + + if (i < j) { + temp = array[i]; + array[i] = array[j]; + array[j] = temp; + } + } while (i < j); + return j; // returns middle subscript +} + +void quicksort(Array &num, int top, int bottom) +{ + // top = subscript of beginning of array + // bottom = subscript of end of array + + int middle; + if (top < bottom) { + middle = partition(num, top, bottom); + quicksort(num, top, middle); // sort first section + quicksort(num, middle+1, bottom); // sort second section + } + return; +} + +void ArraySort( ArrayIterator start , ArrayIterator finish ) +{ + if ( start.m_parent != finish.m_parent ) + throw "Invalid iterators parent mismatch"; + + if ( start.m_idx >= finish.m_idx-1 ) + throw "Invalid iterators are refering to bad values"; + + quicksort( *(start.m_parent) , start.m_idx , finish.m_idx-1 ); +} diff --git a/src/stc/scintilla/src/Array.h b/src/stc/scintilla/src/Array.h new file mode 100644 index 0000000000..e556912f60 --- /dev/null +++ b/src/stc/scintilla/src/Array.h @@ -0,0 +1,209 @@ +/** file Array.h +* This file is defining a kind of tool for simulating std::vector +* for using wx on OS which are not supporting the STL +* @author foldink (foldink@gmail.com) +* @date 26-February-2010 +*/ + +#ifndef ARRAY_H +#define ARRAY_H + +#include +/* defines */ +class Array; +class ArrayIterator; +//struct SelectionRange; + +/** + * @class ArrayIterator + * @brief This class is used to simulate an iterator in the array + * @author foldink (foldink@gmail.com) + * @date 26-February-2010 + */ +class ArrayIterator +{ + friend class Array; + +public : + /** ctor + * @param parent, parented array to store positions in + */ + ArrayIterator( Array* parent , size_t idx ): + m_parent(parent), + m_idx(idx) {}; + + /** dtor */ + virtual ~ArrayIterator() + { + m_parent = 0L; + } + + /** copy ctor */ + ArrayIterator(const ArrayIterator& rhs): + m_parent(rhs.m_parent), + m_idx(rhs.m_idx) { } + + /*********************************************************************** + * OPERATOR OVERLOADS + **********************************************************************/ + /** the equal operator is used to overload copy for the array */ + ArrayIterator& operator=(const ArrayIterator& rhs) + { + m_parent = rhs.m_parent; + m_idx = rhs.m_idx; + + return (*this); + } + + /** Smart pointer part overload as it is in standard templates arrays */ + SelectionRange& operator*(); + + /** a++ operator */ + ArrayIterator operator++(int); + + /** ++a operator */ + ArrayIterator& operator++(); + + /** a-- operator */ + ArrayIterator operator--(int); + + /** --a operator */ + ArrayIterator& operator--(); + + /** a + int operator */ + ArrayIterator operator+(size_t idx); + + /** a - int operator */ + ArrayIterator operator-(size_t idx); + + /** a += int operator */ + ArrayIterator& operator+=(size_t idx); + + /** a -= int operator */ + ArrayIterator& operator-=(size_t idx); + + /** != operator */ + bool operator!=(const ArrayIterator& rhs); + + /** == operator */ + bool operator==(const ArrayIterator& rhs); + + /** Set the idx if needed */ + void SetIdx(size_t idx) {m_idx = idx;}; + /** Get the idx if needed */ + size_t GetIdx() {return m_idx;}; + + Array* m_parent; + size_t m_idx; +}; + +/** + * @class Array + * @brief simple array of SelectionRange + * @brief This class is used to simulate an iterator in the array + * @author foldink (foldink@gmail.com) + * @date 26-February-2010 + */ +class Array +{ + friend class ArrayIterator; + +public : + /** default ctor taking the len in input */ + Array( size_t len = 0 ); + + /** ctor with len and initial value */ + Array( size_t len , const SelectionRange& val ); + + /** copy ctor */ + Array( const Array& rhs ); + + /** dtor */ + virtual ~Array(); + + /** operator= */ + Array& operator=( const Array& rhs ); + + /** operator[] */ + SelectionRange& operator[]( size_t idx ) + { + if( idx >= m_size ) + throw "Error access to vector range out of bounds"; + + return *(m_data + idx); + } + + /** operator[] */ + const SelectionRange& operator[]( size_t idx ) const + { + if( idx >= m_size ) + throw "Error access to vector range out of bounds"; + + return *(m_data + idx); + } + + /** Get the size */ + size_t size() const {return m_size;}; + + /** check if the array is empty or not */ + bool empty() const {return (m_size == 0);}; + + /** reserve */ + void reserve( size_t len ); + + /** front */ + SelectionRange& front() { + if( !m_data ) + throw "Trying to access to an uninitialized array"; + + return (*m_data); + } + + /** back */ + SelectionRange& back() { + if( !m_data ) + throw "Trying to access to an uninitialized array"; + + return *(m_data + m_size-1); + } + + /** push back */ + void push_back( const SelectionRange& val ); + + /** pop back */ + void pop_back( ); + + /** insert before the given iterator position */ + void insert( ArrayIterator it , SelectionRange& val ); + + /** erase */ + void erase( ArrayIterator it ); + + /** clear */ + void clear( ); + + /** resize */ + void resize( size_t n , SelectionRange val = SelectionRange() ); + + /** == operator */ + bool operator==(const Array& rhs); + + /** begin */ + ArrayIterator begin(); + + /** end */ + ArrayIterator end(); + +private : + SelectionRange* m_data; + size_t m_size; +}; + +/** + * @brief Sorting method for a replace in Editor.cxx + * @author foldink (foldink@gmail.com) + * @date 26-February-2010 + */ +extern void ArraySort( ArrayIterator start , ArrayIterator finish ); + +#endif diff --git a/src/stc/scintilla/src/AutoComplete.cxx b/src/stc/scintilla/src/AutoComplete.cxx index af6154ea13..86c64df563 100644 --- a/src/stc/scintilla/src/AutoComplete.cxx +++ b/src/stc/scintilla/src/AutoComplete.cxx @@ -11,7 +11,7 @@ #include "Platform.h" -#include "PropSet.h" +#include "CharClassify.h" #include "AutoComplete.h" #ifdef SCI_NAMESPACE diff --git a/src/stc/scintilla/src/CallTip.cxx b/src/stc/scintilla/src/CallTip.cxx index 5f795d561a..3ea2d48fd3 100644 --- a/src/stc/scintilla/src/CallTip.cxx +++ b/src/stc/scintilla/src/CallTip.cxx @@ -229,7 +229,7 @@ void CallTip::PaintCT(Surface *surfaceWindow) { offsetMain = insetX; // initial alignment assuming no arrows PaintContents(surfaceWindow, true); -#if !defined(__APPLE__) || defined(__WX__) +#ifndef __APPLE__ // OSX doesn't put borders on "help tags" // Draw a raised border around the edges of the window surfaceWindow->MoveTo(0, rcClientSize.bottom - 1); @@ -254,11 +254,9 @@ PRectangle CallTip::CallTipStart(int pos, Point pt, const char *defn, const char *faceName, int size, int codePage_, int characterSet, Window &wParent) { clickPlace = 0; - if (val) - delete []val; + delete []val; + val = 0; val = new char[strlen(defn) + 1]; - if (!val) - return PRectangle(); strcpy(val, defn); codePage = codePage_; Surface *surfaceMeasure = Surface::Allocate(); diff --git a/src/stc/scintilla/src/CallTip.h b/src/stc/scintilla/src/CallTip.h index bdf1123c74..a64755fd18 100644 --- a/src/stc/scintilla/src/CallTip.h +++ b/src/stc/scintilla/src/CallTip.h @@ -27,8 +27,8 @@ class CallTip { bool useStyleCallTip; // if true, STYLE_CALLTIP should be used // Private so CallTip objects can not be copied - CallTip(const CallTip &) {} - CallTip &operator=(const CallTip &) { return *this; } + CallTip(const CallTip &); + CallTip &operator=(const CallTip &); void DrawChunk(Surface *surface, int &x, const char *s, int posStart, int posEnd, int ytext, PRectangle rcClient, bool highlight, bool draw); diff --git a/src/stc/scintilla/src/CellBuffer.cxx b/src/stc/scintilla/src/CellBuffer.cxx index 6d04e04c91..be0440304d 100644 --- a/src/stc/scintilla/src/CellBuffer.cxx +++ b/src/stc/scintilla/src/CellBuffer.cxx @@ -21,165 +21,23 @@ using namespace Scintilla; #endif -MarkerHandleSet::MarkerHandleSet() { - root = 0; -} - -MarkerHandleSet::~MarkerHandleSet() { - MarkerHandleNumber *mhn = root; - while (mhn) { - MarkerHandleNumber *mhnToFree = mhn; - mhn = mhn->next; - delete mhnToFree; - } - root = 0; -} - -int MarkerHandleSet::Length() const { - int c = 0; - MarkerHandleNumber *mhn = root; - while (mhn) { - c++; - mhn = mhn->next; - } - return c; -} - -int MarkerHandleSet::NumberFromHandle(int handle) const { - MarkerHandleNumber *mhn = root; - while (mhn) { - if (mhn->handle == handle) { - return mhn->number; - } - mhn = mhn->next; - } - return - 1; -} - -int MarkerHandleSet::MarkValue() const { - unsigned int m = 0; - MarkerHandleNumber *mhn = root; - while (mhn) { - m |= (1 << mhn->number); - mhn = mhn->next; - } - return m; -} - -bool MarkerHandleSet::Contains(int handle) const { - MarkerHandleNumber *mhn = root; - while (mhn) { - if (mhn->handle == handle) { - return true; - } - mhn = mhn->next; - } - return false; -} - -bool MarkerHandleSet::InsertHandle(int handle, int markerNum) { - MarkerHandleNumber *mhn = new MarkerHandleNumber; - if (!mhn) - return false; - mhn->handle = handle; - mhn->number = markerNum; - mhn->next = root; - root = mhn; - return true; -} - -void MarkerHandleSet::RemoveHandle(int handle) { - MarkerHandleNumber **pmhn = &root; - while (*pmhn) { - MarkerHandleNumber *mhn = *pmhn; - if (mhn->handle == handle) { - *pmhn = mhn->next; - delete mhn; - return; - } - pmhn = &((*pmhn)->next); - } -} - -bool MarkerHandleSet::RemoveNumber(int markerNum) { - bool performedDeletion = false; - MarkerHandleNumber **pmhn = &root; - while (*pmhn) { - MarkerHandleNumber *mhn = *pmhn; - if (mhn->number == markerNum) { - *pmhn = mhn->next; - delete mhn; - performedDeletion = true; - } else { - pmhn = &((*pmhn)->next); - } - } - return performedDeletion; -} - -void MarkerHandleSet::CombineWith(MarkerHandleSet *other) { - MarkerHandleNumber **pmhn = &root; - while (*pmhn) { - pmhn = &((*pmhn)->next); - } - *pmhn = other->root; - other->root = 0; -} - -LineVector::LineVector() : starts(256) { - handleCurrent = 1; - +LineVector::LineVector() : starts(256), perLine(0) { Init(); } LineVector::~LineVector() { starts.DeleteAll(); - for (int line = 0; line < markers.Length(); line++) { - delete markers[line]; - markers[line] = 0; - } - markers.DeleteAll(); - levels.DeleteAll(); } void LineVector::Init() { starts.DeleteAll(); - for (int line = 0; line < markers.Length(); line++) { - delete markers[line]; - markers[line] = 0; + if (perLine) { + perLine->Init(); } - markers.DeleteAll(); - levels.DeleteAll(); -} - -void LineVector::ExpandLevels(int sizeNew) { - levels.InsertValue(levels.Length(), sizeNew - levels.Length(), SC_FOLDLEVELBASE); -} - -void LineVector::ClearLevels() { - levels.DeleteAll(); } -int LineVector::SetLevel(int line, int level) { - int prev = 0; - if ((line >= 0) && (line < Lines())) { - if (!levels.Length()) { - ExpandLevels(Lines() + 1); - } - prev = levels[line]; - if (prev != level) { - levels[line] = level; - } - } - return prev; -} - -int LineVector::GetLevel(int line) { - if (levels.Length() && (line >= 0) && (line < Lines())) { - return levels[line]; - } else { - return SC_FOLDLEVELBASE; - } +void LineVector::SetPerLine(PerLine *pl) { + perLine = pl; } void LineVector::InsertText(int line, int delta) { @@ -188,15 +46,8 @@ void LineVector::InsertText(int line, int delta) { void LineVector::InsertLine(int line, int position) { starts.InsertPartition(line, position); - if (markers.Length()) { - markers.Insert(line, 0); - } - if (levels.Length()) { - int level = SC_FOLDLEVELBASE; - if ((line > 0) && (line < Lines())) { - level = levels[line-1] & ~SC_FOLDLEVELWHITEFLAG; - } - levels.InsertValue(line, 1, level); + if (perLine) { + perLine->InsertLine(line); } } @@ -206,108 +57,21 @@ void LineVector::SetLineStart(int line, int position) { void LineVector::RemoveLine(int line) { starts.RemovePartition(line); - // Retain the markers from the deleted line by oring them into the previous line - if (markers.Length()) { - if (line > 0) { - MergeMarkers(line - 1); - } - markers.Delete(line); - } - if (levels.Length()) { - // Move up following lines but merge header flag from this line - // to line before to avoid a temporary disappearence causing expansion. - int firstHeader = levels[line] & SC_FOLDLEVELHEADERFLAG; - levels.Delete(line); - if (line > 0) - levels[line-1] |= firstHeader; + if (perLine) { + perLine->RemoveLine(line); } } -int LineVector::LineFromPosition(int pos) { +int LineVector::LineFromPosition(int pos) const { return starts.PartitionFromPosition(pos); } -int LineVector::MarkValue(int line) { - if (markers.Length() && markers[line]) - return markers[line]->MarkValue(); - else - return 0; -} - -int LineVector::AddMark(int line, int markerNum) { - handleCurrent++; - if (!markers.Length()) { - // No existing markers so allocate one element per line - markers.InsertValue(0, Lines(), 0); - } - if (!markers[line]) { - // Need new structure to hold marker handle - markers[line] = new MarkerHandleSet(); - if (!markers[line]) - return - 1; - } - markers[line]->InsertHandle(handleCurrent, markerNum); - - return handleCurrent; -} - -void LineVector::MergeMarkers(int pos) { - if (markers[pos + 1] != NULL) { - if (markers[pos] == NULL) - markers[pos] = new MarkerHandleSet; - markers[pos]->CombineWith(markers[pos + 1]); - delete markers[pos + 1]; - markers[pos + 1] = NULL; - } -} - -void LineVector::DeleteMark(int line, int markerNum, bool all) { - if (markers.Length() && markers[line]) { - if (markerNum == -1) { - delete markers[line]; - markers[line] = NULL; - } else { - bool performedDeletion = markers[line]->RemoveNumber(markerNum); - while (all && performedDeletion) { - performedDeletion = markers[line]->RemoveNumber(markerNum); - } - if (markers[line]->Length() == 0) { - delete markers[line]; - markers[line] = NULL; - } - } - } -} - -void LineVector::DeleteMarkFromHandle(int markerHandle) { - int line = LineFromHandle(markerHandle); - if (line >= 0) { - markers[line]->RemoveHandle(markerHandle); - if (markers[line]->Length() == 0) { - delete markers[line]; - markers[line] = NULL; - } - } -} - -int LineVector::LineFromHandle(int markerHandle) { - if (markers.Length()) { - for (int line = 0; line < Lines(); line++) { - if (markers[line]) { - if (markers[line]->Contains(markerHandle)) { - return line; - } - } - } - } - return -1; -} - Action::Action() { at = startAction; position = 0; data = 0; lenData = 0; + mayCoalesce = false; } Action::~Action() { @@ -387,8 +151,6 @@ void UndoHistory::EnsureUndoRoom() { // Run out of undo nodes so extend the array int lenActionsNew = lenActions * 2; Action *actionsNew = new Action[lenActionsNew]; - if (!actionsNew) - return; for (int act = 0; act <= currentAction; act++) actionsNew[act].Grab(&actions[act]); delete []actions; @@ -398,7 +160,7 @@ void UndoHistory::EnsureUndoRoom() { } void UndoHistory::AppendAction(actionType at, int position, char *data, int lengthData, - bool &startSequence) { + bool &startSequence, bool mayCoalesce) { EnsureUndoRoom(); //Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, lengthData, currentAction); //Platform::DebugPrintf("^ %d action %d %d\n", actions[currentAction - 1].at, @@ -410,25 +172,35 @@ void UndoHistory::AppendAction(actionType at, int position, char *data, int leng if (currentAction >= 1) { if (0 == undoSequenceDepth) { // Top level actions may not always be coalesced - Action &actPrevious = actions[currentAction - 1]; + int targetAct = -1; + const Action *actPrevious = &(actions[currentAction + targetAct]); + // Container actions may forward the coalesce state of Scintilla Actions. + while ((actPrevious->at == containerAction) && actPrevious->mayCoalesce) { + targetAct--; + actPrevious = &(actions[currentAction + targetAct]); + } // See if current action can be coalesced into previous action // Will work if both are inserts or deletes and position is same - if (at != actPrevious.at) { + if (currentAction == savePoint) { + currentAction++; + } else if (!actions[currentAction].mayCoalesce) { + // Not allowed to coalesce if this set + currentAction++; + } else if (!mayCoalesce || !actPrevious->mayCoalesce) { currentAction++; - } else if (currentAction == savePoint) { + } else if (at == containerAction || actions[currentAction].at == containerAction) { + ; // A coalescible containerAction + } else if ((at != actPrevious->at) && (actPrevious->at != startAction)) { currentAction++; } else if ((at == insertAction) && - (position != (actPrevious.position + actPrevious.lenData))) { + (position != (actPrevious->position + actPrevious->lenData))) { // Insertions must be immediately after to coalesce currentAction++; - } else if (!actions[currentAction].mayCoalesce) { - // Not allowed to coalesce if this set - currentAction++; } else if (at == removeAction) { if ((lengthData == 1) || (lengthData == 2)){ - if ((position + lengthData) == actPrevious.position) { + if ((position + lengthData) == actPrevious->position) { ; // Backspace -> OK - } else if (position == actPrevious.position) { + } else if (position == actPrevious->position) { ; // Delete -> OK } else { // Removals must be at same position to coalesce @@ -451,7 +223,7 @@ void UndoHistory::AppendAction(actionType at, int position, char *data, int leng currentAction++; } startSequence = oldCurrentAction != currentAction; - actions[currentAction].Create(at, position, data, lengthData); + actions[currentAction].Create(at, position, data, lengthData, mayCoalesce); currentAction++; actions[currentAction].Create(startAction); maxAction = currentAction; @@ -587,6 +359,10 @@ char CellBuffer::StyleAt(int position) { return style.ValueAt(position); } +const char *CellBuffer::BufferPointer() { + return substance.BufferPointer(); +} + // The char* returned is to an allocation owned by the undo history const char *CellBuffer::InsertString(int position, const char *s, int insertLength, bool &startSequence) { char *data = 0; @@ -662,6 +438,10 @@ void CellBuffer::Allocate(int newSize) { style.ReAllocate(newSize); } +void CellBuffer::SetPerLine(PerLine *pl) { + lv.SetPerLine(pl); +} + int CellBuffer::Lines() const { return lv.Lines(); } @@ -691,53 +471,14 @@ bool CellBuffer::IsSavePoint() { return uh.IsSavePoint(); } -int CellBuffer::AddMark(int line, int markerNum) { - if ((line >= 0) && (line < Lines())) { - return lv.AddMark(line, markerNum); - } - return - 1; -} - -void CellBuffer::DeleteMark(int line, int markerNum) { - if ((line >= 0) && (line < Lines())) { - lv.DeleteMark(line, markerNum, false); - } -} - -void CellBuffer::DeleteMarkFromHandle(int markerHandle) { - lv.DeleteMarkFromHandle(markerHandle); -} - -int CellBuffer::GetMark(int line) { - if ((line >= 0) && (line < Lines())) - return lv.MarkValue(line); - return 0; -} - -void CellBuffer::DeleteAllMarks(int markerNum) { - for (int line = 0; line < Lines(); line++) { - lv.DeleteMark(line, markerNum, true); - } -} - -int CellBuffer::LineFromHandle(int markerHandle) { - return lv.LineFromHandle(markerHandle); -} - // Without undo void CellBuffer::InsertLine(int line, int position) { lv.InsertLine(line, position); - if (lineStates.Length()) { - lineStates.Insert(line, 0); - } } void CellBuffer::RemoveLine(int line) { lv.RemoveLine(line); - if (lineStates.Length()) { - lineStates.Delete(line); - } } void CellBuffer::BasicInsertString(int position, const char *s, int insertLength) { @@ -857,6 +598,11 @@ void CellBuffer::EndUndoAction() { uh.EndUndoAction(); } +void CellBuffer::AddUndoAction(int token, bool mayCoalesce) { + bool startSequence; + uh.AppendAction(containerAction, token, 0, 0, startSequence, mayCoalesce); +} + void CellBuffer::DeleteUndoHistory() { uh.DeleteUndoHistory(); } @@ -905,30 +651,3 @@ void CellBuffer::PerformRedoStep() { uh.CompletedRedoStep(); } -int CellBuffer::SetLineState(int line, int state) { - lineStates.EnsureLength(line + 1); - int stateOld = lineStates[line]; - lineStates[line] = state; - return stateOld; -} - -int CellBuffer::GetLineState(int line) { - lineStates.EnsureLength(line + 1); - return lineStates[line]; -} - -int CellBuffer::GetMaxLineState() { - return lineStates.Length(); -} - -int CellBuffer::SetLevel(int line, int level) { - return lv.SetLevel(line, level); -} - -int CellBuffer::GetLevel(int line) { - return lv.GetLevel(line); -} - -void CellBuffer::ClearLevels() { - lv.ClearLevels(); -} diff --git a/src/stc/scintilla/src/CellBuffer.h b/src/stc/scintilla/src/CellBuffer.h index 4f654a8fd9..3381c19c2c 100644 --- a/src/stc/scintilla/src/CellBuffer.h +++ b/src/stc/scintilla/src/CellBuffer.h @@ -12,33 +12,13 @@ namespace Scintilla { #endif -/** - * This holds the marker identifier and the marker type to display. - * MarkerHandleNumbers are members of lists. - */ -struct MarkerHandleNumber { - int handle; - int number; - MarkerHandleNumber *next; -}; - -/** - * A marker handle set contains any number of MarkerHandleNumbers. - */ -class MarkerHandleSet { - MarkerHandleNumber *root; - +// Interface to per-line data that wants to see each line insertion and deletion +class PerLine { public: - MarkerHandleSet(); - ~MarkerHandleSet(); - int Length() const; - int NumberFromHandle(int handle) const; - int MarkValue() const; ///< Bit set of marker numbers. - bool Contains(int handle) const; - bool InsertHandle(int handle, int markerNum); - void RemoveHandle(int handle); - bool RemoveNumber(int markerNum); - void CombineWith(MarkerHandleSet *other); + virtual ~PerLine() {} + virtual void Init()=0; + virtual void InsertLine(int)=0; + virtual void RemoveLine(int)=0; }; /** @@ -47,21 +27,14 @@ public: class LineVector { Partitioning starts; - SplitVector markers; - SplitVector levels; - /// Handles are allocated sequentially and should never have to be reused as 32 bit ints are very big. - int handleCurrent; + PerLine *perLine; public: LineVector(); ~LineVector(); void Init(); - - void ExpandLevels(int sizeNew=-1); - void ClearLevels(); - int SetLevel(int line, int level); - int GetLevel(int line); + void SetPerLine(PerLine *pl); void InsertText(int line, int delta); void InsertLine(int line, int position); @@ -70,7 +43,7 @@ public: int Lines() const { return starts.Partitions(); } - int LineFromPosition(int pos); + int LineFromPosition(int pos) const; int LineStart(int line) const { return starts.PositionFromPartition(line); } @@ -81,9 +54,18 @@ public: void DeleteMark(int line, int markerNum, bool all); void DeleteMarkFromHandle(int markerHandle); int LineFromHandle(int markerHandle); + + void ClearLevels(); + int SetLevel(int line, int level); + int GetLevel(int line); + + int SetLineState(int line, int state); + int GetLineState(int line); + int GetMaxLineState(); + }; -enum actionType { insertAction, removeAction, startAction }; +enum actionType { insertAction, removeAction, startAction, containerAction }; /** * Actions are used to store all the information required to perform one undo/redo step. @@ -120,7 +102,7 @@ public: UndoHistory(); ~UndoHistory(); - void AppendAction(actionType at, int position, char *data, int length, bool &startSequence); + void AppendAction(actionType at, int position, char *data, int length, bool &startSequence, bool mayCoalesce=true); void BeginUndoAction(); void EndUndoAction(); @@ -160,8 +142,6 @@ private: LineVector lv; - SplitVector lineStates; - public: CellBuffer(); @@ -171,12 +151,14 @@ public: char CharAt(int position) const; void GetCharRange(char *buffer, int position, int lengthRetrieve); char StyleAt(int position); + const char *BufferPointer(); int Length() const; void Allocate(int newSize); + void SetPerLine(PerLine *pl); int Lines() const; int LineStart(int line) const; - int LineFromPosition(int pos) { return lv.LineFromPosition(pos); } + int LineFromPosition(int pos) const { return lv.LineFromPosition(pos); } void InsertLine(int line, int position); void RemoveLine(int line); const char *InsertString(int position, const char *s, int insertLength, bool &startSequence); @@ -196,14 +178,6 @@ public: void SetSavePoint(); bool IsSavePoint(); - /// Line marker functions - int AddMark(int line, int markerNum); - void DeleteMark(int line, int markerNum); - void DeleteMarkFromHandle(int markerHandle); - int GetMark(int line); - void DeleteAllMarks(int markerNum); - int LineFromHandle(int markerHandle); - /// Actions without undo void BasicInsertString(int position, const char *s, int insertLength); void BasicDeleteChars(int position, int deleteLength); @@ -212,6 +186,7 @@ public: bool IsCollectingUndo(); void BeginUndoAction(); void EndUndoAction(); + void AddUndoAction(int token, bool mayCoalesce); void DeleteUndoHistory(); /// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is @@ -224,14 +199,6 @@ public: int StartRedo(); const Action &GetRedoStep() const; void PerformRedoStep(); - - int SetLineState(int line, int state); - int GetLineState(int line); - int GetMaxLineState(); - - int SetLevel(int line, int level); - int GetLevel(int line); - void ClearLevels(); }; #ifdef SCI_NAMESPACE diff --git a/src/stc/scintilla/src/CharClassify.cxx b/src/stc/scintilla/src/CharClassify.cxx index acab4b2295..bbd25a0f8d 100644 --- a/src/stc/scintilla/src/CharClassify.cxx +++ b/src/stc/scintilla/src/CharClassify.cxx @@ -5,6 +5,7 @@ // Copyright 2006 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. +#include #include #include "CharClassify.h" @@ -41,3 +42,37 @@ void CharClassify::SetCharClasses(const unsigned char *chars, cc newCharClass) { } } } + +int CompareCaseInsensitive(const char *a, const char *b) { + while (*a && *b) { + if (*a != *b) { + char upperA = MakeUpperCase(*a); + char upperB = MakeUpperCase(*b); + if (upperA != upperB) + return upperA - upperB; + } + a++; + b++; + } + // Either *a or *b is nul + return *a - *b; +} + +int CompareNCaseInsensitive(const char *a, const char *b, size_t len) { + while (*a && *b && len) { + if (*a != *b) { + char upperA = MakeUpperCase(*a); + char upperB = MakeUpperCase(*b); + if (upperA != upperB) + return upperA - upperB; + } + a++; + b++; + len--; + } + if (len == 0) + return 0; + else + // Either *a or *b is nul + return *a - *b; +} diff --git a/src/stc/scintilla/src/CharClassify.h b/src/stc/scintilla/src/CharClassify.h index 881d3a114b..d746fe02dd 100644 --- a/src/stc/scintilla/src/CharClassify.h +++ b/src/stc/scintilla/src/CharClassify.h @@ -2,7 +2,7 @@ /** @file CharClassify.h ** Character classifications used by Document and RESearch. **/ -// Copyright 2006 by Neil Hodgson +// Copyright 2006-2009 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #ifndef CHARCLASSIFY_H @@ -22,4 +22,16 @@ private: enum { maxChar=256 }; unsigned char charClass[maxChar]; // not type cc to save space }; + +// These functions are implemented because each platform calls them something different. +int CompareCaseInsensitive(const char *a, const char *b); +int CompareNCaseInsensitive(const char *a, const char *b, size_t len); + +inline char MakeUpperCase(char ch) { + if (ch < 'a' || ch > 'z') + return ch; + else + return static_cast(ch - 'a' + 'A'); +} + #endif diff --git a/src/stc/scintilla/src/Document.cxx b/src/stc/scintilla/src/Document.cxx index ff8d0fbcfc..a5d1adbbb1 100644 --- a/src/stc/scintilla/src/Document.cxx +++ b/src/stc/scintilla/src/Document.cxx @@ -17,6 +17,7 @@ #include "Partitioning.h" #include "RunStyles.h" #include "CellBuffer.h" +#include "PerLine.h" #include "CharClassify.h" #include "Decoration.h" #include "Document.h" @@ -73,8 +74,15 @@ Document::Document() { lenWatchers = 0; matchesValid = false; - pre = 0; - substituted = 0; + regex = 0; + + perLineData[ldMarkers] = new LineMarkers(); + perLineData[ldLevels] = new LineLevels(); + perLineData[ldState] = new LineState(); + perLineData[ldMargin] = new LineAnnotation(); + perLineData[ldAnnotation] = new LineAnnotation(); + + cb.SetPerLine(this); } Document::~Document() { @@ -82,12 +90,35 @@ Document::~Document() { watchers[i].watcher->NotifyDeleted(this, watchers[i].userData); } delete []watchers; + for (int j=0; jInit(); + } +} + +void Document::InsertLine(int line) { + for (int j=0; jInsertLine(line); + } +} + +void Document::RemoveLine(int line) { + for (int j=0; jRemoveLine(line); + } } // Increase reference count and return its previous value. @@ -109,42 +140,58 @@ void Document::SetSavePoint() { NotifySavePoint(true); } +int Document::GetMark(int line) { + return static_cast(perLineData[ldMarkers])->MarkValue(line); +} + int Document::AddMark(int line, int markerNum) { - int prev = cb.AddMark(line, markerNum); - DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line); - NotifyModified(mh); - return prev; + if (line <= LinesTotal()) { + int prev = static_cast(perLineData[ldMarkers])-> + AddMark(line, markerNum, LinesTotal()); + DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line); + NotifyModified(mh); + return prev; + } else { + return 0; + } } void Document::AddMarkSet(int line, int valueSet) { unsigned int m = valueSet; for (int i = 0; m; i++, m >>= 1) if (m & 1) - cb.AddMark(line, i); + static_cast(perLineData[ldMarkers])-> + AddMark(line, i, LinesTotal()); DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line); NotifyModified(mh); } void Document::DeleteMark(int line, int markerNum) { - cb.DeleteMark(line, markerNum); + static_cast(perLineData[ldMarkers])->DeleteMark(line, markerNum, false); DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line); NotifyModified(mh); } void Document::DeleteMarkFromHandle(int markerHandle) { - cb.DeleteMarkFromHandle(markerHandle); + static_cast(perLineData[ldMarkers])->DeleteMarkFromHandle(markerHandle); DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0); mh.line = -1; NotifyModified(mh); } void Document::DeleteAllMarks(int markerNum) { - cb.DeleteAllMarks(markerNum); + for (int line = 0; line < LinesTotal(); line++) { + static_cast(perLineData[ldMarkers])->DeleteMark(line, markerNum, true); + } DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0); mh.line = -1; NotifyModified(mh); } +int Document::LineFromHandle(int markerHandle) { + return static_cast(perLineData[ldMarkers])->LineFromHandle(markerHandle); +} + int Document::LineStart(int line) const { return cb.LineStart(line); } @@ -162,18 +209,22 @@ int Document::LineEnd(int line) const { } } -int Document::LineFromPosition(int pos) { +int Document::LineFromPosition(int pos) const { return cb.LineFromPosition(pos); } -int Document::LineEndPosition(int position) { +int Document::LineEndPosition(int position) const { return LineEnd(LineFromPosition(position)); } -int Document::VCHomePosition(int position) { +bool Document::IsLineEndPosition(int position) const { + return LineEnd(LineFromPosition(position)) == position; +} + +int Document::VCHomePosition(int position) const { int line = LineFromPosition(position); int startPosition = LineStart(line); - int endLine = LineStart(line + 1) - 1; + int endLine = LineEnd(line); int startText = startPosition; while (startText < endLine && (cb.CharAt(startText) == ' ' || cb.CharAt(startText) == '\t' ) ) startText++; @@ -184,7 +235,7 @@ int Document::VCHomePosition(int position) { } int Document::SetLevel(int line, int level) { - int prev = cb.SetLevel(line, level); + int prev = static_cast(perLineData[ldLevels])->SetLevel(line, level, LinesTotal()); if (prev != level) { DocModification mh(SC_MOD_CHANGEFOLD | SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line); @@ -195,6 +246,14 @@ int Document::SetLevel(int line, int level) { return prev; } +int Document::GetLevel(int line) { + return static_cast(perLineData[ldLevels])->GetLevel(line); +} + +void Document::ClearLevels() { + static_cast(perLineData[ldLevels])->ClearLevels(); +} + static bool IsSubordinate(int levelStart, int levelTry) { if (levelTry & SC_FOLDLEVELWHITEFLAG) return true; @@ -506,21 +565,27 @@ int Document::Undo() { if (action.at == removeAction) { NotifyModified(DocModification( SC_MOD_BEFOREINSERT | SC_PERFORMED_UNDO, action)); + } else if (action.at == containerAction) { + DocModification dm(SC_MOD_CONTAINER | SC_PERFORMED_UNDO); + dm.token = action.position; + NotifyModified(dm); } else { NotifyModified(DocModification( SC_MOD_BEFOREDELETE | SC_PERFORMED_UNDO, action)); } cb.PerformUndoStep(); int cellPosition = action.position; - ModifiedAt(cellPosition); - newPos = cellPosition; + if (action.at != containerAction) { + ModifiedAt(cellPosition); + newPos = cellPosition; + } int modFlags = SC_PERFORMED_UNDO; // With undo, an insertion action becomes a deletion notification if (action.at == removeAction) { newPos += action.lenData; modFlags |= SC_MOD_INSERTTEXT; - } else { + } else if (action.at == insertAction) { modFlags |= SC_MOD_DELETETEXT; } if (steps > 1) @@ -561,19 +626,25 @@ int Document::Redo() { if (action.at == insertAction) { NotifyModified(DocModification( SC_MOD_BEFOREINSERT | SC_PERFORMED_REDO, action)); + } else if (action.at == containerAction) { + DocModification dm(SC_MOD_CONTAINER | SC_PERFORMED_REDO); + dm.token = action.position; + NotifyModified(dm); } else { NotifyModified(DocModification( SC_MOD_BEFOREDELETE | SC_PERFORMED_REDO, action)); } cb.PerformRedoStep(); - ModifiedAt(action.position); - newPos = action.position; + if (action.at != containerAction) { + ModifiedAt(action.position); + newPos = action.position; + } int modFlags = SC_PERFORMED_REDO; if (action.at == insertAction) { newPos += action.lenData; modFlags |= SC_MOD_INSERTTEXT; - } else { + } else if (action.at == removeAction) { modFlags |= SC_MOD_DELETETEXT; } if (steps > 1) @@ -690,10 +761,9 @@ void Document::SetLineIndentation(int line, int indent) { CreateIndentation(linebuf, sizeof(linebuf), indent, tabInChars, !useTabs); int thisLineStart = LineStart(line); int indentPos = GetLineIndentPosition(line); - BeginUndoAction(); + UndoGroup ug(this); DeleteChars(thisLineStart, indentPos - thisLineStart); InsertCString(thisLineStart, linebuf); - EndUndoAction(); } } @@ -734,8 +804,8 @@ int Document::GetColumn(int pos) { int Document::FindColumn(int line, int column) { int position = LineStart(line); - int columnCurrent = 0; if ((line >= 0) && (line < LinesTotal())) { + int columnCurrent = 0; while ((columnCurrent < column) && (position < Length())) { char ch = cb.CharAt(position); if (ch == '\t') { @@ -800,7 +870,7 @@ char *Document::TransformLineEnds(int *pLenOut, const char *s, size_t len, int e } void Document::ConvertLineEnds(int eolModeSet) { - BeginUndoAction(); + UndoGroup ug(this); for (int pos = 0; pos < Length(); pos++) { if (cb.CharAt(pos) == '\r') { @@ -835,7 +905,6 @@ void Document::ConvertLineEnds(int eolModeSet) { } } - EndUndoAction(); } bool Document::IsWhiteLine(int line) const { @@ -998,16 +1067,6 @@ bool Document::IsWordAt(int start, int end) { return IsWordStartAt(start) && IsWordEndAt(end); } -// The comparison and case changing functions here assume ASCII -// or extended ASCII such as the normal Windows code page. - -static inline char MakeUpperCase(char ch) { - if (ch < 'a' || ch > 'z') - return ch; - else - return static_cast(ch - 'a' + 'A'); -} - static inline char MakeLowerCase(char ch) { if (ch < 'A' || ch > 'Z') return ch; @@ -1015,123 +1074,18 @@ static inline char MakeLowerCase(char ch) { return static_cast(ch - 'A' + 'a'); } -// Define a way for the Regular Expression code to access the document -class DocumentIndexer : public CharacterIndexer { - Document *pdoc; - int end; -public: - DocumentIndexer(Document *pdoc_, int end_) : - pdoc(pdoc_), end(end_) { - } - - virtual ~DocumentIndexer() { - } - - virtual char CharAt(int index) { - if (index < 0 || index >= end) - return 0; - else - return pdoc->CharAt(index); - } -}; - /** * Find text in document, supporting both forward and backward * searches (just pass minPos > maxPos to do a backward search) * Has not been tested with backwards DBCS searches yet. */ long Document::FindText(int minPos, int maxPos, const char *s, - bool caseSensitive, bool word, bool wordStart, bool regExp, bool posix, + bool caseSensitive, bool word, bool wordStart, bool regExp, int flags, int *length) { if (regExp) { - if (!pre) - pre = new RESearch(&charClass); - if (!pre) - return -1; - - int increment = (minPos <= maxPos) ? 1 : -1; - - int startPos = minPos; - int endPos = maxPos; - - // Range endpoints should not be inside DBCS characters, but just in case, move them. - startPos = MovePositionOutsideChar(startPos, 1, false); - endPos = MovePositionOutsideChar(endPos, 1, false); - - const char *errmsg = pre->Compile(s, *length, caseSensitive, posix); - if (errmsg) { - return -1; - } - // Find a variable in a property file: \$(\([A-Za-z0-9_.]+\)) - // Replace first '.' with '-' in each property file variable reference: - // Search: \$(\([A-Za-z0-9_-]+\)\.\([A-Za-z0-9_.]+\)) - // Replace: $(\1-\2) - int lineRangeStart = LineFromPosition(startPos); - int lineRangeEnd = LineFromPosition(endPos); - if ((increment == 1) && - (startPos >= LineEnd(lineRangeStart)) && - (lineRangeStart < lineRangeEnd)) { - // the start position is at end of line or between line end characters. - lineRangeStart++; - startPos = LineStart(lineRangeStart); - } - int pos = -1; - int lenRet = 0; - char searchEnd = s[*length - 1]; - int lineRangeBreak = lineRangeEnd + increment; - for (int line = lineRangeStart; line != lineRangeBreak; line += increment) { - int startOfLine = LineStart(line); - int endOfLine = LineEnd(line); - if (increment == 1) { - if (line == lineRangeStart) { - if ((startPos != startOfLine) && (s[0] == '^')) - continue; // Can't match start of line if start position after start of line - startOfLine = startPos; - } - if (line == lineRangeEnd) { - if ((endPos != endOfLine) && (searchEnd == '$')) - continue; // Can't match end of line if end position before end of line - endOfLine = endPos; - } - } else { - if (line == lineRangeEnd) { - if ((endPos != startOfLine) && (s[0] == '^')) - continue; // Can't match start of line if end position after start of line - startOfLine = endPos; - } - if (line == lineRangeStart) { - if ((startPos != endOfLine) && (searchEnd == '$')) - continue; // Can't match end of line if start position before end of line - endOfLine = startPos; - } - } - - DocumentIndexer di(this, endOfLine); - int success = pre->Execute(di, startOfLine, endOfLine); - if (success) { - pos = pre->bopat[0]; - lenRet = pre->eopat[0] - pre->bopat[0]; - if (increment == -1) { - // Check for the last match on this line. - int repetitions = 1000; // Break out of infinite loop - while (success && (pre->eopat[0] <= endOfLine) && (repetitions--)) { - success = pre->Execute(di, pos+1, endOfLine); - if (success) { - if (pre->eopat[0] <= minPos) { - pos = pre->bopat[0]; - lenRet = pre->eopat[0] - pre->bopat[0]; - } else { - success = 0; - } - } - } - } - break; - } - } - *length = lenRet; - return pos; - + if (!regex) + regex = CreateRegexSearch(&charClass); + return regex->FindText(this, minPos, maxPos, s, caseSensitive, word, wordStart, flags, length); } else { bool forward = minPos <= maxPos; @@ -1167,8 +1121,8 @@ long Document::FindText(int minPos, int maxPos, const char *s, } if (found) { if ((!word && !wordStart) || - word && IsWordAt(pos, pos + lengthFind) || - wordStart && IsWordStartAt(pos)) + (word && IsWordAt(pos, pos + lengthFind)) || + (wordStart && IsWordStartAt(pos))) return pos; } } @@ -1183,8 +1137,8 @@ long Document::FindText(int minPos, int maxPos, const char *s, } if (found) { if ((!word && !wordStart) || - word && IsWordAt(pos, pos + lengthFind) || - wordStart && IsWordStartAt(pos)) + (word && IsWordAt(pos, pos + lengthFind)) || + (wordStart && IsWordStartAt(pos))) return pos; } } @@ -1201,86 +1155,7 @@ long Document::FindText(int minPos, int maxPos, const char *s, } const char *Document::SubstituteByPosition(const char *text, int *length) { - if (!pre) - return 0; - delete []substituted; - substituted = 0; - DocumentIndexer di(this, Length()); - if (!pre->GrabMatches(di)) - return 0; - unsigned int lenResult = 0; - for (int i = 0; i < *length; i++) { - if (text[i] == '\\') { - if (text[i + 1] >= '1' && text[i + 1] <= '9') { - unsigned int patNum = text[i + 1] - '0'; - lenResult += pre->eopat[patNum] - pre->bopat[patNum]; - i++; - } else { - switch (text[i + 1]) { - case 'a': - case 'b': - case 'f': - case 'n': - case 'r': - case 't': - case 'v': - i++; - } - lenResult++; - } - } else { - lenResult++; - } - } - substituted = new char[lenResult + 1]; - if (!substituted) - return 0; - char *o = substituted; - for (int j = 0; j < *length; j++) { - if (text[j] == '\\') { - if (text[j + 1] >= '1' && text[j + 1] <= '9') { - unsigned int patNum = text[j + 1] - '0'; - unsigned int len = pre->eopat[patNum] - pre->bopat[patNum]; - if (pre->pat[patNum]) // Will be null if try for a match that did not occur - memcpy(o, pre->pat[patNum], len); - o += len; - j++; - } else { - j++; - switch (text[j]) { - case 'a': - *o++ = '\a'; - break; - case 'b': - *o++ = '\b'; - break; - case 'f': - *o++ = '\f'; - break; - case 'n': - *o++ = '\n'; - break; - case 'r': - *o++ = '\r'; - break; - case 't': - *o++ = '\t'; - break; - case 'v': - *o++ = '\v'; - break; - default: - *o++ = '\\'; - j--; - } - } - } else { - *o++ = text[j]; - } - } - *o = '\0'; - *length = lenResult; - return substituted; + return regex->SubstituteByPosition(this, text, length); } int Document::LinesTotal() const { @@ -1342,7 +1217,7 @@ bool Document::SetStyleFor(int length, char style) { } } -bool Document::SetStyles(int length, char *styles) { +bool Document::SetStyles(int length, const char *styles) { if (enteredStyling != 0) { return false; } else { @@ -1380,8 +1255,8 @@ void Document::EnsureStyledTo(int pos) { } } -int Document::SetLineState(int line, int state) { - int statePrevious = cb.SetLineState(line, state); +int Document::SetLineState(int line, int state) { + int statePrevious = static_cast(perLineData[ldState])->SetLineState(line, state); if (state != statePrevious) { DocModification mh(SC_MOD_CHANGELINESTATE, 0, 0, 0, 0, line); NotifyModified(mh); @@ -1389,6 +1264,89 @@ int Document::SetLineState(int line, int state) { return statePrevious; } +int Document::GetLineState(int line) { + return static_cast(perLineData[ldState])->GetLineState(line); +} + +int Document::GetMaxLineState() { + return static_cast(perLineData[ldState])->GetMaxLineState(); +} + +StyledText Document::MarginStyledText(int line) { + LineAnnotation *pla = static_cast(perLineData[ldMargin]); + return StyledText(pla->Length(line), pla->Text(line), + pla->MultipleStyles(line), pla->Style(line), pla->Styles(line)); +} + +void Document::MarginSetText(int line, const char *text) { + static_cast(perLineData[ldMargin])->SetText(line, text); + DocModification mh(SC_MOD_CHANGEMARGIN, LineStart(line), 0, 0, 0, line); + NotifyModified(mh); +} + +void Document::MarginSetStyle(int line, int style) { + static_cast(perLineData[ldMargin])->SetStyle(line, style); +} + +void Document::MarginSetStyles(int line, const unsigned char *styles) { + static_cast(perLineData[ldMargin])->SetStyles(line, styles); +} + +int Document::MarginLength(int line) const { + return static_cast(perLineData[ldMargin])->Length(line); +} + +void Document::MarginClearAll() { + int maxEditorLine = LinesTotal(); + for (int l=0;l(perLineData[ldMargin])->ClearAll(); +} + +bool Document::AnnotationAny() const { + return static_cast(perLineData[ldAnnotation])->AnySet(); +} + +StyledText Document::AnnotationStyledText(int line) { + LineAnnotation *pla = static_cast(perLineData[ldAnnotation]); + return StyledText(pla->Length(line), pla->Text(line), + pla->MultipleStyles(line), pla->Style(line), pla->Styles(line)); +} + +void Document::AnnotationSetText(int line, const char *text) { + const int linesBefore = AnnotationLines(line); + static_cast(perLineData[ldAnnotation])->SetText(line, text); + const int linesAfter = AnnotationLines(line); + DocModification mh(SC_MOD_CHANGEANNOTATION, LineStart(line), 0, 0, 0, line); + mh.annotationLinesAdded = linesAfter - linesBefore; + NotifyModified(mh); +} + +void Document::AnnotationSetStyle(int line, int style) { + static_cast(perLineData[ldAnnotation])->SetStyle(line, style); +} + +void Document::AnnotationSetStyles(int line, const unsigned char *styles) { + static_cast(perLineData[ldAnnotation])->SetStyles(line, styles); +} + +int Document::AnnotationLength(int line) const { + return static_cast(perLineData[ldAnnotation])->Length(line); +} + +int Document::AnnotationLines(int line) const { + return static_cast(perLineData[ldAnnotation])->Lines(line); +} + +void Document::AnnotationClearAll() { + int maxEditorLine = LinesTotal(); + for (int l=0;l(perLineData[ldAnnotation])->ClearAll(); +} + void Document::IncrementStyleClock() { styleClock = (styleClock + 1) % 0x100000; } @@ -1408,8 +1366,6 @@ bool Document::AddWatcher(DocWatcher *watcher, void *userData) { return false; } WatcherWithUserData *pwNew = new WatcherWithUserData[lenWatchers + 1]; - if (!pwNew) - return false; for (int j = 0; j < lenWatchers; j++) pwNew[j] = watchers[j]; pwNew[lenWatchers].watcher = watcher; @@ -1430,8 +1386,6 @@ bool Document::RemoveWatcher(DocWatcher *watcher, void *userData) { lenWatchers = 0; } else { WatcherWithUserData *pwNew = new WatcherWithUserData[lenWatchers]; - if (!pwNew) - return false; for (int j = 0; j < lenWatchers - 1; j++) { pwNew[j] = (j < i) ? watchers[j] : watchers[j + 1]; } @@ -1630,3 +1584,230 @@ int Document::BraceMatch(int position, int /*maxReStyle*/) { } return - 1; } + +/** + * Implementation of RegexSearchBase for the default built-in regular expression engine + */ +class BuiltinRegex : public RegexSearchBase { +public: + BuiltinRegex(CharClassify *charClassTable) : search(charClassTable), substituted(NULL) {} + + virtual ~BuiltinRegex() { + delete substituted; + } + + virtual long FindText(Document *doc, int minPos, int maxPos, const char *s, + bool caseSensitive, bool word, bool wordStart, int flags, + int *length); + + virtual const char *SubstituteByPosition(Document* doc, const char *text, int *length); + +private: + RESearch search; + char *substituted; +}; + +// Define a way for the Regular Expression code to access the document +class DocumentIndexer : public CharacterIndexer { + Document *pdoc; + int end; +public: + DocumentIndexer(Document *pdoc_, int end_) : + pdoc(pdoc_), end(end_) { + } + + virtual ~DocumentIndexer() { + } + + virtual char CharAt(int index) { + if (index < 0 || index >= end) + return 0; + else + return pdoc->CharAt(index); + } +}; + +long BuiltinRegex::FindText(Document *doc, int minPos, int maxPos, const char *s, + bool caseSensitive, bool, bool, int flags, + int *length) { + bool posix = (flags & SCFIND_POSIX) != 0; + int increment = (minPos <= maxPos) ? 1 : -1; + + int startPos = minPos; + int endPos = maxPos; + + // Range endpoints should not be inside DBCS characters, but just in case, move them. + startPos = doc->MovePositionOutsideChar(startPos, 1, false); + endPos = doc->MovePositionOutsideChar(endPos, 1, false); + + const char *errmsg = search.Compile(s, *length, caseSensitive, posix); + if (errmsg) { + return -1; + } + // Find a variable in a property file: \$(\([A-Za-z0-9_.]+\)) + // Replace first '.' with '-' in each property file variable reference: + // Search: \$(\([A-Za-z0-9_-]+\)\.\([A-Za-z0-9_.]+\)) + // Replace: $(\1-\2) + int lineRangeStart = doc->LineFromPosition(startPos); + int lineRangeEnd = doc->LineFromPosition(endPos); + if ((increment == 1) && + (startPos >= doc->LineEnd(lineRangeStart)) && + (lineRangeStart < lineRangeEnd)) { + // the start position is at end of line or between line end characters. + lineRangeStart++; + startPos = doc->LineStart(lineRangeStart); + } + int pos = -1; + int lenRet = 0; + char searchEnd = s[*length - 1]; + int lineRangeBreak = lineRangeEnd + increment; + for (int line = lineRangeStart; line != lineRangeBreak; line += increment) { + int startOfLine = doc->LineStart(line); + int endOfLine = doc->LineEnd(line); + if (increment == 1) { + if (line == lineRangeStart) { + if ((startPos != startOfLine) && (s[0] == '^')) + continue; // Can't match start of line if start position after start of line + startOfLine = startPos; + } + if (line == lineRangeEnd) { + if ((endPos != endOfLine) && (searchEnd == '$')) + continue; // Can't match end of line if end position before end of line + endOfLine = endPos; + } + } else { + if (line == lineRangeEnd) { + if ((endPos != startOfLine) && (s[0] == '^')) + continue; // Can't match start of line if end position after start of line + startOfLine = endPos; + } + if (line == lineRangeStart) { + if ((startPos != endOfLine) && (searchEnd == '$')) + continue; // Can't match end of line if start position before end of line + endOfLine = startPos; + } + } + + DocumentIndexer di(doc, endOfLine); + int success = search.Execute(di, startOfLine, endOfLine); + if (success) { + pos = search.bopat[0]; + lenRet = search.eopat[0] - search.bopat[0]; + if (increment == -1) { + // Check for the last match on this line. + int repetitions = 1000; // Break out of infinite loop + while (success && (search.eopat[0] <= endOfLine) && (repetitions--)) { + success = search.Execute(di, pos+1, endOfLine); + if (success) { + if (search.eopat[0] <= minPos) { + pos = search.bopat[0]; + lenRet = search.eopat[0] - search.bopat[0]; + } else { + success = 0; + } + } + } + } + break; + } + } + *length = lenRet; + return pos; +} + +const char *BuiltinRegex::SubstituteByPosition(Document* doc, const char *text, int *length) { + delete []substituted; + substituted = 0; + DocumentIndexer di(doc, doc->Length()); + if (!search.GrabMatches(di)) + return 0; + unsigned int lenResult = 0; + for (int i = 0; i < *length; i++) { + if (text[i] == '\\') { + if (text[i + 1] >= '1' && text[i + 1] <= '9') { + unsigned int patNum = text[i + 1] - '0'; + lenResult += search.eopat[patNum] - search.bopat[patNum]; + i++; + } else { + switch (text[i + 1]) { + case 'a': + case 'b': + case 'f': + case 'n': + case 'r': + case 't': + case 'v': + i++; + } + lenResult++; + } + } else { + lenResult++; + } + } + substituted = new char[lenResult + 1]; + char *o = substituted; + for (int j = 0; j < *length; j++) { + if (text[j] == '\\') { + if (text[j + 1] >= '1' && text[j + 1] <= '9') { + unsigned int patNum = text[j + 1] - '0'; + unsigned int len = search.eopat[patNum] - search.bopat[patNum]; + if (search.pat[patNum]) // Will be null if try for a match that did not occur + memcpy(o, search.pat[patNum], len); + o += len; + j++; + } else { + j++; + switch (text[j]) { + case 'a': + *o++ = '\a'; + break; + case 'b': + *o++ = '\b'; + break; + case 'f': + *o++ = '\f'; + break; + case 'n': + *o++ = '\n'; + break; + case 'r': + *o++ = '\r'; + break; + case 't': + *o++ = '\t'; + break; + case 'v': + *o++ = '\v'; + break; + default: + *o++ = '\\'; + j--; + } + } + } else { + *o++ = text[j]; + } + } + *o = '\0'; + *length = lenResult; + return substituted; +} + +#ifndef SCI_OWNREGEX + +#ifdef SCI_NAMESPACE + +RegexSearchBase *Scintilla::CreateRegexSearch(CharClassify *charClassTable) { + return new BuiltinRegex(charClassTable); +} + +#else + +RegexSearchBase *CreateRegexSearch(CharClassify *charClassTable) { + return new BuiltinRegex(charClassTable); +} + +#endif + +#endif diff --git a/src/stc/scintilla/src/Document.h b/src/stc/scintilla/src/Document.h index a36c4aafee..240d59e390 100644 --- a/src/stc/scintilla/src/Document.h +++ b/src/stc/scintilla/src/Document.h @@ -74,11 +74,50 @@ public: class DocWatcher; class DocModification; -class RESearch; +class Document; /** + * Interface class for regular expression searching */ -class Document { +class RegexSearchBase { +public: + virtual ~RegexSearchBase(){} + + virtual long FindText(Document* doc, int minPos, int maxPos, const char *s, + bool caseSensitive, bool word, bool wordStart, int flags, int *length) = 0; + + ///@return String with the substitutions, must remain valid until the next call or destruction + virtual const char *SubstituteByPosition(Document* doc, const char *text, int *length) = 0; +}; + +/// Factory function for RegexSearchBase +extern RegexSearchBase* CreateRegexSearch(CharClassify *charClassTable); + +struct StyledText { + size_t length; + const char *text; + bool multipleStyles; + size_t style; + const unsigned char *styles; + StyledText( size_t length_, const char *text_, bool multipleStyles_, int style_, const unsigned char *styles_) : + length(length_), text(text_), multipleStyles(multipleStyles_), style(style_), styles(styles_) { + } + // Return number of bytes from start to before '\n' or end of text. + // Return 1 when start is outside text + size_t LineLength(size_t start) const { + size_t cur = start; + while ((cur < length) && (text[cur] != '\n')) + cur++; + return cur-start; + } + size_t StyleAt(size_t i) const { + return multipleStyles ? styles[i] : style; + } +}; + +/** + */ +class Document : PerLine { public: /** Used to pair watcher pointer with user data. */ @@ -93,7 +132,6 @@ public: }; enum charClassification { ccSpace, ccNewLine, ccWord, ccPunctuation }; - private: int refCount; CellBuffer cb; @@ -108,9 +146,12 @@ private: WatcherWithUserData *watchers; int lenWatchers; + // ldSize is not real data - it is for dimensions and loops + enum lineData { ldMarkers, ldLevels, ldState, ldMargin, ldAnnotation, ldSize }; + PerLine *perLineData[ldSize]; + bool matchesValid; - RESearch *pre; - char *substituted; + RegexSearchBase* regex; public: int stylingBits; @@ -134,7 +175,11 @@ public: int AddRef(); int Release(); - int LineFromPosition(int pos); + virtual void Init(); + virtual void InsertLine(int line); + virtual void RemoveLine(int line); + + int LineFromPosition(int pos) const; int ClampPositionIntoDocument(int pos); bool IsCrLf(int pos); int LenChar(int pos); @@ -157,8 +202,10 @@ public: bool IsCollectingUndo() { return cb.IsCollectingUndo(); } void BeginUndoAction() { cb.BeginUndoAction(); } void EndUndoAction() { cb.EndUndoAction(); } + void AddUndoAction(int token, bool mayCoalesce) { cb.AddUndoAction(token, mayCoalesce); } void SetSavePoint(); bool IsSavePoint() { return cb.IsSavePoint(); } + const char *BufferPointer() { return cb.BufferPointer(); } int GetLineIndentation(int line); void SetLineIndentation(int line, int indent); @@ -182,21 +229,22 @@ public: cb.GetCharRange(buffer, position, lengthRetrieve); } char StyleAt(int position) { return cb.StyleAt(position); } - int GetMark(int line) { return cb.GetMark(line); } + int GetMark(int line); int AddMark(int line, int markerNum); void AddMarkSet(int line, int valueSet); void DeleteMark(int line, int markerNum); void DeleteMarkFromHandle(int markerHandle); void DeleteAllMarks(int markerNum); - int LineFromHandle(int markerHandle) { return cb.LineFromHandle(markerHandle); } + int LineFromHandle(int markerHandle); int LineStart(int line) const; int LineEnd(int line) const; - int LineEndPosition(int position); - int VCHomePosition(int position); + int LineEndPosition(int position) const; + bool IsLineEndPosition(int position) const; + int VCHomePosition(int position) const; int SetLevel(int line, int level); - int GetLevel(int line) { return cb.GetLevel(line); } - void ClearLevels() { cb.ClearLevels(); } + int GetLevel(int line); + void ClearLevels(); int GetLastChild(int lineParent, int level=-1); int GetFoldParent(int line); @@ -207,7 +255,7 @@ public: int Length() const { return cb.Length(); } void Allocate(int newSize) { cb.Allocate(newSize); } long FindText(int minPos, int maxPos, const char *s, - bool caseSensitive, bool word, bool wordStart, bool regExp, bool posix, int *length); + bool caseSensitive, bool word, bool wordStart, bool regExp, int flags, int *length); long FindText(int iMessage, unsigned long wParam, long lParam); const char *SubstituteByPosition(const char *text, int *length); int LinesTotal() const; @@ -219,7 +267,7 @@ public: void SetStylingBits(int bits); void StartStyling(int position, char mask); bool SetStyleFor(int length, char style); - bool SetStyles(int length, char *styles); + bool SetStyles(int length, const char *styles); int GetEndStyled() { return endStyled; } void EnsureStyledTo(int pos); int GetStyleClock() { return styleClock; } @@ -227,8 +275,24 @@ public: void DecorationFillRange(int position, int value, int fillLength); int SetLineState(int line, int state); - int GetLineState(int line) { return cb.GetLineState(line); } - int GetMaxLineState() { return cb.GetMaxLineState(); } + int GetLineState(int line); + int GetMaxLineState(); + + StyledText MarginStyledText(int line); + void MarginSetStyle(int line, int style); + void MarginSetStyles(int line, const unsigned char *styles); + void MarginSetText(int line, const char *text); + int MarginLength(int line) const; + void MarginClearAll(); + + bool AnnotationAny() const; + StyledText AnnotationStyledText(int line); + void AnnotationSetText(int line, const char *text); + void AnnotationSetStyle(int line, int style); + void AnnotationSetStyles(int line, const unsigned char *styles); + int AnnotationLength(int line) const; + int AnnotationLines(int line) const; + void AnnotationClearAll(); bool AddWatcher(DocWatcher *watcher, void *userData); bool RemoveWatcher(DocWatcher *watcher, void *userData); @@ -256,6 +320,27 @@ private: void NotifyModified(DocModification mh); }; +class UndoGroup { + Document *pdoc; + bool groupNeeded; +public: + UndoGroup(Document *pdoc_, bool groupNeeded_=true) : + pdoc(pdoc_), groupNeeded(groupNeeded_) { + if (groupNeeded) { + pdoc->BeginUndoAction(); + } + } + ~UndoGroup() { + if (groupNeeded) { + pdoc->EndUndoAction(); + } + } + bool Needed() const { + return groupNeeded; + } +}; + + /** * To optimise processing of document modifications by DocWatchers, a hint is passed indicating the * scope of the change. @@ -271,6 +356,8 @@ public: int line; int foldLevelNow; int foldLevelPrev; + int annotationLinesAdded; + int token; DocModification(int modificationType_, int position_=0, int length_=0, int linesAdded_=0, const char *text_=0, int line_=0) : @@ -281,7 +368,9 @@ public: text(text_), line(line_), foldLevelNow(0), - foldLevelPrev(0) {} + foldLevelPrev(0), + annotationLinesAdded(0), + token(0) {} DocModification(int modificationType_, const Action &act, int linesAdded_=0) : modificationType(modificationType_), @@ -291,7 +380,9 @@ public: text(act.data), line(0), foldLevelNow(0), - foldLevelPrev(0) {} + foldLevelPrev(0), + annotationLinesAdded(0), + token(0) {} }; /** diff --git a/src/stc/scintilla/src/DocumentAccessor.h b/src/stc/scintilla/src/DocumentAccessor.h index a3a939d0d3..899865fc1a 100644 --- a/src/stc/scintilla/src/DocumentAccessor.h +++ b/src/stc/scintilla/src/DocumentAccessor.h @@ -14,14 +14,15 @@ class Document; /** */ + class DocumentAccessor : public Accessor { // Private so DocumentAccessor objects can not be copied - DocumentAccessor(const DocumentAccessor &source) : Accessor(), props(source.props) {} - DocumentAccessor &operator=(const DocumentAccessor &) { return *this; } + DocumentAccessor(const DocumentAccessor &source); + DocumentAccessor &operator=(const DocumentAccessor &); protected: Document *pdoc; - PropSet &props; + PropertyGet &props; WindowID id; int lenDoc; @@ -37,7 +38,7 @@ protected: void Fill(int position); public: - DocumentAccessor(Document *pdoc_, PropSet &props_, WindowID id_=0) : + DocumentAccessor(Document *pdoc_, PropertyGet &props_, WindowID id_=0) : Accessor(), pdoc(pdoc_), props(props_), id(id_), lenDoc(-1), validLen(0), chFlags(0), chWhile(0), startSeg(0), startPosStyling(0), diff --git a/src/stc/scintilla/src/Editor.cxx b/src/stc/scintilla/src/Editor.cxx index 9107102ff6..d319a7ac0d 100644 --- a/src/stc/scintilla/src/Editor.cxx +++ b/src/stc/scintilla/src/Editor.cxx @@ -10,11 +10,18 @@ #include #include -#include "Platform.h" +#include -#ifndef PLAT_QT -#define INCLUDE_DEPRECATED_FEATURES +// With Borland C++ 5.5, including includes Windows.h leading to defining +// FindText to FindTextA which makes calls here to Document::FindText fail. +#ifdef __BORLANDC__ +#ifdef FindText +#undef FindText +#endif #endif + +#include "Platform.h" + #include "Scintilla.h" #include "SplitVector.h" @@ -31,6 +38,7 @@ #include "CharClassify.h" #include "Decoration.h" #include "Document.h" +#include "Selection.h" #include "PositionCache.h" #include "Editor.h" @@ -111,18 +119,14 @@ Editor::Editor() { ptMouseLast.y = 0; inDragDrop = ddNone; dropWentOutside = false; - posDrag = invalidPosition; - posDrop = invalidPosition; + posDrag = SelectionPosition(invalidPosition); + posDrop = SelectionPosition(invalidPosition); selectionType = selChar; lastXChosen = 0; lineAnchor = 0; originalAnchorPos = 0; - selType = selStream; - moveExtendsSelection = false; - xStartSelect = 0; - xEndSelect = 0; primarySelection = true; caretXPolicy = CARET_SLOP | CARET_EVEN; @@ -142,6 +146,11 @@ Editor::Editor() { verticalScrollBarVisible = true; endAtLastLine = true; caretSticky = false; + multipleSelection = false; + additionalSelectionTyping = false; + additionalCaretsBlink = true; + additionalCaretsVisible = true; + virtualSpaceOptions = SCVS_NONE; pixmapLine = Surface::Allocate(); pixmapSelMargin = Surface::Allocate(); @@ -149,9 +158,6 @@ Editor::Editor() { pixmapIndentGuide = Surface::Allocate(); pixmapIndentGuideHighlight = Surface::Allocate(); - currentPos = 0; - anchor = 0; - targetStart = 0; targetEnd = 0; searchFlags = 0; @@ -187,7 +193,8 @@ Editor::Editor() { wrapVisualFlags = 0; wrapVisualFlagsLocation = 0; wrapVisualStartIndent = 0; - actualWrapVisualStartIndent = 0; + wrapIndentMode = SC_WRAPINDENT_FIXED; + wrapAddIndent = 0; convertPastes = true; @@ -225,14 +232,10 @@ void Editor::DropGraphics() { void Editor::InvalidateStyleData() { stylesValid = false; - palette.Release(); DropGraphics(); + palette.Release(); llc.Invalidate(LineLayout::llInvalid); posCache.Clear(); - if (selType == selRectangle) { - xStartSelect = XFromPosition(anchor); - xEndSelect = XFromPosition(currentPos); - } } void Editor::InvalidateStyleRedraw() { @@ -255,7 +258,17 @@ void Editor::RefreshStyleData() { palette.Allocate(wMain); RefreshColourPalette(palette, false); } + if (wrapIndentMode == SC_WRAPINDENT_INDENT) { + wrapAddIndent = pdoc->IndentSize() * vs.spaceWidth; + } else if (wrapIndentMode == SC_WRAPINDENT_SAME) { + wrapAddIndent = 0; + } else { //SC_WRAPINDENT_FIXED + wrapAddIndent = wrapVisualStartIndent * vs.aveCharWidth; + if ((wrapVisualFlags & SC_WRAPVISUALFLAG_START) && (wrapAddIndent <= 0)) + wrapAddIndent = vs.aveCharWidth; // must indent to show start visual + } SetScrollBars(); + SetRectangularRange(); } } @@ -321,7 +334,7 @@ const char *ControlCharacterString(unsigned char ch) { class AutoLineLayout { LineLayoutCache &llc; LineLayout *ll; - AutoLineLayout &operator=(const AutoLineLayout &) { return * this; } + AutoLineLayout &operator=(const AutoLineLayout &); public: AutoLineLayout(LineLayoutCache &llc_, LineLayout *ll_) : llc(llc_), ll(ll_) {} ~AutoLineLayout() { @@ -340,98 +353,25 @@ public: } }; -#ifdef SCI_NAMESPACE -namespace Scintilla { -#endif - -/** - * Allows to iterate through the lines of a selection. - * Althought it can be called for a stream selection, in most cases - * it is inefficient and it should be used only for - * a rectangular or a line selection. - */ -class SelectionLineIterator { -private: - Editor *ed; - int line; ///< Current line within the iteration. - bool forward; ///< True if iterating by increasing line number, false otherwise. - int selStart, selEnd; ///< Positions of the start and end of the selection relative to the start of the document. - int minX, maxX; ///< Left and right of selection rectangle. - -public: - int lineStart, lineEnd; ///< Line numbers, first and last lines of the selection. - int startPos, endPos; ///< Positions of the beginning and end of the selection on the current line. - - void Reset() { - if (forward) { - line = lineStart; - } else { - line = lineEnd; - } - } - - SelectionLineIterator(Editor *ed_, bool forward_ = true) : line(0), startPos(0), endPos(0) { - ed = ed_; - forward = forward_; - selStart = ed->SelectionStart(); - selEnd = ed->SelectionEnd(); - lineStart = ed->pdoc->LineFromPosition(selStart); - lineEnd = ed->pdoc->LineFromPosition(selEnd); - // Left of rectangle - minX = Platform::Minimum(ed->xStartSelect, ed->xEndSelect); - // Right of rectangle - maxX = Platform::Maximum(ed->xStartSelect, ed->xEndSelect); - Reset(); - } - ~SelectionLineIterator() {} - - void SetAt(int line) { - if (line < lineStart || line > lineEnd) { - startPos = endPos = INVALID_POSITION; - } else { - if (ed->selType == ed->selRectangle) { - // Measure line and return character closest to minX - startPos = ed->PositionFromLineX(line, minX); - // Measure line and return character closest to maxX - endPos = ed->PositionFromLineX(line, maxX); - } else if (ed->selType == ed->selLines) { - startPos = ed->pdoc->LineStart(line); - endPos = ed->pdoc->LineStart(line + 1); - } else { // Stream selection, here only for completion - if (line == lineStart) { - startPos = selStart; - } else { - startPos = ed->pdoc->LineStart(line); - } - if (line == lineEnd) { - endPos = selEnd; - } else { - endPos = ed->pdoc->LineStart(line + 1); - } - } - } - } - bool Iterate() { - SetAt(line); - if (forward) { - line++; - } else { - line--; - } - return startPos != INVALID_POSITION; +SelectionPosition Editor::ClampPositionIntoDocument(SelectionPosition sp) const { + if (sp.Position() < 0) { + return SelectionPosition(0); + } else if (sp.Position() > pdoc->Length()) { + return SelectionPosition(pdoc->Length()); + } else { + // If not at end of line then set offset to 0 + if (!pdoc->IsLineEndPosition(sp.Position())) + sp.SetVirtualSpace(0); + return sp; } -}; - -#ifdef SCI_NAMESPACE } -#endif -Point Editor::LocationFromPosition(int pos) { +Point Editor::LocationFromPosition(SelectionPosition pos) { Point pt; RefreshStyleData(); - if (pos == INVALID_POSITION) + if (pos.Position() == INVALID_POSITION) return pt; - int line = pdoc->LineFromPosition(pos); + int line = pdoc->LineFromPosition(pos.Position()); int lineVisible = cs.DisplayFromDoc(line); //Platform::DebugPrintf("line=%d\n", line); AutoSurface surface(this); @@ -442,7 +382,7 @@ Point Editor::LocationFromPosition(int pos) { pt.x = 0; unsigned int posLineStart = pdoc->LineStart(line); LayoutLine(line, surface, vs, ll, wrapWidth); - int posInLine = pos - posLineStart; + int posInLine = pos.Position() - posLineStart; // In case of very long line put x at arbitrary large position if (posInLine > ll->maxLineLength) { pt.x = ll->positions[ll->maxLineLength] - ll->positions[ll->LineStart(ll->lines)]; @@ -451,10 +391,10 @@ Point Editor::LocationFromPosition(int pos) { for (int subLine = 0; subLine < ll->lines; subLine++) { if ((posInLine >= ll->LineStart(subLine)) && (posInLine <= ll->LineStart(subLine + 1))) { pt.x = ll->positions[posInLine] - ll->positions[ll->LineStart(subLine)]; - if (actualWrapVisualStartIndent != 0) { + if (ll->wrapIndent != 0) { int lineStart = ll->LineStart(subLine); if (lineStart != 0) // Wrapped - pt.x += actualWrapVisualStartIndent * vs.aveCharWidth; + pt.x += ll->wrapIndent; } } if (posInLine >= ll->LineStart(subLine)) { @@ -463,14 +403,24 @@ Point Editor::LocationFromPosition(int pos) { } pt.x += vs.fixedColumnWidth - xOffset; } + pt.x += pos.VirtualSpace() * static_cast(vs.styles[ll->EndLineStyle()].spaceWidth); return pt; } +Point Editor::LocationFromPosition(int pos) { + return LocationFromPosition(SelectionPosition(pos)); +} + int Editor::XFromPosition(int pos) { Point pt = LocationFromPosition(pos); return pt.x - vs.fixedColumnWidth + xOffset; } +int Editor::XFromPosition(SelectionPosition sp) { + Point pt = LocationFromPosition(sp); + return pt.x - vs.fixedColumnWidth + xOffset; +} + int Editor::LineFromLocation(Point pt) { return cs.DocFromDisplay(pt.y / vs.lineHeight + topLine); } @@ -480,20 +430,31 @@ void Editor::SetTopLine(int topLineNew) { posTopLine = pdoc->LineStart(cs.DocFromDisplay(topLine)); } -int Editor::PositionFromLocation(Point pt) { +SelectionPosition Editor::SPositionFromLocation(Point pt, bool canReturnInvalid, bool charPosition, bool virtualSpace) { RefreshStyleData(); + if (canReturnInvalid) { + PRectangle rcClient = GetTextRectangle(); + if (!rcClient.Contains(pt)) + return SelectionPosition(INVALID_POSITION); + if (pt.x < vs.fixedColumnWidth) + return SelectionPosition(INVALID_POSITION); + if (pt.y < 0) + return SelectionPosition(INVALID_POSITION); + } pt.x = pt.x - vs.fixedColumnWidth + xOffset; int visibleLine = pt.y / vs.lineHeight + topLine; if (pt.y < 0) { // Division rounds towards 0 visibleLine = (pt.y - (vs.lineHeight - 1)) / vs.lineHeight + topLine; } - if (visibleLine < 0) + if (!canReturnInvalid && (visibleLine < 0)) visibleLine = 0; int lineDoc = cs.DocFromDisplay(visibleLine); + if (canReturnInvalid && (lineDoc < 0)) + return SelectionPosition(INVALID_POSITION); if (lineDoc >= pdoc->LinesTotal()) - return pdoc->Length(); + return SelectionPosition(canReturnInvalid ? INVALID_POSITION : pdoc->Length()); unsigned int posLineStart = pdoc->LineStart(lineDoc); - int retVal = posLineStart; + SelectionPosition retVal(canReturnInvalid ? INVALID_POSITION : static_cast(posLineStart)); AutoSurface surface(this); AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc)); if (surface && ll) { @@ -505,84 +466,91 @@ int Editor::PositionFromLocation(Point pt) { int lineEnd = ll->LineLastVisible(subLine); int subLineStart = ll->positions[lineStart]; - if (actualWrapVisualStartIndent != 0) { + if (ll->wrapIndent != 0) { if (lineStart != 0) // Wrapped - pt.x -= actualWrapVisualStartIndent * vs.aveCharWidth; + pt.x -= ll->wrapIndent; } int i = ll->FindBefore(pt.x + subLineStart, lineStart, lineEnd); while (i < lineEnd) { - if ((pt.x + subLineStart) < ((ll->positions[i] + ll->positions[i + 1]) / 2)) { - return pdoc->MovePositionOutsideChar(i + posLineStart, 1); + if (charPosition) { + if ((pt.x + subLineStart) < (ll->positions[i + 1])) { + return SelectionPosition(pdoc->MovePositionOutsideChar(i + posLineStart, 1)); + } + } else { + if ((pt.x + subLineStart) < ((ll->positions[i] + ll->positions[i + 1]) / 2)) { + return SelectionPosition(pdoc->MovePositionOutsideChar(i + posLineStart, 1)); + } } i++; } - return lineEnd + posLineStart; + if (virtualSpace) { + const int spaceWidth = static_cast(vs.styles[ll->EndLineStyle()].spaceWidth); + int spaceOffset = (pt.x + subLineStart - ll->positions[lineEnd] + spaceWidth / 2) / + spaceWidth; + return SelectionPosition(lineEnd + posLineStart, spaceOffset); + } else if (canReturnInvalid) { + if (pt.x < (ll->positions[lineEnd] - subLineStart)) { + return SelectionPosition(pdoc->MovePositionOutsideChar(lineEnd + posLineStart, 1)); + } + } else { + return SelectionPosition(lineEnd + posLineStart); + } } - retVal = ll->numCharsInLine + posLineStart; + if (!canReturnInvalid) + return SelectionPosition(ll->numCharsInLine + posLineStart); } return retVal; } -// Like PositionFromLocation but INVALID_POSITION returned when not near any text. -int Editor::PositionFromLocationClose(Point pt) { +int Editor::PositionFromLocation(Point pt, bool canReturnInvalid, bool charPosition) { + return SPositionFromLocation(pt, canReturnInvalid, charPosition, false).Position(); +} + +/** + * Find the document position corresponding to an x coordinate on a particular document line. + * Ensure is between whole characters when document is in multi-byte or UTF-8 mode. + */ +int Editor::PositionFromLineX(int lineDoc, int x) { RefreshStyleData(); - PRectangle rcClient = GetTextRectangle(); - if (!rcClient.Contains(pt)) - return INVALID_POSITION; - if (pt.x < vs.fixedColumnWidth) - return INVALID_POSITION; - if (pt.y < 0) - return INVALID_POSITION; - pt.x = pt.x - vs.fixedColumnWidth + xOffset; - int visibleLine = pt.y / vs.lineHeight + topLine; - if (pt.y < 0) { // Division rounds towards 0 - visibleLine = (pt.y - (vs.lineHeight - 1)) / vs.lineHeight + topLine; - } - int lineDoc = cs.DocFromDisplay(visibleLine); - if (lineDoc < 0) - return INVALID_POSITION; if (lineDoc >= pdoc->LinesTotal()) - return INVALID_POSITION; + return pdoc->Length(); + //Platform::DebugPrintf("Position of (%d,%d) line = %d top=%d\n", pt.x, pt.y, line, topLine); AutoSurface surface(this); AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc)); + int retVal = 0; if (surface && ll) { - LayoutLine(lineDoc, surface, vs, ll, wrapWidth); unsigned int posLineStart = pdoc->LineStart(lineDoc); - int lineStartSet = cs.DisplayFromDoc(lineDoc); - int subLine = visibleLine - lineStartSet; - if (subLine < ll->lines) { - int lineStart = ll->LineStart(subLine); - int lineEnd = ll->LineLastVisible(subLine); - int subLineStart = ll->positions[lineStart]; + LayoutLine(lineDoc, surface, vs, ll, wrapWidth); + retVal = ll->numCharsBeforeEOL + posLineStart; + int subLine = 0; + int lineStart = ll->LineStart(subLine); + int lineEnd = ll->LineLastVisible(subLine); + int subLineStart = ll->positions[lineStart]; - if (actualWrapVisualStartIndent != 0) { - if (lineStart != 0) // Wrapped - pt.x -= actualWrapVisualStartIndent * vs.aveCharWidth; - } - int i = ll->FindBefore(pt.x + subLineStart, lineStart, lineEnd); - while (i < lineEnd) { - if ((pt.x + subLineStart) < ((ll->positions[i] + ll->positions[i + 1]) / 2)) { - return pdoc->MovePositionOutsideChar(i + posLineStart, 1); - } - i++; - } - if (pt.x < (ll->positions[lineEnd] - subLineStart)) { - return pdoc->MovePositionOutsideChar(lineEnd + posLineStart, 1); + if (ll->wrapIndent != 0) { + if (lineStart != 0) // Wrapped + x -= ll->wrapIndent; + } + int i = ll->FindBefore(x + subLineStart, lineStart, lineEnd); + while (i < lineEnd) { + if ((x + subLineStart) < ((ll->positions[i] + ll->positions[i + 1]) / 2)) { + retVal = pdoc->MovePositionOutsideChar(i + posLineStart, 1); + break; } + i++; } } - - return INVALID_POSITION; + return retVal; } /** * Find the document position corresponding to an x coordinate on a particular document line. * Ensure is between whole characters when document is in multi-byte or UTF-8 mode. */ -int Editor::PositionFromLineX(int lineDoc, int x) { +SelectionPosition Editor::SPositionFromLineX(int lineDoc, int x) { RefreshStyleData(); if (lineDoc >= pdoc->LinesTotal()) - return pdoc->Length(); + return SelectionPosition(pdoc->Length()); //Platform::DebugPrintf("Position of (%d,%d) line = %d top=%d\n", pt.x, pt.y, line, topLine); AutoSurface surface(this); AutoLineLayout ll(llc, RetrieveLineLayout(lineDoc)); @@ -590,26 +558,28 @@ int Editor::PositionFromLineX(int lineDoc, int x) { if (surface && ll) { unsigned int posLineStart = pdoc->LineStart(lineDoc); LayoutLine(lineDoc, surface, vs, ll, wrapWidth); - retVal = ll->numCharsInLine + posLineStart; int subLine = 0; int lineStart = ll->LineStart(subLine); int lineEnd = ll->LineLastVisible(subLine); int subLineStart = ll->positions[lineStart]; - if (actualWrapVisualStartIndent != 0) { + if (ll->wrapIndent != 0) { if (lineStart != 0) // Wrapped - x -= actualWrapVisualStartIndent * vs.aveCharWidth; + x -= ll->wrapIndent; } int i = ll->FindBefore(x + subLineStart, lineStart, lineEnd); while (i < lineEnd) { if ((x + subLineStart) < ((ll->positions[i] + ll->positions[i + 1]) / 2)) { retVal = pdoc->MovePositionOutsideChar(i + posLineStart, 1); - break; + return SelectionPosition(retVal); } i++; } + const int spaceWidth = static_cast(vs.styles[ll->EndLineStyle()].spaceWidth); + int spaceOffset = (x + subLineStart - ll->positions[lineEnd] + spaceWidth / 2) / spaceWidth; + return SelectionPosition(lineEnd + posLineStart, spaceOffset); } - return retVal; + return SelectionPosition(retVal); } /** @@ -697,73 +667,125 @@ void Editor::InvalidateRange(int start, int end) { } int Editor::CurrentPosition() { - return currentPos; + return sel.MainCaret(); } bool Editor::SelectionEmpty() { - return anchor == currentPos; + return sel.Empty(); } -int Editor::SelectionStart() { - return Platform::Minimum(currentPos, anchor); +SelectionPosition Editor::SelectionStart() { + return sel.RangeMain().Start(); } -int Editor::SelectionEnd() { - return Platform::Maximum(currentPos, anchor); +SelectionPosition Editor::SelectionEnd() { + return sel.RangeMain().End(); } void Editor::SetRectangularRange() { - if (selType == selRectangle) { - xStartSelect = XFromPosition(anchor); - xEndSelect = XFromPosition(currentPos); - } -} - -void Editor::InvalidateSelection(int currentPos_, int anchor_) { - int firstAffected = anchor; - if (firstAffected > currentPos) - firstAffected = currentPos; - if (firstAffected > anchor_) - firstAffected = anchor_; - if (firstAffected > currentPos_) - firstAffected = currentPos_; - int lastAffected = anchor; - if (lastAffected < currentPos) - lastAffected = currentPos; - if (lastAffected < anchor_) - lastAffected = anchor_; - if (lastAffected < (currentPos_ + 1)) // +1 ensures caret repainted - lastAffected = (currentPos_ + 1); + if (sel.IsRectangular()) { + int xAnchor = XFromPosition(sel.Rectangular().anchor); + int xCaret = XFromPosition(sel.Rectangular().caret); + if (sel.selType == Selection::selThin) { + xCaret = xAnchor; + } + int lineAnchor = pdoc->LineFromPosition(sel.Rectangular().anchor.Position()); + int lineCaret = pdoc->LineFromPosition(sel.Rectangular().caret.Position()); + int increment = (lineCaret > lineAnchor) ? 1 : -1; + for (int line=lineAnchor; line != lineCaret+increment; line += increment) { + SelectionRange range(SPositionFromLineX(line, xCaret), SPositionFromLineX(line, xAnchor)); + if ((virtualSpaceOptions & SCVS_RECTANGULARSELECTION) == 0) + range.ClearVirtualSpace(); + if (line == lineAnchor) + sel.SetSelection(range); + else + sel.AddSelection(range); + } + } +} + +void Editor::ThinRectangularRange() { + if (sel.IsRectangular()) { + sel.selType = Selection::selThin; + if (sel.Rectangular().caret < sel.Rectangular().anchor) { + sel.Rectangular() = SelectionRange(sel.Range(sel.Count()-1).caret, sel.Range(0).anchor); + } else { + sel.Rectangular() = SelectionRange(sel.Range(sel.Count()-1).anchor, sel.Range(0).caret); + } + SetRectangularRange(); + } +} + +void Editor::InvalidateSelection(SelectionRange newMain, bool invalidateWholeSelection) { + if (sel.Count() > 1 || !(sel.RangeMain().anchor == newMain.anchor) || sel.IsRectangular()) { + invalidateWholeSelection = true; + } + int firstAffected = Platform::Minimum(sel.RangeMain().Start().Position(), newMain.Start().Position()); + // +1 for lastAffected ensures caret repainted + int lastAffected = Platform::Maximum(newMain.caret.Position()+1, newMain.anchor.Position()); + lastAffected = Platform::Maximum(lastAffected, sel.RangeMain().End().Position()); + if (invalidateWholeSelection) { + for (size_t r=0; rClampPositionIntoDocument(currentPos_); - anchor_ = pdoc->ClampPositionIntoDocument(anchor_); - if ((currentPos != currentPos_) || (anchor != anchor_)) { - InvalidateSelection(currentPos_, anchor_); - currentPos = currentPos_; - anchor = anchor_; +void Editor::SetSelection(SelectionPosition currentPos_, SelectionPosition anchor_) { + SelectionRange rangeNew(ClampPositionIntoDocument(currentPos_), + ClampPositionIntoDocument(anchor_)); + if (sel.Count() > 1 || !(sel.RangeMain() == rangeNew)) { + InvalidateSelection(rangeNew); } + sel.RangeMain() = rangeNew; SetRectangularRange(); ClaimSelection(); } +void Editor::SetSelection(int currentPos_, int anchor_) { + SetSelection(SelectionPosition(currentPos_), SelectionPosition(anchor_)); +} + +// Just move the caret on the main selection +void Editor::SetSelection(SelectionPosition currentPos_) { + currentPos_ = ClampPositionIntoDocument(currentPos_); + if (sel.Count() > 1 || !(sel.RangeMain().caret == currentPos_)) { + InvalidateSelection(SelectionRange(currentPos_)); + } + if (sel.IsRectangular()) { + sel.Rectangular() = + SelectionRange(SelectionPosition(currentPos_), sel.Rectangular().anchor); + SetRectangularRange(); + } else { + sel.RangeMain() = + SelectionRange(SelectionPosition(currentPos_), sel.RangeMain().anchor); + } + ClaimSelection(); +} + void Editor::SetSelection(int currentPos_) { - currentPos_ = pdoc->ClampPositionIntoDocument(currentPos_); - if (currentPos != currentPos_) { - InvalidateSelection(currentPos_, currentPos_); - currentPos = currentPos_; + SetSelection(SelectionPosition(currentPos_)); +} + +void Editor::SetEmptySelection(SelectionPosition currentPos_) { + SelectionRange rangeNew(ClampPositionIntoDocument(currentPos_)); + if (sel.Count() > 1 || !(sel.RangeMain() == rangeNew)) { + InvalidateSelection(rangeNew); } + sel.Clear(); + sel.RangeMain() = rangeNew; SetRectangularRange(); ClaimSelection(); + } void Editor::SetEmptySelection(int currentPos_) { - selType = selStream; - moveExtendsSelection = false; - SetSelection(currentPos_, currentPos_); + SetEmptySelection(SelectionPosition(currentPos_)); } bool Editor::RangeContainsProtected(int start, int end) const { @@ -783,54 +805,59 @@ bool Editor::RangeContainsProtected(int start, int end) const { } bool Editor::SelectionContainsProtected() { - // DONE, but untested...: make support rectangular selection - bool scp = false; - if (selType == selStream) { - scp = RangeContainsProtected(anchor, currentPos); - } else { - SelectionLineIterator lineIterator(this); - while (lineIterator.Iterate()) { - if (RangeContainsProtected(lineIterator.startPos, lineIterator.endPos)) { - scp = true; - break; - } + for (size_t r=0; rMovePositionOutsideChar(pos, moveDir, checkLineEnd); +int Editor::MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd) const { + return MovePositionOutsideChar(SelectionPosition(pos), moveDir, checkLineEnd).Position(); +} + +SelectionPosition Editor::MovePositionOutsideChar(SelectionPosition pos, int moveDir, bool checkLineEnd) const { + int posMoved = pdoc->MovePositionOutsideChar(pos.Position(), moveDir, checkLineEnd); + if (posMoved != pos.Position()) + pos.SetPosition(posMoved); if (vs.ProtectionActive()) { int mask = pdoc->stylingBitsMask; if (moveDir > 0) { - if ((pos > 0) && vs.styles[pdoc->StyleAt(pos - 1) & mask].IsProtected()) { - while ((pos < pdoc->Length()) && - (vs.styles[pdoc->StyleAt(pos) & mask].IsProtected())) - pos++; + if ((pos.Position() > 0) && vs.styles[pdoc->StyleAt(pos.Position() - 1) & mask].IsProtected()) { + while ((pos.Position() < pdoc->Length()) && + (vs.styles[pdoc->StyleAt(pos.Position()) & mask].IsProtected())) + pos.Add(1); } } else if (moveDir < 0) { - if (vs.styles[pdoc->StyleAt(pos) & mask].IsProtected()) { - while ((pos > 0) && - (vs.styles[pdoc->StyleAt(pos - 1) & mask].IsProtected())) - pos--; + if (vs.styles[pdoc->StyleAt(pos.Position()) & mask].IsProtected()) { + while ((pos.Position() > 0) && + (vs.styles[pdoc->StyleAt(pos.Position() - 1) & mask].IsProtected())) + pos.Add(-1); } } } return pos; } -int Editor::MovePositionTo(int newPos, selTypes sel, bool ensureVisible) { - int delta = newPos - currentPos; - newPos = pdoc->ClampPositionIntoDocument(newPos); +int Editor::MovePositionTo(SelectionPosition newPos, Selection::selTypes selt, bool ensureVisible) { + int delta = newPos.Position() - sel.MainCaret(); + newPos = ClampPositionIntoDocument(newPos); newPos = MovePositionOutsideChar(newPos, delta); - if (sel != noSel) { - selType = sel; + if (!sel.IsRectangular() && (selt == Selection::selRectangle)) { + // Switching to rectangular + SelectionRange rangeMain = sel.RangeMain(); + sel.Clear(); + sel.Rectangular() = rangeMain; } - if (sel != noSel || moveExtendsSelection) { + if (selt != Selection::noSel) { + sel.selType = selt; + } + if (selt != Selection::noSel || sel.MoveExtends()) { SetSelection(newPos); } else { SetEmptySelection(newPos); @@ -839,14 +866,17 @@ int Editor::MovePositionTo(int newPos, selTypes sel, bool ensureVisible) { if (ensureVisible) { EnsureCaretVisible(); } - NotifyMove(newPos); return 0; } -int Editor::MovePositionSoVisible(int pos, int moveDir) { - pos = pdoc->ClampPositionIntoDocument(pos); +int Editor::MovePositionTo(int newPos, Selection::selTypes selt, bool ensureVisible) { + return MovePositionTo(SelectionPosition(newPos), selt, ensureVisible); +} + +SelectionPosition Editor::MovePositionSoVisible(SelectionPosition pos, int moveDir) { + pos = ClampPositionIntoDocument(pos); pos = MovePositionOutsideChar(pos, moveDir); - int lineDoc = pdoc->LineFromPosition(pos); + int lineDoc = pdoc->LineFromPosition(pos.Position()); if (cs.GetVisible(lineDoc)) { return pos; } else { @@ -854,20 +884,28 @@ int Editor::MovePositionSoVisible(int pos, int moveDir) { if (moveDir > 0) { // lineDisplay is already line before fold as lines in fold use display line of line after fold lineDisplay = Platform::Clamp(lineDisplay, 0, cs.LinesDisplayed()); - return pdoc->LineStart(cs.DocFromDisplay(lineDisplay)); + return SelectionPosition(pdoc->LineStart(cs.DocFromDisplay(lineDisplay))); } else { lineDisplay = Platform::Clamp(lineDisplay - 1, 0, cs.LinesDisplayed()); - return pdoc->LineEnd(cs.DocFromDisplay(lineDisplay)); + return SelectionPosition(pdoc->LineEnd(cs.DocFromDisplay(lineDisplay))); } } } +SelectionPosition Editor::MovePositionSoVisible(int pos, int moveDir) { + return MovePositionSoVisible(SelectionPosition(pos), moveDir); +} + +Point Editor::PointMainCaret() { + return LocationFromPosition(sel.Range(sel.Main()).caret); +} + /** * Choose the x position that the caret will try to stick to * as it moves up and down. */ void Editor::SetLastXChosen() { - Point pt = LocationFromPosition(currentPos); + Point pt = PointMainCaret(); lastXChosen = pt.x; } @@ -912,16 +950,16 @@ void Editor::HorizontalScrollTo(int xPos) { void Editor::MoveCaretInsideView(bool ensureVisible) { PRectangle rcClient = GetTextRectangle(); - Point pt = LocationFromPosition(currentPos); + Point pt = PointMainCaret(); if (pt.y < rcClient.top) { - MovePositionTo(PositionFromLocation( + MovePositionTo(SPositionFromLocation( Point(lastXChosen, rcClient.top)), - noSel, ensureVisible); + Selection::noSel, ensureVisible); } else if ((pt.y + vs.lineHeight - 1) > rcClient.bottom) { int yOfLastLineFullyDisplayed = rcClient.top + (LinesOnScreen() - 1) * vs.lineHeight; - MovePositionTo(PositionFromLocation( + MovePositionTo(SPositionFromLocation( Point(lastXChosen, rcClient.top + yOfLastLineFullyDisplayed)), - noSel, ensureVisible); + Selection::noSel, ensureVisible); } } @@ -972,7 +1010,7 @@ This way, we favour the displaying of useful information: the begining of lines, where most code reside, and the lines after the caret, eg. the body of a function. | | | | | -slop | strict | jumps | even | Caret can go to the margin | When reaching limitÝ(caret going out of +slop | strict | jumps | even | Caret can go to the margin | When reaching limit (caret going out of | | | | | visibility or going into the UZ) display is... -----+--------+-------+------+--------------------------------------------+-------------------------------------------------------------- 0 | 0 | 0 | 0 | Yes | moved to put caret on top/on right @@ -993,14 +1031,14 @@ void Editor::EnsureCaretVisible(bool useMargin, bool vert, bool horiz) { //Platform::DebugPrintf("EnsureCaretVisible %d %s\n", xOffset, useMargin ? " margin" : " "); PRectangle rcClient = GetTextRectangle(); //int rcClientFullWidth = rcClient.Width(); - int posCaret = currentPos; - if (posDrag >= 0) { + SelectionPosition posCaret = sel.RangeMain().caret; + if (posDrag.IsValid()) { posCaret = posDrag; } Point pt = LocationFromPosition(posCaret); Point ptBottomCaret = pt; ptBottomCaret.y += vs.lineHeight - 1; - int lineCaret = DisplayFromPosition(posCaret); + int lineCaret = DisplayFromPosition(posCaret.Position()); bool bSlop, bStrict, bJump, bEven; // Vertical positioning @@ -1237,10 +1275,13 @@ void Editor::DropCaret() { } void Editor::InvalidateCaret() { - if (posDrag >= 0) - InvalidateRange(posDrag, posDrag + 1); - else - InvalidateRange(currentPos, currentPos + 1); + if (posDrag.IsValid()) { + InvalidateRange(posDrag.Position(), posDrag.Position() + 1); + } else { + for (size_t r=0; rlines; } - return cs.SetHeight(lineToWrap, linesWrapped); + return cs.SetHeight(lineToWrap, linesWrapped + + (vs.annotationVisible ? pdoc->AnnotationLines(lineToWrap) : 0)); } // Check if wrapping needed and perform any needed wrapping. // fullwrap: if true, all lines which need wrapping will be done, // in this single call. -// priorityWrapLineStart: If greater than zero, all lines starting from +// priorityWrapLineStart: If greater than or equal to zero, all lines starting from // here to 1 page + 100 lines past will be wrapped (even if there are // more lines under wrapping process in idle). // If it is neither fullwrap, nor priorityWrap, then 1 page + 100 lines will be @@ -1308,7 +1350,8 @@ bool Editor::WrapLines(bool fullWrap, int priorityWrapLineStart) { if (wrapWidth != LineLayout::wrapWidthInfinite) { wrapWidth = LineLayout::wrapWidthInfinite; for (int lineDoc = 0; lineDoc < pdoc->LinesTotal(); lineDoc++) { - cs.SetHeight(lineDoc, 1); + cs.SetHeight(lineDoc, 1 + + (vs.annotationVisible ? pdoc->AnnotationLines(lineDoc) : 0)); } wrapOccurred = true; } @@ -1381,7 +1424,7 @@ bool Editor::WrapLines(bool fullWrap, int priorityWrapLineStart) { void Editor::LinesJoin() { if (!RangeContainsProtected(targetStart, targetEnd)) { - pdoc->BeginUndoAction(); + UndoGroup ug(pdoc); bool prevNonWS = true; for (int pos = targetStart; pos < targetEnd; pos++) { if (IsEOLChar(pdoc->CharAt(pos))) { @@ -1396,11 +1439,10 @@ void Editor::LinesJoin() { prevNonWS = pdoc->CharAt(pos) != ' '; } } - pdoc->EndUndoAction(); } } -const char *StringFromEOLMode(int eolMode) { +const char *Editor::StringFromEOLMode(int eolMode) { if (eolMode == SC_EOL_CRLF) { return "\r\n"; } else if (eolMode == SC_EOL_CR) { @@ -1419,7 +1461,7 @@ void Editor::LinesSplit(int pixelWidth) { int lineStart = pdoc->LineFromPosition(targetStart); int lineEnd = pdoc->LineFromPosition(targetEnd); const char *eol = StringFromEOLMode(pdoc->eolMode); - pdoc->BeginUndoAction(); + UndoGroup ug(pdoc); for (int line = lineStart; line <= lineEnd; line++) { AutoSurface surface(this); AutoLineLayout ll(llc, RetrieveLineLayout(line)); @@ -1434,7 +1476,6 @@ void Editor::LinesSplit(int pixelWidth) { } lineEnd = pdoc->LineFromPosition(targetEnd); } - pdoc->EndUndoAction(); } } @@ -1450,6 +1491,84 @@ static int istrlen(const char *s) { return static_cast(strlen(s)); } +bool ValidStyledText(ViewStyle &vs, size_t styleOffset, const StyledText &st) { + if (st.multipleStyles) { + for (size_t iStyle=0;iStyle(styles[endSegment+1]) == style)) + endSegment++; + width += surface->WidthText(vs.styles[style+styleOffset].font, text + start, endSegment - start + 1); + start = endSegment + 1; + } + return width; +} + +static int WidestLineWidth(Surface *surface, ViewStyle &vs, int styleOffset, const StyledText &st) { + int widthMax = 0; + size_t start = 0; + while (start < st.length) { + size_t lenLine = st.LineLength(start); + int widthSubLine; + if (st.multipleStyles) { + widthSubLine = WidthStyledText(surface, vs, styleOffset, st.text + start, st.styles + start, lenLine); + } else { + widthSubLine = surface->WidthText(vs.styles[styleOffset + st.style].font, st.text + start, lenLine); + } + if (widthSubLine > widthMax) + widthMax = widthSubLine; + start += lenLine + 1; + } + return widthMax; +} + +void DrawStyledText(Surface *surface, ViewStyle &vs, int styleOffset, PRectangle rcText, int ascent, + const StyledText &st, size_t start, size_t length) { + + if (st.multipleStyles) { + int x = rcText.left; + size_t i = 0; + while (i < length) { + size_t end = i; + int style = st.styles[i + start]; + while (end < length-1 && st.styles[start+end+1] == style) + end++; + style += styleOffset; + int width = surface->WidthText(vs.styles[style].font, st.text + start + i, end - i + 1); + PRectangle rcSegment = rcText; + rcSegment.left = x; + rcSegment.right = x + width + 1; + surface->DrawTextNoClip(rcSegment, vs.styles[style].font, + ascent, st.text + start + i, end - i + 1, + vs.styles[style].fore.allocated, + vs.styles[style].back.allocated); + x += width; + i = end + 1; + } + } else { + int style = st.style + styleOffset; + surface->DrawTextNoClip(rcText, vs.styles[style].font, + rcText.top + vs.maxAscent, st.text + start, length, + vs.styles[style].fore.allocated, + vs.styles[style].back.allocated); + } +} + void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { if (vs.fixedColumnWidth == 0) return; @@ -1631,6 +1750,20 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { rcNumber.top + vs.maxAscent, number, istrlen(number), vs.styles[STYLE_LINENUMBER].fore.allocated, vs.styles[STYLE_LINENUMBER].back.allocated); + } else if (vs.ms[margin].style == SC_MARGIN_TEXT || vs.ms[margin].style == SC_MARGIN_RTEXT) { + if (firstSubLine) { + const StyledText stMargin = pdoc->MarginStyledText(lineDoc); + if (stMargin.text && ValidStyledText(vs, vs.marginStyleOffset, stMargin)) { + surface->FillRectangle(rcMarker, + vs.styles[stMargin.StyleAt(0)+vs.marginStyleOffset].back.allocated); + if (vs.ms[margin].style == SC_MARGIN_RTEXT) { + int width = WidestLineWidth(surface, vs, vs.marginStyleOffset, stMargin); + rcMarker.left = rcMarker.right - width - 3; + } + DrawStyledText(surface, vs, vs.marginStyleOffset, rcMarker, rcMarker.top + vs.maxAscent, + stMargin, 0, stMargin.length); + } + } } if (marks) { @@ -1678,7 +1811,7 @@ LineLayout *Editor::RetrieveLineLayout(int lineNumber) { int posLineStart = pdoc->LineStart(lineNumber); int posLineEnd = pdoc->LineStart(lineNumber + 1); PLATFORM_ASSERT(posLineEnd >= posLineStart); - int lineCaret = pdoc->LineFromPosition(currentPos); + int lineCaret = pdoc->LineFromPosition(sel.MainCaret()); return llc.Retrieve(lineNumber, lineCaret, posLineEnd - posLineStart, pdoc->GetStyleClock(), LinesOnScreen() + 1, pdoc->LinesTotal()); @@ -1805,6 +1938,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou ll->widthLine = LineLayout::wrapWidthInfinite; ll->lines = 1; int numCharsInLine = 0; + int numCharsBeforeEOL = 0; if (vstyle.edgeState == EDGE_BACKGROUND) { ll->edgeColumn = pdoc->FindColumn(line, theEdge); if (ll->edgeColumn >= posLineStart) { @@ -1831,6 +1965,8 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou else if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseLower) ll->chars[numCharsInLine] = static_cast(tolower(chDoc)); numCharsInLine++; + if (!IsEOLChar(chDoc)) + numCharsBeforeEOL++; } } ll->xHighlightGuide = 0; @@ -1913,6 +2049,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou ll->positions[startseg] += 2; } ll->numCharsInLine = numCharsInLine; + ll->numCharsBeforeEOL = numCharsBeforeEOL; ll->validity = LineLayout::llPositions; } // Hard to cope when too narrow, so just assume there is space @@ -1930,6 +2067,20 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou if (wrapVisualFlags & SC_WRAPVISUALFLAG_END) { width -= vstyle.aveCharWidth; // take into account the space for end wrap mark } + ll->wrapIndent = wrapAddIndent; + if (wrapIndentMode != SC_WRAPINDENT_FIXED) + for (int i = 0; i < ll->numCharsInLine; i++) { + if (!IsSpaceOrTab(ll->chars[i])) { + ll->wrapIndent += ll->positions[i]; // Add line indent + break; + } + } + // Check for text width minimum + if (ll->wrapIndent > width - static_cast(vstyle.aveCharWidth) * 15) + ll->wrapIndent = wrapAddIndent; + // Check for wrapIndent minimum + if ((wrapVisualFlags & SC_WRAPVISUALFLAG_START) && (ll->wrapIndent < static_cast(vstyle.aveCharWidth))) + ll->wrapIndent = vstyle.aveCharWidth; // Indent to show start visual ll->lines = 0; // Calculate line start positions based upon width. int lastGoodBreak = 0; @@ -1955,7 +2106,7 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou ll->SetLineStart(ll->lines, lastGoodBreak); startOffset = ll->positions[lastGoodBreak]; // take into account the space for start wrap mark and indent - startOffset -= actualWrapVisualStartIndent * vstyle.aveCharWidth; + startOffset -= ll->wrapIndent; p = lastGoodBreak + 1; continue; } @@ -1979,15 +2130,21 @@ void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayou } } -ColourAllocated Editor::SelectionBackground(ViewStyle &vsDraw) { - return primarySelection ? vsDraw.selbackground.allocated : vsDraw.selbackground2.allocated; +ColourAllocated Editor::SelectionBackground(ViewStyle &vsDraw, bool main) { + return main ? + (primarySelection ? vsDraw.selbackground.allocated : vsDraw.selbackground2.allocated) : + vsDraw.selAdditionalBackground.allocated; } ColourAllocated Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground, - ColourAllocated background, bool inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) { - if (inSelection) { + ColourAllocated background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) { + if (inSelection == 1) { if (vsDraw.selbackset && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) { - return SelectionBackground(vsDraw); + return SelectionBackground(vsDraw, true); + } + } else if (inSelection == 2) { + if (vsDraw.selbackset && (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA)) { + return SelectionBackground(vsDraw, false); } } else { if ((vsDraw.edgeState == EDGE_BACKGROUND) && @@ -2061,47 +2218,132 @@ static void SimpleAlphaRectangle(Surface *surface, PRectangle rc, ColourAllocate } } +void DrawTextBlob(Surface *surface, ViewStyle &vsDraw, PRectangle rcSegment, + const char *s, ColourAllocated textBack, ColourAllocated textFore, bool twoPhaseDraw) { + if (!twoPhaseDraw) { + surface->FillRectangle(rcSegment, textBack); + } + Font &ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; + int normalCharHeight = surface->Ascent(ctrlCharsFont) - + surface->InternalLeading(ctrlCharsFont); + PRectangle rcCChar = rcSegment; + rcCChar.left = rcCChar.left + 1; + rcCChar.top = rcSegment.top + vsDraw.maxAscent - normalCharHeight; + rcCChar.bottom = rcSegment.top + vsDraw.maxAscent + 1; + PRectangle rcCentral = rcCChar; + rcCentral.top++; + rcCentral.bottom--; + surface->FillRectangle(rcCentral, textFore); + PRectangle rcChar = rcCChar; + rcChar.left++; + rcChar.right--; + surface->DrawTextClipped(rcChar, ctrlCharsFont, + rcSegment.top + vsDraw.maxAscent, s, istrlen(s), + textBack, textFore); +} + void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll, int line, int lineEnd, int xStart, int subLine, int subLineStart, bool overrideBackground, ColourAllocated background, bool drawWrapMarkEnd, ColourAllocated wrapColour) { - int styleMask = pdoc->stylingBitsMask; + const int posLineStart = pdoc->LineStart(line); + const int styleMask = pdoc->stylingBitsMask; PRectangle rcSegment = rcLine; + const bool lastSubLine = subLine == (ll->lines - 1); + int virtualSpace = 0; + if (lastSubLine) { + const int spaceWidth = static_cast(vsDraw.styles[ll->EndLineStyle()].spaceWidth); + virtualSpace = sel.VirtualSpaceFor(pdoc->LineEnd(line)) * spaceWidth; + } + // Fill in a PRectangle representing the end of line characters + int xEol = ll->positions[lineEnd] - subLineStart; - rcSegment.left = xEol + xStart; - rcSegment.right = xEol + vsDraw.aveCharWidth + xStart; - int posLineEnd = pdoc->LineStart(line + 1); - bool eolInSelection = (subLine == (ll->lines - 1)) && - (posLineEnd > ll->selStart) && (posLineEnd <= ll->selEnd) && (ll->selStart != ll->selEnd); - if (eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) { - surface->FillRectangle(rcSegment, SelectionBackground(vsDraw)); + // Fill the virtual space and show selections within it + if (virtualSpace) { + rcSegment.left = xEol + xStart; + rcSegment.right = xEol + xStart + virtualSpace; + surface->FillRectangle(rcSegment, overrideBackground ? background : vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated); + if (!hideSelection && ((vsDraw.selAlpha == SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA))) { + SelectionSegment virtualSpaceRange(SelectionPosition(pdoc->LineEnd(line)), SelectionPosition(pdoc->LineEnd(line), sel.VirtualSpaceFor(pdoc->LineEnd(line)))); + for (size_t r=0; r(vsDraw.styles[ll->EndLineStyle()].spaceWidth); + rcSegment.left = xStart + ll->positions[portion.start.Position() - posLineStart] - subLineStart + portion.start.VirtualSpace() * spaceWidth; + rcSegment.right = xStart + ll->positions[portion.end.Position() - posLineStart] - subLineStart + portion.end.VirtualSpace() * spaceWidth; + rcSegment.left = Platform::Maximum(rcSegment.left, rcLine.left); + rcSegment.right = Platform::Minimum(rcSegment.right, rcLine.right); + surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, r == sel.Main())); + } + } + } + } + } + + int posAfterLineEnd = pdoc->LineStart(line + 1); + int eolInSelection = (subLine == (ll->lines - 1)) ? sel.InSelectionForEOL(posAfterLineEnd) : 0; + int alpha = (eolInSelection == 1) ? vsDraw.selAlpha : vsDraw.selAdditionalAlpha; + + // Draw the [CR], [LF], or [CR][LF] blobs if visible line ends are on + int blobsWidth = 0; + if (lastSubLine) { + for (int eolPos=ll->numCharsBeforeEOL; eolPosnumCharsInLine; eolPos++) { + rcSegment.left = xStart + ll->positions[eolPos] - subLineStart + virtualSpace; + rcSegment.right = xStart + ll->positions[eolPos+1] - subLineStart + virtualSpace; + blobsWidth += rcSegment.Width(); + const char *ctrlChar = ControlCharacterString(ll->chars[eolPos]); + int inSelection = 0; + bool inHotspot = false; + int styleMain = ll->styles[eolPos]; + ColourAllocated textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, eolPos, ll); + ColourAllocated textFore = vsDraw.styles[styleMain].fore.allocated; + if (!hideSelection && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1)) { + if (alpha == SC_ALPHA_NOALPHA) { + surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, eolInSelection == 1)); + } else { + surface->FillRectangle(rcSegment, textBack); + SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, eolInSelection == 1), alpha); + } + } else { + surface->FillRectangle(rcSegment, textBack); + } + DrawTextBlob(surface, vsDraw, rcSegment, ctrlChar, textBack, textFore, twoPhaseDraw); + } + } + + // Draw the eol-is-selected rectangle + rcSegment.left = xEol + xStart + virtualSpace + blobsWidth; + rcSegment.right = xEol + xStart + virtualSpace + blobsWidth + vsDraw.aveCharWidth; + + if (!hideSelection && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha == SC_ALPHA_NOALPHA)) { + surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, eolInSelection == 1)); } else { if (overrideBackground) { surface->FillRectangle(rcSegment, background); - } else { + } else if (line < pdoc->LinesTotal() - 1) { + surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated); + } else if (vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].eolFilled) { surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated); + } else { + surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back.allocated); } - if (eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (vsDraw.selAlpha != SC_ALPHA_NOALPHA)) { - SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw), vsDraw.selAlpha); + if (!hideSelection && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) { + SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, eolInSelection == 1), alpha); } } - rcSegment.left = xEol + vsDraw.aveCharWidth + xStart; + // Fill the remainder of the line + rcSegment.left = xEol + xStart + virtualSpace + blobsWidth + vsDraw.aveCharWidth; rcSegment.right = rcLine.right; - if (overrideBackground) { - surface->FillRectangle(rcSegment, background); - } else if (vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].eolFilled) { - surface->FillRectangle(rcSegment, vsDraw.styles[ll->styles[ll->numCharsInLine] & styleMask].back.allocated); - } else { - surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back.allocated); - } - if (vsDraw.selEOLFilled && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) { - surface->FillRectangle(rcSegment, SelectionBackground(vsDraw)); + if (!hideSelection && vsDraw.selEOLFilled && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha == SC_ALPHA_NOALPHA)) { + surface->FillRectangle(rcSegment, SelectionBackground(vsDraw, eolInSelection == 1)); } else { if (overrideBackground) { surface->FillRectangle(rcSegment, background); @@ -2110,8 +2352,8 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin } else { surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back.allocated); } - if (vsDraw.selEOLFilled && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (vsDraw.selAlpha != SC_ALPHA_NOALPHA)) { - SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw), vsDraw.selAlpha); + if (!hideSelection && vsDraw.selEOLFilled && eolInSelection && vsDraw.selbackset && (line < pdoc->LinesTotal() - 1) && (alpha != SC_ALPHA_NOALPHA)) { + SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, eolInSelection == 1), alpha); } } @@ -2119,7 +2361,7 @@ void Editor::DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, Lin PRectangle rcPlace = rcSegment; if (wrapVisualFlagsLocation & SC_WRAPVISUALFLAGLOC_END_BY_TEXT) { - rcPlace.left = xEol + xStart; + rcPlace.left = xEol + xStart + virtualSpace; rcPlace.right = rcPlace.left + vsDraw.aveCharWidth; } else { // draw left of the right text margin, to avoid clipping by the current clip rect @@ -2197,28 +2439,56 @@ void Editor::DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int x } } -void DrawTextBlob(Surface *surface, ViewStyle &vsDraw, PRectangle rcSegment, - const char *s, ColourAllocated textBack, ColourAllocated textFore, bool twoPhaseDraw) { - if (!twoPhaseDraw) { - surface->FillRectangle(rcSegment, textBack); +void Editor::DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int xStart, + PRectangle rcLine, LineLayout *ll, int subLine) { + int indent = pdoc->GetLineIndentation(line) * vsDraw.spaceWidth; + PRectangle rcSegment = rcLine; + int annotationLine = subLine - ll->lines; + const StyledText stAnnotation = pdoc->AnnotationStyledText(line); + if (stAnnotation.text && ValidStyledText(vsDraw, vsDraw.annotationStyleOffset, stAnnotation)) { + surface->FillRectangle(rcSegment, vsDraw.styles[0].back.allocated); + if (vs.annotationVisible == ANNOTATION_BOXED) { + // Only care about calculating width if need to draw box + int widthAnnotation = WidestLineWidth(surface, vsDraw, vsDraw.annotationStyleOffset, stAnnotation); + widthAnnotation += vsDraw.spaceWidth * 2; // Margins + rcSegment.left = xStart + indent; + rcSegment.right = rcSegment.left + widthAnnotation; + surface->PenColour(vsDraw.styles[vsDraw.annotationStyleOffset].fore.allocated); + } else { + rcSegment.left = xStart; + } + const int annotationLines = pdoc->AnnotationLines(line); + size_t start = 0; + size_t lengthAnnotation = stAnnotation.LineLength(start); + int lineInAnnotation = 0; + while ((lineInAnnotation < annotationLine) && (start < stAnnotation.length)) { + start += lengthAnnotation + 1; + lengthAnnotation = stAnnotation.LineLength(start); + lineInAnnotation++; + } + PRectangle rcText = rcSegment; + if (vs.annotationVisible == ANNOTATION_BOXED) { + surface->FillRectangle(rcText, + vsDraw.styles[stAnnotation.StyleAt(start) + vsDraw.annotationStyleOffset].back.allocated); + rcText.left += vsDraw.spaceWidth; + } + DrawStyledText(surface, vsDraw, vsDraw.annotationStyleOffset, rcText, rcText.top + vsDraw.maxAscent, + stAnnotation, start, lengthAnnotation); + if (vs.annotationVisible == ANNOTATION_BOXED) { + surface->MoveTo(rcSegment.left, rcSegment.top); + surface->LineTo(rcSegment.left, rcSegment.bottom); + surface->MoveTo(rcSegment.right, rcSegment.top); + surface->LineTo(rcSegment.right, rcSegment.bottom); + if (subLine == ll->lines){ + surface->MoveTo(rcSegment.left, rcSegment.top); + surface->LineTo(rcSegment.right, rcSegment.top); + } + if (subLine == ll->lines+annotationLines-1) { + surface->MoveTo(rcSegment.left, rcSegment.bottom - 1); + surface->LineTo(rcSegment.right, rcSegment.bottom - 1); + } + } } - Font &ctrlCharsFont = vsDraw.styles[STYLE_CONTROLCHAR].font; - int normalCharHeight = surface->Ascent(ctrlCharsFont) - - surface->InternalLeading(ctrlCharsFont); - PRectangle rcCChar = rcSegment; - rcCChar.left = rcCChar.left + 1; - rcCChar.top = rcSegment.top + vsDraw.maxAscent - normalCharHeight; - rcCChar.bottom = rcSegment.top + vsDraw.maxAscent + 1; - PRectangle rcCentral = rcCChar; - rcCentral.top++; - rcCentral.bottom--; - surface->FillRectangle(rcCentral, textFore); - PRectangle rcChar = rcCChar; - rcChar.left++; - rcChar.right--; - surface->DrawTextClipped(rcChar, ctrlCharsFont, - rcSegment.top + vsDraw.maxAscent, s, istrlen(s), - textBack, textFore); } void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart, @@ -2280,11 +2550,18 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis int startseg = ll->LineStart(subLine); int subLineStart = ll->positions[startseg]; + if (subLine >= ll->lines) { + DrawAnnotation(surface, vsDraw, line, xStart, rcLine, ll, subLine); + return; // No further drawing + } int lineStart = 0; int lineEnd = 0; if (subLine < ll->lines) { lineStart = ll->LineStart(subLine); lineEnd = ll->LineStart(subLine + 1); + if (subLine == ll->lines - 1) { + lineEnd = ll->numCharsBeforeEOL; + } } ColourAllocated wrapColour = vsDraw.styles[STYLE_DEFAULT].fore.allocated; @@ -2299,7 +2576,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis } } - if (actualWrapVisualStartIndent != 0) { + if (ll->wrapIndent != 0) { bool continuedWrapLine = false; if (subLine < ll->lines) { @@ -2311,7 +2588,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis PRectangle rcPlace = rcSegment; rcPlace.left = ll->positions[startseg] + xStart - subLineStart; - rcPlace.right = rcPlace.left + actualWrapVisualStartIndent * vsDraw.aveCharWidth; + rcPlace.right = rcPlace.left + ll->wrapIndent; // default bgnd here.. surface->FillRectangle(rcSegment, overrideBackground ? background : @@ -2332,14 +2609,19 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis DrawWrapMarker(surface, rcPlace, false, wrapColour); } - xStart += actualWrapVisualStartIndent * vsDraw.aveCharWidth; + xStart += ll->wrapIndent; } } + bool selBackDrawn = vsDraw.selbackset && + ((vsDraw.selAlpha == SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha == SC_ALPHA_NOALPHA)); + // Does not take margin into account but not significant int xStartVisible = subLineStart - xStart; - BreakFinder bfBack(ll, lineStart, lineEnd, posLineStart, IsUnicodeMode(), xStartVisible); + ll->psel = &sel; + + BreakFinder bfBack(ll, lineStart, lineEnd, posLineStart, IsUnicodeMode(), xStartVisible, selBackDrawn); int next = bfBack.First(); // Background drawing loop @@ -2360,7 +2642,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis rcSegment.right = Platform::Minimum(rcSegment.right, rcLine.right); int styleMain = ll->styles[i]; - bool inSelection = (iDoc >= ll->selStart) && (iDoc < ll->selEnd) && (ll->selStart != ll->selEnd); + const int inSelection = hideSelection ? 0 : sel.CharacterInSelection(iDoc); bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd); ColourAllocated textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, i, ll); if (ll->chars[i] == '\t') { @@ -2382,8 +2664,10 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis if (ll->chars[cpos + startseg] == ' ') { if (drawWhitespaceBackground && (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) { - PRectangle rcSpace(ll->positions[cpos + startseg] + xStart, rcSegment.top, - ll->positions[cpos + startseg + 1] + xStart, rcSegment.bottom); + PRectangle rcSpace(ll->positions[cpos + startseg] + xStart - subLineStart, + rcSegment.top, + ll->positions[cpos + startseg + 1] + xStart - subLineStart, + rcSegment.bottom); surface->FillRectangle(rcSpace, vsDraw.whitespaceBackground.allocated); } } else { @@ -2412,9 +2696,23 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis surface->FillRectangle(rcSegment, vsDraw.edgecolour.allocated); } + // Draw underline mark as part of background if not transparent + int marks = pdoc->GetMark(line); + int markBit; + for (markBit = 0; (markBit < 32) && marks; markBit++) { + if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_UNDERLINE) && + (vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) { + PRectangle rcUnderline = rcLine; + rcUnderline.top = rcUnderline.bottom - 2; + surface->FillRectangle(rcUnderline, vsDraw.markers[markBit].back.allocated); + } + marks >>= 1; + } + inIndentation = subLine == 0; // Do not handle indentation except on first subline. // Foreground drawing loop - BreakFinder bfFore(ll, lineStart, lineEnd, posLineStart, IsUnicodeMode(), xStartVisible); + BreakFinder bfFore(ll, lineStart, lineEnd, posLineStart, IsUnicodeMode(), xStartVisible, + ((!twoPhaseDraw && selBackDrawn) || vsDraw.selforeset)); next = bfFore.First(); while (next < lineEnd) { @@ -2438,9 +2736,9 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis if (vsDraw.hotspotForegroundSet) textFore = vsDraw.hotspotForeground.allocated; } - bool inSelection = (iDoc >= ll->selStart) && (iDoc < ll->selEnd) && (ll->selStart != ll->selEnd); + const int inSelection = hideSelection ? 0 : sel.CharacterInSelection(iDoc); if (inSelection && (vsDraw.selforeset)) { - textFore = vsDraw.selforeground.allocated; + textFore = (inSelection == 1) ? vsDraw.selforeground.allocated : vsDraw.selAdditionalForeground.allocated; } bool inHotspot = (ll->hsStart != -1) && (iDoc >= ll->hsStart) && (iDoc < ll->hsEnd); ColourAllocated textBack = TextBackground(vsDraw, overrideBackground, background, inSelection, inHotspot, styleMain, i, ll); @@ -2515,12 +2813,15 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis if (!twoPhaseDraw && drawWhitespaceBackground && (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways)) { textBack = vsDraw.whitespaceBackground.allocated; - PRectangle rcSpace(ll->positions[cpos + startseg] + xStart, rcSegment.top, ll->positions[cpos + startseg + 1] + xStart, rcSegment.bottom); + PRectangle rcSpace(ll->positions[cpos + startseg] + xStart - subLineStart, + rcSegment.top, + ll->positions[cpos + startseg + 1] + xStart - subLineStart, + rcSegment.bottom); surface->FillRectangle(rcSpace, textBack); } PRectangle rcDot(xmid + xStart - subLineStart, rcSegment.top + vsDraw.lineHeight / 2, 0, 0); - rcDot.right = rcDot.left + 1; - rcDot.bottom = rcDot.top + 1; + rcDot.right = rcDot.left + vs.whitespaceSize; + rcDot.bottom = rcDot.top + vs.whitespaceSize; surface->FillRectangle(rcDot, textFore); } } @@ -2558,13 +2859,16 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis if ((vsDraw.viewIndentationGuides == ivLookForward || vsDraw.viewIndentationGuides == ivLookBoth) && (subLine == 0)) { int indentSpace = pdoc->GetLineIndentation(line); + int xStartText = ll->positions[pdoc->GetLineIndentPosition(line) - posLineStart]; + // Find the most recent line with some text int lineLastWithText = line; - while (lineLastWithText > 0 && pdoc->IsWhiteLine(lineLastWithText)) { + while (lineLastWithText > Platform::Maximum(line-20, 0) && pdoc->IsWhiteLine(lineLastWithText)) { lineLastWithText--; } if (lineLastWithText < line) { + xStartText = 100000; // Don't limit to visible indentation on empty line // This line is empty, so use indentation of last line with text int indentLastWithText = pdoc->GetLineIndentation(lineLastWithText); int isFoldHeader = pdoc->GetLevel(lineLastWithText) & SC_FOLDLEVELHEADERFLAG; @@ -2583,7 +2887,7 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis } int lineNextWithText = line; - while (lineNextWithText < pdoc->LinesTotal() && pdoc->IsWhiteLine(lineNextWithText)) { + while (lineNextWithText < Platform::Minimum(line+20, pdoc->LinesTotal()) && pdoc->IsWhiteLine(lineNextWithText)) { lineNextWithText++; } if (lineNextWithText > line) { @@ -2594,8 +2898,10 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis for (int indentPos = pdoc->IndentSize(); indentPos < indentSpace; indentPos += pdoc->IndentSize()) { int xIndent = indentPos * vsDraw.spaceWidth; - DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment, - (ll->xHighlightGuide == xIndent)); + if (xIndent < xStartText) { + DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIndent + xStart, rcSegment, + (ll->xHighlightGuide == xIndent)); + } } } @@ -2607,15 +2913,28 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis xStart, subLine, subLineStart, overrideBackground, background, drawWrapMarkEnd, wrapColour); } - if ((vsDraw.selAlpha != SC_ALPHA_NOALPHA) && (ll->selStart >= 0) && (ll->selEnd >= 0)) { - int startPosSel = (ll->selStart < posLineStart) ? posLineStart : ll->selStart; - int endPosSel = (ll->selEnd < (lineEnd + posLineStart)) ? ll->selEnd : (lineEnd + posLineStart); - if (startPosSel < endPosSel) { - rcSegment.left = xStart + ll->positions[startPosSel - posLineStart] - subLineStart; - rcSegment.right = xStart + ll->positions[endPosSel - posLineStart] - subLineStart; - rcSegment.left = Platform::Maximum(rcSegment.left, rcLine.left); - rcSegment.right = Platform::Minimum(rcSegment.right, rcLine.right); - SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw), vsDraw.selAlpha); + if (!hideSelection && ((vsDraw.selAlpha != SC_ALPHA_NOALPHA) || (vsDraw.selAdditionalAlpha != SC_ALPHA_NOALPHA))) { + // For each selection draw + int virtualSpaces = 0; + if (subLine == (ll->lines - 1)) { + virtualSpaces = sel.VirtualSpaceFor(pdoc->LineEnd(line)); + } + SelectionPosition posStart(posLineStart); + SelectionPosition posEnd(posLineStart + lineEnd, virtualSpaces); + SelectionSegment virtualSpaceRange(posStart, posEnd); + for (size_t r=0; r(vsDraw.styles[ll->EndLineStyle()].spaceWidth); + rcSegment.left = xStart + ll->positions[portion.start.Position() - posLineStart] - subLineStart + portion.start.VirtualSpace() * spaceWidth; + rcSegment.right = xStart + ll->positions[portion.end.Position() - posLineStart] - subLineStart + portion.end.VirtualSpace() * spaceWidth; + rcSegment.left = Platform::Maximum(rcSegment.left, rcLine.left); + rcSegment.right = Platform::Minimum(rcSegment.right, rcLine.right); + SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw, r == sel.Main()), alpha); + } + } } } @@ -2625,17 +2944,21 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis if (caret.active && vsDraw.showCaretLineBackground && ll->containsCaret) { SimpleAlphaRectangle(surface, rcSegment, vsDraw.caretLineBackground.allocated, vsDraw.caretLineAlpha); } - int marks = pdoc->GetMark(line); - for (int markBit = 0; (markBit < 32) && marks; markBit++) { + marks = pdoc->GetMark(line); + for (markBit = 0; (markBit < 32) && marks; markBit++) { if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND)) { SimpleAlphaRectangle(surface, rcSegment, vsDraw.markers[markBit].back.allocated, vsDraw.markers[markBit].alpha); + } else if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_UNDERLINE)) { + PRectangle rcUnderline = rcSegment; + rcUnderline.top = rcUnderline.bottom - 2; + SimpleAlphaRectangle(surface, rcUnderline, vsDraw.markers[markBit].back.allocated, vsDraw.markers[markBit].alpha); } marks >>= 1; } if (vsDraw.maskInLine) { int marksMasked = pdoc->GetMark(line) & vsDraw.maskInLine; if (marksMasked) { - for (int markBit = 0; (markBit < 32) && marksMasked; markBit++) { + for (markBit = 0; (markBit < 32) && marksMasked; markBit++) { if ((marksMasked & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY)) { SimpleAlphaRectangle(surface, rcSegment, vsDraw.markers[markBit].back.allocated, vsDraw.markers[markBit].alpha); } @@ -2645,7 +2968,8 @@ void Editor::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVis } } -void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine, int xStart, int offset, int posCaret, PRectangle rcCaret) { +void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine, + int xStart, int offset, int posCaret, PRectangle rcCaret, ColourAllocated caretColour) { int lineStart = ll->LineStart(subLine); int posBefore = posCaret; @@ -2688,8 +3012,15 @@ void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, } // We now know what to draw, update the caret drawing rectangle - rcCaret.left = ll->positions[offsetFirstChar] - ll->positions[ll->LineStart(subLine)] + xStart; - rcCaret.right = ll->positions[offsetFirstChar+numCharsToDraw] - ll->positions[ll->LineStart(subLine)] + xStart; + rcCaret.left = ll->positions[offsetFirstChar] - ll->positions[lineStart] + xStart; + rcCaret.right = ll->positions[offsetFirstChar+numCharsToDraw] - ll->positions[lineStart] + xStart; + + // Adjust caret position to take into account any word wrapping symbols. + if ((ll->wrapIndent != 0) && (lineStart != 0)) { + int wordWrapCharWidth = ll->wrapIndent; + rcCaret.left += wordWrapCharWidth; + rcCaret.right += wordWrapCharWidth; + } // This character is where the caret block is, we override the colours // (inversed) for drawing the caret here. @@ -2697,7 +3028,7 @@ void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, surface->DrawTextClipped(rcCaret, vsDraw.styles[styleMain].font, rcCaret.top + vsDraw.maxAscent, ll->chars + offsetFirstChar, numCharsToDraw, vsDraw.styles[styleMain].back.allocated, - vsDraw.caretcolour.allocated); + caretColour); } void Editor::RefreshPixMaps(Surface *surfaceWindow) { @@ -2766,10 +3097,94 @@ void Editor::RefreshPixMaps(Surface *surfaceWindow) { } } +void Editor::DrawCarets(Surface *surface, ViewStyle &vsDraw, int lineDoc, int xStart, + PRectangle rcLine, LineLayout *ll, int subLine) { + // When drag is active it is the only caret drawn + bool drawDrag = posDrag.IsValid(); + if (hideSelection && !drawDrag) + return; + const int posLineStart = pdoc->LineStart(lineDoc); + // For each selection draw + for (size_t r=0; (r(vsDraw.styles[ll->EndLineStyle()].spaceWidth); + const int virtualOffset = posCaret.VirtualSpace() * spaceWidth; + if (ll->InLine(offset, subLine) && offset <= ll->numCharsBeforeEOL) { + int xposCaret = ll->positions[offset] + virtualOffset - ll->positions[ll->LineStart(subLine)]; + if (ll->wrapIndent != 0) { + int lineStart = ll->LineStart(subLine); + if (lineStart != 0) // Wrapped + xposCaret += ll->wrapIndent; + } + bool caretBlinkState = (caret.active && caret.on) || (!additionalCaretsBlink && !mainCaret); + bool caretVisibleState = additionalCaretsVisible || mainCaret; + if ((xposCaret >= 0) && (vsDraw.caretWidth > 0) && (vsDraw.caretStyle != CARETSTYLE_INVISIBLE) && + ((posDrag.IsValid()) || (caretBlinkState && caretVisibleState))) { + bool caretAtEOF = false; + bool caretAtEOL = false; + bool drawBlockCaret = false; + int widthOverstrikeCaret; + int caretWidthOffset = 0; + PRectangle rcCaret = rcLine; + + if (posCaret.Position() == pdoc->Length()) { // At end of document + caretAtEOF = true; + widthOverstrikeCaret = vsDraw.aveCharWidth; + } else if ((posCaret.Position() - posLineStart) >= ll->numCharsInLine) { // At end of line + caretAtEOL = true; + widthOverstrikeCaret = vsDraw.aveCharWidth; + } else { + widthOverstrikeCaret = ll->positions[offset + 1] - ll->positions[offset]; + } + if (widthOverstrikeCaret < 3) // Make sure its visible + widthOverstrikeCaret = 3; + + if (xposCaret > 0) + caretWidthOffset = 1; // Move back so overlaps both character cells. + xposCaret += xStart; + if (posDrag.IsValid()) { + /* Dragging text, use a line caret */ + rcCaret.left = xposCaret - caretWidthOffset; + rcCaret.right = rcCaret.left + vsDraw.caretWidth; + } else if (inOverstrike) { + /* Overstrike (insert mode), use a modified bar caret */ + rcCaret.top = rcCaret.bottom - 2; + rcCaret.left = xposCaret + 1; + rcCaret.right = rcCaret.left + widthOverstrikeCaret - 1; + } else if (vsDraw.caretStyle == CARETSTYLE_BLOCK) { + /* Block caret */ + rcCaret.left = xposCaret; + if (!caretAtEOL && !caretAtEOF && (ll->chars[offset] != '\t') && !(IsControlCharacter(ll->chars[offset]))) { + drawBlockCaret = true; + rcCaret.right = xposCaret + widthOverstrikeCaret; + } else { + rcCaret.right = xposCaret + vsDraw.aveCharWidth; + } + } else { + /* Line caret */ + rcCaret.left = xposCaret - caretWidthOffset; + rcCaret.right = rcCaret.left + vsDraw.caretWidth; + } + ColourAllocated caretColour = mainCaret ? vsDraw.caretcolour.allocated : vsDraw.additionalCaretColour.allocated; + if (drawBlockCaret) { + DrawBlockCaret(surface, vsDraw, ll, subLine, xStart, offset, posCaret.Position(), rcCaret, caretColour); + } else { + surface->FillRectangle(rcCaret, caretColour); + } + } + } + if (drawDrag) + break; + } +} + void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { //Platform::DebugPrintf("Paint:%1d (%3d,%3d) ... (%3d,%3d)\n", // paintingAllText, rcArea.left, rcArea.top, rcArea.right, rcArea.bottom); + pixmapLine->Release(); RefreshStyleData(); RefreshPixMaps(surfaceWindow); @@ -2787,7 +3202,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { //Platform::DebugPrintf("Paint lines = %d .. %d\n", topLine + screenLinePaintFirst, lineStyleLast); int endPosPaint = pdoc->Length(); if (lineStyleLast < cs.LinesDisplayed()) - endPosPaint = pdoc->LineStart(cs.DocFromDisplay(lineStyleLast + 1)); + endPosPaint = pdoc->LineStart(cs.DocFromDisplay(lineStyleLast) + 1); int xStart = vs.fixedColumnWidth - xOffset; int ypos = 0; @@ -2799,10 +3214,17 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { pdoc->EnsureStyledTo(endPosPaint); bool paintAbandonedByStyling = paintState == paintAbandoned; if (needUpdateUI) { + // Deselect palette by selecting a temporary palette + Palette palTemp; + surfaceWindow->SetPalette(&palTemp, true); + NotifyUpdateUI(); needUpdateUI = false; + RefreshStyleData(); RefreshPixMaps(surfaceWindow); + surfaceWindow->SetPalette(&palette, true); + pixmapLine->SetPalette(&palette, !hasFocus); } // Call priority lines wrap on a window of lines which are likely @@ -2810,7 +3232,7 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { // lines first). int startLineToWrap = cs.DocFromDisplay(topLine) - 5; if (startLineToWrap < 0) - startLineToWrap = -1; + startLineToWrap = 0; if (WrapLines(false, startLineToWrap)) { // The wrapping process has changed the height of some lines so // abandon this paint for a complete repaint. @@ -2857,10 +3279,10 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { int visibleLine = topLine + screenLinePaintFirst; - int posCaret = currentPos; - if (posDrag >= 0) + SelectionPosition posCaret = sel.RangeMain().caret; + if (posDrag.IsValid()) posCaret = posDrag; - int lineCaret = pdoc->LineFromPosition(posCaret); + int lineCaret = pdoc->LineFromPosition(posCaret.Position()); // Remove selection margin from drawing area so text will not be drawn // on it in unbuffered mode. @@ -2876,7 +3298,6 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { //ElapsedTime etWhole; int lineDocPrevious = -1; // Used to avoid laying out one document line multiple times AutoLineLayout ll(llc, 0); - SelectionLineIterator lineIterator(this); while (visibleLine < cs.LinesDisplayed() && yposScreen < rcArea.bottom) { int lineDoc = cs.DocFromDisplay(visibleLine); @@ -2890,8 +3311,6 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { //ElapsedTime et; if (lineDoc != lineDocPrevious) { ll.Set(0); - // For rectangular selection this accesses the layout cache so should be after layout returned. - lineIterator.SetAt(lineDoc); ll.Set(RetrieveLineLayout(lineDoc)); LayoutLine(lineDoc, surface, vs, ll, wrapWidth); lineDocPrevious = lineDoc; @@ -2899,17 +3318,8 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { //durLayout += et.Duration(true); if (ll) { - if (selType == selStream) { - ll->selStart = SelectionStart(); - ll->selEnd = SelectionEnd(); - } else { - ll->selStart = lineIterator.startPos; - ll->selEnd = lineIterator.endPos; - } ll->containsCaret = lineDoc == lineCaret; if (hideSelection) { - ll->selStart = -1; - ll->selEnd = -1; ll->containsCaret = false; } @@ -2932,128 +3342,28 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { ll->RestoreBracesHighlight(rangeLine, braces); bool expanded = cs.GetExpanded(lineDoc); - if ((foldFlags & SC_FOLDFLAG_BOX) == 0) { - // Paint the line above the fold - if ((expanded && (foldFlags & SC_FOLDFLAG_LINEBEFORE_EXPANDED)) - || - (!expanded && (foldFlags & SC_FOLDFLAG_LINEBEFORE_CONTRACTED))) { - if (pdoc->GetLevel(lineDoc) & SC_FOLDLEVELHEADERFLAG) { - PRectangle rcFoldLine = rcLine; - rcFoldLine.bottom = rcFoldLine.top + 1; - surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated); - } - } - // Paint the line below the fold - if ((expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_EXPANDED)) - || - (!expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_CONTRACTED))) { - if (pdoc->GetLevel(lineDoc) & SC_FOLDLEVELHEADERFLAG) { - PRectangle rcFoldLine = rcLine; - rcFoldLine.top = rcFoldLine.bottom - 1; - surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated); - } - } - } else { - int FoldLevelCurr = (pdoc->GetLevel(lineDoc) & SC_FOLDLEVELNUMBERMASK) - SC_FOLDLEVELBASE; - int FoldLevelPrev = (pdoc->GetLevel(lineDoc - 1) & SC_FOLDLEVELNUMBERMASK) - SC_FOLDLEVELBASE; - int FoldLevelFlags = (pdoc->GetLevel(lineDoc) & ~SC_FOLDLEVELNUMBERMASK) & ~(0xFFF0000); - int indentationStep = pdoc->IndentSize(); - // Draw line above fold - if ((FoldLevelPrev < FoldLevelCurr) - || - (FoldLevelFlags & SC_FOLDLEVELBOXHEADERFLAG - && - (pdoc->GetLevel(lineDoc - 1) & SC_FOLDLEVELBOXFOOTERFLAG) == 0)) { + // Paint the line above the fold + if ((expanded && (foldFlags & SC_FOLDFLAG_LINEBEFORE_EXPANDED)) + || + (!expanded && (foldFlags & SC_FOLDFLAG_LINEBEFORE_CONTRACTED))) { + if (pdoc->GetLevel(lineDoc) & SC_FOLDLEVELHEADERFLAG) { PRectangle rcFoldLine = rcLine; rcFoldLine.bottom = rcFoldLine.top + 1; - rcFoldLine.left += xStart + FoldLevelCurr * vs.spaceWidth * indentationStep - 1; surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated); } - - // Line below the fold (or below a contracted fold) - if (FoldLevelFlags & SC_FOLDLEVELBOXFOOTERFLAG - || - (!expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_CONTRACTED))) { + } + // Paint the line below the fold + if ((expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_EXPANDED)) + || + (!expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_CONTRACTED))) { + if (pdoc->GetLevel(lineDoc) & SC_FOLDLEVELHEADERFLAG) { PRectangle rcFoldLine = rcLine; rcFoldLine.top = rcFoldLine.bottom - 1; - rcFoldLine.left += xStart + (FoldLevelCurr) * vs.spaceWidth * indentationStep - 1; surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated); } - - PRectangle rcBoxLine = rcLine; - // Draw vertical line for every fold level - for (int i = 0; i <= FoldLevelCurr; i++) { - rcBoxLine.left = xStart + i * vs.spaceWidth * indentationStep - 1; - rcBoxLine.right = rcBoxLine.left + 1; - surface->FillRectangle(rcBoxLine, vs.styles[STYLE_DEFAULT].fore.allocated); - } } - // Draw the Caret - if (lineDoc == lineCaret) { - int offset = Platform::Minimum(posCaret - rangeLine.start, ll->maxLineLength); - if (ll->InLine(offset, subLine)) { - int xposCaret = ll->positions[offset] - ll->positions[ll->LineStart(subLine)] + xStart; - - if (actualWrapVisualStartIndent != 0) { - int lineStart = ll->LineStart(subLine); - if (lineStart != 0) // Wrapped - xposCaret += actualWrapVisualStartIndent * vs.aveCharWidth; - } - if ((xposCaret >= 0) && (vs.caretWidth > 0) && (vs.caretStyle != CARETSTYLE_INVISIBLE) && - ((posDrag >= 0) || (caret.active && caret.on))) { - bool caretAtEOF = false; - bool caretAtEOL = false; - bool drawBlockCaret = false; - int widthOverstrikeCaret; - int caretWidthOffset = 0; - PRectangle rcCaret = rcLine; - - if (posCaret == pdoc->Length()) { // At end of document - caretAtEOF = true; - widthOverstrikeCaret = vs.aveCharWidth; - } else if ((posCaret - rangeLine.start) >= ll->numCharsInLine) { // At end of line - caretAtEOL = true; - widthOverstrikeCaret = vs.aveCharWidth; - } else { - widthOverstrikeCaret = ll->positions[offset + 1] - ll->positions[offset]; - } - if (widthOverstrikeCaret < 3) // Make sure its visible - widthOverstrikeCaret = 3; - - if (offset > ll->LineStart(subLine)) - caretWidthOffset = 1; // Move back so overlaps both character cells. - if (posDrag >= 0) { - /* Dragging text, use a line caret */ - rcCaret.left = xposCaret - caretWidthOffset; - rcCaret.right = rcCaret.left + vs.caretWidth; - } else if (inOverstrike) { - /* Overstrike (insert mode), use a modified bar caret */ - rcCaret.top = rcCaret.bottom - 2; - rcCaret.left = xposCaret + 1; - rcCaret.right = rcCaret.left + widthOverstrikeCaret - 1; - } else if (vs.caretStyle == CARETSTYLE_BLOCK) { - /* Block caret */ - rcCaret.left = xposCaret; - if (!caretAtEOL && !caretAtEOF && (ll->chars[offset] != '\t') && !(IsControlCharacter(ll->chars[offset]))) { - drawBlockCaret = true; - rcCaret.right = xposCaret + widthOverstrikeCaret; - } else { - rcCaret.right = xposCaret + vs.aveCharWidth; - } - } else { - /* Line caret */ - rcCaret.left = xposCaret - caretWidthOffset; - rcCaret.right = rcCaret.left + vs.caretWidth; - } - if (drawBlockCaret) { - DrawBlockCaret(surface, vs, ll, subLine, xStart, offset, posCaret, rcCaret); - } else { - surface->FillRectangle(rcCaret, vs.caretcolour.allocated); - } - } - } - } + DrawCarets(surface, vs, lineDoc, xStart, rcLine, ll, subLine); if (bufferedDraw) { Point from(vs.fixedColumnWidth, 0); @@ -3061,6 +3371,9 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { rcClient.right, yposScreen + vs.lineHeight); surfaceWindow->Copy(rcCopyArea, from, *pixmapLine); } + + lineWidthMaxSeen = Platform::Maximum( + lineWidthMaxSeen, ll->positions[ll->numCharsInLine]); //durCopy += et.Duration(true); } @@ -3071,8 +3384,6 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { yposScreen += vs.lineHeight; visibleLine++; - lineWidthMaxSeen = Platform::Maximum( - lineWidthMaxSeen, ll->positions[ll->numCharsInLine]); //gdk_flush(); } ll.Set(0); @@ -3120,7 +3431,7 @@ ColourDesired InvertedLight(ColourDesired orig) { // This is mostly copied from the Paint method but with some things omitted // such as the margin markers, line numbers, selection and caret // Should be merged back into a combined Draw method. -long Editor::FormatRange(bool draw, RangeToFormat *pfr) { +long Editor::FormatRange(bool draw, Sci_RangeToFormat *pfr) { if (!pfr) return 0; @@ -3155,6 +3466,7 @@ long Editor::FormatRange(bool draw, RangeToFormat *pfr) { vsPrint.selbackset = false; vsPrint.selforeset = false; vsPrint.selAlpha = SC_ALPHA_NOALPHA; + vsPrint.selAdditionalAlpha = SC_ALPHA_NOALPHA; vsPrint.whitespaceBackgroundSet = false; vsPrint.whitespaceForegroundSet = false; vsPrint.showCaretLineBackground = false; @@ -3232,8 +3544,6 @@ long Editor::FormatRange(bool draw, RangeToFormat *pfr) { LineLayout ll(8000); LayoutLine(lineDoc, surfaceMeasure, vsPrint, &ll, widthPrint); - ll.selStart = -1; - ll.selEnd = -1; ll.containsCaret = false; PRectangle rcLine; @@ -3356,6 +3666,15 @@ void Editor::ChangeSize() { } } +int Editor::InsertSpace(int position, unsigned int spaces) { + if (spaces > 0) { + std::string spaceText(spaces, ' '); + pdoc->InsertString(position, spaceText.c_str(), spaces); + position += spaces; + } + return position; +} + void Editor::AddChar(char ch) { char s[2]; s[0] = ch; @@ -3363,34 +3682,60 @@ void Editor::AddChar(char ch) { AddCharUTF(s, 1); } +void Editor::FilterSelections() { + if (!additionalSelectionTyping && (sel.Count() > 1)) { + SelectionRange rangeOnly = sel.RangeMain(); + InvalidateSelection(rangeOnly, true); + sel.SetSelection(rangeOnly); + } +} + // AddCharUTF inserts an array of bytes which may or may not be in UTF-8. void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) { - bool wasSelection = currentPos != anchor; - ClearSelection(); - bool charReplaceAction = false; - if (inOverstrike && !wasSelection && !RangeContainsProtected(currentPos, currentPos + 1)) { - if (currentPos < (pdoc->Length())) { - if (!IsEOLChar(pdoc->CharAt(currentPos))) { - charReplaceAction = true; - pdoc->BeginUndoAction(); - pdoc->DelChar(currentPos); + FilterSelections(); + { + UndoGroup ug(pdoc, (sel.Count() > 1) || !sel.Empty() || inOverstrike); + for (size_t r=0; rDeleteChars(positionInsert, sel.Range(r).Length()); + sel.Range(r).ClearVirtualSpace(); + } else { + // Range is all virtual so collapse to start of virtual space + sel.Range(r).MinimizeVirtualSpace(); + } + } else if (inOverstrike) { + if (positionInsert < pdoc->Length()) { + if (!IsEOLChar(pdoc->CharAt(positionInsert))) { + pdoc->DelChar(positionInsert); + sel.Range(r).ClearVirtualSpace(); + } + } + } + positionInsert = InsertSpace(positionInsert, sel.Range(r).caret.VirtualSpace()); + if (pdoc->InsertString(positionInsert, s, len)) { + sel.Range(r).caret.SetPosition(positionInsert + len); + sel.Range(r).anchor.SetPosition(positionInsert + len); + } + sel.Range(r).ClearVirtualSpace(); + // If in wrap mode rewrap current line so EnsureCaretVisible has accurate information + if (wrapState != eWrapNone) { + AutoSurface surface(this); + if (surface) { + WrapOneLine(surface, pdoc->LineFromPosition(positionInsert)); + } + } } } } - if (pdoc->InsertString(currentPos, s, len)) { - SetEmptySelection(currentPos + len); - } - if (charReplaceAction) { - pdoc->EndUndoAction(); - } - // If in wrap mode rewrap current line so EnsureCaretVisible has accurate information if (wrapState != eWrapNone) { - AutoSurface surface(this); - if (surface) { - WrapOneLine(surface, pdoc->LineFromPosition(currentPos)); - } SetScrollBars(); } + ThinRectangularRange(); + // If in wrap mode rewrap current line so EnsureCaretVisible has accurate information EnsureCaretVisible(); // Avoid blinking during rapid typing: ShowCaretAtCurrentPosition(); @@ -3434,58 +3779,72 @@ void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) { } NotifyChar(byte); } + + if (recordingMacro) { + NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast(s)); + } } void Editor::ClearSelection() { - if (!SelectionContainsProtected()) { - int startPos = SelectionStart(); - if (selType == selStream) { - unsigned int chars = SelectionEnd() - startPos; - if (0 != chars) { - pdoc->BeginUndoAction(); - pdoc->DeleteChars(startPos, chars); - pdoc->EndUndoAction(); + if (!sel.IsRectangular()) + FilterSelections(); + UndoGroup ug(pdoc); + for (size_t r=0; rDeleteChars(sel.Range(r).Start().Position(), + sel.Range(r).Length()); + sel.Range(r) = sel.Range(r).Start(); } - } else { - pdoc->BeginUndoAction(); - SelectionLineIterator lineIterator(this, false); - while (lineIterator.Iterate()) { - startPos = lineIterator.startPos; - unsigned int chars = lineIterator.endPos - startPos; - if (0 != chars) { - pdoc->DeleteChars(startPos, chars); - } - } - pdoc->EndUndoAction(); - selType = selStream; } - SetEmptySelection(startPos); } + ThinRectangularRange(); + sel.RemoveDuplicates(); + ClaimSelection(); } void Editor::ClearAll() { - pdoc->BeginUndoAction(); - if (0 != pdoc->Length()) { - pdoc->DeleteChars(0, pdoc->Length()); - } - if (!pdoc->IsReadOnly()) { - cs.Clear(); + { + UndoGroup ug(pdoc); + if (0 != pdoc->Length()) { + pdoc->DeleteChars(0, pdoc->Length()); + } + if (!pdoc->IsReadOnly()) { + cs.Clear(); + pdoc->AnnotationClearAll(); + pdoc->MarginClearAll(); + } } - pdoc->EndUndoAction(); - anchor = 0; - currentPos = 0; + sel.Clear(); SetTopLine(0); SetVerticalScrollPos(); InvalidateStyleRedraw(); } void Editor::ClearDocumentStyle() { + Decoration *deco = pdoc->decorations.root; + while (deco) { + // Save next in case deco deleted + Decoration *decoNext = deco->next; + if (deco->indicator < INDIC_CONTAINER) { + pdoc->decorations.SetCurrentIndicator(deco->indicator); + pdoc->DecorationFillRange(0, 0, pdoc->Length()); + } + deco = decoNext; + } pdoc->StartStyling(0, '\377'); pdoc->SetStyleFor(pdoc->Length(), 0); cs.ShowAll(); pdoc->ClearLevels(); } +void Editor::CopyAllowLine() { + SelectionText selectedText; + CopySelectionRange(&selectedText, true); + CopyToClipboard(selectedText); +} + void Editor::Cut() { pdoc->CheckReadOnly(); if (!pdoc->IsReadOnly() && !SelectionContainsProtected()) { @@ -3494,15 +3853,20 @@ void Editor::Cut() { } } -void Editor::PasteRectangular(int pos, const char *ptr, int len) { +void Editor::PasteRectangular(SelectionPosition pos, const char *ptr, int len) { if (pdoc->IsReadOnly() || SelectionContainsProtected()) { return; } - currentPos = pos; - int xInsert = XFromPosition(currentPos); - int line = pdoc->LineFromPosition(currentPos); + sel.Clear(); + sel.RangeMain() = SelectionRange(pos); + int line = pdoc->LineFromPosition(sel.MainCaret()); + UndoGroup ug(pdoc); + sel.RangeMain().caret = SelectionPosition( + InsertSpace(sel.RangeMain().caret.Position(), sel.RangeMain().caret.VirtualSpace())); + int xInsert = XFromPosition(sel.RangeMain().caret); bool prevCr = false; - pdoc->BeginUndoAction(); + while ((len > 0) && IsEOLChar(ptr[len-1])) + len--; for (int i = 0; i < len; i++) { if (IsEOLChar(ptr[i])) { if ((ptr[i] == '\r') || (!prevCr)) @@ -3514,21 +3878,20 @@ void Editor::PasteRectangular(int pos, const char *ptr, int len) { pdoc->InsertChar(pdoc->Length(), '\n'); } // Pad the end of lines with spaces if required - currentPos = PositionFromLineX(line, xInsert); - if ((XFromPosition(currentPos) < xInsert) && (i + 1 < len)) { - for (int i = 0; i < xInsert - XFromPosition(currentPos); i++) { - pdoc->InsertChar(currentPos, ' '); - currentPos++; + sel.RangeMain().caret.SetPosition(PositionFromLineX(line, xInsert)); + if ((XFromPosition(sel.MainCaret()) < xInsert) && (i + 1 < len)) { + while (XFromPosition(sel.MainCaret()) < xInsert) { + pdoc->InsertChar(sel.MainCaret(), ' '); + sel.RangeMain().caret.Add(1); } } prevCr = ptr[i] == '\r'; } else { - pdoc->InsertString(currentPos, ptr + i, 1); - currentPos++; + pdoc->InsertString(sel.MainCaret(), ptr + i, 1); + sel.RangeMain().caret.Add(1); prevCr = false; } } - pdoc->EndUndoAction(); SetEmptySelection(pos); } @@ -3537,17 +3900,33 @@ bool Editor::CanPaste() { } void Editor::Clear() { - if (currentPos == anchor) { - if (!RangeContainsProtected(currentPos, currentPos + 1)) { - DelChar(); + UndoGroup ug(pdoc); + // If multiple selections, don't delete EOLS + if (sel.Empty()) { + for (size_t r=0; rCharAt(sel.Range(r).caret.Position()))) { + pdoc->DelChar(sel.Range(r).caret.Position()); + sel.Range(r).ClearVirtualSpace(); + } // else multiple selection so don't eat line ends + } else { + sel.Range(r).ClearVirtualSpace(); + } } } else { ClearSelection(); } - SetEmptySelection(currentPos); + sel.RemoveDuplicates(); } void Editor::SelectAll() { + sel.Clear(); SetSelection(0, pdoc->Length()); Redraw(); } @@ -3572,39 +3951,54 @@ void Editor::Redo() { } void Editor::DelChar() { - if (!RangeContainsProtected(currentPos, currentPos + 1)) { - pdoc->DelChar(currentPos); + if (!RangeContainsProtected(sel.MainCaret(), sel.MainCaret() + 1)) { + pdoc->DelChar(sel.MainCaret()); } // Avoid blinking during rapid typing: ShowCaretAtCurrentPosition(); } void Editor::DelCharBack(bool allowLineStartDeletion) { - if (currentPos == anchor) { - if (!RangeContainsProtected(currentPos - 1, currentPos)) { - int lineCurrentPos = pdoc->LineFromPosition(currentPos); - if (allowLineStartDeletion || (pdoc->LineStart(lineCurrentPos) != currentPos)) { - if (pdoc->GetColumn(currentPos) <= pdoc->GetLineIndentation(lineCurrentPos) && - pdoc->GetColumn(currentPos) > 0 && pdoc->backspaceUnindents) { - pdoc->BeginUndoAction(); - int indentation = pdoc->GetLineIndentation(lineCurrentPos); - int indentationStep = pdoc->IndentSize(); - if (indentation % indentationStep == 0) { - pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep); - } else { - pdoc->SetLineIndentation(lineCurrentPos, indentation - (indentation % indentationStep)); - } - SetEmptySelection(pdoc->GetLineIndentPosition(lineCurrentPos)); - pdoc->EndUndoAction(); + if (!sel.IsRectangular()) + FilterSelections(); + if (sel.IsRectangular()) + allowLineStartDeletion = false; + UndoGroup ug(pdoc, (sel.Count() > 1) || !sel.Empty()); + if (sel.Empty()) { + for (size_t r=0; rDelCharBack(currentPos); + int lineCurrentPos = pdoc->LineFromPosition(sel.Range(r).caret.Position()); + if (allowLineStartDeletion || (pdoc->LineStart(lineCurrentPos) != sel.Range(r).caret.Position())) { + if (pdoc->GetColumn(sel.Range(r).caret.Position()) <= pdoc->GetLineIndentation(lineCurrentPos) && + pdoc->GetColumn(sel.Range(r).caret.Position()) > 0 && pdoc->backspaceUnindents) { + UndoGroup ugInner(pdoc, !ug.Needed()); + int indentation = pdoc->GetLineIndentation(lineCurrentPos); + int indentationStep = pdoc->IndentSize(); + if (indentation % indentationStep == 0) { + pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep); + } else { + pdoc->SetLineIndentation(lineCurrentPos, indentation - (indentation % indentationStep)); + } + // SetEmptySelection + sel.Range(r) = SelectionRange(pdoc->GetLineIndentPosition(lineCurrentPos), + pdoc->GetLineIndentPosition(lineCurrentPos)); + } else { + pdoc->DelCharBack(sel.Range(r).caret.Position()); + } + } } + } else { + sel.Range(r).ClearVirtualSpace(); } } } else { ClearSelection(); - SetEmptySelection(currentPos); } + sel.RemoveDuplicates(); // Avoid blinking during rapid typing: ShowCaretAtCurrentPosition(); } @@ -3627,12 +4021,6 @@ void Editor::NotifyChar(int ch) { scn.nmhdr.code = SCN_CHARADDED; scn.ch = ch; NotifyParent(scn); - if (recordingMacro) { - char txt[2]; - txt[0] = static_cast(ch); - txt[1] = '\0'; - NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast(txt)); - } } void Editor::NotifySavePoint(bool isSavePoint) { @@ -3655,7 +4043,7 @@ void Editor::NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt) { SCNotification scn = {0}; scn.nmhdr.code = SCN_DOUBLECLICK; scn.line = LineFromLocation(pt); - scn.position = PositionFromLocationClose(pt); + scn.position = PositionFromLocation(pt, true); scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | (alt ? SCI_ALT : 0); NotifyParent(scn); @@ -3736,7 +4124,7 @@ void Editor::NotifyNeedShown(int pos, int len) { void Editor::NotifyDwelling(Point pt, bool state) { SCNotification scn = {0}; scn.nmhdr.code = state ? SCN_DWELLSTART : SCN_DWELLEND; - scn.position = PositionFromLocationClose(pt); + scn.position = PositionFromLocation(pt, true); scn.x = pt.x; scn.y = pt.y; NotifyParent(scn); @@ -3754,13 +4142,6 @@ void Editor::NotifyModifyAttempt(Document*, void *) { NotifyModifyAttempt(); } -void Editor::NotifyMove(int position) { - SCNotification scn = {0}; - scn.nmhdr.code = SCN_POSCHANGED; - scn.position = position; - NotifyParent(scn); -} - void Editor::NotifySavePoint(Document*, void *, bool atSavePoint) { //Platform::DebugPrintf("** Save Point %s\n", atSavePoint ? "On" : "Off"); NotifySavePoint(atSavePoint); @@ -3774,6 +4155,10 @@ void Editor::CheckModificationForWrap(DocModification mh) { int lines = Platform::Maximum(0, mh.linesAdded); NeedWrapping(lineDoc, lineDoc + lines + 1); } + // Fix up annotation heights + int lineDoc = pdoc->LineFromPosition(mh.position); + int lines = Platform::Maximum(0, mh.linesAdded); + SetAnnotationHeights(lineDoc, lineDoc + lines + 2); } } @@ -3832,13 +4217,11 @@ void Editor::NotifyModified(Document*, DocModification mh, void *) { } else { // Move selection and brace highlights if (mh.modificationType & SC_MOD_INSERTTEXT) { - currentPos = MovePositionForInsertion(currentPos, mh.position, mh.length); - anchor = MovePositionForInsertion(anchor, mh.position, mh.length); + sel.MovePositions(true, mh.position, mh.length); braces[0] = MovePositionForInsertion(braces[0], mh.position, mh.length); braces[1] = MovePositionForInsertion(braces[1], mh.position, mh.length); } else if (mh.modificationType & SC_MOD_DELETETEXT) { - currentPos = MovePositionForDeletion(currentPos, mh.position, mh.length); - anchor = MovePositionForDeletion(anchor, mh.position, mh.length); + sel.MovePositions(false, mh.position, mh.length); braces[0] = MovePositionForDeletion(braces[0], mh.position, mh.length); braces[1] = MovePositionForDeletion(braces[1], mh.position, mh.length); } @@ -3861,6 +4244,12 @@ void Editor::NotifyModified(Document*, DocModification mh, void *) { cs.DeleteLines(lineOfPos, -mh.linesAdded); } } + if (mh.modificationType & SC_MOD_CHANGEANNOTATION) { + int lineDoc = pdoc->LineFromPosition(mh.position); + if (vs.annotationVisible) { + cs.SetHeight(lineDoc, cs.GetHeight(lineDoc) + mh.annotationLinesAdded); + } + } CheckModificationForWrap(mh); if (mh.linesAdded != 0) { // Avoid scrolling of display if change before current display @@ -3891,7 +4280,7 @@ void Editor::NotifyModified(Document*, DocModification mh, void *) { SetScrollBars(); } - if (mh.modificationType & SC_MOD_CHANGEMARKER) { + if ((mh.modificationType & SC_MOD_CHANGEMARKER) || (mh.modificationType & SC_MOD_CHANGEMARGIN)) { if ((paintState == notPainting) || !PaintContainsMargin()) { if (mh.modificationType & SC_MOD_CHANGEFOLD) { // Fold changes can affect the drawing of following lines so redraw whole margin @@ -3925,6 +4314,8 @@ void Editor::NotifyModified(Document*, DocModification mh, void *) { scn.line = mh.line; scn.foldLevelNow = mh.foldLevelNow; scn.foldLevelPrev = mh.foldLevelPrev; + scn.token = mh.token; + scn.annotationLinesAdded = mh.annotationLinesAdded; NotifyParent(scn); } } @@ -4036,6 +4427,7 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lPar case SCI_PAGEUPRECTEXTEND: case SCI_PAGEDOWNRECTEXTEND: case SCI_SELECTIONDUPLICATE: + case SCI_COPYALLOWLINE: break; // Filter out all others like display changes. Also, newlines are redundant @@ -4061,11 +4453,11 @@ void Editor::NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lPar * If stuttered = true and not already at first/last row, move to first/last row of window. * If stuttered = true and already at first/last row, scroll as normal. */ -void Editor::PageMove(int direction, selTypes sel, bool stuttered) { +void Editor::PageMove(int direction, Selection::selTypes selt, bool stuttered) { int topLineNew, newPos; // I consider only the caretYSlop, and ignore the caretYPolicy-- is that a problem? - int currentLine = pdoc->LineFromPosition(currentPos); + int currentLine = pdoc->LineFromPosition(sel.MainCaret()); int topStutterLine = topLine + caretYSlop; int bottomStutterLine = pdoc->LineFromPosition(PositionFromLocation( @@ -4081,7 +4473,7 @@ void Editor::PageMove(int direction, selTypes sel, bool stuttered) { newPos = PositionFromLocation(Point(lastXChosen, vs.lineHeight * (LinesToScroll() - caretYSlop))); } else { - Point pt = LocationFromPosition(currentPos); + Point pt = LocationFromPosition(sel.MainCaret()); topLineNew = Platform::Clamp( topLine + direction * LinesToScroll(), 0, MaxScrollPos()); @@ -4091,39 +4483,29 @@ void Editor::PageMove(int direction, selTypes sel, bool stuttered) { if (topLineNew != topLine) { SetTopLine(topLineNew); - MovePositionTo(newPos, sel); + MovePositionTo(SelectionPosition(newPos), selt); Redraw(); SetVerticalScrollPos(); } else { - MovePositionTo(newPos, sel); + MovePositionTo(SelectionPosition(newPos), selt); } } void Editor::ChangeCaseOfSelection(bool makeUpperCase) { - pdoc->BeginUndoAction(); - int startCurrent = currentPos; - int startAnchor = anchor; - if (selType == selStream) { - pdoc->ChangeCase(Range(SelectionStart(), SelectionEnd()), - makeUpperCase); - SetSelection(startCurrent, startAnchor); - } else { - SelectionLineIterator lineIterator(this, false); - while (lineIterator.Iterate()) { - pdoc->ChangeCase( - Range(lineIterator.startPos, lineIterator.endPos), - makeUpperCase); - } - // Would be nicer to keep the rectangular selection but this is complex - SetEmptySelection(startCurrent); + UndoGroup ug(pdoc); + for (size_t r=0; rChangeCase(Range(current.Start().Position(), current.End().Position()), + makeUpperCase); + // Automatic movement cuts off last character so reset to exactly the same as it was. + sel.Range(r) = current; } - pdoc->EndUndoAction(); } void Editor::LineTranspose() { - int line = pdoc->LineFromPosition(currentPos); + int line = pdoc->LineFromPosition(sel.MainCaret()); if (line > 0) { - pdoc->BeginUndoAction(); + UndoGroup ug(pdoc); int startPrev = pdoc->LineStart(line - 1); int endPrev = pdoc->LineEnd(line - 1); int start = pdoc->LineStart(line); @@ -4136,37 +4518,54 @@ void Editor::LineTranspose() { pdoc->DeleteChars(startPrev, len1); pdoc->InsertString(startPrev, line2, len2); pdoc->InsertString(start - len1 + len2, line1, len1); - MovePositionTo(start - len1 + len2); + MovePositionTo(SelectionPosition(start - len1 + len2)); delete []line1; delete []line2; - pdoc->EndUndoAction(); } } void Editor::Duplicate(bool forLine) { - int start = SelectionStart(); - int end = SelectionEnd(); - if (start == end) { + if (sel.Empty()) { forLine = true; } + UndoGroup ug(pdoc, sel.Count() > 1); + SelectionPosition last; + const char *eol = ""; + int eolLen = 0; if (forLine) { - int line = pdoc->LineFromPosition(currentPos); - start = pdoc->LineStart(line); - end = pdoc->LineEnd(line); + eol = StringFromEOLMode(pdoc->eolMode); + eolLen = istrlen(eol); + } + for (size_t r=0; rLineFromPosition(sel.Range(r).caret.Position()); + start = SelectionPosition(pdoc->LineStart(line)); + end = SelectionPosition(pdoc->LineEnd(line)); + } + char *text = CopyRange(start.Position(), end.Position()); + if (forLine) + pdoc->InsertString(end.Position(), eol, eolLen); + pdoc->InsertString(end.Position() + eolLen, text, SelectionRange(end, start).Length()); + delete []text; } - char *text = CopyRange(start, end); - if (forLine) { - const char *eol = StringFromEOLMode(pdoc->eolMode); - pdoc->InsertCString(end, eol); - pdoc->InsertString(end + istrlen(eol), text, end - start); - } else { - pdoc->InsertString(end, text, end - start); + if (sel.Count() && sel.IsRectangular()) { + SelectionPosition last = sel.Last(); + if (forLine) { + int line = pdoc->LineFromPosition(last.Position()); + last = SelectionPosition(last.Position() + pdoc->LineStart(line+1) - pdoc->LineStart(line)); + } + if (sel.Rectangular().anchor > sel.Rectangular().caret) + sel.Rectangular().anchor = last; + else + sel.Rectangular().caret = last; + SetRectangularRange(); } - delete []text; } void Editor::CancelModes() { - moveExtendsSelection = false; + sel.SetMoveExtends(false); } void Editor::NewLine() { @@ -4177,10 +4576,16 @@ void Editor::NewLine() { } else if (pdoc->eolMode == SC_EOL_CR) { eol = "\r"; } // else SC_EOL_LF -> "\n" already set - if (pdoc->InsertCString(currentPos, eol)) { - SetEmptySelection(currentPos + istrlen(eol)); + if (pdoc->InsertCString(sel.MainCaret(), eol)) { + SetEmptySelection(sel.MainCaret() + istrlen(eol)); while (*eol) { NotifyChar(*eol); + if (recordingMacro) { + char txt[2]; + txt[0] = *eol; + txt[1] = '\0'; + NotifyMacroRecord(SCI_REPLACESEL, 0, reinterpret_cast(txt)); + } eol++; } } @@ -4191,33 +4596,50 @@ void Editor::NewLine() { ShowCaretAtCurrentPosition(); } -void Editor::CursorUpOrDown(int direction, selTypes sel) { - Point pt = LocationFromPosition(currentPos); - int posNew = PositionFromLocation( - Point(lastXChosen, pt.y + direction * vs.lineHeight)); +void Editor::CursorUpOrDown(int direction, Selection::selTypes selt) { + SelectionPosition caretToUse = sel.Range(sel.Main()).caret; + if (sel.IsRectangular()) { + if (selt == Selection::noSel) { + caretToUse = (direction > 0) ? sel.Limits().end : sel.Limits().start; + } else { + caretToUse = sel.Rectangular().caret; + } + } + Point pt = LocationFromPosition(caretToUse); + int lineDoc = pdoc->LineFromPosition(caretToUse.Position()); + Point ptStartLine = LocationFromPosition(pdoc->LineStart(lineDoc)); + int subLine = (pt.y - ptStartLine.y) / vs.lineHeight; + int commentLines = vs.annotationVisible ? pdoc->AnnotationLines(lineDoc) : 0; + SelectionPosition posNew = SPositionFromLocation( + Point(lastXChosen, pt.y + direction * vs.lineHeight), false, false, UserVirtualSpace()); + if ((direction > 0) && (subLine >= (cs.GetHeight(lineDoc) - 1 - commentLines))) { + posNew = SPositionFromLocation( + Point(lastXChosen, pt.y + (commentLines + 1) * vs.lineHeight), false, false, UserVirtualSpace()); + } if (direction < 0) { // Line wrapping may lead to a location on the same line, so // seek back if that is the case. // There is an equivalent case when moving down which skips // over a line but as that does not trap the user it is fine. - Point ptNew = LocationFromPosition(posNew); - while ((posNew > 0) && (pt.y == ptNew.y)) { - posNew--; - ptNew = LocationFromPosition(posNew); + Point ptNew = LocationFromPosition(posNew.Position()); + while ((posNew.Position() > 0) && (pt.y == ptNew.y)) { + posNew.Add(- 1); + posNew.SetVirtualSpace(0); + ptNew = LocationFromPosition(posNew.Position()); } } - MovePositionTo(posNew, sel); + MovePositionTo(posNew, selt); } -void Editor::ParaUpOrDown(int direction, selTypes sel) { - int lineDoc, savedPos = currentPos; +void Editor::ParaUpOrDown(int direction, Selection::selTypes selt) { + int lineDoc, savedPos = sel.MainCaret(); do { - MovePositionTo(direction > 0 ? pdoc->ParaDown(currentPos) : pdoc->ParaUp(currentPos), sel); - lineDoc = pdoc->LineFromPosition(currentPos); + MovePositionTo(SelectionPosition(direction > 0 ? pdoc->ParaDown(sel.MainCaret()) : pdoc->ParaUp(sel.MainCaret())), selt); + lineDoc = pdoc->LineFromPosition(sel.MainCaret()); if (direction > 0) { - if (currentPos >= pdoc->Length() && !cs.GetVisible(lineDoc)) { - if (sel == noSel) { - MovePositionTo(pdoc->LineEndPosition(savedPos)); + if (sel.MainCaret() >= pdoc->Length() && !cs.GetVisible(lineDoc)) { + if (selt == Selection::noSel) { + MovePositionTo(SelectionPosition(pdoc->LineEndPosition(savedPos))); } break; } @@ -4263,16 +4685,16 @@ int Editor::KeyCommand(unsigned int iMessage) { CursorUpOrDown(1); break; case SCI_LINEDOWNEXTEND: - CursorUpOrDown(1, selStream); + CursorUpOrDown(1, Selection::selStream); break; case SCI_LINEDOWNRECTEXTEND: - CursorUpOrDown(1, selRectangle); + CursorUpOrDown(1, Selection::selRectangle); break; case SCI_PARADOWN: ParaUpOrDown(1); break; case SCI_PARADOWNEXTEND: - ParaUpOrDown(1, selStream); + ParaUpOrDown(1, Selection::selStream); break; case SCI_LINESCROLLDOWN: ScrollTo(topLine + 1); @@ -4282,144 +4704,182 @@ int Editor::KeyCommand(unsigned int iMessage) { CursorUpOrDown(-1); break; case SCI_LINEUPEXTEND: - CursorUpOrDown(-1, selStream); + CursorUpOrDown(-1, Selection::selStream); break; case SCI_LINEUPRECTEXTEND: - CursorUpOrDown(-1, selRectangle); + CursorUpOrDown(-1, Selection::selRectangle); break; case SCI_PARAUP: ParaUpOrDown(-1); break; case SCI_PARAUPEXTEND: - ParaUpOrDown(-1, selStream); + ParaUpOrDown(-1, Selection::selStream); break; case SCI_LINESCROLLUP: ScrollTo(topLine - 1); MoveCaretInsideView(false); break; case SCI_CHARLEFT: - if (SelectionEmpty() || moveExtendsSelection) { - MovePositionTo(MovePositionSoVisible(currentPos - 1, -1)); + if (SelectionEmpty() || sel.MoveExtends()) { + if ((sel.Count() == 1) && pdoc->IsLineEndPosition(sel.MainCaret()) && sel.RangeMain().caret.VirtualSpace()) { + SelectionPosition spCaret = sel.RangeMain().caret; + spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1); + MovePositionTo(spCaret); + } else { + MovePositionTo(MovePositionSoVisible( + SelectionPosition((sel.LimitsForRectangularElseMain().start).Position() - 1), -1)); + } } else { - MovePositionTo(SelectionStart()); + MovePositionTo(sel.LimitsForRectangularElseMain().start); } SetLastXChosen(); break; case SCI_CHARLEFTEXTEND: - MovePositionTo(MovePositionSoVisible(currentPos - 1, -1), selStream); + if (pdoc->IsLineEndPosition(sel.MainCaret()) && sel.RangeMain().caret.VirtualSpace()) { + SelectionPosition spCaret = sel.RangeMain().caret; + spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1); + MovePositionTo(spCaret, Selection::selStream); + } else { + MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() - 1), -1), Selection::selStream); + } SetLastXChosen(); break; case SCI_CHARLEFTRECTEXTEND: - MovePositionTo(MovePositionSoVisible(currentPos - 1, -1), selRectangle); + if (pdoc->IsLineEndPosition(sel.MainCaret()) && sel.RangeMain().caret.VirtualSpace()) { + SelectionPosition spCaret = sel.RangeMain().caret; + spCaret.SetVirtualSpace(spCaret.VirtualSpace() - 1); + MovePositionTo(spCaret, Selection::selRectangle); + } else { + MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() - 1), -1), Selection::selRectangle); + } SetLastXChosen(); break; case SCI_CHARRIGHT: - if (SelectionEmpty() || moveExtendsSelection) { - MovePositionTo(MovePositionSoVisible(currentPos + 1, 1)); + if (SelectionEmpty() || sel.MoveExtends()) { + if ((virtualSpaceOptions & SCVS_USERACCESSIBLE) && pdoc->IsLineEndPosition(sel.MainCaret())) { + SelectionPosition spCaret = sel.RangeMain().caret; + spCaret.SetVirtualSpace(spCaret.VirtualSpace() + 1); + MovePositionTo(spCaret); + } else { + MovePositionTo(MovePositionSoVisible( + SelectionPosition((sel.LimitsForRectangularElseMain().end).Position() + 1), 1)); + } } else { - MovePositionTo(SelectionEnd()); + MovePositionTo(sel.LimitsForRectangularElseMain().end); } SetLastXChosen(); break; case SCI_CHARRIGHTEXTEND: - MovePositionTo(MovePositionSoVisible(currentPos + 1, 1), selStream); + if ((virtualSpaceOptions & SCVS_USERACCESSIBLE) && pdoc->IsLineEndPosition(sel.MainCaret())) { + SelectionPosition spCaret = sel.RangeMain().caret; + spCaret.SetVirtualSpace(spCaret.VirtualSpace() + 1); + MovePositionTo(spCaret, Selection::selStream); + } else { + MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() + 1), 1), Selection::selStream); + } SetLastXChosen(); break; case SCI_CHARRIGHTRECTEXTEND: - MovePositionTo(MovePositionSoVisible(currentPos + 1, 1), selRectangle); + if ((virtualSpaceOptions & SCVS_RECTANGULARSELECTION) && pdoc->IsLineEndPosition(sel.MainCaret())) { + SelectionPosition spCaret = sel.RangeMain().caret; + spCaret.SetVirtualSpace(spCaret.VirtualSpace() + 1); + MovePositionTo(spCaret, Selection::selRectangle); + } else { + MovePositionTo(MovePositionSoVisible(SelectionPosition(sel.MainCaret() + 1), 1), Selection::selRectangle); + } SetLastXChosen(); break; case SCI_WORDLEFT: - MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(currentPos, -1), -1)); + MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(sel.MainCaret(), -1), -1)); SetLastXChosen(); break; case SCI_WORDLEFTEXTEND: - MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(currentPos, -1), -1), selStream); + MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(sel.MainCaret(), -1), -1), Selection::selStream); SetLastXChosen(); break; case SCI_WORDRIGHT: - MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(currentPos, 1), 1)); + MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(sel.MainCaret(), 1), 1)); SetLastXChosen(); break; case SCI_WORDRIGHTEXTEND: - MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(currentPos, 1), 1), selStream); + MovePositionTo(MovePositionSoVisible(pdoc->NextWordStart(sel.MainCaret(), 1), 1), Selection::selStream); SetLastXChosen(); break; case SCI_WORDLEFTEND: - MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(currentPos, -1), -1)); + MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(sel.MainCaret(), -1), -1)); SetLastXChosen(); break; case SCI_WORDLEFTENDEXTEND: - MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(currentPos, -1), -1), selStream); + MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(sel.MainCaret(), -1), -1), Selection::selStream); SetLastXChosen(); break; case SCI_WORDRIGHTEND: - MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(currentPos, 1), 1)); + MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(sel.MainCaret(), 1), 1)); SetLastXChosen(); break; case SCI_WORDRIGHTENDEXTEND: - MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(currentPos, 1), 1), selStream); + MovePositionTo(MovePositionSoVisible(pdoc->NextWordEnd(sel.MainCaret(), 1), 1), Selection::selStream); SetLastXChosen(); break; case SCI_HOME: - MovePositionTo(pdoc->LineStart(pdoc->LineFromPosition(currentPos))); + MovePositionTo(pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret()))); SetLastXChosen(); break; case SCI_HOMEEXTEND: - MovePositionTo(pdoc->LineStart(pdoc->LineFromPosition(currentPos)), selStream); + MovePositionTo(pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret())), Selection::selStream); SetLastXChosen(); break; case SCI_HOMERECTEXTEND: - MovePositionTo(pdoc->LineStart(pdoc->LineFromPosition(currentPos)), selRectangle); + MovePositionTo(pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret())), Selection::selRectangle); SetLastXChosen(); break; case SCI_LINEEND: - MovePositionTo(pdoc->LineEndPosition(currentPos)); + MovePositionTo(pdoc->LineEndPosition(sel.MainCaret())); SetLastXChosen(); break; case SCI_LINEENDEXTEND: - MovePositionTo(pdoc->LineEndPosition(currentPos), selStream); + MovePositionTo(pdoc->LineEndPosition(sel.MainCaret()), Selection::selStream); SetLastXChosen(); break; case SCI_LINEENDRECTEXTEND: - MovePositionTo(pdoc->LineEndPosition(currentPos), selRectangle); + MovePositionTo(pdoc->LineEndPosition(sel.MainCaret()), Selection::selRectangle); SetLastXChosen(); break; case SCI_HOMEWRAP: { - int homePos = MovePositionSoVisible(StartEndDisplayLine(currentPos, true), -1); - if (currentPos <= homePos) - homePos = pdoc->LineStart(pdoc->LineFromPosition(currentPos)); + SelectionPosition homePos = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), true), -1); + if (sel.RangeMain().caret <= homePos) + homePos = SelectionPosition(pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret()))); MovePositionTo(homePos); SetLastXChosen(); } break; case SCI_HOMEWRAPEXTEND: { - int homePos = MovePositionSoVisible(StartEndDisplayLine(currentPos, true), -1); - if (currentPos <= homePos) - homePos = pdoc->LineStart(pdoc->LineFromPosition(currentPos)); - MovePositionTo(homePos, selStream); + SelectionPosition homePos = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), true), -1); + if (sel.RangeMain().caret <= homePos) + homePos = SelectionPosition(pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret()))); + MovePositionTo(homePos, Selection::selStream); SetLastXChosen(); } break; case SCI_LINEENDWRAP: { - int endPos = MovePositionSoVisible(StartEndDisplayLine(currentPos, false), 1); - int realEndPos = pdoc->LineEndPosition(currentPos); + SelectionPosition endPos = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), false), 1); + SelectionPosition realEndPos = SelectionPosition(pdoc->LineEndPosition(sel.MainCaret())); if (endPos > realEndPos // if moved past visible EOLs - || currentPos >= endPos) // if at end of display line already + || sel.RangeMain().caret >= endPos) // if at end of display line already endPos = realEndPos; MovePositionTo(endPos); SetLastXChosen(); } break; case SCI_LINEENDWRAPEXTEND: { - int endPos = MovePositionSoVisible(StartEndDisplayLine(currentPos, false), 1); - int realEndPos = pdoc->LineEndPosition(currentPos); + SelectionPosition endPos = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), false), 1); + SelectionPosition realEndPos = SelectionPosition(pdoc->LineEndPosition(sel.MainCaret())); if (endPos > realEndPos // if moved past visible EOLs - || currentPos >= endPos) // if at end of display line already + || sel.RangeMain().caret >= endPos) // if at end of display line already endPos = realEndPos; - MovePositionTo(endPos, selStream); + MovePositionTo(endPos, Selection::selStream); SetLastXChosen(); } break; @@ -4428,7 +4888,7 @@ int Editor::KeyCommand(unsigned int iMessage) { SetLastXChosen(); break; case SCI_DOCUMENTSTARTEXTEND: - MovePositionTo(0, selStream); + MovePositionTo(0, Selection::selStream); SetLastXChosen(); break; case SCI_DOCUMENTEND: @@ -4436,38 +4896,38 @@ int Editor::KeyCommand(unsigned int iMessage) { SetLastXChosen(); break; case SCI_DOCUMENTENDEXTEND: - MovePositionTo(pdoc->Length(), selStream); + MovePositionTo(pdoc->Length(), Selection::selStream); SetLastXChosen(); break; case SCI_STUTTEREDPAGEUP: - PageMove(-1, noSel, true); + PageMove(-1, Selection::noSel, true); break; case SCI_STUTTEREDPAGEUPEXTEND: - PageMove(-1, selStream, true); + PageMove(-1, Selection::selStream, true); break; case SCI_STUTTEREDPAGEDOWN: - PageMove(1, noSel, true); + PageMove(1, Selection::noSel, true); break; case SCI_STUTTEREDPAGEDOWNEXTEND: - PageMove(1, selStream, true); + PageMove(1, Selection::selStream, true); break; case SCI_PAGEUP: PageMove(-1); break; case SCI_PAGEUPEXTEND: - PageMove(-1, selStream); + PageMove(-1, Selection::selStream); break; case SCI_PAGEUPRECTEXTEND: - PageMove(-1, selRectangle); + PageMove(-1, Selection::selRectangle); break; case SCI_PAGEDOWN: PageMove(1); break; case SCI_PAGEDOWNEXTEND: - PageMove(1, selStream); + PageMove(1, Selection::selStream); break; case SCI_PAGEDOWNRECTEXTEND: - PageMove(1, selRectangle); + PageMove(1, Selection::selRectangle); break; case SCI_EDITTOGGLEOVERTYPE: inOverstrike = !inOverstrike; @@ -4499,6 +4959,7 @@ int Editor::KeyCommand(unsigned int iMessage) { SetLastXChosen(); } EnsureCaretVisible(); + ShowCaretAtCurrentPosition(); // Avoid blinking break; case SCI_BACKTAB: Indent(false); @@ -4506,6 +4967,7 @@ int Editor::KeyCommand(unsigned int iMessage) { SetLastXChosen(); } EnsureCaretVisible(); + ShowCaretAtCurrentPosition(); // Avoid blinking break; case SCI_NEWLINE: NewLine(); @@ -4514,21 +4976,21 @@ int Editor::KeyCommand(unsigned int iMessage) { AddChar('\f'); break; case SCI_VCHOME: - MovePositionTo(pdoc->VCHomePosition(currentPos)); + MovePositionTo(pdoc->VCHomePosition(sel.MainCaret())); SetLastXChosen(); break; case SCI_VCHOMEEXTEND: - MovePositionTo(pdoc->VCHomePosition(currentPos), selStream); + MovePositionTo(pdoc->VCHomePosition(sel.MainCaret()), Selection::selStream); SetLastXChosen(); break; case SCI_VCHOMERECTEXTEND: - MovePositionTo(pdoc->VCHomePosition(currentPos), selRectangle); + MovePositionTo(pdoc->VCHomePosition(sel.MainCaret()), Selection::selRectangle); SetLastXChosen(); break; case SCI_VCHOMEWRAP: { - int homePos = pdoc->VCHomePosition(currentPos); - int viewLineStart = MovePositionSoVisible(StartEndDisplayLine(currentPos, true), -1); - if ((viewLineStart < currentPos) && (viewLineStart > homePos)) + SelectionPosition homePos = SelectionPosition(pdoc->VCHomePosition(sel.MainCaret())); + SelectionPosition viewLineStart = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), true), -1); + if ((viewLineStart < sel.RangeMain().caret) && (viewLineStart > homePos)) homePos = viewLineStart; MovePositionTo(homePos); @@ -4536,12 +4998,12 @@ int Editor::KeyCommand(unsigned int iMessage) { } break; case SCI_VCHOMEWRAPEXTEND: { - int homePos = pdoc->VCHomePosition(currentPos); - int viewLineStart = MovePositionSoVisible(StartEndDisplayLine(currentPos, true), -1); - if ((viewLineStart < currentPos) && (viewLineStart > homePos)) + SelectionPosition homePos = SelectionPosition(pdoc->VCHomePosition(sel.MainCaret())); + SelectionPosition viewLineStart = MovePositionSoVisible(StartEndDisplayLine(sel.MainCaret(), true), -1); + if ((viewLineStart < sel.RangeMain().caret) && (viewLineStart > homePos)) homePos = viewLineStart; - MovePositionTo(homePos, selStream); + MovePositionTo(homePos, Selection::selStream); SetLastXChosen(); } break; @@ -4560,44 +5022,52 @@ int Editor::KeyCommand(unsigned int iMessage) { } break; case SCI_DELWORDLEFT: { - int startWord = pdoc->NextWordStart(currentPos, -1); - pdoc->DeleteChars(startWord, currentPos - startWord); + int startWord = pdoc->NextWordStart(sel.MainCaret(), -1); + pdoc->DeleteChars(startWord, sel.MainCaret() - startWord); + sel.RangeMain().ClearVirtualSpace(); SetLastXChosen(); } break; case SCI_DELWORDRIGHT: { - int endWord = pdoc->NextWordStart(currentPos, 1); - pdoc->DeleteChars(currentPos, endWord - currentPos); + UndoGroup ug(pdoc); + sel.RangeMain().caret = SelectionPosition( + InsertSpace(sel.RangeMain().caret.Position(), sel.RangeMain().caret.VirtualSpace())); + int endWord = pdoc->NextWordStart(sel.MainCaret(), 1); + pdoc->DeleteChars(sel.MainCaret(), endWord - sel.MainCaret()); } break; case SCI_DELWORDRIGHTEND: { - int endWord = pdoc->NextWordEnd(currentPos, 1); - pdoc->DeleteChars(currentPos, endWord - currentPos); + UndoGroup ug(pdoc); + sel.RangeMain().caret = SelectionPosition( + InsertSpace(sel.RangeMain().caret.Position(), sel.RangeMain().caret.VirtualSpace())); + int endWord = pdoc->NextWordEnd(sel.MainCaret(), 1); + pdoc->DeleteChars(sel.MainCaret(), endWord - sel.MainCaret()); } break; case SCI_DELLINELEFT: { - int line = pdoc->LineFromPosition(currentPos); + int line = pdoc->LineFromPosition(sel.MainCaret()); int start = pdoc->LineStart(line); - pdoc->DeleteChars(start, currentPos - start); + pdoc->DeleteChars(start, sel.MainCaret() - start); + sel.RangeMain().ClearVirtualSpace(); SetLastXChosen(); } break; case SCI_DELLINERIGHT: { - int line = pdoc->LineFromPosition(currentPos); + int line = pdoc->LineFromPosition(sel.MainCaret()); int end = pdoc->LineEnd(line); - pdoc->DeleteChars(currentPos, end - currentPos); + pdoc->DeleteChars(sel.MainCaret(), end - sel.MainCaret()); } break; case SCI_LINECOPY: { - int lineStart = pdoc->LineFromPosition(SelectionStart()); - int lineEnd = pdoc->LineFromPosition(SelectionEnd()); + int lineStart = pdoc->LineFromPosition(SelectionStart().Position()); + int lineEnd = pdoc->LineFromPosition(SelectionEnd().Position()); CopyRangeToClipboard(pdoc->LineStart(lineStart), pdoc->LineStart(lineEnd + 1)); } break; case SCI_LINECUT: { - int lineStart = pdoc->LineFromPosition(SelectionStart()); - int lineEnd = pdoc->LineFromPosition(SelectionEnd()); + int lineStart = pdoc->LineFromPosition(SelectionStart().Position()); + int lineEnd = pdoc->LineFromPosition(SelectionEnd().Position()); int start = pdoc->LineStart(lineStart); int end = pdoc->LineStart(lineEnd + 1); SetSelection(start, end); @@ -4606,7 +5076,7 @@ int Editor::KeyCommand(unsigned int iMessage) { } break; case SCI_LINEDELETE: { - int line = pdoc->LineFromPosition(currentPos); + int line = pdoc->LineFromPosition(sel.MainCaret()); int start = pdoc->LineStart(line); int end = pdoc->LineStart(line + 1); pdoc->DeleteChars(start, end - start); @@ -4628,39 +5098,39 @@ int Editor::KeyCommand(unsigned int iMessage) { ChangeCaseOfSelection(true); break; case SCI_WORDPARTLEFT: - MovePositionTo(MovePositionSoVisible(pdoc->WordPartLeft(currentPos), -1)); + MovePositionTo(MovePositionSoVisible(pdoc->WordPartLeft(sel.MainCaret()), -1)); SetLastXChosen(); break; case SCI_WORDPARTLEFTEXTEND: - MovePositionTo(MovePositionSoVisible(pdoc->WordPartLeft(currentPos), -1), selStream); + MovePositionTo(MovePositionSoVisible(pdoc->WordPartLeft(sel.MainCaret()), -1), Selection::selStream); SetLastXChosen(); break; case SCI_WORDPARTRIGHT: - MovePositionTo(MovePositionSoVisible(pdoc->WordPartRight(currentPos), 1)); + MovePositionTo(MovePositionSoVisible(pdoc->WordPartRight(sel.MainCaret()), 1)); SetLastXChosen(); break; case SCI_WORDPARTRIGHTEXTEND: - MovePositionTo(MovePositionSoVisible(pdoc->WordPartRight(currentPos), 1), selStream); + MovePositionTo(MovePositionSoVisible(pdoc->WordPartRight(sel.MainCaret()), 1), Selection::selStream); SetLastXChosen(); break; case SCI_HOMEDISPLAY: MovePositionTo(MovePositionSoVisible( - StartEndDisplayLine(currentPos, true), -1)); + StartEndDisplayLine(sel.MainCaret(), true), -1)); SetLastXChosen(); break; case SCI_HOMEDISPLAYEXTEND: MovePositionTo(MovePositionSoVisible( - StartEndDisplayLine(currentPos, true), -1), selStream); + StartEndDisplayLine(sel.MainCaret(), true), -1), Selection::selStream); SetLastXChosen(); break; case SCI_LINEENDDISPLAY: MovePositionTo(MovePositionSoVisible( - StartEndDisplayLine(currentPos, false), 1)); + StartEndDisplayLine(sel.MainCaret(), false), 1)); SetLastXChosen(); break; case SCI_LINEENDDISPLAYEXTEND: MovePositionTo(MovePositionSoVisible( - StartEndDisplayLine(currentPos, false), 1), selStream); + StartEndDisplayLine(sel.MainCaret(), false), 1), Selection::selStream); SetLastXChosen(); break; } @@ -4696,77 +5166,79 @@ int Editor::GetWhitespaceVisible() { } void Editor::Indent(bool forwards) { - //Platform::DebugPrintf("INdent %d\n", forwards); - int lineOfAnchor = pdoc->LineFromPosition(anchor); - int lineCurrentPos = pdoc->LineFromPosition(currentPos); - if (lineOfAnchor == lineCurrentPos) { - if (forwards) { - pdoc->BeginUndoAction(); - ClearSelection(); - if (pdoc->GetColumn(currentPos) <= pdoc->GetColumn(pdoc->GetLineIndentPosition(lineCurrentPos)) && - pdoc->tabIndents) { - int indentation = pdoc->GetLineIndentation(lineCurrentPos); - int indentationStep = pdoc->IndentSize(); - pdoc->SetLineIndentation(lineCurrentPos, indentation + indentationStep - indentation % indentationStep); - SetEmptySelection(pdoc->GetLineIndentPosition(lineCurrentPos)); - } else { - if (pdoc->useTabs) { - pdoc->InsertChar(currentPos, '\t'); - SetEmptySelection(currentPos + 1); + for (size_t r=0; rLineFromPosition(sel.Range(r).anchor.Position()); + int caretPosition = sel.Range(r).caret.Position(); + int lineCurrentPos = pdoc->LineFromPosition(caretPosition); + if (lineOfAnchor == lineCurrentPos) { + if (forwards) { + UndoGroup ug(pdoc); + pdoc->DeleteChars(sel.Range(r).Start().Position(), sel.Range(r).Length()); + caretPosition = sel.Range(r).caret.Position(); + if (pdoc->GetColumn(caretPosition) <= pdoc->GetColumn(pdoc->GetLineIndentPosition(lineCurrentPos)) && + pdoc->tabIndents) { + int indentation = pdoc->GetLineIndentation(lineCurrentPos); + int indentationStep = pdoc->IndentSize(); + pdoc->SetLineIndentation(lineCurrentPos, indentation + indentationStep - indentation % indentationStep); + sel.Range(r) = SelectionRange(pdoc->GetLineIndentPosition(lineCurrentPos)); } else { - int numSpaces = (pdoc->tabInChars) - - (pdoc->GetColumn(currentPos) % (pdoc->tabInChars)); - if (numSpaces < 1) - numSpaces = pdoc->tabInChars; - for (int i = 0; i < numSpaces; i++) { - pdoc->InsertChar(currentPos + i, ' '); + if (pdoc->useTabs) { + pdoc->InsertChar(caretPosition, '\t'); + sel.Range(r) = SelectionRange(caretPosition+1); + } else { + int numSpaces = (pdoc->tabInChars) - + (pdoc->GetColumn(caretPosition) % (pdoc->tabInChars)); + if (numSpaces < 1) + numSpaces = pdoc->tabInChars; + for (int i = 0; i < numSpaces; i++) { + pdoc->InsertChar(caretPosition + i, ' '); + } + sel.Range(r) = SelectionRange(caretPosition+numSpaces); } - SetEmptySelection(currentPos + numSpaces); + } + } else { + if (pdoc->GetColumn(caretPosition) <= pdoc->GetLineIndentation(lineCurrentPos) && + pdoc->tabIndents) { + UndoGroup ug(pdoc); + int indentation = pdoc->GetLineIndentation(lineCurrentPos); + int indentationStep = pdoc->IndentSize(); + pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep); + SetEmptySelection(pdoc->GetLineIndentPosition(lineCurrentPos)); + } else { + int newColumn = ((pdoc->GetColumn(caretPosition) - 1) / pdoc->tabInChars) * + pdoc->tabInChars; + if (newColumn < 0) + newColumn = 0; + int newPos = caretPosition; + while (pdoc->GetColumn(newPos) > newColumn) + newPos--; + sel.Range(r) = SelectionRange(newPos); } } - pdoc->EndUndoAction(); - } else { - if (pdoc->GetColumn(currentPos) <= pdoc->GetLineIndentation(lineCurrentPos) && - pdoc->tabIndents) { - pdoc->BeginUndoAction(); - int indentation = pdoc->GetLineIndentation(lineCurrentPos); - int indentationStep = pdoc->IndentSize(); - pdoc->SetLineIndentation(lineCurrentPos, indentation - indentationStep); - SetEmptySelection(pdoc->GetLineIndentPosition(lineCurrentPos)); - pdoc->EndUndoAction(); + } else { // Multiline + int anchorPosOnLine = sel.Range(r).anchor.Position() - pdoc->LineStart(lineOfAnchor); + int currentPosPosOnLine = caretPosition - pdoc->LineStart(lineCurrentPos); + // Multiple lines selected so indent / dedent + int lineTopSel = Platform::Minimum(lineOfAnchor, lineCurrentPos); + int lineBottomSel = Platform::Maximum(lineOfAnchor, lineCurrentPos); + if (pdoc->LineStart(lineBottomSel) == sel.Range(r).anchor.Position() || pdoc->LineStart(lineBottomSel) == caretPosition) + lineBottomSel--; // If not selecting any characters on a line, do not indent + { + UndoGroup ug(pdoc); + pdoc->Indent(forwards, lineBottomSel, lineTopSel); + } + if (lineOfAnchor < lineCurrentPos) { + if (currentPosPosOnLine == 0) + sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos), pdoc->LineStart(lineOfAnchor)); + else + sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos + 1), pdoc->LineStart(lineOfAnchor)); } else { - int newColumn = ((pdoc->GetColumn(currentPos) - 1) / pdoc->tabInChars) * - pdoc->tabInChars; - if (newColumn < 0) - newColumn = 0; - int newPos = currentPos; - while (pdoc->GetColumn(newPos) > newColumn) - newPos--; - SetEmptySelection(newPos); + if (anchorPosOnLine == 0) + sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos), pdoc->LineStart(lineOfAnchor)); + else + sel.Range(r) = SelectionRange(pdoc->LineStart(lineCurrentPos), pdoc->LineStart(lineOfAnchor + 1)); } } - } else { - int anchorPosOnLine = anchor - pdoc->LineStart(lineOfAnchor); - int currentPosPosOnLine = currentPos - pdoc->LineStart(lineCurrentPos); - // Multiple lines selected so indent / dedent - int lineTopSel = Platform::Minimum(lineOfAnchor, lineCurrentPos); - int lineBottomSel = Platform::Maximum(lineOfAnchor, lineCurrentPos); - if (pdoc->LineStart(lineBottomSel) == anchor || pdoc->LineStart(lineBottomSel) == currentPos) - lineBottomSel--; // If not selecting any characters on a line, do not indent - pdoc->BeginUndoAction(); - pdoc->Indent(forwards, lineBottomSel, lineTopSel); - pdoc->EndUndoAction(); - if (lineOfAnchor < lineCurrentPos) { - if (currentPosPosOnLine == 0) - SetSelection(pdoc->LineStart(lineCurrentPos), pdoc->LineStart(lineOfAnchor)); - else - SetSelection(pdoc->LineStart(lineCurrentPos + 1), pdoc->LineStart(lineOfAnchor)); - } else { - if (anchorPosOnLine == 0) - SetSelection(pdoc->LineStart(lineCurrentPos), pdoc->LineStart(lineOfAnchor)); - else - SetSelection(pdoc->LineStart(lineCurrentPos), pdoc->LineStart(lineOfAnchor + 1)); - } } } @@ -4779,14 +5251,14 @@ long Editor::FindText( ///< @c SCFIND_WORDSTART, @c SCFIND_REGEXP or @c SCFIND_POSIX. sptr_t lParam) { ///< @c TextToFind structure: The text to search for in the given range. - TextToFind *ft = reinterpret_cast(lParam); + Sci_TextToFind *ft = reinterpret_cast(lParam); int lengthFound = istrlen(ft->lpstrText); int pos = pdoc->FindText(ft->chrg.cpMin, ft->chrg.cpMax, ft->lpstrText, (wParam & SCFIND_MATCHCASE) != 0, (wParam & SCFIND_WHOLEWORD) != 0, (wParam & SCFIND_WORDSTART) != 0, (wParam & SCFIND_REGEXP) != 0, - (wParam & SCFIND_POSIX) != 0, + wParam, &lengthFound); if (pos != -1) { ft->chrgText.cpMin = pos; @@ -4807,7 +5279,7 @@ long Editor::FindText( * operation is self-contained. */ void Editor::SearchAnchor() { - searchAnchor = SelectionStart(); + searchAnchor = SelectionStart().Position(); } /** @@ -4830,7 +5302,7 @@ long Editor::SearchText( (wParam & SCFIND_WHOLEWORD) != 0, (wParam & SCFIND_WORDSTART) != 0, (wParam & SCFIND_REGEXP) != 0, - (wParam & SCFIND_POSIX) != 0, + wParam, &lengthFound); } else { pos = pdoc->FindText(searchAnchor, 0, txt, @@ -4838,7 +5310,7 @@ long Editor::SearchText( (wParam & SCFIND_WHOLEWORD) != 0, (wParam & SCFIND_WORDSTART) != 0, (wParam & SCFIND_REGEXP) != 0, - (wParam & SCFIND_POSIX) != 0, + wParam, &lengthFound); } @@ -4860,7 +5332,7 @@ long Editor::SearchInTarget(const char *text, int length) { (searchFlags & SCFIND_WHOLEWORD) != 0, (searchFlags & SCFIND_WORDSTART) != 0, (searchFlags & SCFIND_REGEXP) != 0, - (searchFlags & SCFIND_POSIX) != 0, + searchFlags, &lengthFound); if (pos != -1) { targetStart = pos; @@ -4892,62 +5364,71 @@ char *Editor::CopyRange(int start, int end) { if (start < end) { int len = end - start; text = new char[len + 1]; - if (text) { - for (int i = 0; i < len; i++) { - text[i] = pdoc->CharAt(start + i); - } - text[len] = '\0'; + for (int i = 0; i < len; i++) { + text[i] = pdoc->CharAt(start + i); } + text[len] = '\0'; } return text; } -void Editor::CopySelectionFromRange(SelectionText *ss, int start, int end) { - ss->Set(CopyRange(start, end), end - start + 1, - pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false); -} - -void Editor::CopySelectionRange(SelectionText *ss) { - if (selType == selStream) { - CopySelectionFromRange(ss, SelectionStart(), SelectionEnd()); +void Editor::CopySelectionRange(SelectionText *ss, bool allowLineCopy) { + if (sel.Empty()) { + if (allowLineCopy) { + int currentLine = pdoc->LineFromPosition(sel.MainCaret()); + int start = pdoc->LineStart(currentLine); + int end = pdoc->LineEnd(currentLine); + + char *text = CopyRange(start, end); + int textLen = text ? strlen(text) : 0; + // include room for \r\n\0 + textLen += 3; + char *textWithEndl = new char[textLen]; + textWithEndl[0] = '\0'; + if (text) + strncat(textWithEndl, text, textLen); + if (pdoc->eolMode != SC_EOL_LF) + strncat(textWithEndl, "\r", textLen); + if (pdoc->eolMode != SC_EOL_CR) + strncat(textWithEndl, "\n", textLen); + ss->Set(textWithEndl, strlen(textWithEndl) + 1, + pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, true); + delete []text; + } } else { - char *text = 0; - int size = 0; - SelectionLineIterator lineIterator(this); - while (lineIterator.Iterate()) { - size += lineIterator.endPos - lineIterator.startPos; - if (selType != selLines) { - size++; - if (pdoc->eolMode == SC_EOL_CRLF) { - size++; - } + int delimiterLength = 0; + if (sel.selType == Selection::selRectangle) { + if (pdoc->eolMode == SC_EOL_CRLF) { + delimiterLength = 2; + } else { + delimiterLength = 1; } } - if (size > 0) { - text = new char[size + 1]; - if (text) { - int j = 0; - lineIterator.Reset(); - while (lineIterator.Iterate()) { - for (int i = lineIterator.startPos; - i < lineIterator.endPos; - i++) { - text[j++] = pdoc->CharAt(i); - } - if (selType != selLines) { - if (pdoc->eolMode != SC_EOL_LF) { - text[j++] = '\r'; - } - if (pdoc->eolMode != SC_EOL_CR) { - text[j++] = '\n'; - } - } + int size = sel.Length() + delimiterLength * sel.Count(); + char *text = new char[size + 1]; + int j = 0; + SelRangeArray rangesInOrder = sel.RangesCopy(); + if (sel.selType == Selection::selRectangle) + SelRangeArraySort(rangesInOrder.begin(), rangesInOrder.end()); + for (size_t r=0; rCharAt(i); + } + if (sel.selType == Selection::selRectangle) { + if (pdoc->eolMode != SC_EOL_LF) { + text[j++] = '\r'; + } + if (pdoc->eolMode != SC_EOL_CR) { + text[j++] = '\n'; } - text[size] = '\0'; } } + text[size] = '\0'; ss->Set(text, size + 1, pdoc->dbcsCodePage, - vs.styles[STYLE_DEFAULT].characterSet, selType == selRectangle); + vs.styles[STYLE_DEFAULT].characterSet, sel.IsRectangular(), sel.selType == Selection::selLines); } } @@ -4956,23 +5437,23 @@ void Editor::CopyRangeToClipboard(int start, int end) { end = pdoc->ClampPositionIntoDocument(end); SelectionText selectedText; selectedText.Set(CopyRange(start, end), end - start + 1, - pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false); + pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, false); CopyToClipboard(selectedText); } void Editor::CopyText(int length, const char *text) { SelectionText selectedText; selectedText.Copy(text, length + 1, - pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false); + pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, false); CopyToClipboard(selectedText); } -void Editor::SetDragPosition(int newPos) { - if (newPos >= 0) { +void Editor::SetDragPosition(SelectionPosition newPos) { + if (newPos.Position() >= 0) { newPos = MovePositionOutsideChar(newPos, 1); posDrop = newPos; } - if (posDrag != newPos) { + if (!(posDrag == newPos)) { caret.on = true; SetTicking(true); InvalidateCaret(); @@ -5001,41 +5482,40 @@ void Editor::StartDrag() { //DisplayCursor(Window::cursorArrow); } -void Editor::DropAt(int position, const char *value, bool moving, bool rectangular) { +void Editor::DropAt(SelectionPosition position, const char *value, bool moving, bool rectangular) { //Platform::DebugPrintf("DropAt %d %d\n", inDragDrop, position); if (inDragDrop == ddDragging) dropWentOutside = false; - int positionWasInSelection = PositionInSelection(position); + bool positionWasInSelection = PositionInSelection(position.Position()); bool positionOnEdgeOfSelection = (position == SelectionStart()) || (position == SelectionEnd()); - if ((inDragDrop != ddDragging) || !(0 == positionWasInSelection) || + if ((inDragDrop != ddDragging) || !(positionWasInSelection) || (positionOnEdgeOfSelection && !moving)) { - int selStart = SelectionStart(); - int selEnd = SelectionEnd(); + SelectionPosition selStart = SelectionStart(); + SelectionPosition selEnd = SelectionEnd(); - pdoc->BeginUndoAction(); + UndoGroup ug(pdoc); - int positionAfterDeletion = position; + SelectionPosition positionAfterDeletion = position; if ((inDragDrop == ddDragging) && moving) { // Remove dragged out text - if (rectangular || selType == selLines) { - SelectionLineIterator lineIterator(this); - while (lineIterator.Iterate()) { - if (position >= lineIterator.startPos) { - if (position > lineIterator.endPos) { - positionAfterDeletion -= lineIterator.endPos - lineIterator.startPos; + if (rectangular || sel.selType == Selection::selLines) { + for (size_t r=0; r= sel.Range(r).Start()) { + if (position > sel.Range(r).End()) { + positionAfterDeletion.Add(-sel.Range(r).Length()); } else { - positionAfterDeletion -= position - lineIterator.startPos; + positionAfterDeletion.Add(-SelectionRange(position, sel.Range(r).Start()).Length()); } } } } else { if (position > selStart) { - positionAfterDeletion -= selEnd - selStart; + positionAfterDeletion.Add(-SelectionRange(selEnd, selStart).Length()); } } ClearSelection(); @@ -5044,78 +5524,56 @@ void Editor::DropAt(int position, const char *value, bool moving, bool rectangul if (rectangular) { PasteRectangular(position, value, istrlen(value)); - pdoc->EndUndoAction(); // Should try to select new rectangle but it may not be a rectangle now so just select the drop position - SetEmptySelection(position); - } else { - position = MovePositionOutsideChar(position, currentPos - position); - if (pdoc->InsertCString(position, value)) { - SetSelection(position + istrlen(value), position); - } - pdoc->EndUndoAction(); - } - } else if (inDragDrop == ddDragging) { - SetEmptySelection(position); - } -} - -/** - * @return -1 if given position is before the selection, - * 1 if position is after the selection, - * 0 if position is inside the selection, - */ -int Editor::PositionInSelection(int pos) { - pos = MovePositionOutsideChar(pos, currentPos - pos); - if (pos < SelectionStart()) { - return -1; - } - if (pos > SelectionEnd()) { - return 1; - } - if (selType == selStream) { - return 0; - } else { - SelectionLineIterator lineIterator(this); - lineIterator.SetAt(pdoc->LineFromPosition(pos)); - if (pos < lineIterator.startPos) { - return -1; - } else if (pos > lineIterator.endPos) { - return 1; + SetEmptySelection(position); } else { - return 0; + position = MovePositionOutsideChar(position, sel.MainCaret() - position.Position()); + position = SelectionPosition(InsertSpace(position.Position(), position.VirtualSpace())); + if (pdoc->InsertCString(position.Position(), value)) { + SelectionPosition posAfterInsertion = position; + posAfterInsertion.Add(istrlen(value)); + SetSelection(posAfterInsertion, position); + } } + } else if (inDragDrop == ddDragging) { + SetEmptySelection(position); + } +} + +/** + * @return true if given position is inside the selection, + */ +bool Editor::PositionInSelection(int pos) { + pos = MovePositionOutsideChar(pos, sel.MainCaret() - pos); + for (size_t r=0; rLineFromPosition(pos)); - selStart = lineIterator.startPos; - selEnd = lineIterator.endPos; - } - if (pos == selStart) { - // see if just before selection - Point locStart = LocationFromPosition(pos); - if (pt.x < locStart.x) { - return false; + SelectionPosition pos = SPositionFromLocation(pt); + int xPos = XFromPosition(pos); + for (size_t r=0; r locEnd.x) { - return false; + if (pos == range.End()) { + // see if just after selection + if (pt.x > xPos) { + hit = false; + } } + if (hit) + return true; } - return true; } return false; } @@ -5155,28 +5613,33 @@ void Editor::DwellEnd(bool mouseMoved) { } } +static bool AllowVirtualSpace(int virtualSpaceOptions, bool rectangular) { + return ((virtualSpaceOptions & SCVS_USERACCESSIBLE) != 0) + || (rectangular && ((virtualSpaceOptions & SCVS_RECTANGULARSELECTION) != 0)); +} + void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) { //Platform::DebugPrintf("ButtonDown %d %d = %d alt=%d %d\n", curTime, lastClickTime, curTime - lastClickTime, alt, inDragDrop); ptMouseLast = pt; - int newPos = PositionFromLocation(pt); - newPos = MovePositionOutsideChar(newPos, currentPos - newPos); + SelectionPosition newPos = SPositionFromLocation(pt, false, false, AllowVirtualSpace(virtualSpaceOptions, alt)); + newPos = MovePositionOutsideChar(newPos, sel.MainCaret() - newPos.Position()); inDragDrop = ddNone; - moveExtendsSelection = false; + sel.SetMoveExtends(false); bool processed = NotifyMarginClick(pt, shift, ctrl, alt); if (processed) return; - NotifyIndicatorClick(true, newPos, shift, ctrl, alt); + NotifyIndicatorClick(true, newPos.Position(), shift, ctrl, alt); bool inSelMargin = PointInSelMargin(pt); if (shift & !inSelMargin) { - SetSelection(newPos); + SetSelection(newPos.Position()); } if (((curTime - lastClickTime) < Platform::DoubleClickTime()) && Close(pt, lastClick)) { //Platform::DebugPrintf("Double click %d %d = %d\n", curTime, lastClickTime, curTime - lastClickTime); SetMouseCapture(true); - SetEmptySelection(newPos); + SetEmptySelection(newPos.Position()); bool doubleClick = false; // Stop mouse button bounce changing selection type if (!Platform::MouseButtonBounce() || curTime != lastClickTime) { @@ -5187,16 +5650,16 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b selectionType = selLine; } else { selectionType = selChar; - originalAnchorPos = currentPos; + originalAnchorPos = sel.MainCaret(); } } if (selectionType == selWord) { - if (currentPos >= originalAnchorPos) { // Moved forward - SetSelection(pdoc->ExtendWordSelect(currentPos, 1), + if (sel.MainCaret() >= originalAnchorPos) { // Moved forward + SetSelection(pdoc->ExtendWordSelect(sel.MainCaret(), 1), pdoc->ExtendWordSelect(originalAnchorPos, -1)); } else { // Moved backward - SetSelection(pdoc->ExtendWordSelect(currentPos, -1), + SetSelection(pdoc->ExtendWordSelect(sel.MainCaret(), -1), pdoc->ExtendWordSelect(originalAnchorPos, 1)); } } else if (selectionType == selLine) { @@ -5204,17 +5667,17 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b SetSelection(pdoc->LineStart(lineAnchor + 1), pdoc->LineStart(lineAnchor)); //Platform::DebugPrintf("Triple click: %d - %d\n", anchor, currentPos); } else { - SetEmptySelection(currentPos); + SetEmptySelection(sel.MainCaret()); } //Platform::DebugPrintf("Double click: %d - %d\n", anchor, currentPos); if (doubleClick) { NotifyDoubleClick(pt, shift, ctrl, alt); - if (PositionIsHotspot(newPos)) - NotifyHotSpotDoubleClicked(newPos, shift, ctrl, alt); + if (PositionIsHotspot(newPos.Position())) + NotifyHotSpotDoubleClicked(newPos.Position(), shift, ctrl, alt); } } else { // Single click if (inSelMargin) { - selType = selStream; + sel.selType = Selection::selStream; if (ctrl) { SelectAll(); lastClickTime = curTime; @@ -5228,21 +5691,21 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b pdoc->LineStart(lineAnchor)); } else { // Single shift+click in margin: select from line anchor to clicked line - if (anchor > currentPos) - lineAnchor = pdoc->LineFromPosition(anchor - 1); + if (sel.MainAnchor() > sel.MainCaret()) + lineAnchor = pdoc->LineFromPosition(sel.MainAnchor() - 1); else - lineAnchor = pdoc->LineFromPosition(anchor); + lineAnchor = pdoc->LineFromPosition(sel.MainAnchor()); int lineStart = LineFromLocation(pt); LineSelection(lineStart, lineAnchor); //lineAnchor = lineStart; // Keep the same anchor for ButtonMove } - SetDragPosition(invalidPosition); + SetDragPosition(SelectionPosition(invalidPosition)); SetMouseCapture(true); selectionType = selLine; } else { if (PointIsHotspot(pt)) { - NotifyHotSpotClicked(newPos, shift, ctrl, alt); + NotifyHotSpotClicked(newPos.Position(), shift, ctrl, alt); } if (!shift) { if (PointInSelection(pt) && !SelectionEmpty()) @@ -5252,13 +5715,29 @@ void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, b } SetMouseCapture(true); if (inDragDrop != ddInitial) { - SetDragPosition(invalidPosition); + SetDragPosition(SelectionPosition(invalidPosition)); if (!shift) { - SetEmptySelection(newPos); + if (ctrl && multipleSelection) { + SelectionRange range(newPos); + sel.TentativeSelection(range); + InvalidateSelection(range, true); + } else { + InvalidateSelection(SelectionRange(newPos), true); + if (sel.Count() > 1) + Redraw(); + sel.Clear(); + sel.selType = alt ? Selection::selRectangle : Selection::selStream; + SetSelection(newPos, newPos); + } } - selType = alt ? selRectangle : selStream; + SelectionPosition anchorCurrent = newPos; + if (shift) + anchorCurrent = sel.IsRectangular() ? + sel.Rectangular().anchor : sel.RangeMain().anchor; + sel.selType = alt ? Selection::selRectangle : Selection::selStream; selectionType = selChar; - originalAnchorPos = currentPos; + originalAnchorPos = sel.MainCaret(); + sel.Rectangular() = SelectionRange(newPos, anchorCurrent); SetRectangularRange(); } } @@ -5273,7 +5752,7 @@ bool Editor::PositionIsHotspot(int position) { } bool Editor::PointIsHotspot(Point pt) { - int pos = PositionFromLocationClose(pt); + int pos = PositionFromLocation(pt, true); if (pos == INVALID_POSITION) return false; return PositionIsHotspot(pos); @@ -5322,8 +5801,9 @@ void Editor::ButtonMove(Point pt) { DwellEnd(true); } - int movePos = PositionFromLocation(pt); - movePos = MovePositionOutsideChar(movePos, currentPos - movePos); + SelectionPosition movePos = SPositionFromLocation(pt, false, false, + AllowVirtualSpace(virtualSpaceOptions, sel.IsRectangular())); + movePos = MovePositionOutsideChar(movePos, sel.MainCaret() - movePos.Position()); if (inDragDrop == ddInitial) { if (DragThreshold(ptMouseLast, pt)) { @@ -5346,14 +5826,23 @@ void Editor::ButtonMove(Point pt) { autoScrollTimer.ticksToWait = autoScrollDelay; // Adjust selection - if (posDrag >= 0) { + if (posDrag.IsValid()) { SetDragPosition(movePos); } else { if (selectionType == selChar) { - SetSelection(movePos); + if (sel.IsRectangular()) { + sel.Rectangular() = SelectionRange(movePos, sel.Rectangular().anchor); + SetSelection(movePos, sel.RangeMain().anchor); + } else if (sel.Count() > 1) { + SelectionRange range(movePos, sel.RangeMain().anchor); + sel.TentativeSelection(range); + InvalidateSelection(range, true); + } else { + SetSelection(movePos, sel.RangeMain().anchor); + } } else if (selectionType == selWord) { // Continue selecting by word - if (movePos == originalAnchorPos) { // Didn't move + if (movePos.Position() == originalAnchorPos) { // Didn't move // No need to do anything. Previously this case was lumped // in with "Moved forward", but that can be harmful in this // case: a handler for the NotifyDoubleClick re-adjusts @@ -5363,11 +5852,11 @@ void Editor::ButtonMove(Point pt) { // the ButtonMove() called via Tick() for auto-scrolling // could result in the fancier word selection adjustment // being unmade. - } else if (movePos > originalAnchorPos) { // Moved forward - SetSelection(pdoc->ExtendWordSelect(movePos, 1), + } else if (movePos.Position() > originalAnchorPos) { // Moved forward + SetSelection(pdoc->ExtendWordSelect(movePos.Position(), 1), pdoc->ExtendWordSelect(originalAnchorPos, -1)); } else { // Moved backward - SetSelection(pdoc->ExtendWordSelect(movePos, -1), + SetSelection(pdoc->ExtendWordSelect(movePos.Position(), -1), pdoc->ExtendWordSelect(originalAnchorPos, 1)); } } else { @@ -5376,10 +5865,6 @@ void Editor::ButtonMove(Point pt) { LineSelection(lineMove, lineAnchor); } } - // While dragging to make rectangular selection, we don't want the current - // position to jump to the end of smaller or empty lines. - //xEndSelect = pt.x - vs.fixedColumnWidth + xOffset; - xEndSelect = XFromPosition(movePos); // Autoscroll PRectangle rcClient = GetClientRectangle(); @@ -5388,16 +5873,16 @@ void Editor::ButtonMove(Point pt) { if (lineMove < 0) { lineMove = cs.DisplayFromDoc(pdoc->LinesTotal() - 1); } - ScrollTo(lineMove - LinesOnScreen() + 5); + ScrollTo(lineMove - LinesOnScreen() + 1); Redraw(); } else if (pt.y < rcClient.top) { int lineMove = cs.DisplayFromDoc(LineFromLocation(pt)); - ScrollTo(lineMove - 5); + ScrollTo(lineMove - 1); Redraw(); } EnsureCaretVisible(false, false, true); - if (hsStart != -1 && !PositionIsHotspot(movePos)) + if (hsStart != -1 && !PositionIsHotspot(movePos.Position())) SetHotSpotRange(NULL); } else { @@ -5422,11 +5907,12 @@ void Editor::ButtonMove(Point pt) { void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) { //Platform::DebugPrintf("ButtonUp %d %d\n", HaveMouseCapture(), inDragDrop); - int newPos = PositionFromLocation(pt); - newPos = MovePositionOutsideChar(newPos, currentPos - newPos); + SelectionPosition newPos = SPositionFromLocation(pt, false, false, + AllowVirtualSpace(virtualSpaceOptions, sel.IsRectangular())); + newPos = MovePositionOutsideChar(newPos, sel.MainCaret() - newPos.Position()); if (inDragDrop == ddInitial) { inDragDrop = ddNone; - SetEmptySelection(newPos); + SetEmptySelection(newPos.Position()); } if (HaveMouseCapture()) { if (PointInSelMargin(pt)) { @@ -5437,31 +5923,29 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) { } ptMouseLast = pt; SetMouseCapture(false); - int newPos = PositionFromLocation(pt); - newPos = MovePositionOutsideChar(newPos, currentPos - newPos); - NotifyIndicatorClick(false, newPos, false, false, false); + NotifyIndicatorClick(false, newPos.Position(), false, false, false); if (inDragDrop == ddDragging) { - int selStart = SelectionStart(); - int selEnd = SelectionEnd(); + SelectionPosition selStart = SelectionStart(); + SelectionPosition selEnd = SelectionEnd(); if (selStart < selEnd) { if (drag.len) { if (ctrl) { - if (pdoc->InsertString(newPos, drag.s, drag.len)) { - SetSelection(newPos, newPos + drag.len); + if (pdoc->InsertString(newPos.Position(), drag.s, drag.len)) { + SetSelection(newPos.Position(), newPos.Position() + drag.len); } } else if (newPos < selStart) { - pdoc->DeleteChars(selStart, drag.len); - if (pdoc->InsertString(newPos, drag.s, drag.len)) { - SetSelection(newPos, newPos + drag.len); + pdoc->DeleteChars(selStart.Position(), drag.len); + if (pdoc->InsertString(newPos.Position(), drag.s, drag.len)) { + SetSelection(newPos.Position(), newPos.Position() + drag.len); } } else if (newPos > selEnd) { - pdoc->DeleteChars(selStart, drag.len); - newPos -= drag.len; - if (pdoc->InsertString(newPos, drag.s, drag.len)) { - SetSelection(newPos, newPos + drag.len); + pdoc->DeleteChars(selStart.Position(), drag.len); + newPos.Add(-drag.len); + if (pdoc->InsertString(newPos.Position(), drag.s, drag.len)) { + SetSelection(newPos.Position(), newPos.Position() + drag.len); } } else { - SetEmptySelection(newPos); + SetEmptySelection(newPos.Position()); } drag.Free(); } @@ -5469,14 +5953,21 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) { } } else { if (selectionType == selChar) { - SetSelection(newPos); + if (sel.Count() > 1) { + sel.RangeMain() = + SelectionRange(newPos, sel.Range(sel.Count() - 1).anchor); + InvalidateSelection(sel.RangeMain(), true); + } else { + SetSelection(newPos, sel.RangeMain().anchor); + } } + sel.CommitTentative(); } SetRectangularRange(); lastClickTime = curTime; lastClick = pt; lastXChosen = pt.x; - if (selType == selStream) { + if (sel.selType == Selection::selStream) { SetLastXChosen(); } inDragDrop = ddNone; @@ -5605,6 +6096,14 @@ void Editor::SetBraceHighlight(Position pos0, Position pos1, int matchStyle) { } } +void Editor::SetAnnotationHeights(int start, int end) { + if (vs.annotationVisible) { + for (int line=start; lineAnnotationLines(line) + 1); + } + } +} + void Editor::SetDocPointer(Document *document) { //Platform::DebugPrintf("** %x setdoc to %x\n", pdoc, document); pdoc->RemoveWatcher(this, 0); @@ -5617,9 +6116,7 @@ void Editor::SetDocPointer(Document *document) { pdoc->AddRef(); // Ensure all positions within document - selType = selStream; - currentPos = 0; - anchor = 0; + sel.Clear(); targetStart = 0; targetEnd = 0; @@ -5629,6 +6126,7 @@ void Editor::SetDocPointer(Document *document) { // Reset the contraction state to fully shown. cs.Clear(); cs.InsertLines(0, pdoc->LinesTotal() - 1); + SetAnnotationHeights(0, pdoc->LinesTotal()); llc.Deallocate(); NeedWrapping(); @@ -5637,6 +6135,22 @@ void Editor::SetDocPointer(Document *document) { Redraw(); } +void Editor::SetAnnotationVisible(int visible) { + if (vs.annotationVisible != visible) { + bool changedFromOrToHidden = ((vs.annotationVisible != 0) != (visible != 0)); + vs.annotationVisible = visible; + if (changedFromOrToHidden) { + int dir = vs.annotationVisible ? 1 : -1; + for (int line=0; lineLinesTotal(); line++) { + int annotationLines = pdoc->AnnotationLines(line); + if (annotationLines > 0) { + cs.SetHeight(line, cs.GetHeight(line) + annotationLines * dir); + } + } + } + } +} + /** * Recursively expand a fold, making lines visible except where they have an unexpanded parent. */ @@ -5673,7 +6187,7 @@ void Editor::ToggleContraction(int line) { if (lineMaxSubord > line) { cs.SetVisible(line + 1, lineMaxSubord, false); - int lineCurrent = pdoc->LineFromPosition(currentPos); + int lineCurrent = pdoc->LineFromPosition(sel.MainCaret()); if (lineCurrent > line && lineCurrent <= lineMaxSubord) { // This does not re-expand the fold EnsureCaretVisible(); @@ -5742,13 +6256,12 @@ void Editor::EnsureLineVisible(int lineDoc, bool enforcePolicy) { } int Editor::ReplaceTarget(bool replacePatterns, const char *text, int length) { - pdoc->BeginUndoAction(); + UndoGroup ug(pdoc); if (length == -1) length = istrlen(text); if (replacePatterns) { text = pdoc->SubstituteByPosition(text, &length); if (!text) { - pdoc->EndUndoAction(); return 0; } } @@ -5757,7 +6270,6 @@ int Editor::ReplaceTarget(bool replacePatterns, const char *text, int length) { targetEnd = targetStart; pdoc->InsertString(targetStart, text, length); targetEnd = targetStart + length; - pdoc->EndUndoAction(); return length; } @@ -5788,20 +6300,18 @@ void Editor::AddStyledText(char *buffer, int appendLength) { // The buffer consists of alternating character bytes and style bytes size_t textLength = appendLength / 2; char *text = new char[textLength]; - if (text) { - size_t i; - for (i = 0;i < textLength;i++) { - text[i] = buffer[i*2]; - } - pdoc->InsertString(CurrentPosition(), text, textLength); - for (i = 0;i < textLength;i++) { - text[i] = buffer[i*2+1]; - } - pdoc->StartStyling(CurrentPosition(), static_cast(0xff)); - pdoc->SetStyles(textLength, text); - delete []text; + size_t i; + for (i = 0;i < textLength;i++) { + text[i] = buffer[i*2]; } - SetEmptySelection(currentPos + textLength); + pdoc->InsertString(CurrentPosition(), text, textLength); + for (i = 0;i < textLength;i++) { + text[i] = buffer[i*2+1]; + } + pdoc->StartStyling(CurrentPosition(), static_cast(0xff)); + pdoc->SetStyles(textLength, text); + delete []text; + SetEmptySelection(sel.MainCaret() + textLength); } static bool ValidMargin(unsigned long wParam) { @@ -5876,6 +6386,8 @@ sptr_t Editor::StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lPar case SCI_STYLEGETSIZE: return vs.styles[wParam].size; case SCI_STYLEGETFONT: + if (!vs.styles[wParam].fontName) + return 0; if (lParam != 0) strcpy(CharPtrFromSPtr(lParam), vs.styles[wParam].fontName); return strlen(vs.styles[wParam].fontName); @@ -5895,6 +6407,15 @@ sptr_t Editor::StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lPar return 0; } +sptr_t Editor::StringResult(sptr_t lParam, const char *val) { + const int n = strlen(val); + if (lParam != 0) { + char *ptr = reinterpret_cast(lParam); + strcpy(ptr, val); + } + return n; // Not including NUL +} + sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { //Platform::DebugPrintf("S start wnd proc %d %d %d\n",iMessage, wParam, lParam); @@ -5920,11 +6441,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETTEXT: { if (lParam == 0) return 0; - pdoc->BeginUndoAction(); + UndoGroup ug(pdoc); pdoc->DeleteChars(0, pdoc->Length()); SetEmptySelection(0); pdoc->InsertCString(0, CharPtrFromSPtr(lParam)); - pdoc->EndUndoAction(); return 1; } @@ -5940,6 +6460,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { Copy(); break; + case SCI_COPYALLOWLINE: + CopyAllowLine(); + break; + case SCI_COPYRANGE: CopyRangeToClipboard(wParam, lParam); break; @@ -5977,6 +6501,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETFIRSTVISIBLELINE: return topLine; + case SCI_SETFIRSTVISIBLELINE: + ScrollTo(wParam); + break; + case SCI_GETLINE: { // Risk of overwriting the end of the buffer int lineStart = pdoc->LineStart(wParam); int lineEnd = pdoc->LineStart(wParam + 1); @@ -6007,41 +6535,30 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { nEnd = pdoc->Length(); if (nStart < 0) nStart = nEnd; // Remove selection - selType = selStream; + InvalidateSelection(SelectionRange(nStart, nEnd)); + sel.Clear(); + sel.selType = Selection::selStream; SetSelection(nEnd, nStart); EnsureCaretVisible(); } break; case SCI_GETSELTEXT: { - if (lParam == 0) { - if (selType == selStream) { - return 1 + SelectionEnd() - SelectionStart(); - } else { - // TODO: why is selLines handled the slow way? - int size = 0; - int extraCharsPerLine = 0; - if (selType != selLines) - extraCharsPerLine = (pdoc->eolMode == SC_EOL_CRLF) ? 2 : 1; - SelectionLineIterator lineIterator(this); - while (lineIterator.Iterate()) { - size += lineIterator.endPos + extraCharsPerLine - lineIterator.startPos; - } - - return 1 + size; - } - } SelectionText selectedText; CopySelectionRange(&selectedText); - char *ptr = CharPtrFromSPtr(lParam); - int iChar = 0; - if (selectedText.len) { - for (; iChar < selectedText.len; iChar++) - ptr[iChar] = selectedText.s[iChar]; + if (lParam == 0) { + return selectedText.len ? selectedText.len : 1; } else { - ptr[0] = '\0'; + char *ptr = CharPtrFromSPtr(lParam); + int iChar = 0; + if (selectedText.len) { + for (; iChar < selectedText.len; iChar++) + ptr[iChar] = selectedText.s[iChar]; + } else { + ptr[0] = '\0'; + } + return iChar; } - return iChar; } case SCI_LINEFROMPOSITION: @@ -6051,7 +6568,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_POSITIONFROMLINE: if (static_cast(wParam) < 0) - wParam = pdoc->LineFromPosition(SelectionStart()); + wParam = pdoc->LineFromPosition(SelectionStart().Position()); if (wParam == 0) return 0; // Even if there is no text, there is a first line that starts at 0 if (static_cast(wParam) > pdoc->LinesTotal()) @@ -6070,12 +6587,11 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_REPLACESEL: { if (lParam == 0) return 0; - pdoc->BeginUndoAction(); + UndoGroup ug(pdoc); ClearSelection(); char *replacement = CharPtrFromSPtr(lParam); - pdoc->InsertCString(currentPos, replacement); - pdoc->EndUndoAction(); - SetEmptySelection(currentPos + istrlen(replacement)); + pdoc->InsertCString(sel.MainCaret(), replacement); + SetEmptySelection(sel.MainCaret() + istrlen(replacement)); EnsureCaretVisible(); } break; @@ -6095,12 +6611,12 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return targetEnd; case SCI_TARGETFROMSELECTION: - if (currentPos < anchor) { - targetStart = currentPos; - targetEnd = anchor; + if (sel.MainCaret() < sel.MainAnchor()) { + targetStart = sel.MainCaret(); + targetEnd = sel.MainAnchor(); } else { - targetStart = anchor; - targetEnd = currentPos; + targetStart = sel.MainAnchor(); + targetEnd = sel.MainCaret(); } break; @@ -6183,7 +6699,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETTEXTRANGE: { if (lParam == 0) return 0; - TextRange *tr = reinterpret_cast(lParam); + Sci_TextRange *tr = reinterpret_cast(lParam); int cpMax = tr->chrg.cpMax; if (cpMax == -1) cpMax = pdoc->Length(); @@ -6201,7 +6717,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_FORMATRANGE: - return FormatRange(wParam != 0, reinterpret_cast(lParam)); + return FormatRange(wParam != 0, reinterpret_cast(lParam)); case SCI_GETMARGINLEFT: return vs.leftMarginWidth; @@ -6225,7 +6741,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { if (lParam == 0) return 0; pdoc->InsertString(CurrentPosition(), CharPtrFromSPtr(lParam), wParam); - SetEmptySelection(currentPos + wParam); + SetEmptySelection(sel.MainCaret() + wParam); return 0; } @@ -6313,32 +6829,44 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return pdoc->CharAt(wParam); case SCI_SETCURRENTPOS: - SetSelection(wParam, anchor); + if (sel.IsRectangular()) { + sel.Rectangular().caret.SetPosition(wParam); + SetRectangularRange(); + Redraw(); + } else { + SetSelection(wParam, sel.MainAnchor()); + } break; case SCI_GETCURRENTPOS: - return currentPos; + return sel.IsRectangular() ? sel.Rectangular().caret.Position() : sel.MainCaret(); case SCI_SETANCHOR: - SetSelection(currentPos, wParam); + if (sel.IsRectangular()) { + sel.Rectangular().anchor.SetPosition(wParam); + SetRectangularRange(); + Redraw(); + } else { + SetSelection(sel.MainCaret(), wParam); + } break; case SCI_GETANCHOR: - return anchor; + return sel.IsRectangular() ? sel.Rectangular().anchor.Position() : sel.MainAnchor(); case SCI_SETSELECTIONSTART: - SetSelection(Platform::Maximum(currentPos, wParam), wParam); + SetSelection(Platform::Maximum(sel.MainCaret(), wParam), wParam); break; case SCI_GETSELECTIONSTART: - return Platform::Minimum(anchor, currentPos); + return Platform::Minimum(sel.MainAnchor(), sel.MainCaret()); case SCI_SETSELECTIONEND: - SetSelection(wParam, Platform::Minimum(anchor, wParam)); + SetSelection(wParam, Platform::Minimum(sel.MainAnchor(), wParam)); break; case SCI_GETSELECTIONEND: - return Platform::Maximum(anchor, currentPos); + return Platform::Maximum(sel.MainAnchor(), sel.MainCaret()); case SCI_SETPRINTMAGNIFICATION: printMagnification = wParam; @@ -6382,7 +6910,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETSTYLEDTEXT: { if (lParam == 0) return 0; - TextRange *tr = reinterpret_cast(lParam); + Sci_TextRange *tr = reinterpret_cast(lParam); int iPlace = 0; for (int iChar = tr->chrg.cpMin; iChar < tr->chrg.cpMax; iChar++) { tr->lpstrText[iPlace++] = pdoc->CharAt(iChar); @@ -6411,11 +6939,25 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { Redraw(); break; + case SCI_GETWHITESPACESIZE: + return vs.whitespaceSize; + + case SCI_SETWHITESPACESIZE: + vs.whitespaceSize = static_cast(wParam); + Redraw(); + break; + case SCI_POSITIONFROMPOINT: - return PositionFromLocation(Point(wParam, lParam)); + return PositionFromLocation(Point(wParam, lParam), false, false); case SCI_POSITIONFROMPOINTCLOSE: - return PositionFromLocationClose(Point(wParam, lParam)); + return PositionFromLocation(Point(wParam, lParam), true, false); + + case SCI_CHARPOSITIONFROMPOINT: + return PositionFromLocation(Point(wParam, lParam), false, true); + + case SCI_CHARPOSITIONFROMPOINTCLOSE: + return PositionFromLocation(Point(wParam, lParam), true, true); case SCI_GOTOLINE: GoToLine(wParam); @@ -6428,7 +6970,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_GETCURLINE: { - int lineCurrentPos = pdoc->LineFromPosition(currentPos); + int lineCurrentPos = pdoc->LineFromPosition(sel.MainCaret()); int lineStart = pdoc->LineStart(lineCurrentPos); unsigned int lineEnd = pdoc->LineStart(lineCurrentPos + 1); if (lParam == 0) { @@ -6441,7 +6983,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { ptr[iPlace++] = pdoc->CharAt(iChar); } ptr[iPlace] = '\0'; - return currentPos - lineStart; + return sel.MainCaret() - lineStart; } case SCI_GETENDSTYLED: @@ -6483,6 +7025,15 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { InvalidateStyleRedraw(); break; + case SCI_SETFONTQUALITY: + vs.extraFontFlag &= ~SC_EFF_QUALITY_MASK; + vs.extraFontFlag |= (wParam & SC_EFF_QUALITY_MASK); + InvalidateStyleRedraw(); + break; + + case SCI_GETFONTQUALITY: + return (vs.extraFontFlag & SC_EFF_QUALITY_MASK); + case SCI_SETTABWIDTH: if (wParam > 0) { pdoc->tabInChars = wParam; @@ -6575,9 +7126,6 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETWRAPVISUALFLAGS: wrapVisualFlags = wParam; - actualWrapVisualStartIndent = wrapVisualStartIndent; - if ((wrapVisualFlags & SC_WRAPVISUALFLAG_START) && (actualWrapVisualStartIndent == 0)) - actualWrapVisualStartIndent = 1; // must indent to show start visual InvalidateStyleRedraw(); ReconfigureScrollBars(); break; @@ -6595,9 +7143,6 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETWRAPSTARTINDENT: wrapVisualStartIndent = wParam; - actualWrapVisualStartIndent = wrapVisualStartIndent; - if ((wrapVisualFlags & SC_WRAPVISUALFLAG_START) && (actualWrapVisualStartIndent == 0)) - actualWrapVisualStartIndent = 1; // must indent to show start visual InvalidateStyleRedraw(); ReconfigureScrollBars(); break; @@ -6605,6 +7150,15 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETWRAPSTARTINDENT: return wrapVisualStartIndent; + case SCI_SETWRAPINDENTMODE: + wrapIndentMode = wParam; + InvalidateStyleRedraw(); + ReconfigureScrollBars(); + break; + + case SCI_GETWRAPINDENTMODE: + return wrapIndentMode; + case SCI_SETLAYOUTCACHE: llc.SetLevel(wParam); break; @@ -6753,6 +7307,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { InvalidateStyleData(); RedrawSelMargin(); break; + + case SCI_MARKERSYMBOLDEFINED: + if (wParam <= MARKER_MAX) + return vs.markers[wParam].markType; + else + return 0; + case SCI_MARKERSETFORE: if (wParam <= MARKER_MAX) vs.markers[wParam].fore.desired = ColourDesired(lParam); @@ -6980,7 +7541,8 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { break; case SCI_HIDELINES: - cs.SetVisible(wParam, lParam, false); + if (wParam > 0) + cs.SetVisible(wParam, lParam, false); SetScrollBars(); Redraw(); break; @@ -7022,13 +7584,6 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SEARCHPREV: return SearchText(iMessage, wParam, lParam); -#ifdef INCLUDE_DEPRECATED_FEATURES - case SCI_SETCARETPOLICY: // Deprecated - caretXPolicy = caretYPolicy = wParam; - caretXSlop = caretYSlop = lParam; - break; -#endif - case SCI_SETXCARETPOLICY: caretXPolicy = wParam; caretXSlop = lParam; @@ -7050,17 +7605,20 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_SETSELFORE: vs.selforeset = wParam != 0; vs.selforeground.desired = ColourDesired(lParam); + vs.selAdditionalForeground.desired = ColourDesired(lParam); InvalidateStyleRedraw(); break; case SCI_SETSELBACK: vs.selbackset = wParam != 0; vs.selbackground.desired = ColourDesired(lParam); + vs.selAdditionalBackground.desired = ColourDesired(lParam); InvalidateStyleRedraw(); break; case SCI_SETSELALPHA: vs.selAlpha = wParam; + vs.selAdditionalAlpha = wParam; InvalidateStyleRedraw(); break; @@ -7164,6 +7722,16 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_INDICGETUNDER: return (wParam <= INDIC_MAX) ? vs.indicators[wParam].under : 0; + case SCI_INDICSETALPHA: + if (wParam <= INDIC_MAX && lParam >=0 && lParam <= 100) { + vs.indicators[wParam].fillAlpha = lParam; + InvalidateStyleRedraw(); + } + break; + + case SCI_INDICGETALPHA: + return (wParam <= INDIC_MAX) ? vs.indicators[wParam].fillAlpha : 0; + case SCI_SETINDICATORCURRENT: pdoc->decorations.SetCurrentIndicator(wParam); break; @@ -7372,7 +7940,7 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_CONVERTEOLS: pdoc->ConvertLineEnds(wParam); - SetSelection(currentPos, anchor); // Ensure selection inside document + SetSelection(sel.MainCaret(), sel.MainAnchor()); // Ensure selection inside document return 0; case SCI_SETLENGTHFORENCODE: @@ -7380,48 +7948,56 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return 0; case SCI_SELECTIONISRECTANGLE: - return selType == selRectangle ? 1 : 0; + return sel.selType == Selection::selRectangle ? 1 : 0; case SCI_SETSELECTIONMODE: { switch (wParam) { case SC_SEL_STREAM: - moveExtendsSelection = !moveExtendsSelection || (selType != selStream); - selType = selStream; + sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::selStream)); + sel.selType = Selection::selStream; break; case SC_SEL_RECTANGLE: - moveExtendsSelection = !moveExtendsSelection || (selType != selRectangle); - selType = selRectangle; + sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::selRectangle)); + sel.selType = Selection::selRectangle; break; case SC_SEL_LINES: - moveExtendsSelection = !moveExtendsSelection || (selType != selLines); - selType = selLines; + sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::selLines)); + sel.selType = Selection::selLines; + break; + case SC_SEL_THIN: + sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::selThin)); + sel.selType = Selection::selThin; break; default: - moveExtendsSelection = !moveExtendsSelection || (selType != selStream); - selType = selStream; + sel.SetMoveExtends(!sel.MoveExtends() || (sel.selType != Selection::selStream)); + sel.selType = Selection::selStream; } - InvalidateSelection(currentPos, anchor); + InvalidateSelection(sel.RangeMain(), true); } case SCI_GETSELECTIONMODE: - switch (selType) { - case selStream: + switch (sel.selType) { + case Selection::selStream: return SC_SEL_STREAM; - case selRectangle: + case Selection::selRectangle: return SC_SEL_RECTANGLE; - case selLines: + case Selection::selLines: return SC_SEL_LINES; + case Selection::selThin: + return SC_SEL_THIN; default: // ?! return SC_SEL_STREAM; } - case SCI_GETLINESELSTARTPOSITION: { - SelectionLineIterator lineIterator(this); - lineIterator.SetAt(wParam); - return lineIterator.startPos; - } + case SCI_GETLINESELSTARTPOSITION: case SCI_GETLINESELENDPOSITION: { - SelectionLineIterator lineIterator(this); - lineIterator.SetAt(wParam); - return lineIterator.endPos; + SelectionSegment segmentLine(SelectionPosition(pdoc->LineStart(wParam)), + SelectionPosition(pdoc->LineEnd(wParam))); + for (size_t r=0; r(pdoc->BufferPointer()); + + case SCI_SETEXTRAASCENT: + vs.extraAscent = wParam; + InvalidateStyleRedraw(); + break; + + case SCI_GETEXTRAASCENT: + return vs.extraAscent; + + case SCI_SETEXTRADESCENT: + vs.extraDescent = wParam; + InvalidateStyleRedraw(); + break; + + case SCI_GETEXTRADESCENT: + return vs.extraDescent; + + case SCI_MARGINSETSTYLEOFFSET: + vs.marginStyleOffset = wParam; + InvalidateStyleRedraw(); + break; + + case SCI_MARGINGETSTYLEOFFSET: + return vs.marginStyleOffset; + + case SCI_MARGINSETTEXT: + pdoc->MarginSetText(wParam, CharPtrFromSPtr(lParam)); + break; + + case SCI_MARGINGETTEXT: { + const StyledText st = pdoc->MarginStyledText(wParam); + if (lParam) { + if (st.text) + memcpy(CharPtrFromSPtr(lParam), st.text, st.length); + else + strcpy(CharPtrFromSPtr(lParam), ""); + } + return st.length; + } + + case SCI_MARGINSETSTYLE: + pdoc->MarginSetStyle(wParam, lParam); + break; + + case SCI_MARGINGETSTYLE: { + const StyledText st = pdoc->MarginStyledText(wParam); + return st.style; + } + + case SCI_MARGINSETSTYLES: + pdoc->MarginSetStyles(wParam, reinterpret_cast(lParam)); + break; + + case SCI_MARGINGETSTYLES: { + const StyledText st = pdoc->MarginStyledText(wParam); + if (lParam) { + if (st.styles) + memcpy(CharPtrFromSPtr(lParam), st.styles, st.length); + else + strcpy(CharPtrFromSPtr(lParam), ""); + } + return st.styles ? st.length : 0; + } + + case SCI_MARGINTEXTCLEARALL: + pdoc->MarginClearAll(); + break; + + case SCI_ANNOTATIONSETTEXT: + pdoc->AnnotationSetText(wParam, CharPtrFromSPtr(lParam)); + break; + + case SCI_ANNOTATIONGETTEXT: { + const StyledText st = pdoc->AnnotationStyledText(wParam); + if (lParam) { + if (st.text) + memcpy(CharPtrFromSPtr(lParam), st.text, st.length); + else + strcpy(CharPtrFromSPtr(lParam), ""); + } + return st.length; + } + + case SCI_ANNOTATIONGETSTYLE: { + const StyledText st = pdoc->AnnotationStyledText(wParam); + return st.style; + } + + case SCI_ANNOTATIONSETSTYLE: + pdoc->AnnotationSetStyle(wParam, lParam); + break; + + case SCI_ANNOTATIONSETSTYLES: + pdoc->AnnotationSetStyles(wParam, reinterpret_cast(lParam)); + break; + + case SCI_ANNOTATIONGETSTYLES: { + const StyledText st = pdoc->AnnotationStyledText(wParam); + if (lParam) { + if (st.styles) + memcpy(CharPtrFromSPtr(lParam), st.styles, st.length); + else + strcpy(CharPtrFromSPtr(lParam), ""); + } + return st.styles ? st.length : 0; + } + + case SCI_ANNOTATIONGETLINES: + return pdoc->AnnotationLines(wParam); + + case SCI_ANNOTATIONCLEARALL: + pdoc->AnnotationClearAll(); + break; + + case SCI_ANNOTATIONSETVISIBLE: + SetAnnotationVisible(wParam); + break; + + case SCI_ANNOTATIONGETVISIBLE: + return vs.annotationVisible; + + case SCI_ANNOTATIONSETSTYLEOFFSET: + vs.annotationStyleOffset = wParam; + InvalidateStyleRedraw(); + break; + + case SCI_ANNOTATIONGETSTYLEOFFSET: + return vs.annotationStyleOffset; + + case SCI_ADDUNDOACTION: + pdoc->AddUndoAction(wParam, lParam & UNDO_MAY_COALESCE); + break; + + case SCI_SETMULTIPLESELECTION: + multipleSelection = wParam != 0; + InvalidateCaret(); + break; + + case SCI_GETMULTIPLESELECTION: + return multipleSelection; + + case SCI_SETADDITIONALSELECTIONTYPING: + additionalSelectionTyping = wParam != 0; + InvalidateCaret(); + break; + + case SCI_GETADDITIONALSELECTIONTYPING: + return additionalSelectionTyping; + + case SCI_SETADDITIONALCARETSBLINK: + additionalCaretsBlink = wParam != 0; + InvalidateCaret(); + break; + + case SCI_GETADDITIONALCARETSBLINK: + return additionalCaretsBlink; + + case SCI_SETADDITIONALCARETSVISIBLE: + additionalCaretsVisible = wParam != 0; + InvalidateCaret(); + break; + + case SCI_GETADDITIONALCARETSVISIBLE: + return additionalCaretsVisible; + + case SCI_GETSELECTIONS: + return sel.Count(); + + case SCI_CLEARSELECTIONS: + sel.Clear(); + Redraw(); + break; + + case SCI_SETSELECTION: + sel.SetSelection(SelectionRange(wParam, lParam)); + Redraw(); + break; + + case SCI_ADDSELECTION: + sel.AddSelection(SelectionRange(wParam, lParam)); + Redraw(); + break; + + case SCI_SETMAINSELECTION: + sel.SetMain(wParam); + Redraw(); + break; + + case SCI_GETMAINSELECTION: + return sel.Main(); + + case SCI_SETSELECTIONNCARET: + sel.Range(wParam).caret.SetPosition(lParam); + Redraw(); + break; + + case SCI_GETSELECTIONNCARET: + return sel.Range(wParam).caret.Position(); + + case SCI_SETSELECTIONNANCHOR: + sel.Range(wParam).anchor.SetPosition(lParam); + Redraw(); + break; + case SCI_GETSELECTIONNANCHOR: + return sel.Range(wParam).anchor.Position(); + + case SCI_SETSELECTIONNCARETVIRTUALSPACE: + sel.Range(wParam).caret.SetVirtualSpace(lParam); + Redraw(); + break; + + case SCI_GETSELECTIONNCARETVIRTUALSPACE: + return sel.Range(wParam).caret.VirtualSpace(); + + case SCI_SETSELECTIONNANCHORVIRTUALSPACE: + sel.Range(wParam).anchor.SetVirtualSpace(lParam); + Redraw(); + break; + + case SCI_GETSELECTIONNANCHORVIRTUALSPACE: + return sel.Range(wParam).anchor.VirtualSpace(); + + case SCI_SETSELECTIONNSTART: + sel.Range(wParam).anchor.SetPosition(lParam); + Redraw(); + break; + + case SCI_GETSELECTIONNSTART: + return sel.Range(wParam).Start().Position(); + + case SCI_SETSELECTIONNEND: + sel.Range(wParam).caret.SetPosition(lParam); + Redraw(); + break; + + case SCI_GETSELECTIONNEND: + return sel.Range(wParam).End().Position(); + + case SCI_SETRECTANGULARSELECTIONCARET: + if (!sel.IsRectangular()) + sel.Clear(); + sel.selType = Selection::selRectangle; + sel.Rectangular().caret.SetPosition(wParam); + SetRectangularRange(); + Redraw(); + break; + + case SCI_GETRECTANGULARSELECTIONCARET: + return sel.Rectangular().caret.Position(); + + case SCI_SETRECTANGULARSELECTIONANCHOR: + if (!sel.IsRectangular()) + sel.Clear(); + sel.selType = Selection::selRectangle; + sel.Rectangular().anchor.SetPosition(wParam); + SetRectangularRange(); + Redraw(); + break; + + case SCI_GETRECTANGULARSELECTIONANCHOR: + return sel.Rectangular().anchor.Position(); + + case SCI_SETRECTANGULARSELECTIONCARETVIRTUALSPACE: + if (!sel.IsRectangular()) + sel.Clear(); + sel.selType = Selection::selRectangle; + sel.Rectangular().caret.SetVirtualSpace(wParam); + SetRectangularRange(); + Redraw(); + break; + + case SCI_GETRECTANGULARSELECTIONCARETVIRTUALSPACE: + return sel.Rectangular().caret.VirtualSpace(); + + case SCI_SETRECTANGULARSELECTIONANCHORVIRTUALSPACE: + if (!sel.IsRectangular()) + sel.Clear(); + sel.selType = Selection::selRectangle; + sel.Rectangular().anchor.SetVirtualSpace(wParam); + SetRectangularRange(); + Redraw(); + break; + + case SCI_GETRECTANGULARSELECTIONANCHORVIRTUALSPACE: + return sel.Rectangular().anchor.VirtualSpace(); + + case SCI_SETVIRTUALSPACEOPTIONS: + virtualSpaceOptions = wParam; + break; + + case SCI_GETVIRTUALSPACEOPTIONS: + return virtualSpaceOptions; + + case SCI_SETADDITIONALSELFORE: + vs.selAdditionalForeground.desired = ColourDesired(wParam); + InvalidateStyleRedraw(); + break; + + case SCI_SETADDITIONALSELBACK: + vs.selAdditionalBackground.desired = ColourDesired(wParam); + InvalidateStyleRedraw(); + break; + + case SCI_SETADDITIONALSELALPHA: + vs.selAdditionalAlpha = wParam; + InvalidateStyleRedraw(); + break; + + case SCI_GETADDITIONALSELALPHA: + return vs.selAdditionalAlpha; + + case SCI_SETADDITIONALCARETFORE: + vs.additionalCaretColour.desired = ColourDesired(wParam); + InvalidateStyleRedraw(); + break; + + case SCI_GETADDITIONALCARETFORE: + return vs.additionalCaretColour.desired.AsLong(); + + case SCI_ROTATESELECTION: + sel.RotateMain(); + InvalidateSelection(sel.RangeMain(), true); + break; + + case SCI_SWAPMAINANCHORCARET: + InvalidateSelection(sel.RangeMain()); + sel.RangeMain() = SelectionRange(sel.RangeMain().anchor, sel.RangeMain().caret); + break; + default: return DefWndProc(iMessage, wParam, lParam); } diff --git a/src/stc/scintilla/src/Editor.h b/src/stc/scintilla/src/Editor.h index 049cc373f5..92dcfb14bf 100644 --- a/src/stc/scintilla/src/Editor.h +++ b/src/stc/scintilla/src/Editor.h @@ -54,16 +54,17 @@ public: char *s; int len; bool rectangular; + bool lineCopy; int codePage; int characterSet; - SelectionText() : s(0), len(0), rectangular(false), codePage(0), characterSet(0) {} + SelectionText() : s(0), len(0), rectangular(false), lineCopy(false), codePage(0), characterSet(0) {} ~SelectionText() { Free(); } void Free() { - Set(0, 0, 0, 0, false); + Set(0, 0, 0, 0, false, false); } - void Set(char *s_, int len_, int codePage_, int characterSet_, bool rectangular_) { + void Set(char *s_, int len_, int codePage_, int characterSet_, bool rectangular_, bool lineCopy_) { delete []s; s = s_; if (s) @@ -73,24 +74,23 @@ public: codePage = codePage_; characterSet = characterSet_; rectangular = rectangular_; + lineCopy = lineCopy_; } - void Copy(const char *s_, int len_, int codePage_, int characterSet_, bool rectangular_) { + void Copy(const char *s_, int len_, int codePage_, int characterSet_, bool rectangular_, bool lineCopy_) { delete []s; + s = 0; s = new char[len_]; - if (s) { - len = len_; - for (int i = 0; i < len_; i++) { - s[i] = s_[i]; - } - } else { - len = 0; + len = len_; + for (int i = 0; i < len_; i++) { + s[i] = s_[i]; } codePage = codePage_; characterSet = characterSet_; rectangular = rectangular_; + lineCopy = lineCopy_; } void Copy(const SelectionText &other) { - Copy(other.s, other.len, other.codePage, other.characterSet, other.rectangular); + Copy(other.s, other.len, other.codePage, other.characterSet, other.rectangular, other.lineCopy); } }; @@ -98,8 +98,8 @@ public: */ class Editor : public DocWatcher { // Private so Editor objects can not be copied - Editor(const Editor &) : DocWatcher() {} - Editor &operator=(const Editor &) { return *this; } + Editor(const Editor &); + Editor &operator=(const Editor &); protected: // ScintillaBase subclass needs access to much of Editor @@ -122,7 +122,6 @@ protected: // ScintillaBase subclass needs access to much of Editor bool hasFocus; bool hideSelection; bool inOverstrike; - int errorStatus; bool mouseDownCaptures; /** In bufferedDraw mode, graphics operations are drawn to a pixmap and then copied to @@ -141,6 +140,12 @@ protected: // ScintillaBase subclass needs access to much of Editor bool verticalScrollBarVisible; bool endAtLastLine; bool caretSticky; + bool multipleSelection; + bool additionalSelectionTyping; + bool additionalCaretsBlink; + bool additionalCaretsVisible; + + int virtualSpaceOptions; Surface *pixmapLine; Surface *pixmapSelMargin; @@ -169,13 +174,11 @@ protected: // ScintillaBase subclass needs access to much of Editor Point ptMouseLast; enum { ddNone, ddInitial, ddDragging } inDragDrop; bool dropWentOutside; - int posDrag; - int posDrop; + SelectionPosition posDrag; + SelectionPosition posDrop; int lastXChosen; int lineAnchor; int originalAnchorPos; - int currentPos; - int anchor; int targetStart; int targetEnd; int searchFlags; @@ -197,11 +200,7 @@ protected: // ScintillaBase subclass needs access to much of Editor int modEventMask; SelectionText drag; - enum selTypes { noSel, selStream, selRectangle, selLines }; - selTypes selType; - bool moveExtendsSelection; - int xStartSelect; ///< x position of start of rectangular selection - int xEndSelect; ///< x position of end of rectangular selection + Selection sel; bool primarySelection; int caretXPolicy; @@ -233,7 +232,8 @@ protected: // ScintillaBase subclass needs access to much of Editor int wrapVisualFlags; int wrapVisualFlagsLocation; int wrapVisualStartIndent; - int actualWrapVisualStartIndent; + int wrapAddIndent; // This will be added to initial indent of line + int wrapIndentMode; // SC_WRAPINDENT_FIXED, _SAME, _INDENT bool convertPastes; @@ -256,10 +256,14 @@ protected: // ScintillaBase subclass needs access to much of Editor int LinesOnScreen(); int LinesToScroll(); int MaxScrollPos(); + SelectionPosition ClampPositionIntoDocument(SelectionPosition sp) const; + Point LocationFromPosition(SelectionPosition pos); Point LocationFromPosition(int pos); int XFromPosition(int pos); - int PositionFromLocation(Point pt); - int PositionFromLocationClose(Point pt); + int XFromPosition(SelectionPosition sp); + SelectionPosition SPositionFromLocation(Point pt, bool canReturnInvalid=false, bool charPosition=false, bool virtualSpace=true); + int PositionFromLocation(Point pt, bool canReturnInvalid=false, bool charPosition=false); + SelectionPosition SPositionFromLineX(int lineDoc, int x); int PositionFromLineX(int line, int x); int LineFromLocation(Point pt); void SetTopLine(int topLineNew); @@ -271,20 +275,31 @@ protected: // ScintillaBase subclass needs access to much of Editor PRectangle RectangleFromRange(int start, int end); void InvalidateRange(int start, int end); + bool UserVirtualSpace() const { + return ((virtualSpaceOptions & SCVS_USERACCESSIBLE) != 0); + } int CurrentPosition(); bool SelectionEmpty(); - int SelectionStart(); - int SelectionEnd(); + SelectionPosition SelectionStart(); + SelectionPosition SelectionEnd(); void SetRectangularRange(); - void InvalidateSelection(int currentPos_, int anchor_); + void ThinRectangularRange(); + void InvalidateSelection(SelectionRange newMain, bool invalidateWholeSelection=false); + void SetSelection(SelectionPosition currentPos_, SelectionPosition anchor_); void SetSelection(int currentPos_, int anchor_); + void SetSelection(SelectionPosition currentPos_); void SetSelection(int currentPos_); + void SetEmptySelection(SelectionPosition currentPos_); void SetEmptySelection(int currentPos_); bool RangeContainsProtected(int start, int end) const; bool SelectionContainsProtected(); - int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true); - int MovePositionTo(int newPos, selTypes sel=noSel, bool ensureVisible=true); - int MovePositionSoVisible(int pos, int moveDir); + int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true) const; + SelectionPosition MovePositionOutsideChar(SelectionPosition pos, int moveDir, bool checkLineEnd=true) const; + int MovePositionTo(SelectionPosition newPos, Selection::selTypes sel=Selection::noSel, bool ensureVisible=true); + int MovePositionTo(int newPos, Selection::selTypes sel=Selection::noSel, bool ensureVisible=true); + SelectionPosition MovePositionSoVisible(SelectionPosition pos, int moveDir); + SelectionPosition MovePositionSoVisible(int pos, int moveDir); + Point PointMainCaret(); void SetLastXChosen(); void ScrollTo(int line, bool moveThumb=true); @@ -309,8 +324,8 @@ protected: // ScintillaBase subclass needs access to much of Editor LineLayout *RetrieveLineLayout(int lineNumber); void LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll, int width=LineLayout::wrapWidthInfinite); - ColourAllocated SelectionBackground(ViewStyle &vsDraw); - ColourAllocated TextBackground(ViewStyle &vsDraw, bool overrideBackground, ColourAllocated background, bool inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll); + ColourAllocated SelectionBackground(ViewStyle &vsDraw, bool main); + ColourAllocated TextBackground(ViewStyle &vsDraw, bool overrideBackground, ColourAllocated background, int inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll); void DrawIndentGuide(Surface *surface, int lineVisible, int lineHeight, int start, PRectangle rcSegment, bool highlight); void DrawWrapMarker(Surface *surface, PRectangle rcPlace, bool isEndMarker, ColourAllocated wrapColour); void DrawEOL(Surface *surface, ViewStyle &vsDraw, PRectangle rcLine, LineLayout *ll, @@ -319,12 +334,17 @@ protected: // ScintillaBase subclass needs access to much of Editor bool drawWrapMark, ColourAllocated wrapColour); void DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int xStart, PRectangle rcLine, LineLayout *ll, int subLine, int lineEnd, bool under); + void DrawAnnotation(Surface *surface, ViewStyle &vsDraw, int line, int xStart, + PRectangle rcLine, LineLayout *ll, int subLine); void DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart, - PRectangle rcLine, LineLayout *ll, int subLine=0); - void DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine, int xStart, int offset, int posCaret, PRectangle rcCaret); + PRectangle rcLine, LineLayout *ll, int subLine); + void DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine, + int xStart, int offset, int posCaret, PRectangle rcCaret, ColourAllocated caretColour); + void DrawCarets(Surface *surface, ViewStyle &vsDraw, int line, int xStart, + PRectangle rcLine, LineLayout *ll, int subLine); void RefreshPixMaps(Surface *surfaceWindow); void Paint(Surface *surfaceWindow, PRectangle rcArea); - long FormatRange(bool draw, RangeToFormat *pfr); + long FormatRange(bool draw, Sci_RangeToFormat *pfr); int TextWidth(int style, const char *text); virtual void SetVerticalScrollPos() = 0; @@ -334,14 +354,17 @@ protected: // ScintillaBase subclass needs access to much of Editor void SetScrollBars(); void ChangeSize(); + void FilterSelections(); + int InsertSpace(int position, unsigned int spaces); void AddChar(char ch); virtual void AddCharUTF(char *s, unsigned int len, bool treatAsDBCS=false); void ClearSelection(); void ClearAll(); void ClearDocumentStyle(); void Cut(); - void PasteRectangular(int pos, const char *ptr, int len); + void PasteRectangular(SelectionPosition pos, const char *ptr, int len); virtual void Copy() = 0; + virtual void CopyAllowLine(); virtual bool CanPaste(); virtual void Paste() = 0; void Clear(); @@ -358,7 +381,6 @@ protected: // ScintillaBase subclass needs access to much of Editor virtual void NotifyParent(SCNotification scn) = 0; virtual void NotifyStyleToNeeded(int endStyleNeeded); void NotifyChar(int ch); - void NotifyMove(int position); void NotifySavePoint(bool isSavePoint); void NotifyModifyAttempt(); virtual void NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt); @@ -380,14 +402,14 @@ protected: // ScintillaBase subclass needs access to much of Editor void NotifyStyleNeeded(Document *doc, void *userData, int endPos); void NotifyMacroRecord(unsigned int iMessage, uptr_t wParam, sptr_t lParam); - void PageMove(int direction, selTypes sel=noSel, bool stuttered = false); + void PageMove(int direction, Selection::selTypes sel=Selection::noSel, bool stuttered = false); void ChangeCaseOfSelection(bool makeUpperCase); void LineTranspose(); void Duplicate(bool forLine); virtual void CancelModes(); void NewLine(); - void CursorUpOrDown(int direction, selTypes sel=noSel); - void ParaUpOrDown(int direction, selTypes sel=noSel); + void CursorUpOrDown(int direction, Selection::selTypes sel=Selection::noSel); + void ParaUpOrDown(int direction, Selection::selTypes sel=Selection::noSel); int StartEndDisplayLine(int pos, bool start); virtual int KeyCommand(unsigned int iMessage); virtual int KeyDefault(int /* key */, int /*modifiers*/); @@ -406,18 +428,16 @@ protected: // ScintillaBase subclass needs access to much of Editor virtual void CopyToClipboard(const SelectionText &selectedText) = 0; char *CopyRange(int start, int end); - void CopySelectionFromRange(SelectionText *ss, int start, int end); - void CopySelectionRange(SelectionText *ss); + void CopySelectionRange(SelectionText *ss, bool allowLineCopy=false); void CopyRangeToClipboard(int start, int end); void CopyText(int length, const char *text); - void SetDragPosition(int newPos); + void SetDragPosition(SelectionPosition newPos); virtual void DisplayCursor(Window::Cursor c); virtual bool DragThreshold(Point ptStart, Point ptNow); virtual void StartDrag(); - void DropAt(int position, const char *value, bool moving, bool rectangular); - /** PositionInSelection returns 0 if position in selection, -1 if position before selection, and 1 if after. - * Before means either before any line of selection or before selection on its line, with a similar meaning to after. */ - int PositionInSelection(int pos); + void DropAt(SelectionPosition position, const char *value, bool moving, bool rectangular); + /** PositionInSelection returns true if position in selection. */ + bool PositionInSelection(int pos); bool PointInSelection(Point pt); bool PointInSelMargin(Point pt); void LineSelection(int lineCurrent_, int lineAnchor_); @@ -439,7 +459,10 @@ protected: // ScintillaBase subclass needs access to much of Editor void CheckForChangeOutsidePaint(Range r); void SetBraceHighlight(Position pos0, Position pos1, int matchStyle); + void SetAnnotationHeights(int start, int end); void SetDocPointer(Document *document); + + void SetAnnotationVisible(int visible); void Expand(int &line, bool doExpand); void ToggleContraction(int line); @@ -460,6 +483,10 @@ protected: // ScintillaBase subclass needs access to much of Editor void StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam); sptr_t StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam); + static const char *StringFromEOLMode(int eolMode); + + static sptr_t StringResult(sptr_t lParam, const char *val); + public: // Public so the COM thunks can access it. bool IsUnicodeMode() const; @@ -467,6 +494,8 @@ public: virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam); // Public so scintilla_set_id can use it. int ctrlID; + // Public so COM methods for drag and drop can set it. + int errorStatus; friend class AutoSurface; friend class SelectionLineIterator; }; diff --git a/src/stc/scintilla/src/ExternalLexer.cxx b/src/stc/scintilla/src/ExternalLexer.cxx index 0344debd78..098df4dd5b 100644 --- a/src/stc/scintilla/src/ExternalLexer.cxx +++ b/src/stc/scintilla/src/ExternalLexer.cxx @@ -10,6 +10,8 @@ #include #include +#include + #include "Platform.h" #include "Scintilla.h" @@ -39,7 +41,7 @@ char **WordListsToStrings(WordList *val[]) { dim++; char **wls = new char * [dim + 1]; for (int i = 0;i < dim;i++) { - SString words; + std::string words; words = ""; for (int n = 0; n < val[i]->len; n++) { words += val[i]->words[n]; @@ -172,13 +174,13 @@ LexerLibrary::~LexerLibrary() { void LexerLibrary::Release() { //TODO maintain a list of lexers created, and delete them! LexerMinder *lm; - LexerMinder *next; + LexerMinder *lmNext; lm = first; while (NULL != lm) { - next = lm->next; + lmNext = lm->next; delete lm->self; delete lm; - lm = next; + lm = lmNext; } first = NULL; diff --git a/src/stc/scintilla/src/ExternalLexer.h b/src/stc/scintilla/src/ExternalLexer.h index 55e127b40a..29f42ccf74 100644 --- a/src/stc/scintilla/src/ExternalLexer.h +++ b/src/stc/scintilla/src/ExternalLexer.h @@ -40,6 +40,7 @@ public: ExternalLexerModule(int language_, LexerFunction fnLexer_, const char *languageName_=0, LexerFunction fnFolder_=0) : LexerModule(language_, fnLexer_, 0, fnFolder_){ strncpy(name, languageName_, sizeof(name)); + name[sizeof(name)-1] = '\0'; languageName = name; }; virtual void Lex(unsigned int startPos, int lengthDoc, int initStyle, @@ -68,7 +69,7 @@ public: void Release(); LexerLibrary *next; - SString m_sModuleName; + std::string m_sModuleName; }; /// LexerManager manages external lexers, contains LexerLibrarys. diff --git a/src/stc/scintilla/src/FontQuality.h b/src/stc/scintilla/src/FontQuality.h new file mode 100644 index 0000000000..2c8d548a86 --- /dev/null +++ b/src/stc/scintilla/src/FontQuality.h @@ -0,0 +1,12 @@ +// Scintilla source code edit control +/** @file FontQuality.h + ** Definitions to control font anti-aliasing. + **/ +// Copyright 1998-2009 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. + +#define SC_EFF_QUALITY_MASK 0xF +#define SC_EFF_QUALITY_DEFAULT 0 +#define SC_EFF_QUALITY_NON_ANTIALIASED 1 +#define SC_EFF_QUALITY_ANTIALIASED 2 +#define SC_EFF_QUALITY_LCD_OPTIMIZED 3 diff --git a/src/stc/scintilla/src/Indicator.cxx b/src/stc/scintilla/src/Indicator.cxx index 139e2b0eab..da9531224a 100644 --- a/src/stc/scintilla/src/Indicator.cxx +++ b/src/stc/scintilla/src/Indicator.cxx @@ -72,7 +72,7 @@ void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &r rcBox.top = rcLine.top + 1; rcBox.left = rc.left; rcBox.right = rc.right; - surface->AlphaRectangle(rcBox, 1, fore.allocated, 30, fore.allocated, 50, 0); + surface->AlphaRectangle(rcBox, 1, fore.allocated, fillAlpha, fore.allocated, 50, 0); } else { // Either INDIC_PLAIN or unknown surface->MoveTo(rc.left, ymid); surface->LineTo(rc.right, ymid); diff --git a/src/stc/scintilla/src/Indicator.h b/src/stc/scintilla/src/Indicator.h index 2081db544e..42b56f07e7 100644 --- a/src/stc/scintilla/src/Indicator.h +++ b/src/stc/scintilla/src/Indicator.h @@ -19,7 +19,8 @@ public: int style; bool under; ColourPair fore; - Indicator() : style(INDIC_PLAIN), under(false), fore(ColourDesired(0,0,0)) { + int fillAlpha; + Indicator() : style(INDIC_PLAIN), under(false), fore(ColourDesired(0,0,0)), fillAlpha(30) { } void Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine); }; diff --git a/src/stc/scintilla/src/KeyWords.cxx b/src/stc/scintilla/src/KeyWords.cxx index 29538d57b5..5e4de668d0 100644 --- a/src/stc/scintilla/src/KeyWords.cxx +++ b/src/stc/scintilla/src/KeyWords.cxx @@ -23,6 +23,192 @@ using namespace Scintilla; #endif +/** + * Creates an array that points into each word in the string and puts \0 terminators + * after each word. + */ +static char **ArrayFromWordList(char *wordlist, int *len, bool onlyLineEnds = false) { + int prev = '\n'; + int words = 0; + // For rapid determination of whether a character is a separator, build + // a look up table. + bool wordSeparator[256]; + for (int i=0;i<256; i++) { + wordSeparator[i] = false; + } + wordSeparator['\r'] = true; + wordSeparator['\n'] = true; + if (!onlyLineEnds) { + wordSeparator[' '] = true; + wordSeparator['\t'] = true; + } + for (int j = 0; wordlist[j]; j++) { + int curr = static_cast(wordlist[j]); + if (!wordSeparator[curr] && wordSeparator[prev]) + words++; + prev = curr; + } + char **keywords = new char *[words + 1]; + if (keywords) { + words = 0; + prev = '\0'; + size_t slen = strlen(wordlist); + for (size_t k = 0; k < slen; k++) { + if (!wordSeparator[static_cast(wordlist[k])]) { + if (!prev) { + keywords[words] = &wordlist[k]; + words++; + } + } else { + wordlist[k] = '\0'; + } + prev = wordlist[k]; + } + keywords[words] = &wordlist[slen]; + *len = words; + } else { + *len = 0; + } + return keywords; +} + +void WordList::Clear() { + if (words) { + delete []list; + delete []words; + } + words = 0; + list = 0; + len = 0; + sorted = false; +} + +void WordList::Set(const char *s) { + list = new char[strlen(s) + 1]; + strcpy(list, s); + sorted = false; + words = ArrayFromWordList(list, &len, onlyLineEnds); +} + +extern "C" int cmpString(const void *a1, const void *a2) { + // Can't work out the correct incantation to use modern casts here + return strcmp(*(char**)(a1), *(char**)(a2)); +} + +static void SortWordList(char **words, unsigned int len) { + qsort(reinterpret_cast(words), len, sizeof(*words), + cmpString); +} + +bool WordList::InList(const char *s) { + if (0 == words) + return false; + if (!sorted) { + sorted = true; + SortWordList(words, len); + for (unsigned int k = 0; k < (sizeof(starts) / sizeof(starts[0])); k++) + starts[k] = -1; + for (int l = len - 1; l >= 0; l--) { + unsigned char indexChar = words[l][0]; + starts[indexChar] = l; + } + } + unsigned char firstChar = s[0]; + int j = starts[firstChar]; + if (j >= 0) { + while ((unsigned char)words[j][0] == firstChar) { + if (s[1] == words[j][1]) { + const char *a = words[j] + 1; + const char *b = s + 1; + while (*a && *a == *b) { + a++; + b++; + } + if (!*a && !*b) + return true; + } + j++; + } + } + j = starts['^']; + if (j >= 0) { + while (words[j][0] == '^') { + const char *a = words[j] + 1; + const char *b = s; + while (*a && *a == *b) { + a++; + b++; + } + if (!*a) + return true; + j++; + } + } + return false; +} + +/** similar to InList, but word s can be a substring of keyword. + * eg. the keyword define is defined as def~ine. This means the word must start + * with def to be a keyword, but also defi, defin and define are valid. + * The marker is ~ in this case. + */ +bool WordList::InListAbbreviated(const char *s, const char marker) { + if (0 == words) + return false; + if (!sorted) { + sorted = true; + SortWordList(words, len); + for (unsigned int k = 0; k < (sizeof(starts) / sizeof(starts[0])); k++) + starts[k] = -1; + for (int l = len - 1; l >= 0; l--) { + unsigned char indexChar = words[l][0]; + starts[indexChar] = l; + } + } + unsigned char firstChar = s[0]; + int j = starts[firstChar]; + if (j >= 0) { + while (words[j][0] == firstChar) { + bool isSubword = false; + int start = 1; + if (words[j][1] == marker) { + isSubword = true; + start++; + } + if (s[1] == words[j][start]) { + const char *a = words[j] + start; + const char *b = s + 1; + while (*a && *a == *b) { + a++; + if (*a == marker) { + isSubword = true; + a++; + } + b++; + } + if ((!*a || isSubword) && !*b) + return true; + } + j++; + } + } + j = starts['^']; + if (j >= 0) { + while (words[j][0] == '^') { + const char *a = words[j] + 1; + const char *b = s; + while (*a && *a == *b) { + a++; + b++; + } + if (!*a) + return true; + j++; + } + } + return false; +} + const LexerModule *LexerModule::base = 0; int LexerModule::nextLanguage = SCLEX_AUTOMATIC+1; @@ -146,7 +332,6 @@ int Scintilla_LinkLexers() { LINK_LEXER(lmAns1); LINK_LEXER(lmAPDL); LINK_LEXER(lmAsm); - LINK_LEXER(lmASP); LINK_LEXER(lmASY); LINK_LEXER(lmAU3); LINK_LEXER(lmAVE); @@ -159,6 +344,7 @@ int Scintilla_LinkLexers() { LINK_LEXER(lmClw); LINK_LEXER(lmClwNoCase); LINK_LEXER(lmCmake); + LINK_LEXER(lmCOBOL); LINK_LEXER(lmConf); LINK_LEXER(lmCPP); LINK_LEXER(lmCPPNoCase); @@ -187,11 +373,15 @@ int Scintilla_LinkLexers() { LINK_LEXER(lmLot); LINK_LEXER(lmLout); LINK_LEXER(lmLua); + LINK_LEXER(lmMagikSF); LINK_LEXER(lmMake); + LINK_LEXER(lmMarkdown); LINK_LEXER(lmMatlab); LINK_LEXER(lmMETAPOST); LINK_LEXER(lmMMIXAL); LINK_LEXER(lmMSSQL); + LINK_LEXER(lmMySQL); + LINK_LEXER(lmNimrod); LINK_LEXER(lmNncrontab); LINK_LEXER(lmNsis); LINK_LEXER(lmNull); @@ -200,10 +390,12 @@ int Scintilla_LinkLexers() { LINK_LEXER(lmPascal); LINK_LEXER(lmPB); LINK_LEXER(lmPerl); - LINK_LEXER(lmPHP); LINK_LEXER(lmPHPSCRIPT); LINK_LEXER(lmPLM); + LINK_LEXER(lmPo); LINK_LEXER(lmPOV); + LINK_LEXER(lmPowerPro); + LINK_LEXER(lmPowerShell); LINK_LEXER(lmProgress); LINK_LEXER(lmProps); LINK_LEXER(lmPS); @@ -214,10 +406,14 @@ int Scintilla_LinkLexers() { LINK_LEXER(lmRuby); LINK_LEXER(lmScriptol); LINK_LEXER(lmSmalltalk); + LINK_LEXER(lmSML); + LINK_LEXER(lmSorc); LINK_LEXER(lmSpecman); LINK_LEXER(lmSpice); LINK_LEXER(lmSQL); + LINK_LEXER(lmTACL); LINK_LEXER(lmTADS3); + LINK_LEXER(lmTAL); LINK_LEXER(lmTCL); LINK_LEXER(lmTeX); LINK_LEXER(lmVB); diff --git a/src/stc/scintilla/src/LexAU3.cxx b/src/stc/scintilla/src/LexAU3.cxx index cedf261f5c..cfff9279db 100644 --- a/src/stc/scintilla/src/LexAU3.cxx +++ b/src/stc/scintilla/src/LexAU3.cxx @@ -253,11 +253,12 @@ static void ColouriseAU3Doc(unsigned int startPos, //Reset at line end if (sc.atLineEnd) { ci=0; - if ((strcmp(s, "#ce")== 0 || strcmp(s, "#comments-end")== 0)) + if (strcmp(s, "#ce")== 0 || strcmp(s, "#comments-end")== 0) { if (sc.atLineEnd) sc.SetState(SCE_AU3_DEFAULT); else sc.SetState(SCE_AU3_COMMENTBLOCK); + } break; } //skip rest of line when a ; is encountered diff --git a/src/stc/scintilla/src/LexAbaqus.cxx b/src/stc/scintilla/src/LexAbaqus.cxx index 194b84c516..10e8b76b1e 100644 --- a/src/stc/scintilla/src/LexAbaqus.cxx +++ b/src/stc/scintilla/src/LexAbaqus.cxx @@ -2,6 +2,7 @@ /** @file LexABAQUS.cxx ** Lexer for ABAQUS. Based on the lexer for APDL by Hadar Raz. ** By Sergio Lucato. + ** Sort of completely rewritten by Gertjan Kloosterman **/ // The License.txt file describes the conditions under which this software may be distributed. @@ -27,7 +28,15 @@ using namespace Scintilla; #endif static inline bool IsAWordChar(const int ch) { - return (ch < 0x80 && (isalnum(ch) || ch == '_')); + return (ch < 0x80 && (isalnum(ch) || (ch == '_'))); +} + +static inline bool IsAKeywordChar(const int ch) { + return (ch < 0x80 && (isalnum(ch) || (ch == '_') || (ch == ' '))); +} + +static inline bool IsASetChar(const int ch) { + return (ch < 0x80 && (isalnum(ch) || (ch == '_') || (ch == '.') || (ch == '-'))); } static inline bool IsAnOperator(char ch) { @@ -41,90 +50,228 @@ static inline bool IsAnOperator(char ch) { return false; } -static void ColouriseABAQUSDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], +static void ColouriseABAQUSDoc(unsigned int startPos, int length, int initStyle, WordList*[] /* *keywordlists[] */, Accessor &styler) { - - int stringStart = ' '; - - WordList &processors = *keywordlists[0]; - WordList &commands = *keywordlists[1]; - WordList &slashcommands = *keywordlists[2]; - WordList &starcommands = *keywordlists[3]; - WordList &arguments = *keywordlists[4]; - WordList &functions = *keywordlists[5]; + enum localState { KW_LINE_KW, KW_LINE_COMMA, KW_LINE_PAR, KW_LINE_EQ, KW_LINE_VAL, \ + DAT_LINE_VAL, DAT_LINE_COMMA,\ + COMMENT_LINE,\ + ST_ERROR, LINE_END } state ; // Do not leak onto next line + state = LINE_END ; initStyle = SCE_ABAQUS_DEFAULT; StyleContext sc(startPos, length, initStyle, styler); - for (; sc.More(); sc.Forward()) { - // Determine if the current state should terminate. - if (sc.state == SCE_ABAQUS_NUMBER) { - if (!(IsADigit(sc.ch) || sc.ch == '.' || (sc.ch == 'e' || sc.ch == 'E') || - ((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E')))) { - sc.SetState(SCE_ABAQUS_DEFAULT); - } - } else if (sc.state == SCE_ABAQUS_COMMENT) { - if (sc.atLineEnd) { - sc.SetState(SCE_ABAQUS_DEFAULT); - } - } else if (sc.state == SCE_ABAQUS_COMMENTBLOCK) { - if (sc.atLineEnd) { - if (sc.ch == '\r') { - sc.Forward(); - } - sc.ForwardSetState(SCE_ABAQUS_DEFAULT); - } - } else if (sc.state == SCE_ABAQUS_STRING) { - if (sc.atLineEnd) { - sc.SetState(SCE_ABAQUS_DEFAULT); - } else if ((sc.ch == '\'' && stringStart == '\'') || (sc.ch == '\"' && stringStart == '\"')) { - sc.ForwardSetState(SCE_ABAQUS_DEFAULT); - } - } else if (sc.state == SCE_ABAQUS_WORD) { - if (!IsAWordChar(sc.ch)) { - char s[100]; - sc.GetCurrentLowered(s, sizeof(s)); - if (processors.InList(s)) { - sc.ChangeState(SCE_ABAQUS_PROCESSOR); - } else if (slashcommands.InList(s)) { - sc.ChangeState(SCE_ABAQUS_SLASHCOMMAND); - } else if (starcommands.InList(s)) { - sc.ChangeState(SCE_ABAQUS_STARCOMMAND); - } else if (commands.InList(s)) { - sc.ChangeState(SCE_ABAQUS_COMMAND); - } else if (arguments.InList(s)) { - sc.ChangeState(SCE_ABAQUS_ARGUMENT); - } else if (functions.InList(s)) { - sc.ChangeState(SCE_ABAQUS_FUNCTION); - } - sc.SetState(SCE_ABAQUS_DEFAULT); - } - } else if (sc.state == SCE_ABAQUS_OPERATOR) { - if (!IsAnOperator(static_cast(sc.ch))) { - sc.SetState(SCE_ABAQUS_DEFAULT); - } - } + // Things are actually quite simple + // we have commentlines + // keywordlines and datalines + // On a data line there will only be colouring of numbers + // a keyword line is constructed as + // *word,[ paramname[=paramvalue]]* + // if the line ends with a , the keyword line continues onto the new line - // Determine if a new state should be entered. - if (sc.state == SCE_ABAQUS_DEFAULT) { - if (sc.ch == '*' && sc.chNext == '*') { - sc.SetState(SCE_ABAQUS_COMMENTBLOCK); - } else if (sc.ch == '!') { - sc.SetState(SCE_ABAQUS_COMMENT); - } else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { - sc.SetState(SCE_ABAQUS_NUMBER); - } else if (sc.ch == '\'' || sc.ch == '\"') { - sc.SetState(SCE_ABAQUS_STRING); - stringStart = sc.ch; - } else if (IsAWordChar(sc.ch) || ((sc.ch == '*' || sc.ch == '/') && !isgraph(sc.chPrev))) { - sc.SetState(SCE_ABAQUS_WORD); - } else if (IsAnOperator(static_cast(sc.ch))) { - sc.SetState(SCE_ABAQUS_OPERATOR); - } - } - } - sc.Complete(); + for (; sc.More(); sc.Forward()) { + switch ( state ) { + case KW_LINE_KW : + if ( sc.atLineEnd ) { + // finished the line in keyword state, switch to LINE_END + sc.SetState(SCE_ABAQUS_DEFAULT) ; + state = LINE_END ; + } else if ( IsAKeywordChar(sc.ch) ) { + // nothing changes + state = KW_LINE_KW ; + } else if ( sc.ch == ',' ) { + // Well well we say a comma, arguments *MUST* follow + sc.SetState(SCE_ABAQUS_OPERATOR) ; + state = KW_LINE_COMMA ; + } else { + // Flag an error + sc.SetState(SCE_ABAQUS_PROCESSOR) ; + state = ST_ERROR ; + } + // Done with processing + break ; + case KW_LINE_COMMA : + // acomma on a keywordline was seen + if ( IsAKeywordChar(sc.ch)) { + sc.SetState(SCE_ABAQUS_ARGUMENT) ; + state = KW_LINE_PAR ; + } else if ( sc.atLineEnd || (sc.ch == ',') ) { + // we remain in keyword mode + state = KW_LINE_COMMA ; + } else if ( sc.ch == ' ' ) { + sc.SetState(SCE_ABAQUS_DEFAULT) ; + state = KW_LINE_COMMA ; + } else { + // Anything else constitutes an error + sc.SetState(SCE_ABAQUS_PROCESSOR) ; + state = ST_ERROR ; + } + break ; + case KW_LINE_PAR : + if ( sc.atLineEnd ) { + sc.SetState(SCE_ABAQUS_DEFAULT) ; + state = LINE_END ; + } else if ( IsAKeywordChar(sc.ch) || (sc.ch == '-') ) { + // remain in this state + state = KW_LINE_PAR ; + } else if ( sc.ch == ',' ) { + sc.SetState(SCE_ABAQUS_OPERATOR) ; + state = KW_LINE_COMMA ; + } else if ( sc.ch == '=' ) { + sc.SetState(SCE_ABAQUS_OPERATOR) ; + state = KW_LINE_EQ ; + } else { + // Anything else constitutes an error + sc.SetState(SCE_ABAQUS_PROCESSOR) ; + state = ST_ERROR ; + } + break ; + case KW_LINE_EQ : + if ( sc.ch == ' ' ) { + sc.SetState(SCE_ABAQUS_DEFAULT) ; + // remain in this state + state = KW_LINE_EQ ; + } else if ( IsADigit(sc.ch) || (sc.ch == '-') || (sc.ch == '.' && IsADigit(sc.chNext)) ) { + sc.SetState(SCE_ABAQUS_NUMBER) ; + state = KW_LINE_VAL ; + } else if ( IsAKeywordChar(sc.ch) ) { + sc.SetState(SCE_ABAQUS_DEFAULT) ; + state = KW_LINE_VAL ; + } else if ( (sc.ch == '\'') || (sc.ch == '\"') ) { + sc.SetState(SCE_ABAQUS_STRING) ; + state = KW_LINE_VAL ; + } else { + sc.SetState(SCE_ABAQUS_PROCESSOR) ; + state = ST_ERROR ; + } + break ; + case KW_LINE_VAL : + if ( sc.atLineEnd ) { + sc.SetState(SCE_ABAQUS_DEFAULT) ; + state = LINE_END ; + } else if ( IsASetChar(sc.ch) && (sc.state == SCE_ABAQUS_DEFAULT) ) { + // nothing changes + state = KW_LINE_VAL ; + } else if (( (IsADigit(sc.ch) || sc.ch == '.' || (sc.ch == 'e' || sc.ch == 'E') || + ((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E')))) && + (sc.state == SCE_ABAQUS_NUMBER)) { + // remain in number mode + state = KW_LINE_VAL ; + } else if (sc.state == SCE_ABAQUS_STRING) { + // accept everything until a closing quote + if ( sc.ch == '\'' || sc.ch == '\"' ) { + sc.SetState(SCE_ABAQUS_DEFAULT) ; + state = KW_LINE_VAL ; + } + } else if ( sc.ch == ',' ) { + sc.SetState(SCE_ABAQUS_OPERATOR) ; + state = KW_LINE_COMMA ; + } else { + // anything else is an error + sc.SetState(SCE_ABAQUS_PROCESSOR) ; + state = ST_ERROR ; + } + break ; + case DAT_LINE_VAL : + if ( sc.atLineEnd ) { + sc.SetState(SCE_ABAQUS_DEFAULT) ; + state = LINE_END ; + } else if ( IsASetChar(sc.ch) && (sc.state == SCE_ABAQUS_DEFAULT) ) { + // nothing changes + state = DAT_LINE_VAL ; + } else if (( (IsADigit(sc.ch) || sc.ch == '.' || (sc.ch == 'e' || sc.ch == 'E') || + ((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E')))) && + (sc.state == SCE_ABAQUS_NUMBER)) { + // remain in number mode + state = DAT_LINE_VAL ; + } else if (sc.state == SCE_ABAQUS_STRING) { + // accept everything until a closing quote + if ( sc.ch == '\'' || sc.ch == '\"' ) { + sc.SetState(SCE_ABAQUS_DEFAULT) ; + state = DAT_LINE_VAL ; + } + } else if ( sc.ch == ',' ) { + sc.SetState(SCE_ABAQUS_OPERATOR) ; + state = DAT_LINE_COMMA ; + } else { + // anything else is an error + sc.SetState(SCE_ABAQUS_PROCESSOR) ; + state = ST_ERROR ; + } + break ; + case DAT_LINE_COMMA : + // a comma on a data line was seen + if ( sc.atLineEnd ) { + sc.SetState(SCE_ABAQUS_DEFAULT) ; + state = LINE_END ; + } else if ( sc.ch == ' ' ) { + sc.SetState(SCE_ABAQUS_DEFAULT) ; + state = DAT_LINE_COMMA ; + } else if (sc.ch == ',') { + sc.SetState(SCE_ABAQUS_OPERATOR) ; + state = DAT_LINE_COMMA ; + } else if ( IsADigit(sc.ch) || (sc.ch == '-')|| (sc.ch == '.' && IsADigit(sc.chNext)) ) { + sc.SetState(SCE_ABAQUS_NUMBER) ; + state = DAT_LINE_VAL ; + } else if ( IsAKeywordChar(sc.ch) ) { + sc.SetState(SCE_ABAQUS_DEFAULT) ; + state = DAT_LINE_VAL ; + } else if ( (sc.ch == '\'') || (sc.ch == '\"') ) { + sc.SetState(SCE_ABAQUS_STRING) ; + state = DAT_LINE_VAL ; + } else { + sc.SetState(SCE_ABAQUS_PROCESSOR) ; + state = ST_ERROR ; + } + break ; + case COMMENT_LINE : + if ( sc.atLineEnd ) { + sc.SetState(SCE_ABAQUS_DEFAULT) ; + state = LINE_END ; + } + break ; + case ST_ERROR : + if ( sc.atLineEnd ) { + sc.SetState(SCE_ABAQUS_DEFAULT) ; + state = LINE_END ; + } + break ; + case LINE_END : + if ( sc.atLineEnd || sc.ch == ' ' ) { + // nothing changes + state = LINE_END ; + } else if ( sc.ch == '*' ) { + if ( sc.chNext == '*' ) { + state = COMMENT_LINE ; + sc.SetState(SCE_ABAQUS_COMMENT) ; + } else { + state = KW_LINE_KW ; + sc.SetState(SCE_ABAQUS_STARCOMMAND) ; + } + } else { + // it must be a data line, things are as if we are in DAT_LINE_COMMA + if ( sc.ch == ',' ) { + sc.SetState(SCE_ABAQUS_OPERATOR) ; + state = DAT_LINE_COMMA ; + } else if ( IsADigit(sc.ch) || (sc.ch == '-')|| (sc.ch == '.' && IsADigit(sc.chNext)) ) { + sc.SetState(SCE_ABAQUS_NUMBER) ; + state = DAT_LINE_VAL ; + } else if ( IsAKeywordChar(sc.ch) ) { + sc.SetState(SCE_ABAQUS_DEFAULT) ; + state = DAT_LINE_VAL ; + } else if ( (sc.ch == '\'') || (sc.ch == '\"') ) { + sc.SetState(SCE_ABAQUS_STRING) ; + state = DAT_LINE_VAL ; + } else { + sc.SetState(SCE_ABAQUS_PROCESSOR) ; + state = ST_ERROR ; + } + } + break ; + } + } + sc.Complete(); } //------------------------------------------------------------------------------ @@ -166,85 +313,295 @@ static int LowerCase(int c) return c; } -static int CheckABAQUSFoldPoint(char const *token, int &level) { - if (!strcmp(token, "*step") || - !strcmp(token, "*part") || - !strcmp(token, "*instance") || - !strcmp(token, "*assembly") || - !strcmp(token, "***region") ) { - level |= SC_FOLDLEVELHEADERFLAG; - return 1; - } - if (!strcmp(token, "*end step") || - !strcmp(token, "*end part") || - !strcmp(token, "*end instance") || - !strcmp(token, "*end assembly") || - !strcmp(token, "***end region") ) { - return -1; - } - return 0; +static int LineEnd(int line, Accessor &styler) +{ + const int docLines = styler.GetLine(styler.Length() - 1); // Available last line + int eol_pos ; + // if the line is the last line, the eol_pos is styler.Length() + // eol will contain a new line, or a virtual new line + if ( docLines == line ) + eol_pos = styler.Length() ; + else + eol_pos = styler.LineStart(line + 1) - 1; + return eol_pos ; +} + +static int LineStart(int line, Accessor &styler) +{ + return styler.LineStart(line) ; +} + +// LineType +// +// bits determines the line type +// 1 : data line +// 2 : only whitespace +// 3 : data line with only whitespace +// 4 : keyword line +// 5 : block open keyword line +// 6 : block close keyword line +// 7 : keyword line in error +// 8 : comment line +static int LineType(int line, Accessor &styler) { + int pos = LineStart(line, styler) ; + int eol_pos = LineEnd(line, styler) ; + + int c ; + char ch = ' '; + + int i = pos ; + while ( i < eol_pos ) { + c = styler.SafeGetCharAt(i); + ch = static_cast(LowerCase(c)); + // We can say something as soon as no whitespace + // was encountered + if ( !IsSpace(c) ) + break ; + i++ ; + } + + if ( i >= eol_pos ) { + // This is a whitespace line, currently + // classifies as data line + return 3 ; + } + + if ( ch != '*' ) { + // This is a data line + return 1 ; + } + + if ( i == eol_pos - 1 ) { + // Only a single *, error but make keyword line + return 4+3 ; + } + + // This means we can have a second character + // if that is also a * this means a comment + // otherwise it is a keyword. + c = styler.SafeGetCharAt(i+1); + ch = static_cast(LowerCase(c)); + if ( ch == '*' ) { + return 8 ; + } + + // At this point we know this is a keyword line + // the character at position i is a * + // it is not a comment line + char word[256] ; + int wlen = 0; + + word[wlen] = '*' ; + wlen++ ; + + i++ ; + while ( (i < eol_pos) && (wlen < 255) ) { + c = styler.SafeGetCharAt(i); + ch = static_cast(LowerCase(c)); + + if ( (!IsSpace(c)) && (!IsIdentifier(c)) ) + break ; + + if ( IsIdentifier(c) ) { + word[wlen] = ch ; + wlen++ ; + } + + i++ ; + } + + word[wlen] = 0 ; + + // Make a comparison + if ( !strcmp(word, "*step") || + !strcmp(word, "*part") || + !strcmp(word, "*instance") || + !strcmp(word, "*assembly")) { + return 4+1 ; + } + + if ( !strcmp(word, "*endstep") || + !strcmp(word, "*endpart") || + !strcmp(word, "*endinstance") || + !strcmp(word, "*endassembly")) { + return 4+2 ; + } + + return 4 ; +} + +static void SafeSetLevel(int line, int level, Accessor &styler) +{ + if ( line < 0 ) + return ; + + int mask = ((~SC_FOLDLEVELHEADERFLAG) | (~SC_FOLDLEVELWHITEFLAG)); + + if ( (level & mask) < 0 ) + return ; + + if ( styler.LevelAt(line) != level ) + styler.SetLevel(line, level) ; } static void FoldABAQUSDoc(unsigned int startPos, int length, int, - WordList *[], Accessor &styler) { - - int line = styler.GetLine(startPos); - int level = styler.LevelAt(line); - int go = 0, done = 0; - int endPos = startPos + length; - char word[256]; - int wordlen = 0; - int i; - bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; - // Scan for tokens at the start of the line (they may include - // whitespace, for tokens like "End Function" - for (i = startPos; i < endPos; i++) { - int c = styler.SafeGetCharAt(i); - if (!done && !go) { - if (wordlen) { // are we scanning a token already? - word[wordlen] = static_cast(LowerCase(c)); - if (!IsIdentifier(c)) { // done with token - word[wordlen] = '\0'; - go = CheckABAQUSFoldPoint(word, level); - if (!go) { - // Treat any whitespace as single blank, for - // things like "End Function". - if (IsSpace(c) && IsIdentifier(word[wordlen - 1])) { - word[wordlen] = ' '; - if (wordlen < 255) - wordlen++; - } - else // done with this line - done = 1; - } - } else if (wordlen < 255) { - wordlen++; +WordList *[], Accessor &styler) { + int startLine = styler.GetLine(startPos) ; + int endLine = styler.GetLine(startPos+length-1) ; + + // bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; + // We want to deal with all the cases + // To know the correct indentlevel, we need to look back to the + // previous command line indentation level + // order of formatting keyline datalines commentlines + int beginData = -1 ; + int beginComment = -1 ; + int prvKeyLine = startLine ; + int prvKeyLineTp = 0 ; + + // Scan until we find the previous keyword line + // this will give us the level reference that we need + while ( prvKeyLine > 0 ) { + prvKeyLine-- ; + prvKeyLineTp = LineType(prvKeyLine, styler) ; + if ( prvKeyLineTp & 4 ) + break ; + } + + // Determine the base line level of all lines following + // the previous keyword + // new keyword lines are placed on this level + //if ( prvKeyLineTp & 4 ) { + int level = styler.LevelAt(prvKeyLine) & ~SC_FOLDLEVELHEADERFLAG ; + //} + + // uncomment line below if weird behaviour continues + prvKeyLine = -1 ; + + // Now start scanning over the lines. + for ( int line = startLine; line <= endLine; line++ ) { + int lineType = LineType(line, styler) ; + + // Check for comment line + if ( lineType == 8 ) { + if ( beginComment < 0 ) { + beginComment = line ; + } + } + + // Check for data line + if ( (lineType == 1) || (lineType == 3) ) { + if ( beginData < 0 ) { + if ( beginComment >= 0 ) { + beginData = beginComment ; + } else { + beginData = line ; + } + } + beginComment = -1 ; + } + + // Check for keywordline. + // As soon as a keyword line is encountered, we can set the + // levels of everything from the previous keyword line to this one + if ( lineType & 4 ) { + // this is a keyword, we can now place the previous keyword + // all its data lines and the remainder + + // Write comments and data line + if ( beginComment < 0 ) { + beginComment = line ; + } + + if ( beginData < 0 ) { + beginData = beginComment ; + if ( prvKeyLineTp != 5 ) + SafeSetLevel(prvKeyLine, level, styler) ; + else + SafeSetLevel(prvKeyLine, level | SC_FOLDLEVELHEADERFLAG, styler) ; + } else { + SafeSetLevel(prvKeyLine, level | SC_FOLDLEVELHEADERFLAG, styler) ; + } + + int datLevel = level + 1 ; + if ( !(prvKeyLineTp & 4) ) { + datLevel = level ; + } + + for ( int ll = beginData; ll < beginComment; ll++ ) + SafeSetLevel(ll, datLevel, styler) ; + + // The keyword we just found is going to be written at another level + // if we have a type 5 and type 6 + if ( prvKeyLineTp == 5 ) { + level += 1 ; + } + + if ( prvKeyLineTp == 6 ) { + level -= 1 ; + if ( level < 0 ) { + level = 0 ; } - } else { // start scanning at first non-whitespace character - if (!IsSpace(c)) { - if (IsIdentifier(c)) { - word[0] = static_cast(LowerCase(c)); - wordlen = 1; - } else // done with this line - done = 1; + } + + for ( int lll = beginComment; lll < line; lll++ ) + SafeSetLevel(lll, level, styler) ; + + // wrap and reset + beginComment = -1 ; + beginData = -1 ; + prvKeyLine = line ; + prvKeyLineTp = lineType ; + } + + } + + if ( beginComment < 0 ) { + beginComment = endLine + 1 ; + } else { + // We need to find out whether this comment block is followed by + // a data line or a keyword line + const int docLines = styler.GetLine(styler.Length() - 1); + + for ( int line = endLine + 1; line <= docLines; line++ ) { + int lineType = LineType(line, styler) ; + + if ( lineType != 8 ) { + if ( !(lineType & 4) ) { + beginComment = endLine + 1 ; } + break ; } - } - if (c == '\n') { // line end - if (!done && wordlen == 0 && foldCompact) // line was only space - level |= SC_FOLDLEVELWHITEFLAG; - if (level != styler.LevelAt(line)) - styler.SetLevel(line, level); - level += go; - line++; - // reset state - wordlen = 0; - level &= ~SC_FOLDLEVELHEADERFLAG; - level &= ~SC_FOLDLEVELWHITEFLAG; - go = 0; - done = 0; - } + } + } + + if ( beginData < 0 ) { + beginData = beginComment ; + if ( prvKeyLineTp != 5 ) + SafeSetLevel(prvKeyLine, level, styler) ; + else + SafeSetLevel(prvKeyLine, level | SC_FOLDLEVELHEADERFLAG, styler) ; + } else { + SafeSetLevel(prvKeyLine, level | SC_FOLDLEVELHEADERFLAG, styler) ; + } + + int datLevel = level + 1 ; + if ( !(prvKeyLineTp & 4) ) { + datLevel = level ; + } + + for ( int ll = beginData; ll < beginComment; ll++ ) + SafeSetLevel(ll, datLevel, styler) ; + + if ( prvKeyLineTp == 5 ) { + level += 1 ; + } + + if ( prvKeyLineTp == 6 ) { + level -= 1 ; } + for ( int m = beginComment; m <= endLine; m++ ) + SafeSetLevel(m, level, styler) ; } static const char * const abaqusWordListDesc[] = { diff --git a/src/stc/scintilla/src/LexAda.cxx b/src/stc/scintilla/src/LexAda.cxx index f6c9e7ee7a..654bfbebad 100644 --- a/src/stc/scintilla/src/LexAda.cxx +++ b/src/stc/scintilla/src/LexAda.cxx @@ -10,6 +10,8 @@ #include #include +#include + #include "Platform.h" #include "Accessor.h" @@ -17,7 +19,6 @@ #include "PropSet.h" #include "KeyWords.h" #include "SciLexer.h" -#include "SString.h" #ifdef SCI_NAMESPACE using namespace Scintilla; @@ -62,8 +63,8 @@ static inline bool IsDelimiterCharacter(int ch); static inline bool IsNumberStartCharacter(int ch); static inline bool IsNumberCharacter(int ch); static inline bool IsSeparatorOrDelimiterCharacter(int ch); -static bool IsValidIdentifier(const SString& identifier); -static bool IsValidNumber(const SString& number); +static bool IsValidIdentifier(const std::string& identifier); +static bool IsValidNumber(const std::string& number); static inline bool IsWordStartCharacter(int ch); static inline bool IsWordCharacter(int ch); @@ -117,7 +118,7 @@ static void ColouriseLabel(StyleContext& sc, WordList& keywords, bool& apostroph sc.Forward(); sc.Forward(); - SString identifier; + std::string identifier; while (!sc.atLineEnd && !IsSeparatorOrDelimiterCharacter(sc.ch)) { identifier += static_cast(tolower(sc.ch)); @@ -144,7 +145,7 @@ static void ColouriseLabel(StyleContext& sc, WordList& keywords, bool& apostroph static void ColouriseNumber(StyleContext& sc, bool& apostropheStartsAttribute) { apostropheStartsAttribute = true; - SString number; + std::string number; sc.SetState(SCE_ADA_NUMBER); // Get all characters up to a delimiter or a separator, including points, but excluding @@ -192,7 +193,7 @@ static void ColouriseWord(StyleContext& sc, WordList& keywords, bool& apostrophe apostropheStartsAttribute = true; sc.SetState(SCE_ADA_IDENTIFIER); - SString word; + std::string word; while (!sc.atLineEnd && !IsSeparatorOrDelimiterCharacter(sc.ch)) { word += static_cast(tolower(sc.ch)); @@ -321,7 +322,7 @@ static inline bool IsSeparatorOrDelimiterCharacter(int ch) { return IsASpace(ch) || IsDelimiterCharacter(ch); } -static bool IsValidIdentifier(const SString& identifier) { +static bool IsValidIdentifier(const std::string& identifier) { // First character can't be '_', so initialize the flag to true bool lastWasUnderscore = true; @@ -355,8 +356,8 @@ static bool IsValidIdentifier(const SString& identifier) { return true; } -static bool IsValidNumber(const SString& number) { - int hashPos = number.search("#"); +static bool IsValidNumber(const std::string& number) { + size_t hashPos = number.find("#"); bool seenDot = false; size_t i = 0; @@ -366,7 +367,7 @@ static bool IsValidNumber(const SString& number) { return false; // Just in case // Decimal number - if (hashPos == -1) { + if (hashPos == std::string::npos) { bool canBeSpecial = false; for (; i < length; i++) { diff --git a/src/stc/scintilla/src/LexAsm.cxx b/src/stc/scintilla/src/LexAsm.cxx index 9dd4df4565..17c938420a 100644 --- a/src/stc/scintilla/src/LexAsm.cxx +++ b/src/stc/scintilla/src/LexAsm.cxx @@ -37,8 +37,8 @@ static inline bool IsAWordStart(const int ch) { ch == '%' || ch == '@' || ch == '$' || ch == '?'); } -static inline bool IsAsmOperator(char ch) { - if (isalnum(ch)) +static inline bool IsAsmOperator(const int ch) { + if ((ch < 0x80) && (isalnum(ch))) return false; // '.' left out as it is used to make up numbers if (ch == '*' || ch == '/' || ch == '-' || ch == '+' || @@ -89,7 +89,7 @@ static void ColouriseAsmDoc(unsigned int startPos, int length, int initStyle, Wo // Determine if the current state should terminate. if (sc.state == SCE_ASM_OPERATOR) { - if (!IsAsmOperator(static_cast(sc.ch))) { + if (!IsAsmOperator(sc.ch)) { sc.SetState(SCE_ASM_DEFAULT); } }else if (sc.state == SCE_ASM_NUMBER) { @@ -149,7 +149,7 @@ static void ColouriseAsmDoc(unsigned int startPos, int length, int initStyle, Wo if (sc.state == SCE_ASM_DEFAULT) { if (sc.ch == ';'){ sc.SetState(SCE_ASM_COMMENT); - } else if (isdigit(sc.ch) || (sc.ch == '.' && isdigit(sc.chNext))) { + } else if (isascii(sc.ch) && (isdigit(sc.ch) || (sc.ch == '.' && isascii(sc.chNext) && isdigit(sc.chNext)))) { sc.SetState(SCE_ASM_NUMBER); } else if (IsAWordStart(sc.ch)) { sc.SetState(SCE_ASM_IDENTIFIER); @@ -157,7 +157,7 @@ static void ColouriseAsmDoc(unsigned int startPos, int length, int initStyle, Wo sc.SetState(SCE_ASM_STRING); } else if (sc.ch == '\'') { sc.SetState(SCE_ASM_CHARACTER); - } else if (IsAsmOperator(static_cast(sc.ch))) { + } else if (IsAsmOperator(sc.ch)) { sc.SetState(SCE_ASM_OPERATOR); } } diff --git a/src/stc/scintilla/src/LexBash.cxx b/src/stc/scintilla/src/LexBash.cxx index f0376b9474..5801278bec 100644 --- a/src/stc/scintilla/src/LexBash.cxx +++ b/src/stc/scintilla/src/LexBash.cxx @@ -2,8 +2,8 @@ /** @file LexBash.cxx ** Lexer for Bash. **/ -// Copyright 2004-2007 by Neil Hodgson -// Adapted from LexPerl by Kein-Hong Man 2004 +// Copyright 2004-2008 by Neil Hodgson +// Adapted from LexPerl by Kein-Hong Man 2004 // The License.txt file describes the conditions under which this software may be distributed. #include @@ -16,9 +16,17 @@ #include "PropSet.h" #include "Accessor.h" +#include "StyleContext.h" #include "KeyWords.h" #include "Scintilla.h" #include "SciLexer.h" +#include "CharacterSet.h" + +#ifdef SCI_NAMESPACE +using namespace Scintilla; +#endif + +#define HERE_DELIM_MAX 256 // define this if you want 'invalid octals' to be marked as errors // usually, this is not a good idea, permissive lexing is better @@ -32,13 +40,7 @@ #define BASH_BASE_OCTAL_ERROR 69 #endif -#define HERE_DELIM_MAX 256 - -#ifdef SCI_NAMESPACE -using namespace Scintilla; -#endif - -static inline int translateBashDigit(char ch) { +static inline int translateBashDigit(int ch) { if (ch >= '0' && ch <= '9') { return ch - '0'; } else if (ch >= 'a' && ch <= 'z') { @@ -53,407 +55,210 @@ static inline int translateBashDigit(char ch) { return BASH_BASE_ERROR; } -static inline bool isEOLChar(char ch) { - return (ch == '\r') || (ch == '\n'); -} - -static bool isSingleCharOp(char ch) { - char strCharSet[2]; - strCharSet[0] = ch; - strCharSet[1] = '\0'; - return (NULL != strstr("rwxoRWXOezsfdlpSbctugkTBMACahGLNn", strCharSet)); -} - -static inline bool isBashOperator(char ch) { - if (ch == '^' || ch == '&' || ch == '\\' || ch == '%' || - ch == '(' || ch == ')' || ch == '-' || ch == '+' || - ch == '=' || ch == '|' || ch == '{' || ch == '}' || - ch == '[' || ch == ']' || ch == ':' || ch == ';' || - ch == '>' || ch == ',' || ch == '/' || ch == '<' || - ch == '?' || ch == '!' || ch == '.' || ch == '~' || - ch == '@') - return true; - return false; -} - -static int classifyWordBash(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) { - char s[100]; - for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) { - s[i] = styler[start + i]; - s[i + 1] = '\0'; - } - char chAttr = SCE_SH_IDENTIFIER; - if (keywords.InList(s)) - chAttr = SCE_SH_WORD; - styler.ColourTo(end, chAttr); - return chAttr; -} - -static inline int getBashNumberBase(unsigned int start, unsigned int end, Accessor &styler) { +static inline int getBashNumberBase(char *s) { + int i = 0; int base = 0; - for (unsigned int i = 0; i < end - start + 1 && i < 10; i++) { - base = base * 10 + (styler[start + i] - '0'); + while (*s) { + base = base * 10 + (*s++ - '0'); + i++; } - if (base > 64 || (end - start) > 1) { + if (base > 64 || i > 2) { return BASH_BASE_ERROR; } return base; } -static inline bool isEndVar(char ch) { - return !isalnum(ch) && ch != '$' && ch != '_'; -} - -static inline bool isNonQuote(char ch) { - return isalnum(ch) || ch == '_'; -} - -static bool isMatch(Accessor &styler, int lengthDoc, int pos, const char *val) { - if ((pos + static_cast(strlen(val))) >= lengthDoc) { - return false; - } - while (*val) { - if (*val != styler[pos++]) { - return false; - } - val++; - } - return true; -} - -static char opposite(char ch) { - if (ch == '(') - return ')'; - if (ch == '[') - return ']'; - if (ch == '{') - return '}'; - if (ch == '<') - return '>'; +static int opposite(int ch) { + if (ch == '(') return ')'; + if (ch == '[') return ']'; + if (ch == '{') return '}'; + if (ch == '<') return '>'; return ch; } static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle, - WordList *keywordlists[], Accessor &styler) { - - // Lexer for bash often has to backtrack to start of current style to determine - // which characters are being used as quotes, how deeply nested is the - // start position and what the termination string is for here documents + WordList *keywordlists[], Accessor &styler) { WordList &keywords = *keywordlists[0]; - class HereDocCls { + CharacterSet setWordStart(CharacterSet::setAlpha, "_"); + // note that [+-] are often parts of identifiers in shell scripts + CharacterSet setWord(CharacterSet::setAlphaNum, "._+-"); + CharacterSet setBashOperator(CharacterSet::setNone, "^&\\%()-+=|{}[]:;>,*/(ch); + Delimiter[DelimiterLength] = '\0'; + } ~HereDocCls() { delete []Delimiter; } }; HereDocCls HereDoc; - class QuoteCls { + class QuoteCls { // Class to manage quote pairs (simplified vs LexPerl) public: - int Rep; - int Count; - char Up; - char Down; + int Count; + int Up, Down; QuoteCls() { - this->New(1); - } - void New(int r) { - Rep = r; Count = 0; Up = '\0'; Down = '\0'; } - void Open(char u) { + void Open(int u) { Count++; Up = u; Down = opposite(Up); } + void Start(int u) { + Count = 0; + Open(u); + } }; QuoteCls Quote; - int state = initStyle; int numBase = 0; - unsigned int lengthDoc = startPos + length; + int digit; + unsigned int endPos = startPos + length; - // If in a long distance lexical state, seek to the beginning to find quote characters - // Bash strings can be multi-line with embedded newlines, so backtrack. - // Bash numbers have additional state during lexing, so backtrack too. - if (state == SCE_SH_HERE_Q) { + // Backtrack to beginning of style if required... + // If in a long distance lexical state, backtrack to find quote characters + if (initStyle == SCE_SH_HERE_Q) { while ((startPos > 1) && (styler.StyleAt(startPos) != SCE_SH_HERE_DELIM)) { startPos--; } startPos = styler.LineStart(styler.GetLine(startPos)); - state = styler.StyleAt(startPos - 1); + initStyle = styler.StyleAt(startPos - 1); } - if (state == SCE_SH_STRING - || state == SCE_SH_BACKTICKS - || state == SCE_SH_CHARACTER - || state == SCE_SH_NUMBER - || state == SCE_SH_IDENTIFIER - || state == SCE_SH_COMMENTLINE - ) { - while ((startPos > 1) && (styler.StyleAt(startPos - 1) == state)) { + // Bash strings can be multi-line with embedded newlines, so backtrack. + // Bash numbers have additional state during lexing, so backtrack too. + if (initStyle == SCE_SH_STRING + || initStyle == SCE_SH_BACKTICKS + || initStyle == SCE_SH_CHARACTER + || initStyle == SCE_SH_NUMBER + || initStyle == SCE_SH_IDENTIFIER + || initStyle == SCE_SH_COMMENTLINE) { + while ((startPos > 1) && (styler.StyleAt(startPos - 1) == initStyle)) { startPos--; } - state = SCE_SH_DEFAULT; + initStyle = SCE_SH_DEFAULT; } - styler.StartAt(startPos); - char chPrev = styler.SafeGetCharAt(startPos - 1); - if (startPos == 0) - chPrev = '\n'; - char chNext = styler[startPos]; - styler.StartSegment(startPos); - - for (unsigned int i = startPos; i < lengthDoc; i++) { - char ch = chNext; - // if the current character is not consumed due to the completion of an - // earlier style, lexing can be restarted via a simple goto - restartLexer: - chNext = styler.SafeGetCharAt(i + 1); - char chNext2 = styler.SafeGetCharAt(i + 2); - - if (styler.IsLeadByte(ch)) { - chNext = styler.SafeGetCharAt(i + 2); - chPrev = ' '; - i += 1; - continue; - } - - if ((chPrev == '\r' && ch == '\n')) { // skip on DOS/Windows - styler.ColourTo(i, state); - chPrev = ch; - continue; - } - - if (HereDoc.State == 1 && isEOLChar(ch)) { - // Begin of here-doc (the line after the here-doc delimiter): - // Lexically, the here-doc starts from the next line after the >>, but the - // first line of here-doc seem to follow the style of the last EOL sequence - HereDoc.State = 2; - if (HereDoc.Quoted) { - if (state == SCE_SH_HERE_DELIM) { - // Missing quote at end of string! We are stricter than bash. - // Colour here-doc anyway while marking this bit as an error. - state = SCE_SH_ERROR; - } - styler.ColourTo(i - 1, state); - // HereDoc.Quote always == '\'' - state = SCE_SH_HERE_Q; - } else { - styler.ColourTo(i - 1, state); - // always switch - state = SCE_SH_HERE_Q; - } - } - - if (state == SCE_SH_DEFAULT) { - if (ch == '\\') { // escaped character - if (i < lengthDoc - 1) - i++; - ch = chNext; - chNext = chNext2; - styler.ColourTo(i, SCE_SH_IDENTIFIER); - } else if (isdigit(ch)) { - state = SCE_SH_NUMBER; - numBase = BASH_BASE_DECIMAL; - if (ch == '0') { // hex,octal - if (chNext == 'x' || chNext == 'X') { - numBase = BASH_BASE_HEX; - i++; - ch = chNext; - chNext = chNext2; - } else if (isdigit(chNext)) { -#ifdef PEDANTIC_OCTAL - numBase = BASH_BASE_OCTAL; -#else - numBase = BASH_BASE_HEX; -#endif + StyleContext sc(startPos, endPos - startPos, initStyle, styler); + + for (; sc.More(); sc.Forward()) { + + // Determine if the current state should terminate. + switch (sc.state) { + case SCE_SH_OPERATOR: + sc.SetState(SCE_SH_DEFAULT); + break; + case SCE_SH_WORD: + // "." never used in Bash variable names but used in file names + if (!setWord.Contains(sc.ch)) { + char s[1000]; + sc.GetCurrent(s, sizeof(s)); + if (s[0] != '-' && // for file operators + !keywords.InList(s)) { + sc.ChangeState(SCE_SH_IDENTIFIER); } + sc.SetState(SCE_SH_DEFAULT); } - } else if (iswordstart(ch)) { - state = SCE_SH_WORD; - if (!iswordchar(chNext) && chNext != '+' && chNext != '-') { - // We need that if length of word == 1! - // This test is copied from the SCE_SH_WORD handler. - classifyWordBash(styler.GetStartSegment(), i, keywords, styler); - state = SCE_SH_DEFAULT; + break; + case SCE_SH_IDENTIFIER: + if (sc.chPrev == '\\') { // for escaped chars + sc.ForwardSetState(SCE_SH_DEFAULT); + } else if (!setWord.Contains(sc.ch)) { + sc.SetState(SCE_SH_DEFAULT); } - } else if (ch == '#') { - state = SCE_SH_COMMENTLINE; - } else if (ch == '\"') { - state = SCE_SH_STRING; - Quote.New(1); - Quote.Open(ch); - } else if (ch == '\'') { - state = SCE_SH_CHARACTER; - Quote.New(1); - Quote.Open(ch); - } else if (ch == '`') { - state = SCE_SH_BACKTICKS; - Quote.New(1); - Quote.Open(ch); - } else if (ch == '$') { - if (chNext == '{') { - state = SCE_SH_PARAM; - goto startQuote; - } else if (chNext == '\'') { - state = SCE_SH_CHARACTER; - goto startQuote; - } else if (chNext == '"') { - state = SCE_SH_STRING; - goto startQuote; - } else if (chNext == '(' && chNext2 == '(') { - styler.ColourTo(i, SCE_SH_OPERATOR); - state = SCE_SH_DEFAULT; - goto skipChar; - } else if (chNext == '(' || chNext == '`') { - state = SCE_SH_BACKTICKS; - startQuote: - Quote.New(1); - Quote.Open(chNext); - goto skipChar; - } else { - state = SCE_SH_SCALAR; - skipChar: - i++; - ch = chNext; - chNext = chNext2; - } - } else if (ch == '*') { - if (chNext == '*') { // exponentiation - i++; - ch = chNext; - chNext = chNext2; - } - styler.ColourTo(i, SCE_SH_OPERATOR); - } else if (ch == '<' && chNext == '<') { - state = SCE_SH_HERE_DELIM; - HereDoc.State = 0; - HereDoc.Indent = false; - } else if (ch == '-' // file test operators - && isSingleCharOp(chNext) - && !isalnum((chNext2 = styler.SafeGetCharAt(i+2))) - && isspace(chPrev)) { - styler.ColourTo(i + 1, SCE_SH_WORD); - state = SCE_SH_DEFAULT; - i++; - ch = chNext; - chNext = chNext2; - } else if (isBashOperator(ch)) { - styler.ColourTo(i, SCE_SH_OPERATOR); - } else { - // keep colouring defaults to make restart easier - styler.ColourTo(i, SCE_SH_DEFAULT); - } - } else if (state == SCE_SH_NUMBER) { - int digit = translateBashDigit(ch); - if (numBase == BASH_BASE_DECIMAL) { - if (ch == '#') { - numBase = getBashNumberBase(styler.GetStartSegment(), i - 1, styler); - if (numBase == BASH_BASE_ERROR) // take the rest as comment - goto numAtEnd; - } else if (!isdigit(ch)) - goto numAtEnd; - } else if (numBase == BASH_BASE_HEX) { - if ((digit < 16) || (digit >= 36 && digit <= 41)) { - // hex digit 0-9a-fA-F - } else - goto numAtEnd; + break; + case SCE_SH_NUMBER: + digit = translateBashDigit(sc.ch); + if (numBase == BASH_BASE_DECIMAL) { + if (sc.ch == '#') { + char s[10]; + sc.GetCurrent(s, sizeof(s)); + numBase = getBashNumberBase(s); + if (numBase != BASH_BASE_ERROR) + break; + } else if (IsADigit(sc.ch)) + break; + } else if (numBase == BASH_BASE_HEX) { + if (IsADigit(sc.ch, 16)) + break; #ifdef PEDANTIC_OCTAL - } else if (numBase == BASH_BASE_OCTAL || - numBase == BASH_BASE_OCTAL_ERROR) { - if (digit > 7) { + } else if (numBase == BASH_BASE_OCTAL || + numBase == BASH_BASE_OCTAL_ERROR) { + if (digit <= 7) + break; if (digit <= 9) { - numBase = BASH_BASE_OCTAL_ERROR; - } else - goto numAtEnd; - } -#endif - } else if (numBase == BASH_BASE_ERROR) { - if (digit > 9) - goto numAtEnd; - } else { // DD#DDDD number style handling - if (digit != BASH_BASE_ERROR) { - if (numBase <= 36) { - // case-insensitive if base<=36 - if (digit >= 36) digit -= 26; + numBase = BASH_BASE_OCTAL_ERROR; + break; } - if (digit >= numBase) { +#endif + } else if (numBase == BASH_BASE_ERROR) { + if (digit <= 9) + break; + } else { // DD#DDDD number style handling + if (digit != BASH_BASE_ERROR) { + if (numBase <= 36) { + // case-insensitive if base<=36 + if (digit >= 36) digit -= 26; + } + if (digit < numBase) + break; if (digit <= 9) { numBase = BASH_BASE_ERROR; - } else - goto numAtEnd; + break; + } } - } else { - numAtEnd: - if (numBase == BASH_BASE_ERROR + } + // fallthrough when number is at an end or error + if (numBase == BASH_BASE_ERROR #ifdef PEDANTIC_OCTAL - || numBase == BASH_BASE_OCTAL_ERROR + || numBase == BASH_BASE_OCTAL_ERROR #endif - ) - state = SCE_SH_ERROR; - styler.ColourTo(i - 1, state); - state = SCE_SH_DEFAULT; - goto restartLexer; + ) { + sc.ChangeState(SCE_SH_ERROR); } - } - } else if (state == SCE_SH_WORD) { - if (!iswordchar(chNext) && chNext != '+' && chNext != '-') { - // "." never used in Bash variable names - // but used in file names - classifyWordBash(styler.GetStartSegment(), i, keywords, styler); - state = SCE_SH_DEFAULT; - ch = ' '; - } - } else if (state == SCE_SH_IDENTIFIER) { - if (!iswordchar(chNext) && chNext != '+' && chNext != '-') { - styler.ColourTo(i, SCE_SH_IDENTIFIER); - state = SCE_SH_DEFAULT; - ch = ' '; - } - } else { - if (state == SCE_SH_COMMENTLINE) { - if (ch == '\\' && isEOLChar(chNext)) { + sc.SetState(SCE_SH_DEFAULT); + break; + case SCE_SH_COMMENTLINE: + if (sc.ch == '\\' && (sc.chNext == '\r' || sc.chNext == '\n')) { // comment continuation - if (chNext == '\r' && chNext2 == '\n') { - i += 2; - ch = styler.SafeGetCharAt(i); - chNext = styler.SafeGetCharAt(i + 1); - } else { - i++; - ch = chNext; - chNext = chNext2; + sc.Forward(); + if (sc.ch == '\r' && sc.chNext == '\n') { + sc.Forward(); } - } else if (isEOLChar(ch)) { - styler.ColourTo(i - 1, state); - state = SCE_SH_DEFAULT; - goto restartLexer; - } else if (isEOLChar(chNext)) { - styler.ColourTo(i, state); - state = SCE_SH_DEFAULT; + } else if (sc.atLineEnd) { + sc.ForwardSetState(SCE_SH_DEFAULT); } - } else if (state == SCE_SH_HERE_DELIM) { - // + break; + case SCE_SH_HERE_DELIM: // From Bash info: // --------------- // Specifier format is: <<[-]WORD @@ -461,150 +266,198 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle, // Whitespace acceptable after <<[-] operator // if (HereDoc.State == 0) { // '<<' encountered - HereDoc.State = 1; - HereDoc.Quote = chNext; + HereDoc.Quote = sc.chNext; HereDoc.Quoted = false; HereDoc.DelimiterLength = 0; HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0'; - if (chNext == '\'' || chNext == '\"') { // a quoted here-doc delimiter (' or ") - i++; - ch = chNext; - chNext = chNext2; + if (sc.chNext == '\'' || sc.chNext == '\"') { // a quoted here-doc delimiter (' or ") + sc.Forward(); HereDoc.Quoted = true; - } else if (!HereDoc.Indent && chNext == '-') { // <<- indent case + HereDoc.State = 1; + } else if (!HereDoc.Indent && sc.chNext == '-') { // <<- indent case HereDoc.Indent = true; - HereDoc.State = 0; - } else if (isalpha(chNext) || chNext == '_' || chNext == '\\' - || chNext == '-' || chNext == '+' || chNext == '!') { + } else if (setHereDoc.Contains(sc.chNext)) { // an unquoted here-doc delimiter, no special handling - // TODO check what exactly bash considers part of the delim - } else if (chNext == '<') { // HERE string <<< - i++; - ch = chNext; - chNext = chNext2; - styler.ColourTo(i, SCE_SH_HERE_DELIM); - state = SCE_SH_DEFAULT; - HereDoc.State = 0; - } else if (isspacechar(chNext)) { + // TODO check what exactly bash considers part of the delim + HereDoc.State = 1; + } else if (sc.chNext == '<') { // HERE string <<< + sc.Forward(); + sc.ForwardSetState(SCE_SH_DEFAULT); + } else if (IsASpace(sc.chNext)) { // eat whitespace - HereDoc.State = 0; - } else if (isdigit(chNext) || chNext == '=' || chNext == '$') { + } else if (setLeftShift.Contains(sc.chNext)) { // left shift << or <<= operator cases - styler.ColourTo(i, SCE_SH_OPERATOR); - state = SCE_SH_DEFAULT; - HereDoc.State = 0; + sc.ChangeState(SCE_SH_OPERATOR); + sc.ForwardSetState(SCE_SH_DEFAULT); } else { // symbols terminates; deprecated zero-length delimiter + HereDoc.State = 1; } } else if (HereDoc.State == 1) { // collect the delimiter if (HereDoc.Quoted) { // a quoted here-doc delimiter - if (ch == HereDoc.Quote) { // closing quote => end of delimiter - styler.ColourTo(i, state); - state = SCE_SH_DEFAULT; + if (sc.ch == HereDoc.Quote) { // closing quote => end of delimiter + sc.ForwardSetState(SCE_SH_DEFAULT); } else { - if (ch == '\\' && chNext == HereDoc.Quote) { // escaped quote - i++; - ch = chNext; - chNext = chNext2; + if (sc.ch == '\\' && sc.chNext == HereDoc.Quote) { // escaped quote + sc.Forward(); } - HereDoc.Delimiter[HereDoc.DelimiterLength++] = ch; - HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0'; + HereDoc.Append(sc.ch); } } else { // an unquoted here-doc delimiter - if (isalnum(ch) || ch == '_' || ch == '-' || ch == '+' || ch == '!') { - HereDoc.Delimiter[HereDoc.DelimiterLength++] = ch; - HereDoc.Delimiter[HereDoc.DelimiterLength] = '\0'; - } else if (ch == '\\') { + if (setHereDoc2.Contains(sc.ch)) { + HereDoc.Append(sc.ch); + } else if (sc.ch == '\\') { // skip escape prefix } else { - styler.ColourTo(i - 1, state); - state = SCE_SH_DEFAULT; - goto restartLexer; + sc.SetState(SCE_SH_DEFAULT); } } - if (HereDoc.DelimiterLength >= HERE_DELIM_MAX - 1) { - styler.ColourTo(i - 1, state); - state = SCE_SH_ERROR; - goto restartLexer; + if (HereDoc.DelimiterLength >= HERE_DELIM_MAX - 1) { // force blowup + sc.SetState(SCE_SH_ERROR); + HereDoc.State = 0; } } - } else if (HereDoc.State == 2) { - // state == SCE_SH_HERE_Q - if (isMatch(styler, lengthDoc, i, HereDoc.Delimiter)) { - if (!HereDoc.Indent && isEOLChar(chPrev)) { - endHereDoc: - // standard HERE delimiter - i += HereDoc.DelimiterLength; - chPrev = styler.SafeGetCharAt(i - 1); - ch = styler.SafeGetCharAt(i); - if (isEOLChar(ch)) { - styler.ColourTo(i - 1, state); - state = SCE_SH_DEFAULT; - HereDoc.State = 0; - goto restartLexer; - } - chNext = styler.SafeGetCharAt(i + 1); - } else if (HereDoc.Indent) { - // indented HERE delimiter - unsigned int bk = (i > 0)? i - 1: 0; - while (i > 0) { - ch = styler.SafeGetCharAt(bk--); - if (isEOLChar(ch)) { - goto endHereDoc; - } else if (!isspacechar(ch)) { - break; // got leading non-whitespace - } + break; + case SCE_SH_HERE_Q: + // HereDoc.State == 2 + if (sc.atLineStart) { + sc.SetState(SCE_SH_HERE_Q); + int prefixws = 0; + while (IsASpace(sc.ch) && !sc.atLineEnd) { // whitespace prefix + sc.Forward(); + prefixws++; + } + if (prefixws > 0) + sc.SetState(SCE_SH_HERE_Q); + while (!sc.atLineEnd) { + sc.Forward(); + } + char s[HERE_DELIM_MAX]; + sc.GetCurrent(s, sizeof(s)); + if (sc.LengthCurrent() == 0) + break; + if (s[strlen(s) - 1] == '\r') + s[strlen(s) - 1] = '\0'; + if (strcmp(HereDoc.Delimiter, s) == 0) { + if ((prefixws > 0 && HereDoc.Indent) || // indentation rule + (prefixws == 0 && !HereDoc.Indent)) { + sc.SetState(SCE_SH_DEFAULT); + break; } } } - } else if (state == SCE_SH_SCALAR) { // variable names - if (isEndVar(ch)) { - if ((state == SCE_SH_SCALAR) - && i == (styler.GetStartSegment() + 1)) { + break; + case SCE_SH_SCALAR: // variable names + if (!setParam.Contains(sc.ch)) { + if (sc.LengthCurrent() == 1) { // Special variable: $(, $_ etc. - styler.ColourTo(i, state); - state = SCE_SH_DEFAULT; + sc.ForwardSetState(SCE_SH_DEFAULT); } else { - styler.ColourTo(i - 1, state); - state = SCE_SH_DEFAULT; - goto restartLexer; + sc.SetState(SCE_SH_DEFAULT); } } - } else if (state == SCE_SH_STRING - || state == SCE_SH_CHARACTER - || state == SCE_SH_BACKTICKS - || state == SCE_SH_PARAM - ) { - if (!Quote.Down && !isspacechar(ch)) { - Quote.Open(ch); - } else if (ch == '\\' && Quote.Up != '\\') { - i++; - ch = chNext; - chNext = styler.SafeGetCharAt(i + 1); - } else if (ch == Quote.Down) { + break; + case SCE_SH_STRING: // delimited styles + case SCE_SH_CHARACTER: + case SCE_SH_BACKTICKS: + case SCE_SH_PARAM: + if (sc.ch == '\\' && Quote.Up != '\\') { + sc.Forward(); + } else if (sc.ch == Quote.Down) { Quote.Count--; if (Quote.Count == 0) { - Quote.Rep--; - if (Quote.Rep <= 0) { - styler.ColourTo(i, state); - state = SCE_SH_DEFAULT; - ch = ' '; - } - if (Quote.Up == Quote.Down) { - Quote.Count++; - } + sc.ForwardSetState(SCE_SH_DEFAULT); } - } else if (ch == Quote.Up) { + } else if (sc.ch == Quote.Up) { Quote.Count++; } + break; + } + + // Must check end of HereDoc state 1 before default state is handled + if (HereDoc.State == 1 && sc.atLineEnd) { + // Begin of here-doc (the line after the here-doc delimiter): + // Lexically, the here-doc starts from the next line after the >>, but the + // first line of here-doc seem to follow the style of the last EOL sequence + HereDoc.State = 2; + if (HereDoc.Quoted) { + if (sc.state == SCE_SH_HERE_DELIM) { + // Missing quote at end of string! We are stricter than bash. + // Colour here-doc anyway while marking this bit as an error. + sc.ChangeState(SCE_SH_ERROR); + } + // HereDoc.Quote always == '\'' } + sc.SetState(SCE_SH_HERE_Q); } - if (state == SCE_SH_ERROR) { - break; + + // Determine if a new state should be entered. + if (sc.state == SCE_SH_DEFAULT) { + if (sc.ch == '\\') { // escaped character + sc.SetState(SCE_SH_IDENTIFIER); + } else if (IsADigit(sc.ch)) { + sc.SetState(SCE_SH_NUMBER); + numBase = BASH_BASE_DECIMAL; + if (sc.ch == '0') { // hex,octal + if (sc.chNext == 'x' || sc.chNext == 'X') { + numBase = BASH_BASE_HEX; + sc.Forward(); + } else if (IsADigit(sc.chNext)) { +#ifdef PEDANTIC_OCTAL + numBase = BASH_BASE_OCTAL; +#else + numBase = BASH_BASE_HEX; +#endif + } + } + } else if (setWordStart.Contains(sc.ch)) { + sc.SetState(SCE_SH_WORD); + } else if (sc.ch == '#') { + sc.SetState(SCE_SH_COMMENTLINE); + } else if (sc.ch == '\"') { + sc.SetState(SCE_SH_STRING); + Quote.Start(sc.ch); + } else if (sc.ch == '\'') { + sc.SetState(SCE_SH_CHARACTER); + Quote.Start(sc.ch); + } else if (sc.ch == '`') { + sc.SetState(SCE_SH_BACKTICKS); + Quote.Start(sc.ch); + } else if (sc.ch == '$') { + sc.SetState(SCE_SH_SCALAR); + sc.Forward(); + if (sc.ch == '{') { + sc.ChangeState(SCE_SH_PARAM); + } else if (sc.ch == '\'') { + sc.ChangeState(SCE_SH_CHARACTER); + } else if (sc.ch == '"') { + sc.ChangeState(SCE_SH_STRING); + } else if (sc.ch == '(' || sc.ch == '`') { + sc.ChangeState(SCE_SH_BACKTICKS); + if (sc.chNext == '(') { // $(( is lexed as operator + sc.ChangeState(SCE_SH_OPERATOR); + } + } else { + continue; // scalar has no delimiter pair + } + // fallthrough, open delim for $[{'"(`] + Quote.Start(sc.ch); + } else if (sc.Match('<', '<')) { + sc.SetState(SCE_SH_HERE_DELIM); + HereDoc.State = 0; + HereDoc.Indent = false; + } else if (sc.ch == '-' && // one-char file test operators + setSingleCharOp.Contains(sc.chNext) && + !setWord.Contains(sc.GetRelative(2)) && + IsASpace(sc.chPrev)) { + sc.SetState(SCE_SH_WORD); + sc.Forward(); + } else if (setBashOperator.Contains(sc.ch)) { + sc.SetState(SCE_SH_OPERATOR); + } } - chPrev = ch; } - styler.ColourTo(lengthDoc - 1, state); + sc.Complete(); } static bool IsCommentLine(int line, Accessor &styler) { @@ -621,7 +474,7 @@ static bool IsCommentLine(int line, Accessor &styler) { } static void FoldBashDoc(unsigned int startPos, int length, int, WordList *[], - Accessor &styler) { + Accessor &styler) { bool foldComment = styler.GetPropertyInt("fold.comment") != 0; bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; unsigned int endPos = startPos + length; @@ -637,16 +490,16 @@ static void FoldBashDoc(unsigned int startPos, int length, int, WordList *[], int style = styleNext; styleNext = styler.StyleAt(i + 1); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); - // Comment folding + // Comment folding if (foldComment && atEOL && IsCommentLine(lineCurrent, styler)) - { - if (!IsCommentLine(lineCurrent - 1, styler) - && IsCommentLine(lineCurrent + 1, styler)) - levelCurrent++; - else if (IsCommentLine(lineCurrent - 1, styler) - && !IsCommentLine(lineCurrent+1, styler)) - levelCurrent--; - } + { + if (!IsCommentLine(lineCurrent - 1, styler) + && IsCommentLine(lineCurrent + 1, styler)) + levelCurrent++; + else if (IsCommentLine(lineCurrent - 1, styler) + && !IsCommentLine(lineCurrent + 1, styler)) + levelCurrent--; + } if (style == SCE_SH_OPERATOR) { if (ch == '{') { levelCurrent++; diff --git a/src/stc/scintilla/src/LexCOBOL.cxx b/src/stc/scintilla/src/LexCOBOL.cxx new file mode 100644 index 0000000000..d061d5c674 --- /dev/null +++ b/src/stc/scintilla/src/LexCOBOL.cxx @@ -0,0 +1,368 @@ +// Scintilla source code edit control +/** @file LexCOBOL.cxx + ** Lexer for COBOL + ** Based on LexPascal.cxx + ** Written by Laurent le Tynevez + ** Updated by Simon Steele September 2002 + ** Updated by Mathias Rauen May 2003 (Delphi adjustments) + ** Updated by Rod Falck, Aug 2006 Converted to COBOL + **/ + +#include +#include +#include +#include +#include + +#include "Platform.h" + +#include "PropSet.h" +#include "Accessor.h" +#include "KeyWords.h" +#include "Scintilla.h" +#include "SciLexer.h" +#include "StyleContext.h" + +#ifdef SCI_NAMESPACE +using namespace Scintilla; +#endif + +#define IN_DIVISION 0x01 +#define IN_DECLARATIVES 0x02 +#define IN_SECTION 0x04 +#define IN_PARAGRAPH 0x08 +#define IN_FLAGS 0xF +#define NOT_HEADER 0x10 + +inline bool isCOBOLoperator(char ch) + { + return isoperator(ch); + } + +inline bool isCOBOLwordchar(char ch) + { + return isascii(ch) && (isalnum(ch) || ch == '-'); + + } + +inline bool isCOBOLwordstart(char ch) + { + return isascii(ch) && isalnum(ch); + } + +static int CountBits(int nBits) + { + int count = 0; + for (int i = 0; i < 32; ++i) + { + count += nBits & 1; + nBits >>= 1; + } + return count; + } + +static void getRange(unsigned int start, + unsigned int end, + Accessor &styler, + char *s, + unsigned int len) { + unsigned int i = 0; + while ((i < end - start + 1) && (i < len-1)) { + s[i] = static_cast(tolower(styler[start + i])); + i++; + } + s[i] = '\0'; +} + +static void ColourTo(Accessor &styler, unsigned int end, unsigned int attr) { + styler.ColourTo(end, attr); +} + + +static int classifyWordCOBOL(unsigned int start, unsigned int end, /*WordList &keywords*/WordList *keywordlists[], Accessor &styler, int nContainment, bool *bAarea) { + int ret = 0; + + WordList& a_keywords = *keywordlists[0]; + WordList& b_keywords = *keywordlists[1]; + WordList& c_keywords = *keywordlists[2]; + + char s[100]; + getRange(start, end, styler, s, sizeof(s)); + + char chAttr = SCE_C_IDENTIFIER; + if (isdigit(s[0]) || (s[0] == '.')) { + chAttr = SCE_C_NUMBER; + char *p = s + 1; + while (*p) { + if (!isdigit(*p) && isCOBOLwordchar(*p)) { + chAttr = SCE_C_IDENTIFIER; + break; + } + ++p; + } + } + else { + if (a_keywords.InList(s)) { + chAttr = SCE_C_WORD; + } + else if (b_keywords.InList(s)) { + chAttr = SCE_C_WORD2; + } + else if (c_keywords.InList(s)) { + chAttr = SCE_C_UUID; + } + } + if (*bAarea) { + if (strcmp(s, "division") == 0) { + ret = IN_DIVISION; + // we've determined the containment, anything else is just ignored for those purposes + *bAarea = false; + } else if (strcmp(s, "declaratives") == 0) { + ret = IN_DIVISION | IN_DECLARATIVES; + if (nContainment & IN_DECLARATIVES) + ret |= NOT_HEADER | IN_SECTION; + // we've determined the containment, anything else is just ignored for those purposes + *bAarea = false; + } else if (strcmp(s, "section") == 0) { + ret = (nContainment &~ IN_PARAGRAPH) | IN_SECTION; + // we've determined the containment, anything else is just ignored for those purposes + *bAarea = false; + } else if (strcmp(s, "end") == 0 && (nContainment & IN_DECLARATIVES)) { + ret = IN_DIVISION | IN_DECLARATIVES | IN_SECTION | NOT_HEADER; + } else { + ret = nContainment | IN_PARAGRAPH; + } + } + ColourTo(styler, end, chAttr); + return ret; +} + +static void ColouriseCOBOLDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], + Accessor &styler) { + + styler.StartAt(startPos); + + int state = initStyle; + if (state == SCE_C_CHARACTER) // Does not leak onto next line + state = SCE_C_DEFAULT; + char chPrev = ' '; + char chNext = styler[startPos]; + unsigned int lengthDoc = startPos + length; + + int nContainment; + + int currentLine = styler.GetLine(startPos); + if (currentLine > 0) { + styler.SetLineState(currentLine, styler.GetLineState(currentLine-1)); + nContainment = styler.GetLineState(currentLine); + nContainment &= ~NOT_HEADER; + } else { + styler.SetLineState(currentLine, 0); + nContainment = 0; + } + + styler.StartSegment(startPos); + bool bNewLine = true; + bool bAarea = !isspacechar(chNext); + int column = 0; + for (unsigned int i = startPos; i < lengthDoc; i++) { + char ch = chNext; + + chNext = styler.SafeGetCharAt(i + 1); + + ++column; + + if (bNewLine) { + column = 0; + } + if (column <= 1 && !bAarea) { + bAarea = !isspacechar(ch); + } + bool bSetNewLine = false; + if ((ch == '\r' && chNext != '\n') || (ch == '\n')) { + // Trigger on CR only (Mac style) or either on LF from CR+LF (Dos/Win) or on LF alone (Unix) + // Avoid triggering two times on Dos/Win + // End of line + if (state == SCE_C_CHARACTER) { + ColourTo(styler, i, state); + state = SCE_C_DEFAULT; + } + styler.SetLineState(currentLine, nContainment); + currentLine++; + bSetNewLine = true; + if (nContainment & NOT_HEADER) + nContainment &= ~(NOT_HEADER | IN_DECLARATIVES | IN_SECTION); + } + + if (styler.IsLeadByte(ch)) { + chNext = styler.SafeGetCharAt(i + 2); + chPrev = ' '; + i += 1; + continue; + } + + if (state == SCE_C_DEFAULT) { + if (isCOBOLwordstart(ch) || (ch == '$' && isalpha(chNext))) { + ColourTo(styler, i-1, state); + state = SCE_C_IDENTIFIER; + } else if (column == 0 && ch == '*' && chNext != '*') { + ColourTo(styler, i-1, state); + state = SCE_C_COMMENTLINE; + } else if (column == 0 && ch == '/' && chNext != '*') { + ColourTo(styler, i-1, state); + state = SCE_C_COMMENTLINE; + } else if (column == 0 && ch == '*' && chNext == '*') { + ColourTo(styler, i-1, state); + state = SCE_C_COMMENTDOC; + } else if (column == 0 && ch == '/' && chNext == '*') { + ColourTo(styler, i-1, state); + state = SCE_C_COMMENTDOC; + } else if (ch == '"') { + ColourTo(styler, i-1, state); + state = SCE_C_STRING; + } else if (ch == '\'') { + ColourTo(styler, i-1, state); + state = SCE_C_CHARACTER; + } else if (ch == '?' && column == 0) { + ColourTo(styler, i-1, state); + state = SCE_C_PREPROCESSOR; + } else if (isCOBOLoperator(ch)) { + ColourTo(styler, i-1, state); + ColourTo(styler, i, SCE_C_OPERATOR); + } + } else if (state == SCE_C_IDENTIFIER) { + if (!isCOBOLwordchar(ch)) { + int lStateChange = classifyWordCOBOL(styler.GetStartSegment(), i - 1, keywordlists, styler, nContainment, &bAarea); + + if(lStateChange != 0) { + styler.SetLineState(currentLine, lStateChange); + nContainment = lStateChange; + } + + state = SCE_C_DEFAULT; + chNext = styler.SafeGetCharAt(i + 1); + if (ch == '"') { + state = SCE_C_STRING; + } else if (ch == '\'') { + state = SCE_C_CHARACTER; + } else if (isCOBOLoperator(ch)) { + ColourTo(styler, i, SCE_C_OPERATOR); + } + } + } else { + if (state == SCE_C_PREPROCESSOR) { + if ((ch == '\r' || ch == '\n') && !(chPrev == '\\' || chPrev == '\r')) { + ColourTo(styler, i-1, state); + state = SCE_C_DEFAULT; + } + } else if (state == SCE_C_COMMENT) { + if (ch == '\r' || ch == '\n') { + ColourTo(styler, i, state); + state = SCE_C_DEFAULT; + } + } else if (state == SCE_C_COMMENTDOC) { + if (ch == '\r' || ch == '\n') { + if (((i > styler.GetStartSegment() + 2) || ( + (initStyle == SCE_C_COMMENTDOC) && + (styler.GetStartSegment() == static_cast(startPos))))) { + ColourTo(styler, i, state); + state = SCE_C_DEFAULT; + } + } + } else if (state == SCE_C_COMMENTLINE) { + if (ch == '\r' || ch == '\n') { + ColourTo(styler, i-1, state); + state = SCE_C_DEFAULT; + } + } else if (state == SCE_C_STRING) { + if (ch == '"') { + ColourTo(styler, i, state); + state = SCE_C_DEFAULT; + } + } else if (state == SCE_C_CHARACTER) { + if (ch == '\'') { + ColourTo(styler, i, state); + state = SCE_C_DEFAULT; + } + } + } + chPrev = ch; + bNewLine = bSetNewLine; + if (bNewLine) + { + bAarea = false; + } + } + ColourTo(styler, lengthDoc - 1, state); +} + +static void FoldCOBOLDoc(unsigned int startPos, int length, int, WordList *[], + Accessor &styler) { + bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; + unsigned int endPos = startPos + length; + int visibleChars = 0; + int lineCurrent = styler.GetLine(startPos); + int levelPrev = lineCurrent > 0 ? styler.LevelAt(lineCurrent - 1) & SC_FOLDLEVELNUMBERMASK : 0xFFF; + char chNext = styler[startPos]; + + bool bNewLine = true; + bool bAarea = !isspacechar(chNext); + int column = 0; + bool bComment = false; + for (unsigned int i = startPos; i < endPos; i++) { + char ch = chNext; + chNext = styler.SafeGetCharAt(i + 1); + ++column; + + if (bNewLine) { + column = 0; + bComment = (ch == '*' || ch == '/' || ch == '?'); + } + if (column <= 1 && !bAarea) { + bAarea = !isspacechar(ch); + } + bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); + if (atEOL) { + int nContainment = styler.GetLineState(lineCurrent); + int lev = CountBits(nContainment & IN_FLAGS) | SC_FOLDLEVELBASE; + if (bAarea && !bComment) + --lev; + if (visibleChars == 0 && foldCompact) + lev |= SC_FOLDLEVELWHITEFLAG; + if ((bAarea) && (visibleChars > 0) && !(nContainment & NOT_HEADER) && !bComment) + lev |= SC_FOLDLEVELHEADERFLAG; + if (lev != styler.LevelAt(lineCurrent)) { + styler.SetLevel(lineCurrent, lev); + } + if ((lev & SC_FOLDLEVELNUMBERMASK) <= (levelPrev & SC_FOLDLEVELNUMBERMASK)) { + // this level is at the same level or less than the previous line + // therefore these is nothing for the previous header to collapse, so remove the header + styler.SetLevel(lineCurrent - 1, levelPrev & ~SC_FOLDLEVELHEADERFLAG); + } + levelPrev = lev; + visibleChars = 0; + bAarea = false; + bNewLine = true; + lineCurrent++; + } else { + bNewLine = false; + } + + + if (!isspacechar(ch)) + visibleChars++; + } + + // Fill in the real level of the next line, keeping the current flags as they will be filled in later + int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; + styler.SetLevel(lineCurrent, levelPrev | flagsNext); +} + +static const char * const COBOLWordListDesc[] = { + "A Keywords", + "B Keywords", + "Extended Keywords", + 0 +}; + +LexerModule lmCOBOL(SCLEX_COBOL, ColouriseCOBOLDoc, "COBOL", FoldCOBOLDoc, COBOLWordListDesc); diff --git a/src/stc/scintilla/src/LexCPP.cxx b/src/stc/scintilla/src/LexCPP.cxx index bf351280fe..9577afbdaf 100644 --- a/src/stc/scintilla/src/LexCPP.cxx +++ b/src/stc/scintilla/src/LexCPP.cxx @@ -58,15 +58,21 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo WordList &keywords3 = *keywordlists[2]; WordList &keywords4 = *keywordlists[3]; + // property styling.within.preprocessor + // For C++ code, determines whether all preprocessor code is styled in the preprocessor style (0, the default) + // or only from the initial # to the end of the command word(1). bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor") != 0; CharacterSet setOKBeforeRE(CharacterSet::setNone, "([{=,:;!%^&*|?~+-"); CharacterSet setCouldBePostOp(CharacterSet::setNone, "+-"); - CharacterSet setDoxygen(CharacterSet::setLower, "$@\\&<>#{}[]"); + CharacterSet setDoxygen(CharacterSet::setAlpha, "$@\\&<>#{}[]"); CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true); CharacterSet setWord(CharacterSet::setAlphaNum, "._", 0x80, true); + + // property lexer.cpp.allow.dollars + // Set to 0 to disallow the '$' character in identifiers with the cpp lexer. if (styler.GetPropertyInt("lexer.cpp.allow.dollars", 1) != 0) { setWordStart.Add('$'); setWord.Add('$'); @@ -77,6 +83,7 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo bool lastWordWasUUID = false; int styleBeforeDCKeyword = SCE_C_DEFAULT; bool continuationLine = false; + bool isIncludePreprocessor = false; if (initStyle == SCE_C_PREPROCESSOR) { // Set continuationLine if last character of previous line is '\' @@ -118,6 +125,7 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo // if different sets of lines lexed. visibleChars = 0; lastWordWasUUID = false; + isIncludePreprocessor = false; } // Handle line continuation generically. @@ -230,6 +238,11 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo case SCE_C_STRING: if (sc.atLineEnd) { sc.ChangeState(SCE_C_STRINGEOL); + } else if (isIncludePreprocessor) { + if (sc.ch == '>') { + sc.ForwardSetState(SCE_C_DEFAULT); + isIncludePreprocessor = false; + } } else if (sc.ch == '\\') { if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { sc.Forward(); @@ -321,6 +334,9 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo sc.SetState(SCE_C_REGEX); // JavaScript's RegEx } else if (sc.ch == '\"') { sc.SetState(SCE_C_STRING); + isIncludePreprocessor = false; // ensure that '>' won't end the string + } else if (isIncludePreprocessor && sc.ch == '<') { + sc.SetState(SCE_C_STRING); } else if (sc.ch == '\'') { sc.SetState(SCE_C_CHARACTER); } else if (sc.ch == '#' && visibleChars == 0) { @@ -332,6 +348,8 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo } while ((sc.ch == ' ' || sc.ch == '\t') && sc.More()); if (sc.atLineEnd) { sc.SetState(SCE_C_DEFAULT); + } else if (sc.Match("include")) { + isIncludePreprocessor = true; } } else if (isoperator(static_cast(sc.ch))) { sc.SetState(SCE_C_OPERATOR); @@ -359,10 +377,24 @@ static bool IsStreamCommentStyle(int style) { // and to make it possible to fiddle the current level for "} else {". static void FoldCppDoc(unsigned int startPos, int length, int initStyle, WordList *[], Accessor &styler) { + + // property fold.comment + // 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. bool foldComment = styler.GetPropertyInt("fold.comment") != 0; + + // property fold.preprocessor + // This option enables folding preprocessor directives when using the C++ lexer. + // Includes C#'s explicit #region and #endregion folding directives. bool foldPreprocessor = styler.GetPropertyInt("fold.preprocessor") != 0; + bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; + + // property fold.at.else + // This option enables C++ folding on a "} else {" line of an if statement. bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) != 0; + unsigned int endPos = startPos + length; int visibleChars = 0; int lineCurrent = styler.GetLine(startPos); @@ -424,7 +456,9 @@ static void FoldCppDoc(unsigned int startPos, int length, int initStyle, levelNext--; } } - if (atEOL) { + if (!IsASpace(ch)) + visibleChars++; + if (atEOL || (i == endPos-1)) { int levelUse = levelCurrent; if (foldAtElse) { levelUse = levelMinCurrent; @@ -440,10 +474,12 @@ static void FoldCppDoc(unsigned int startPos, int length, int initStyle, lineCurrent++; levelCurrent = levelNext; levelMinCurrent = levelCurrent; + if (atEOL && (i == static_cast(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; } - if (!IsASpace(ch)) - visibleChars++; } } diff --git a/src/stc/scintilla/src/LexCSS.cxx b/src/stc/scintilla/src/LexCSS.cxx index f5c112d6f1..3b139cdcdd 100644 --- a/src/stc/scintilla/src/LexCSS.cxx +++ b/src/stc/scintilla/src/LexCSS.cxx @@ -28,11 +28,16 @@ using namespace Scintilla; static inline bool IsAWordChar(const unsigned int ch) { - return (isalnum(ch) || ch == '-' || ch == '_' || ch >= 161); // _ is not in fact correct CSS word-character + /* FIXME: + * The CSS spec allows "ISO 10646 characters U+00A1 and higher" to be treated as word chars. + * Unfortunately, we are only getting string bytes here, and not full unicode characters. We cannot guarantee + * that our byte is between U+0080 - U+00A0 (to return false), so we have to allow all characters U+0080 and higher + */ + return ch >= 0x80 || isalnum(ch) || ch == '-' || ch == '_'; } -inline bool IsCssOperator(const char ch) { - if (!isalnum(ch) && +inline bool IsCssOperator(const int ch) { + if (!((ch < 0x80) && isalnum(ch)) && (ch == '{' || ch == '}' || ch == ':' || ch == ',' || ch == ';' || ch == '.' || ch == '#' || ch == '!' || ch == '@' || /* CSS2 */ @@ -44,15 +49,21 @@ inline bool IsCssOperator(const char ch) { } static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { - WordList &keywords = *keywordlists[0]; + WordList &css1Props = *keywordlists[0]; WordList &pseudoClasses = *keywordlists[1]; - WordList &keywords2 = *keywordlists[2]; + WordList &css2Props = *keywordlists[2]; + WordList &css3Props = *keywordlists[3]; + WordList &pseudoElements = *keywordlists[4]; + WordList &exProps = *keywordlists[5]; + WordList &exPseudoClasses = *keywordlists[6]; + WordList &exPseudoElements = *keywordlists[7]; StyleContext sc(startPos, length, initStyle, styler); int lastState = -1; // before operator int lastStateC = -1; // before comment int op = ' '; // last operator + int opPrev = ' '; // last operator for (; sc.More(); sc.Forward()) { if (sc.state == SCE_CSS_COMMENT && sc.Match('*', '/')) { @@ -64,6 +75,7 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo if ((lastStateC = styler.StyleAt(i-1)) != SCE_CSS_COMMENT) { if (lastStateC == SCE_CSS_OPERATOR) { op = styler.SafeGetCharAt(i-1); + opPrev = styler.SafeGetCharAt(i-2); while (--i) { lastState = styler.StyleAt(i-1); if (lastState != SCE_CSS_OPERATOR && lastState != SCE_CSS_COMMENT) @@ -100,6 +112,7 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo if (op == ' ') { unsigned int i = startPos; op = styler.SafeGetCharAt(i-1); + opPrev = styler.SafeGetCharAt(i-2); while (--i) { lastState = styler.StyleAt(i-1); if (lastState != SCE_CSS_OPERATOR && lastState != SCE_CSS_COMMENT) @@ -111,19 +124,15 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo if (lastState == SCE_CSS_DEFAULT) sc.SetState(SCE_CSS_DIRECTIVE); break; - case '*': - if (lastState == SCE_CSS_DEFAULT) - sc.SetState(SCE_CSS_TAG); - break; case '>': case '+': - if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_PSEUDOCLASS || lastState == SCE_CSS_CLASS - || lastState == SCE_CSS_ID || lastState == SCE_CSS_UNKNOWN_PSEUDOCLASS) + if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_CLASS || lastState == SCE_CSS_ID || + lastState == SCE_CSS_PSEUDOCLASS || lastState == SCE_CSS_EXTENDED_PSEUDOCLASS || lastState == SCE_CSS_UNKNOWN_PSEUDOCLASS) sc.SetState(SCE_CSS_DEFAULT); break; case '[': - if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_PSEUDOCLASS || lastState == SCE_CSS_DEFAULT || - lastState == SCE_CSS_CLASS || lastState == SCE_CSS_ID || lastState == SCE_CSS_UNKNOWN_PSEUDOCLASS) + if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_DEFAULT || lastState == SCE_CSS_CLASS || lastState == SCE_CSS_ID || + lastState == SCE_CSS_PSEUDOCLASS || lastState == SCE_CSS_EXTENDED_PSEUDOCLASS || lastState == SCE_CSS_UNKNOWN_PSEUDOCLASS) sc.SetState(SCE_CSS_ATTRIBUTE); break; case ']': @@ -138,27 +147,44 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo break; case '}': if (lastState == SCE_CSS_DEFAULT || lastState == SCE_CSS_VALUE || lastState == SCE_CSS_IMPORTANT || - lastState == SCE_CSS_IDENTIFIER || lastState == SCE_CSS_IDENTIFIER2) + lastState == SCE_CSS_IDENTIFIER || lastState == SCE_CSS_IDENTIFIER2 || lastState == SCE_CSS_IDENTIFIER3) sc.SetState(SCE_CSS_DEFAULT); break; + case '(': + if (lastState == SCE_CSS_PSEUDOCLASS) + sc.SetState(SCE_CSS_TAG); + else if (lastState == SCE_CSS_EXTENDED_PSEUDOCLASS) + sc.SetState(SCE_CSS_EXTENDED_PSEUDOCLASS); + break; + case ')': + if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_DEFAULT || lastState == SCE_CSS_CLASS || lastState == SCE_CSS_ID || + lastState == SCE_CSS_PSEUDOCLASS || lastState == SCE_CSS_EXTENDED_PSEUDOCLASS || lastState == SCE_CSS_UNKNOWN_PSEUDOCLASS || + lastState == SCE_CSS_PSEUDOELEMENT || lastState == SCE_CSS_EXTENDED_PSEUDOELEMENT) + sc.SetState(SCE_CSS_TAG); + break; case ':': - if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_PSEUDOCLASS || lastState == SCE_CSS_DEFAULT || - lastState == SCE_CSS_CLASS || lastState == SCE_CSS_ID || lastState == SCE_CSS_UNKNOWN_PSEUDOCLASS) + if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_DEFAULT || lastState == SCE_CSS_CLASS || lastState == SCE_CSS_ID || + lastState == SCE_CSS_PSEUDOCLASS || lastState == SCE_CSS_EXTENDED_PSEUDOCLASS || lastState == SCE_CSS_UNKNOWN_PSEUDOCLASS || + lastState == SCE_CSS_PSEUDOELEMENT || lastState == SCE_CSS_EXTENDED_PSEUDOELEMENT) sc.SetState(SCE_CSS_PSEUDOCLASS); - else if (lastState == SCE_CSS_IDENTIFIER || lastState == SCE_CSS_IDENTIFIER2 || lastState == SCE_CSS_UNKNOWN_IDENTIFIER) + else if (lastState == SCE_CSS_IDENTIFIER || lastState == SCE_CSS_IDENTIFIER2 || + lastState == SCE_CSS_IDENTIFIER3 || lastState == SCE_CSS_EXTENDED_IDENTIFIER || + lastState == SCE_CSS_UNKNOWN_IDENTIFIER) sc.SetState(SCE_CSS_VALUE); break; case '.': - if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_PSEUDOCLASS || lastState == SCE_CSS_DEFAULT || - lastState == SCE_CSS_CLASS || lastState == SCE_CSS_ID || lastState == SCE_CSS_UNKNOWN_PSEUDOCLASS) + if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_DEFAULT || lastState == SCE_CSS_CLASS || lastState == SCE_CSS_ID || + lastState == SCE_CSS_PSEUDOCLASS || lastState == SCE_CSS_EXTENDED_PSEUDOCLASS || lastState == SCE_CSS_UNKNOWN_PSEUDOCLASS) sc.SetState(SCE_CSS_CLASS); break; case '#': - if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_PSEUDOCLASS || lastState == SCE_CSS_DEFAULT || - lastState == SCE_CSS_CLASS || lastState == SCE_CSS_ID || lastState == SCE_CSS_UNKNOWN_PSEUDOCLASS) + if (lastState == SCE_CSS_TAG || lastState == SCE_CSS_DEFAULT || lastState == SCE_CSS_CLASS || lastState == SCE_CSS_ID || + lastState == SCE_CSS_PSEUDOCLASS || lastState == SCE_CSS_EXTENDED_PSEUDOCLASS || lastState == SCE_CSS_UNKNOWN_PSEUDOCLASS) sc.SetState(SCE_CSS_ID); break; case ',': + case '|': + case '~': if (lastState == SCE_CSS_TAG) sc.SetState(SCE_CSS_DEFAULT); break; @@ -181,11 +207,19 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo continue; } + if (sc.ch == '*' && sc.state == SCE_CSS_DEFAULT) { + sc.SetState(SCE_CSS_TAG); + continue; + } + if (IsAWordChar(sc.chPrev) && ( - sc.state == SCE_CSS_IDENTIFIER || sc.state == SCE_CSS_IDENTIFIER2 - || sc.state == SCE_CSS_UNKNOWN_IDENTIFIER - || sc.state == SCE_CSS_PSEUDOCLASS || sc.state == SCE_CSS_UNKNOWN_PSEUDOCLASS - || sc.state == SCE_CSS_IMPORTANT + sc.state == SCE_CSS_IDENTIFIER || sc.state == SCE_CSS_IDENTIFIER2 || + sc.state == SCE_CSS_IDENTIFIER3 || sc.state == SCE_CSS_EXTENDED_IDENTIFIER || + sc.state == SCE_CSS_UNKNOWN_IDENTIFIER || + sc.state == SCE_CSS_PSEUDOCLASS || sc.state == SCE_CSS_PSEUDOELEMENT || + sc.state == SCE_CSS_EXTENDED_PSEUDOCLASS || sc.state == SCE_CSS_EXTENDED_PSEUDOELEMENT || + sc.state == SCE_CSS_UNKNOWN_PSEUDOCLASS || + sc.state == SCE_CSS_IMPORTANT )) { char s[100]; sc.GetCurrentLowered(s, sizeof(s)); @@ -194,27 +228,36 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo s2++; switch (sc.state) { case SCE_CSS_IDENTIFIER: - if (!keywords.InList(s2)) { - if (keywords2.InList(s2)) { - sc.ChangeState(SCE_CSS_IDENTIFIER2); - } else { - sc.ChangeState(SCE_CSS_UNKNOWN_IDENTIFIER); - } - } - break; + case SCE_CSS_IDENTIFIER2: + case SCE_CSS_IDENTIFIER3: + case SCE_CSS_EXTENDED_IDENTIFIER: case SCE_CSS_UNKNOWN_IDENTIFIER: - if (keywords.InList(s2)) + if (css1Props.InList(s2)) sc.ChangeState(SCE_CSS_IDENTIFIER); - else if (keywords2.InList(s2)) + else if (css2Props.InList(s2)) sc.ChangeState(SCE_CSS_IDENTIFIER2); + else if (css3Props.InList(s2)) + sc.ChangeState(SCE_CSS_IDENTIFIER3); + else if (exProps.InList(s2)) + sc.ChangeState(SCE_CSS_EXTENDED_IDENTIFIER); + else + sc.ChangeState(SCE_CSS_UNKNOWN_IDENTIFIER); break; case SCE_CSS_PSEUDOCLASS: - if (!pseudoClasses.InList(s2)) - sc.ChangeState(SCE_CSS_UNKNOWN_PSEUDOCLASS); - break; + case SCE_CSS_PSEUDOELEMENT: + case SCE_CSS_EXTENDED_PSEUDOCLASS: + case SCE_CSS_EXTENDED_PSEUDOELEMENT: case SCE_CSS_UNKNOWN_PSEUDOCLASS: - if (pseudoClasses.InList(s2)) + if (op == ':' && opPrev != ':' && pseudoClasses.InList(s2)) sc.ChangeState(SCE_CSS_PSEUDOCLASS); + else if (opPrev == ':' && pseudoElements.InList(s2)) + sc.ChangeState(SCE_CSS_PSEUDOELEMENT); + else if ((op == ':' || (op == '(' && lastState == SCE_CSS_EXTENDED_PSEUDOCLASS)) && opPrev != ':' && exPseudoClasses.InList(s2)) + sc.ChangeState(SCE_CSS_EXTENDED_PSEUDOCLASS); + else if (opPrev == ':' && exPseudoElements.InList(s2)) + sc.ChangeState(SCE_CSS_EXTENDED_PSEUDOELEMENT); + else + sc.ChangeState(SCE_CSS_UNKNOWN_PSEUDOCLASS); break; case SCE_CSS_IMPORTANT: if (strcmp(s2, "important") != 0) @@ -223,7 +266,14 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo } } - if (sc.ch != '.' && sc.ch != ':' && sc.ch != '#' && (sc.state == SCE_CSS_CLASS || sc.state == SCE_CSS_PSEUDOCLASS || sc.state == SCE_CSS_UNKNOWN_PSEUDOCLASS || sc.state == SCE_CSS_ID)) + if (sc.ch != '.' && sc.ch != ':' && sc.ch != '#' && ( + sc.state == SCE_CSS_CLASS || sc.state == SCE_CSS_ID || + (sc.ch != '(' && sc.ch != ')' && ( /* This line of the condition makes it possible to extend pseudo-classes with parentheses */ + sc.state == SCE_CSS_PSEUDOCLASS || sc.state == SCE_CSS_PSEUDOELEMENT || + sc.state == SCE_CSS_EXTENDED_PSEUDOCLASS || sc.state == SCE_CSS_EXTENDED_PSEUDOELEMENT || + sc.state == SCE_CSS_UNKNOWN_PSEUDOCLASS + )) + )) sc.SetState(SCE_CSS_TAG); if (sc.Match('/', '*')) { @@ -232,7 +282,7 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo sc.Forward(); } else if (sc.state == SCE_CSS_VALUE && (sc.ch == '\"' || sc.ch == '\'')) { sc.SetState((sc.ch == '\"' ? SCE_CSS_DOUBLESTRING : SCE_CSS_SINGLESTRING)); - } else if (IsCssOperator(static_cast(sc.ch)) + } else if (IsCssOperator(sc.ch) && (sc.state != SCE_CSS_ATTRIBUTE || sc.ch == ']') && (sc.state != SCE_CSS_VALUE || sc.ch == ';' || sc.ch == '}' || sc.ch == '!') && (sc.state != SCE_CSS_DIRECTIVE || sc.ch == ';' || sc.ch == '{') @@ -241,6 +291,7 @@ static void ColouriseCssDoc(unsigned int startPos, int length, int initStyle, Wo lastState = sc.state; sc.SetState(SCE_CSS_OPERATOR); op = sc.ch; + opPrev = sc.chPrev; } } @@ -298,9 +349,14 @@ static void FoldCSSDoc(unsigned int startPos, int length, int, WordList *[], Acc } static const char * const cssWordListDesc[] = { - "CSS1 Keywords", - "Pseudo classes", - "CSS2 Keywords", + "CSS1 Properties", + "Pseudo-classes", + "CSS2 Properties", + "CSS3 Properties", + "Pseudo-elements", + "Browser-Specific CSS Properties", + "Browser-Specific Pseudo-classes", + "Browser-Specific Pseudo-elements", 0 }; diff --git a/src/stc/scintilla/src/LexCaml.cxx b/src/stc/scintilla/src/LexCaml.cxx index 539eee0de7..0d11622593 100644 --- a/src/stc/scintilla/src/LexCaml.cxx +++ b/src/stc/scintilla/src/LexCaml.cxx @@ -2,7 +2,7 @@ /** @file LexCaml.cxx ** Lexer for Objective Caml. **/ -// Copyright 2005 by Robert Roessler +// Copyright 2005-2009 by Robert Roessler // The License.txt file describes the conditions under which this software may be distributed. /* Release History 20050204 Initial release. @@ -15,6 +15,7 @@ 20051125 Added 2nd "optional" keywords class. 20051129 Support "magic" (read-only) comments for RCaml. 20051204 Swtich to using StyleContext infrastructure. + 20090629 Add full Standard ML '97 support. */ #include @@ -26,6 +27,7 @@ #include "Platform.h" #include "PropSet.h" +#include "PropSetSimple.h" #include "Accessor.h" #include "StyleContext.h" #include "KeyWords.h" @@ -35,7 +37,6 @@ // Since the Microsoft __iscsym[f] funcs are not ANSI... inline int iscaml(int c) {return isalnum(c) || c == '_';} inline int iscamlf(int c) {return isalpha(c) || c == '_';} -inline int iscamld(int c) {return isdigit(c) || c == '_';} static const int baseT[24] = { 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* A - L */ @@ -143,7 +144,7 @@ static void InternalLexOrFold(int foldOrLex, unsigned int startPos, int length, int initStyle, char *words[], WindowID window, char *props) { // create and initialize a WindowAccessor (including contained PropSet) - PropSet ps; + PropSetSimple ps; ps.SetMultiple(props); WindowAccessor wa(window, ps); // create and initialize WordList(s) @@ -179,25 +180,27 @@ void ColouriseCamlDoc( { // initialize styler StyleContext sc(startPos, length, initStyle, styler); - // set up [initial] state info (terminating states that shouldn't "bleed") - int nesting = 0; - if (sc.state < SCE_CAML_STRING) - sc.state = SCE_CAML_DEFAULT; - if (sc.state >= SCE_CAML_COMMENT) - nesting = (sc.state & 0x0f) - SCE_CAML_COMMENT; int chBase = 0, chToken = 0, chLit = 0; WordList& keywords = *keywordlists[0]; WordList& keywords2 = *keywordlists[1]; WordList& keywords3 = *keywordlists[2]; + const bool isSML = keywords.InList("andalso"); const int useMagic = styler.GetPropertyInt("lexer.caml.magic", 0); + // set up [initial] state info (terminating states that shouldn't "bleed") + const int state_ = sc.state & 0x0f; + if (state_ <= SCE_CAML_CHAR + || (isSML && state_ == SCE_CAML_STRING)) + sc.state = SCE_CAML_DEFAULT; + int nesting = (state_ >= SCE_CAML_COMMENT)? (state_ - SCE_CAML_COMMENT): 0; + // foreach char in range... while (sc.More()) { // set up [per-char] state info - int state2 = -1; // (ASSUME no state change) + int state2 = -1; // (ASSUME no state change) int chColor = sc.currentPos - 1;// (ASSUME standard coloring range) - bool advance = true; // (ASSUME scanner "eats" 1 char) + bool advance = true; // (ASSUME scanner "eats" 1 char) // step state machine switch (sc.state & 0x0f) { @@ -206,25 +209,38 @@ void ColouriseCamlDoc( // it's wide open; what do we have? if (iscamlf(sc.ch)) state2 = SCE_CAML_IDENTIFIER; - else if (sc.Match('`') && iscamlf(sc.chNext)) + else if (!isSML && sc.Match('`') && iscamlf(sc.chNext)) state2 = SCE_CAML_TAGNAME; - else if (sc.Match('#') && isdigit(sc.chNext)) + else if (!isSML && sc.Match('#') && isdigit(sc.chNext)) state2 = SCE_CAML_LINENUM; else if (isdigit(sc.ch)) { + // it's a number, assume base 10 state2 = SCE_CAML_NUMBER, chBase = 10; - if (sc.Match('0') && strchr("bBoOxX", sc.chNext)) - chBase = baseT[tolower(sc.chNext) - 'a'], sc.Forward(); - } else if (sc.Match('\'')) /* (char literal?) */ + if (sc.Match('0')) { + // there MAY be a base specified... + const char* baseC = "bBoOxX"; + if (isSML) { + if (sc.chNext == 'w') + sc.Forward(); // (consume SML "word" indicator) + baseC = "x"; + } + // ... change to specified base AS REQUIRED + if (strchr(baseC, sc.chNext)) + chBase = baseT[tolower(sc.chNext) - 'a'], sc.Forward(); + } + } else if (!isSML && sc.Match('\'')) // (Caml char literal?) state2 = SCE_CAML_CHAR, chLit = 0; - else if (sc.Match('\"')) + else if (isSML && sc.Match('#', '"')) // (SML char literal?) + state2 = SCE_CAML_CHAR, sc.Forward(); + else if (sc.Match('"')) state2 = SCE_CAML_STRING; else if (sc.Match('(', '*')) - state2 = SCE_CAML_COMMENT, - sc.ch = ' ', // (make SURE "(*)" isn't seen as a closed comment) - sc.Forward(); - else if (strchr("!?~" /* Caml "prefix-symbol" */ - "=<>@^|&+-*/$%" /* Caml "infix-symbol" */ - "()[]{};,:.#", sc.ch)) /* Caml "bracket" or ;,:.# */ + state2 = SCE_CAML_COMMENT, sc.Forward(), sc.ch = ' '; // (*)... + else if (strchr("!?~" /* Caml "prefix-symbol" */ + "=<>@^|&+-*/$%" /* Caml "infix-symbol" */ + "()[]{};,:.#", sc.ch) // Caml "bracket" or ;,:.# + // SML "extra" ident chars + || (isSML && (sc.Match('\\') || sc.Match('`')))) state2 = SCE_CAML_OPERATOR; break; @@ -273,9 +289,12 @@ void ColouriseCamlDoc( case SCE_CAML_OPERATOR: { // [try to] interpret as [additional] operator char const char* o = 0; - if (iscaml(sc.ch) || isspace(sc.ch) /* ident or whitespace */ - || (o = strchr(")]};,\'\"`#", sc.ch),o)/* "termination" chars */ - || !strchr("!$%&*+-./:<=>?@^|~", sc.ch)/* "operator" chars */) { + if (iscaml(sc.ch) || isspace(sc.ch) // ident or whitespace + || (o = strchr(")]};,\'\"#", sc.ch),o) // "termination" chars + || (!isSML && sc.Match('`')) // Caml extra term char + || (!strchr("!$%&*+-./:<=>?@^|~", sc.ch)// "operator" chars + // SML extra ident chars + && !(isSML && (sc.Match('\\') || sc.Match('`'))))) { // check for INCLUSIVE termination if (o && strchr(")]};,", sc.ch)) { if ((sc.Match(')') && sc.chPrev == '(') @@ -292,24 +311,27 @@ void ColouriseCamlDoc( case SCE_CAML_NUMBER: // [try to] interpret as [additional] numeric literal char - // N.B. - improperly accepts "extra" digits in base 2 or 8 literals - if (iscamld(sc.ch) || IsADigit(sc.ch, chBase)) + if ((!isSML && sc.Match('_')) || IsADigit(sc.ch, chBase)) break; // how about an integer suffix? - if ((sc.Match('l') || sc.Match('L') || sc.Match('n')) - && (iscamld(sc.chPrev) || IsADigit(sc.chPrev, chBase))) + if (!isSML && (sc.Match('l') || sc.Match('L') || sc.Match('n')) + && (sc.chPrev == '_' || IsADigit(sc.chPrev, chBase))) break; // or a floating-point literal? if (chBase == 10) { // with a decimal point? - if (sc.Match('.') && iscamld(sc.chPrev)) + if (sc.Match('.') + && ((!isSML && sc.chPrev == '_') + || IsADigit(sc.chPrev, chBase))) break; // with an exponent? (I) if ((sc.Match('e') || sc.Match('E')) - && (iscamld(sc.chPrev) || sc.chPrev == '.')) + && ((!isSML && (sc.chPrev == '.' || sc.chPrev == '_')) + || IsADigit(sc.chPrev, chBase))) break; // with an exponent? (II) - if ((sc.Match('+') || sc.Match('-')) + if (((!isSML && (sc.Match('+') || sc.Match('-'))) + || (isSML && sc.Match('~'))) && (sc.chPrev == 'e' || sc.chPrev == 'E')) break; } @@ -318,29 +340,56 @@ void ColouriseCamlDoc( break; case SCE_CAML_CHAR: - // [try to] interpret as [additional] char literal char - if (sc.Match('\\')) { - chLit = 1; // (definitely IS a char literal) - if (sc.chPrev == '\\') - sc.ch = ' '; // (so termination test isn't fooled) + if (!isSML) { + // [try to] interpret as [additional] char literal char + if (sc.Match('\\')) { + chLit = 1; // (definitely IS a char literal) + if (sc.chPrev == '\\') + sc.ch = ' '; // (...\\') + // should we be terminating - one way or another? + } else if ((sc.Match('\'') && sc.chPrev != '\\') + || sc.atLineEnd) { + state2 = SCE_CAML_DEFAULT; + if (sc.Match('\'')) + chColor++; + else + sc.ChangeState(SCE_CAML_IDENTIFIER); + // ... maybe a char literal, maybe not + } else if (chLit < 1 && sc.currentPos - chToken >= 2) + sc.ChangeState(SCE_CAML_IDENTIFIER), advance = false; + break; + }/* else + // fall through for SML char literal (handle like string) */ + + case SCE_CAML_STRING: + // [try to] interpret as [additional] [SML char/] string literal char + if (isSML && sc.Match('\\') && sc.chPrev != '\\' && isspace(sc.chNext)) + state2 = SCE_CAML_WHITE; + else if (sc.Match('\\') && sc.chPrev == '\\') + sc.ch = ' '; // (...\\") // should we be terminating - one way or another? - } else if ((sc.Match('\'') && sc.chPrev != '\\') || sc.atLineEnd) { + else if ((sc.Match('"') && sc.chPrev != '\\') + || (isSML && sc.atLineEnd)) { state2 = SCE_CAML_DEFAULT; - if (sc.Match('\'')) + if (sc.Match('"')) chColor++; - else - sc.ChangeState(SCE_CAML_IDENTIFIER); - // ... maybe a char literal, maybe not - } else if (chLit < 1 && sc.currentPos - chToken >= 2) - sc.ChangeState(SCE_CAML_IDENTIFIER), advance = false; + } break; - case SCE_CAML_STRING: - // [try to] interpret as [additional] string literal char - if (sc.Match('\\') && sc.chPrev == '\\') - sc.ch = ' '; // (so '\\' doesn't cause us trouble) - else if (sc.Match('\"') && sc.chPrev != '\\') - state2 = SCE_CAML_DEFAULT, chColor++; + case SCE_CAML_WHITE: + // [try to] interpret as [additional] SML embedded whitespace char + if (sc.Match('\\')) { + // style this puppy NOW... + state2 = SCE_CAML_STRING, sc.ch = ' ' /* (...\") */, chColor++, + styler.ColourTo(chColor, SCE_CAML_WHITE), styler.Flush(); + // ... then backtrack to determine original SML literal type + int p = chColor - 2; + for (; p >= 0 && styler.StyleAt(p) == SCE_CAML_WHITE; p--) ; + if (p >= 0) + state2 = static_cast(styler.StyleAt(p)); + // take care of state change NOW + sc.ChangeState(state2), state2 = -1; + } break; case SCE_CAML_COMMENT: @@ -350,8 +399,7 @@ void ColouriseCamlDoc( // we're IN a comment - does this start a NESTED comment? if (sc.Match('(', '*')) state2 = sc.state + 1, chToken = sc.currentPos, - sc.ch = ' ', // (make SURE "(*)" isn't seen as a closed comment) - sc.Forward(), nesting++; + sc.Forward(), sc.ch = ' ' /* (*)... */, nesting++; // [try to] interpret as [additional] comment char else if (sc.Match(')') && sc.chPrev == '*') { if (nesting) @@ -366,7 +414,7 @@ void ColouriseCamlDoc( break; } - // handle state change and char coloring as required + // handle state change and char coloring AS REQUIRED if (state2 >= 0) styler.ColourTo(chColor, sc.state), sc.ChangeState(state2); // move to next char UNLESS re-scanning current char diff --git a/src/stc/scintilla/src/LexCmake.cxx b/src/stc/scintilla/src/LexCmake.cxx index f63eb399f7..1f51f474e8 100644 --- a/src/stc/scintilla/src/LexCmake.cxx +++ b/src/stc/scintilla/src/LexCmake.cxx @@ -13,6 +13,7 @@ #include "Platform.h" +#include "CharClassify.h" #include "PropSet.h" #include "Accessor.h" #include "KeyWords.h" diff --git a/src/stc/scintilla/src/LexD.cxx b/src/stc/scintilla/src/LexD.cxx index 95be129d59..4c4bcb343e 100644 --- a/src/stc/scintilla/src/LexD.cxx +++ b/src/stc/scintilla/src/LexD.cxx @@ -25,20 +25,20 @@ using namespace Scintilla; #endif -/*/ Nested comments require keeping the value of the nesting level for every - position in the document. But since scintilla always styles line by line, - we only need to store one value per line. The non-negative number indicates - nesting level at the end of the line. -/*/ +/* Nested comments require keeping the value of the nesting level for every + position in the document. But since scintilla always styles line by line, + we only need to store one value per line. The non-negative number indicates + nesting level at the end of the line. +*/ -// We use custom qualifiers since it is not clear what D allows. +// Underscore, letter, digit and universal alphas from C99 Appendix D. static bool IsWordStart(int ch) { - return isascii(ch) && (isalpha(ch) || ch == '_'); + return (isascii(ch) && (isalpha(ch) || ch == '_')) || !isascii(ch); } static bool IsWord(int ch) { - return isascii(ch) && (isalnum(ch) || ch == '_'); + return (isascii(ch) && (isalnum(ch) || ch == '_')) || !isascii(ch); } static bool IsDoxygen(int ch) { @@ -51,308 +51,349 @@ static bool IsDoxygen(int ch) { return false; } +static bool IsStringSuffix(int ch) { + return ch == 'c' || ch == 'w' || ch == 'd'; +} -static void ColouriseDoc(unsigned int startPos, int length, int initStyle, - WordList *keywordlists[], Accessor &styler, bool caseSensitive) { - WordList &keywords = *keywordlists[0]; - WordList &keywords2 = *keywordlists[1]; - WordList &keywords3 = *keywordlists[2]; - WordList &keywords4 = *keywordlists[3]; +static void ColouriseDoc(unsigned int startPos, int length, int initStyle, + WordList *keywordlists[], Accessor &styler, bool caseSensitive) { - int styleBeforeDCKeyword = SCE_D_DEFAULT; + 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]; - StyleContext sc(startPos, length, initStyle, styler); + int styleBeforeDCKeyword = SCE_D_DEFAULT; - int curLine = styler.GetLine(startPos); - int curNcLevel = curLine > 0? styler.GetLineState(curLine-1): 0; + StyleContext sc(startPos, length, initStyle, styler); - for (; sc.More(); sc.Forward()) { + int curLine = styler.GetLine(startPos); + int curNcLevel = curLine > 0? styler.GetLineState(curLine-1): 0; + bool numFloat = false; // Float literals have '+' and '-' signs + bool numHex = false; - if (sc.atLineStart) { - if (sc.state == SCE_D_STRING) { - // Prevent SCE_D_STRINGEOL from leaking back to previous line which - // ends with a line continuation by locking in the state upto this position. - sc.SetState(SCE_D_STRING); - } - curLine = styler.GetLine(sc.currentPos); - styler.SetLineState(curLine, curNcLevel); - } + for (; sc.More(); sc.Forward()) { - // Handle line continuation generically. - if (sc.ch == '\\') { - if (sc.chNext == '\n' || sc.chNext == '\r') { - sc.Forward(); - if (sc.ch == '\r' && sc.chNext == '\n') { - sc.Forward(); - } - continue; - } - } + if (sc.atLineStart) { + curLine = styler.GetLine(sc.currentPos); + styler.SetLineState(curLine, curNcLevel); + } - // Determine if the current state should terminate. - switch (sc.state) { - case SCE_D_OPERATOR: - sc.SetState(SCE_D_DEFAULT); - break; - case SCE_D_NUMBER: - // We accept almost anything because of hex. and number suffixes - if (!IsWord(sc.ch) && sc.ch != '.') { - sc.SetState(SCE_D_DEFAULT); - } - break; - case SCE_D_IDENTIFIER: - if (!IsWord(sc.ch)) { - char s[1000]; - if (caseSensitive) { - sc.GetCurrent(s, sizeof(s)); - } else { - sc.GetCurrentLowered(s, sizeof(s)); - } - if (keywords.InList(s)) { - sc.ChangeState(SCE_D_WORD); - } else if (keywords2.InList(s)) { - sc.ChangeState(SCE_D_WORD2); - } else if (keywords4.InList(s)) { - sc.ChangeState(SCE_D_TYPEDEF); - } - sc.SetState(SCE_D_DEFAULT); - } - break; - case SCE_D_COMMENT: - if (sc.Match('*', '/')) { - sc.Forward(); - sc.ForwardSetState(SCE_D_DEFAULT); - } - break; - case SCE_D_COMMENTDOC: - if (sc.Match('*', '/')) { - sc.Forward(); - sc.ForwardSetState(SCE_D_DEFAULT); - } else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support - // Verify that we have the conditions to mark a comment-doc-keyword - if ((IsASpace(sc.chPrev) || sc.chPrev == '*') && (!IsASpace(sc.chNext))) { - styleBeforeDCKeyword = SCE_D_COMMENTDOC; - sc.SetState(SCE_D_COMMENTDOCKEYWORD); - } - } - break; - case SCE_D_COMMENTLINE: - if (sc.atLineStart) { - sc.SetState(SCE_D_DEFAULT); - } - break; - case SCE_D_COMMENTLINEDOC: - if (sc.atLineStart) { - sc.SetState(SCE_D_DEFAULT); - } else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support - // Verify that we have the conditions to mark a comment-doc-keyword - if ((IsASpace(sc.chPrev) || sc.chPrev == '/' || sc.chPrev == '!') && (!IsASpace(sc.chNext))) { - styleBeforeDCKeyword = SCE_D_COMMENTLINEDOC; - sc.SetState(SCE_D_COMMENTDOCKEYWORD); - } - } - break; - case SCE_D_COMMENTDOCKEYWORD: - if ((styleBeforeDCKeyword == SCE_D_COMMENTDOC) && sc.Match('*', '/')) { - sc.ChangeState(SCE_D_COMMENTDOCKEYWORDERROR); - sc.Forward(); - sc.ForwardSetState(SCE_D_DEFAULT); - } else if (!IsDoxygen(sc.ch)) { - char s[100]; - if (caseSensitive) { - sc.GetCurrent(s, sizeof(s)); - } else { - sc.GetCurrentLowered(s, sizeof(s)); - } - if (!IsASpace(sc.ch) || !keywords3.InList(s + 1)) { - sc.ChangeState(SCE_D_COMMENTDOCKEYWORDERROR); - } - sc.SetState(styleBeforeDCKeyword); - } - break; - case SCE_D_COMMENTNESTED: - if (sc.Match('+', '/')) { - if (curNcLevel > 0) - curNcLevel -= 1; - curLine = styler.GetLine(sc.currentPos); - styler.SetLineState(curLine, curNcLevel); - sc.Forward(); - if (curNcLevel == 0) { - sc.ForwardSetState(SCE_D_DEFAULT); - } - } - else if (sc.Match('/','+')) { - curNcLevel += 1; - curLine = styler.GetLine(sc.currentPos); - styler.SetLineState(curLine, curNcLevel); - sc.Forward(); - } - break; - case SCE_D_STRING: - if (sc.atLineEnd) { - sc.ChangeState(SCE_D_STRINGEOL); - } else if (sc.ch == '\\') { - if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { - sc.Forward(); - } - } else if (sc.ch == '\"') { - sc.ForwardSetState(SCE_D_DEFAULT); - } - break; - case SCE_D_CHARACTER: - if (sc.atLineEnd) { - sc.ChangeState(SCE_D_STRINGEOL); - } else if (sc.ch == '\\') { - if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') { - sc.Forward(); - } - } else if (sc.ch == '\'') { - sc.ForwardSetState(SCE_D_DEFAULT); - } - break; - case SCE_D_STRINGEOL: - if (sc.atLineStart) { - sc.SetState(SCE_D_DEFAULT); - } - break; - } + // Determine if the current state should terminate. + switch (sc.state) { + case SCE_D_OPERATOR: + sc.SetState(SCE_D_DEFAULT); + break; + case SCE_D_NUMBER: + // We accept almost anything because of hex. and number suffixes + if (isascii(sc.ch) && (isalnum(sc.ch) || sc.ch == '_')) { + continue; + } else if (sc.ch == '.' && sc.chNext != '.' && !numFloat) { + // Don't parse 0..2 as number. + numFloat=true; + continue; + } else if ( ( sc.ch == '-' || sc.ch == '+' ) && ( /*sign and*/ + ( !numHex && ( sc.chPrev == 'e' || sc.chPrev == 'E' ) ) || /*decimal or*/ + ( sc.chPrev == 'p' || sc.chPrev == 'P' ) ) ) { /*hex*/ + // Parse exponent sign in float literals: 2e+10 0x2e+10 + continue; + } else { + sc.SetState(SCE_D_DEFAULT); + } + break; + case SCE_D_IDENTIFIER: + if (!IsWord(sc.ch)) { + char s[1000]; + if (caseSensitive) { + sc.GetCurrent(s, sizeof(s)); + } else { + sc.GetCurrentLowered(s, sizeof(s)); + } + if (keywords.InList(s)) { + sc.ChangeState(SCE_D_WORD); + } else if (keywords2.InList(s)) { + sc.ChangeState(SCE_D_WORD2); + } else if (keywords4.InList(s)) { + sc.ChangeState(SCE_D_TYPEDEF); + } else if (keywords5.InList(s)) { + sc.ChangeState(SCE_D_WORD5); + } else if (keywords6.InList(s)) { + sc.ChangeState(SCE_D_WORD6); + } else if (keywords7.InList(s)) { + sc.ChangeState(SCE_D_WORD7); + } + sc.SetState(SCE_D_DEFAULT); + } + break; + case SCE_D_COMMENT: + if (sc.Match('*', '/')) { + sc.Forward(); + sc.ForwardSetState(SCE_D_DEFAULT); + } + break; + case SCE_D_COMMENTDOC: + if (sc.Match('*', '/')) { + sc.Forward(); + sc.ForwardSetState(SCE_D_DEFAULT); + } else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support + // Verify that we have the conditions to mark a comment-doc-keyword + if ((IsASpace(sc.chPrev) || sc.chPrev == '*') && (!IsASpace(sc.chNext))) { + styleBeforeDCKeyword = SCE_D_COMMENTDOC; + sc.SetState(SCE_D_COMMENTDOCKEYWORD); + } + } + break; + case SCE_D_COMMENTLINE: + if (sc.atLineStart) { + sc.SetState(SCE_D_DEFAULT); + } + break; + case SCE_D_COMMENTLINEDOC: + if (sc.atLineStart) { + sc.SetState(SCE_D_DEFAULT); + } else if (sc.ch == '@' || sc.ch == '\\') { // JavaDoc and Doxygen support + // Verify that we have the conditions to mark a comment-doc-keyword + if ((IsASpace(sc.chPrev) || sc.chPrev == '/' || sc.chPrev == '!') && (!IsASpace(sc.chNext))) { + styleBeforeDCKeyword = SCE_D_COMMENTLINEDOC; + sc.SetState(SCE_D_COMMENTDOCKEYWORD); + } + } + break; + case SCE_D_COMMENTDOCKEYWORD: + if ((styleBeforeDCKeyword == SCE_D_COMMENTDOC) && sc.Match('*', '/')) { + sc.ChangeState(SCE_D_COMMENTDOCKEYWORDERROR); + sc.Forward(); + sc.ForwardSetState(SCE_D_DEFAULT); + } else if (!IsDoxygen(sc.ch)) { + char s[100]; + if (caseSensitive) { + sc.GetCurrent(s, sizeof(s)); + } else { + sc.GetCurrentLowered(s, sizeof(s)); + } + if (!IsASpace(sc.ch) || !keywords3.InList(s + 1)) { + sc.ChangeState(SCE_D_COMMENTDOCKEYWORDERROR); + } + sc.SetState(styleBeforeDCKeyword); + } + break; + case SCE_D_COMMENTNESTED: + if (sc.Match('+', '/')) { + if (curNcLevel > 0) + curNcLevel -= 1; + curLine = styler.GetLine(sc.currentPos); + styler.SetLineState(curLine, curNcLevel); + sc.Forward(); + if (curNcLevel == 0) { + sc.ForwardSetState(SCE_D_DEFAULT); + } + } else if (sc.Match('/','+')) { + curNcLevel += 1; + curLine = styler.GetLine(sc.currentPos); + styler.SetLineState(curLine, curNcLevel); + sc.Forward(); + } + break; + case SCE_D_STRING: + if (sc.ch == '\\') { + if (sc.chNext == '"' || sc.chNext == '\\') { + sc.Forward(); + } + } else if (sc.ch == '"') { + if(IsStringSuffix(sc.chNext)) + sc.Forward(); + sc.ForwardSetState(SCE_D_DEFAULT); + } + break; + case SCE_D_CHARACTER: + if (sc.atLineEnd) { + sc.ChangeState(SCE_D_STRINGEOL); + } else if (sc.ch == '\\') { + if (sc.chNext == '\'' || sc.chNext == '\\') { + sc.Forward(); + } + } else if (sc.ch == '\'') { + // Char has no suffixes + sc.ForwardSetState(SCE_D_DEFAULT); + } + break; + case SCE_D_STRINGEOL: + if (sc.atLineStart) { + sc.SetState(SCE_D_DEFAULT); + } + break; + case SCE_D_STRINGB: + if (sc.ch == '`') { + if(IsStringSuffix(sc.chNext)) + sc.Forward(); + sc.ForwardSetState(SCE_D_DEFAULT); + } + break; + case SCE_D_STRINGR: + if (sc.ch == '"') { + if(IsStringSuffix(sc.chNext)) + sc.Forward(); + sc.ForwardSetState(SCE_D_DEFAULT); + } + break; + } - // Determine if a new state should be entered. - if (sc.state == SCE_D_DEFAULT) { - if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { - sc.SetState(SCE_D_NUMBER); - } else if (IsWordStart(sc.ch)) { - sc.SetState(SCE_D_IDENTIFIER); - } else if (sc.Match('/','+')) { - curNcLevel += 1; - curLine = styler.GetLine(sc.currentPos); - styler.SetLineState(curLine, curNcLevel); - sc.SetState(SCE_D_COMMENTNESTED); - sc.Forward(); - } else if (sc.Match('/', '*')) { - if (sc.Match("/**") || sc.Match("/*!")) { // Support of Qt/Doxygen doc. style - sc.SetState(SCE_D_COMMENTDOC); - } else { - sc.SetState(SCE_D_COMMENT); - } - sc.Forward(); // Eat the * so it isn't used for the end of the comment - } else if (sc.Match('/', '/')) { - if ((sc.Match("///") && !sc.Match("////")) || sc.Match("//!")) - // Support of Qt/Doxygen doc. style - sc.SetState(SCE_D_COMMENTLINEDOC); - else - sc.SetState(SCE_D_COMMENTLINE); - } else if (sc.ch == '\"') { - sc.SetState(SCE_D_STRING); - } else if (sc.ch == '\'') { - sc.SetState(SCE_D_CHARACTER); - } else if (isoperator(static_cast(sc.ch))) { - sc.SetState(SCE_D_OPERATOR); - } - } - } - sc.Complete(); + // Determine if a new state should be entered. + if (sc.state == SCE_D_DEFAULT) { + if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { + sc.SetState(SCE_D_NUMBER); + numFloat = sc.ch == '.'; + // Remember hex literal + numHex = sc.ch == '0' && ( sc.chNext == 'x' || sc.chNext == 'X' ); + } else if ( (sc.ch == 'r' || sc.ch == 'x' || sc.ch == 'q') + && sc.chNext == '"' ) { + // Limited support for hex and delimited strings: parse as r"" + sc.SetState(SCE_D_STRINGR); + sc.Forward(); + } else if (IsWordStart(sc.ch) || sc.ch == '$') { + sc.SetState(SCE_D_IDENTIFIER); + } else if (sc.Match('/','+')) { + curNcLevel += 1; + curLine = styler.GetLine(sc.currentPos); + styler.SetLineState(curLine, curNcLevel); + sc.SetState(SCE_D_COMMENTNESTED); + sc.Forward(); + } else if (sc.Match('/', '*')) { + if (sc.Match("/**") || sc.Match("/*!")) { // Support of Qt/Doxygen doc. style + sc.SetState(SCE_D_COMMENTDOC); + } else { + sc.SetState(SCE_D_COMMENT); + } + sc.Forward(); // Eat the * so it isn't used for the end of the comment + } else if (sc.Match('/', '/')) { + if ((sc.Match("///") && !sc.Match("////")) || sc.Match("//!")) + // Support of Qt/Doxygen doc. style + sc.SetState(SCE_D_COMMENTLINEDOC); + else + sc.SetState(SCE_D_COMMENTLINE); + } else if (sc.ch == '"') { + sc.SetState(SCE_D_STRING); + } else if (sc.ch == '\'') { + sc.SetState(SCE_D_CHARACTER); + } else if (sc.ch == '`') { + sc.SetState(SCE_D_STRINGB); + } else if (isoperator(static_cast(sc.ch))) { + sc.SetState(SCE_D_OPERATOR); + if (sc.ch == '.' && sc.chNext == '.') sc.Forward(); // Range operator + } + } + } + sc.Complete(); } static bool IsStreamCommentStyle(int style) { - return style == SCE_D_COMMENT || - style == SCE_D_COMMENTDOC || - style == SCE_D_COMMENTDOCKEYWORD || - style == SCE_D_COMMENTDOCKEYWORDERROR; + 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; - bool foldAtElse = styler.GetPropertyInt("lexer.d.fold.at.else", + 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; - 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 levelMinCurrent = levelCurrent; - int levelNext = levelCurrent; - char chNext = styler[startPos]; - int styleNext = styler.StyleAt(startPos); - int style = initStyle; - 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 (foldComment && 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 (style == SCE_D_OPERATOR) { - if (ch == '{') { - // Measure the minimum before a '{' to allow - // folding on "} else {" - if (levelMinCurrent > levelNext) { - levelMinCurrent = levelNext; - } - levelNext++; - } else if (ch == '}') { - levelNext--; - } - } - if (atEOL) { - if (foldComment) { // Handle nested comments - int nc; - nc = styler.GetLineState(lineCurrent); - nc -= lineCurrent>0? styler.GetLineState(lineCurrent-1): 0; - levelNext += nc; - } - int levelUse = levelCurrent; - if (foldAtElse) { - levelUse = levelMinCurrent; - } - int lev = levelUse | levelNext << 16; - if (visibleChars == 0 && foldCompact) - lev |= SC_FOLDLEVELWHITEFLAG; - if (levelUse < levelNext) - lev |= SC_FOLDLEVELHEADERFLAG; - if (lev != styler.LevelAt(lineCurrent)) { - styler.SetLevel(lineCurrent, lev); - } - lineCurrent++; - levelCurrent = levelNext; - levelMinCurrent = levelCurrent; - visibleChars = 0; - } - if (!IsASpace(ch)) - visibleChars++; - } + 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 levelMinCurrent = levelCurrent; + int levelNext = levelCurrent; + char chNext = styler[startPos]; + int styleNext = styler.StyleAt(startPos); + int style = initStyle; + 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 (foldComment && 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 (style == SCE_D_OPERATOR) { + if (ch == '{') { + // Measure the minimum before a '{' to allow + // folding on "} else {" + if (levelMinCurrent > levelNext) { + levelMinCurrent = levelNext; + } + levelNext++; + } else if (ch == '}') { + levelNext--; + } + } + if (atEOL) { + if (foldComment) { // Handle nested comments + int nc; + nc = styler.GetLineState(lineCurrent); + nc -= lineCurrent>0? styler.GetLineState(lineCurrent-1): 0; + levelNext += nc; + } + int levelUse = levelCurrent; + if (foldAtElse) { + levelUse = levelMinCurrent; + } + int lev = levelUse | levelNext << 16; + if (visibleChars == 0 && foldCompact) + lev |= SC_FOLDLEVELWHITEFLAG; + if (levelUse < levelNext) + lev |= SC_FOLDLEVELHEADERFLAG; + if (lev != styler.LevelAt(lineCurrent)) { + styler.SetLevel(lineCurrent, lev); + } + lineCurrent++; + levelCurrent = levelNext; + levelMinCurrent = levelCurrent; + visibleChars = 0; + } + if (!IsASpace(ch)) + visibleChars++; + } } static void FoldDDoc(unsigned int startPos, int length, int initStyle, - WordList *[], Accessor &styler) { - FoldDoc(startPos, length, initStyle, styler); + 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", - 0, - }; + "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); +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); diff --git a/src/stc/scintilla/src/LexErlang.cxx b/src/stc/scintilla/src/LexErlang.cxx index d56f785287..45577bda4c 100644 --- a/src/stc/scintilla/src/LexErlang.cxx +++ b/src/stc/scintilla/src/LexErlang.cxx @@ -1,10 +1,12 @@ // Scintilla source code edit control +// Copyright 1998-2001 by Neil Hodgson +// The License.txt file describes the conditions under which this software may be distributed. /** @file LexErlang.cxx ** Lexer for Erlang. - ** Written by Peter-Henry Mander, based on Matlab lexer by Jose' Fonseca + ** Enhanced by Etienne 'Lenain' Girondel (lenaing@gmail.com) + ** Originally wrote by Peter-Henry Mander, + ** based on Matlab lexer by José Fonseca. **/ -// Copyright 1998-2001 by Neil Hodgson -// The License.txt file describes the conditions under which this software may be distributed. #include #include @@ -13,7 +15,6 @@ #include #include "Platform.h" - #include "PropSet.h" #include "Accessor.h" #include "StyleContext.h" @@ -25,502 +26,594 @@ using namespace Scintilla; #endif -/* - TODO: - o _Param should be a new lexical type -*/ - static int is_radix(int radix, int ch) { - int digit; - if ( 16 < radix || 2 > radix ) { - return 0; - } - if ( isdigit(ch) ) { - digit = ch - '0'; - } else if ( isxdigit(ch) ) { - digit = toupper(ch) - 'A' + 10; - } else { - return 0; - } - if ( digit < radix ) { - return 1; - } else { - return 0; - } + int digit; + + if (36 < radix || 2 > radix) + return 0; + + if (isdigit(ch)) { + digit = ch - '0'; + } else if (isalnum(ch)) { + digit = toupper(ch) - 'A' + 10; + } else { + return 0; + } + + return (digit < radix); } typedef enum { - STATE_NULL, - ATOM_UNQUOTED, - ATOM_QUOTED, - ATOM_FUN_NAME, - NODE_NAME_UNQUOTED, - NODE_NAME_QUOTED, - MACRO_START, - MACRO_UNQUOTED, - MACRO_QUOTED, - RECORD_START, - RECORD_UNQUOTED, - RECORD_QUOTED, - NUMERAL_START, - NUMERAL_SIGNED, - NUMERAL_RADIX_LITERAL, - NUMERAL_SPECULATIVE_MANTISSA, - NUMERAL_FLOAT_MANTISSA, - NUMERAL_FLOAT_EXPONENT, - NUMERAL_FLOAT_SIGNED_EXPONENT, - PARSE_ERROR + STATE_NULL, + COMMENT, + COMMENT_FUNCTION, + COMMENT_MODULE, + COMMENT_DOC, + COMMENT_DOC_MACRO, + ATOM_UNQUOTED, + ATOM_QUOTED, + NODE_NAME_UNQUOTED, + NODE_NAME_QUOTED, + MACRO_START, + MACRO_UNQUOTED, + MACRO_QUOTED, + RECORD_START, + RECORD_UNQUOTED, + RECORD_QUOTED, + NUMERAL_START, + NUMERAL_BASE_VALUE, + NUMERAL_FLOAT, + NUMERAL_EXPONENT, + PREPROCESSOR } atom_parse_state_t; +static inline bool IsAWordChar(const int ch) { + return (ch < 0x80) && (ch != ' ') && (isalnum(ch) || ch == '_'); +} + static void ColouriseErlangDoc(unsigned int startPos, int length, int initStyle, - WordList *keywordlists[], Accessor &styler) { + WordList *keywordlists[], Accessor &styler) { - WordList &keywords = *keywordlists[0]; + StyleContext sc(startPos, length, initStyle, styler); + WordList &reservedWords = *keywordlists[0]; + WordList &erlangBIFs = *keywordlists[1]; + WordList &erlangPreproc = *keywordlists[2]; + WordList &erlangModulesAtt = *keywordlists[3]; + WordList &erlangDoc = *keywordlists[4]; + WordList &erlangDocMacro = *keywordlists[5]; + int radix_digits = 0; + int exponent_digits = 0; + atom_parse_state_t parse_state = STATE_NULL; + atom_parse_state_t old_parse_state = STATE_NULL; + bool to_late_to_comment = false; + char cur[100]; + int old_style = SCE_ERLANG_DEFAULT; styler.StartAt(startPos); - StyleContext sc(startPos, length, initStyle, styler); - atom_parse_state_t parse_state = STATE_NULL; - int radix_digits = 0; - int exponent_digits = 0; for (; sc.More(); sc.Forward()) { - if ( STATE_NULL != parse_state ) { - switch (parse_state) { - case STATE_NULL: - sc.SetState(SCE_ERLANG_DEFAULT); - break; - case ATOM_UNQUOTED: - if ( '@' == sc.ch ){ - parse_state = NODE_NAME_UNQUOTED; - } else if ( !isalnum(sc.ch) && sc.ch != '_' ) { - char s[100]; - sc.GetCurrent(s, sizeof(s)); - if (keywords.InList(s)) { - sc.ChangeState(SCE_ERLANG_KEYWORD); - sc.SetState(SCE_ERLANG_DEFAULT); - parse_state = STATE_NULL; - } else { - if ( '/' == sc.ch ) { - parse_state = ATOM_FUN_NAME; - } else { - sc.ChangeState(SCE_ERLANG_ATOM); - sc.SetState(SCE_ERLANG_DEFAULT); - parse_state = STATE_NULL; - } - } - } - break; - case ATOM_QUOTED: - if ( '@' == sc.ch ){ - parse_state = NODE_NAME_QUOTED; - } else if ( '\'' == sc.ch && '\\' != sc.chPrev ) { - sc.ChangeState(SCE_ERLANG_ATOM); - sc.ForwardSetState(SCE_ERLANG_DEFAULT); - parse_state = STATE_NULL; - } - break; - case ATOM_FUN_NAME: - if ( !isdigit(sc.ch) ) { - sc.ChangeState(SCE_ERLANG_FUNCTION_NAME); - sc.SetState(SCE_ERLANG_DEFAULT); - parse_state = STATE_NULL; - } - break; - case NODE_NAME_QUOTED: - if ( '@' == sc.ch ) { - sc.SetState(SCE_ERLANG_DEFAULT); - parse_state = STATE_NULL; - } else if ( '\'' == sc.ch && '\\' != sc.chPrev ) { - sc.ChangeState(SCE_ERLANG_NODE_NAME); - sc.ForwardSetState(SCE_ERLANG_DEFAULT); - parse_state = STATE_NULL; - } - break; - case NODE_NAME_UNQUOTED: - if ( '@' == sc.ch ) { - sc.SetState(SCE_ERLANG_DEFAULT); - parse_state = STATE_NULL; - } else if ( !isalnum(sc.ch) && sc.ch != '_' ) { - sc.ChangeState(SCE_ERLANG_NODE_NAME); - sc.SetState(SCE_ERLANG_DEFAULT); - parse_state = STATE_NULL; - } - break; - case RECORD_START: - if ( '\'' == sc.ch ) { - parse_state = RECORD_QUOTED; - } else if (isalpha(sc.ch) && islower(sc.ch)) { - parse_state = RECORD_UNQUOTED; - } else { // error - sc.SetState(SCE_ERLANG_DEFAULT); - parse_state = STATE_NULL; - } - break; - case RECORD_QUOTED: - if ( '\'' == sc.ch && '\\' != sc.chPrev ) { - sc.ChangeState(SCE_ERLANG_RECORD); - sc.ForwardSetState(SCE_ERLANG_DEFAULT); - parse_state = STATE_NULL; - } - break; - case RECORD_UNQUOTED: - if ( !isalpha(sc.ch) && '_' != sc.ch ) { - sc.ChangeState(SCE_ERLANG_RECORD); - sc.SetState(SCE_ERLANG_DEFAULT); - parse_state = STATE_NULL; - } - break; - case MACRO_START: - if ( '\'' == sc.ch ) { - parse_state = MACRO_QUOTED; - } else if (isalpha(sc.ch)) { - parse_state = MACRO_UNQUOTED; - } else { // error - sc.SetState(SCE_ERLANG_DEFAULT); - parse_state = STATE_NULL; - } - break; - case MACRO_UNQUOTED: - if ( !isalpha(sc.ch) && '_' != sc.ch ) { - sc.ChangeState(SCE_ERLANG_MACRO); - sc.SetState(SCE_ERLANG_DEFAULT); - parse_state = STATE_NULL; - } - break; - case MACRO_QUOTED: - if ( '\'' == sc.ch && '\\' != sc.chPrev ) { - sc.ChangeState(SCE_ERLANG_MACRO); - sc.ForwardSetState(SCE_ERLANG_DEFAULT); - parse_state = STATE_NULL; - } - break; - case NUMERAL_START: - if ( isdigit(sc.ch) ) { - radix_digits *= 10; - radix_digits += sc.ch - '0'; // Assuming ASCII here! - } else if ( '#' == sc.ch ) { - if ( 2 > radix_digits || 16 < radix_digits) { - sc.SetState(SCE_ERLANG_DEFAULT); - parse_state = STATE_NULL; - } else { - parse_state = NUMERAL_RADIX_LITERAL; - } - } else if ( '.' == sc.ch && isdigit(sc.chNext)) { - radix_digits = 0; - parse_state = NUMERAL_FLOAT_MANTISSA; - } else if ( 'e' == sc.ch || 'E' == sc.ch ) { - exponent_digits = 0; - parse_state = NUMERAL_FLOAT_EXPONENT; - } else { - radix_digits = 0; - sc.ChangeState(SCE_ERLANG_NUMBER); - sc.SetState(SCE_ERLANG_DEFAULT); - parse_state = STATE_NULL; - } - break; - case NUMERAL_RADIX_LITERAL: - if ( !is_radix(radix_digits,sc.ch) ) { - radix_digits = 0; - if ( !isalnum(sc.ch) ) { - sc.ChangeState(SCE_ERLANG_NUMBER); - } - sc.SetState(SCE_ERLANG_DEFAULT); - parse_state = STATE_NULL; - } - break; - case NUMERAL_FLOAT_MANTISSA: - if ( 'e' == sc.ch || 'E' == sc.ch ) { - exponent_digits = 0; - parse_state = NUMERAL_FLOAT_EXPONENT; - } else if ( !isdigit(sc.ch) ) { - sc.ChangeState(SCE_ERLANG_NUMBER); - sc.SetState(SCE_ERLANG_DEFAULT); - parse_state = STATE_NULL; - } - break; - case NUMERAL_FLOAT_EXPONENT: - if ( '-' == sc.ch || '+' == sc.ch ) { - parse_state = NUMERAL_FLOAT_SIGNED_EXPONENT; - } else if ( !isdigit(sc.ch) ) { - if ( 0 < exponent_digits ) { - sc.ChangeState(SCE_ERLANG_NUMBER); - } - sc.SetState(SCE_ERLANG_DEFAULT); - parse_state = STATE_NULL; - } else { - ++exponent_digits; - } - break; - case NUMERAL_FLOAT_SIGNED_EXPONENT: - if ( !isdigit(sc.ch) ) { - if ( 0 < exponent_digits ) { - sc.ChangeState(SCE_ERLANG_NUMBER); - } - sc.SetState(SCE_ERLANG_DEFAULT); - parse_state = STATE_NULL; - } else { - ++exponent_digits; - } - break; - case NUMERAL_SIGNED: - if ( !isdigit(sc.ch) ) { - sc.ChangeState(SCE_ERLANG_NUMBER); - sc.SetState(SCE_ERLANG_DEFAULT); - parse_state = STATE_NULL; - } else if ( '.' == sc.ch ) { - parse_state = NUMERAL_FLOAT_MANTISSA; - } - break; - case NUMERAL_SPECULATIVE_MANTISSA: - if ( !isdigit(sc.ch) ) { - sc.ChangeState(SCE_ERLANG_OPERATOR); - sc.SetState(SCE_ERLANG_DEFAULT); - parse_state = STATE_NULL; - } else { - parse_state = NUMERAL_FLOAT_MANTISSA; - } - break; - case PARSE_ERROR: - sc.SetState(SCE_ERLANG_DEFAULT); - parse_state = STATE_NULL; - break; - } - } else if (sc.state == SCE_ERLANG_OPERATOR) { - if (sc.chPrev == '.') { - if (sc.ch == '*' || sc.ch == '/' || sc.ch == '\\' || sc.ch == '^') { - sc.ForwardSetState(SCE_ERLANG_DEFAULT); - } else if (sc.ch == '\'') { - sc.ForwardSetState(SCE_ERLANG_DEFAULT); - } else { - sc.SetState(SCE_ERLANG_DEFAULT); + int style = SCE_ERLANG_DEFAULT; + if (STATE_NULL != parse_state) { + + switch (parse_state) { + + case STATE_NULL : sc.SetState(SCE_ERLANG_DEFAULT); break; + + /* COMMENTS ------------------------------------------------------*/ + case COMMENT : { + if (sc.ch != '%') { + to_late_to_comment = true; + } else if (!to_late_to_comment && sc.ch == '%') { + // Switch to comment level 2 (Function) + sc.ChangeState(SCE_ERLANG_COMMENT_FUNCTION); + old_style = SCE_ERLANG_COMMENT_FUNCTION; + parse_state = COMMENT_FUNCTION; + sc.Forward(); + } } - } else { - sc.SetState(SCE_ERLANG_DEFAULT); - } - } else if (sc.state == SCE_ERLANG_VARIABLE) { - if (!isalnum(sc.ch) && sc.ch != '_') { - sc.SetState(SCE_ERLANG_DEFAULT); - } - } else if (sc.state == SCE_ERLANG_STRING) { - if (sc.ch == '\"' && sc.chPrev != '\\') { - sc.ForwardSetState(SCE_ERLANG_DEFAULT); + // V--- Falling through! + case COMMENT_FUNCTION : { + if (sc.ch != '%') { + to_late_to_comment = true; + } else if (!to_late_to_comment && sc.ch == '%') { + // Switch to comment level 3 (Module) + sc.ChangeState(SCE_ERLANG_COMMENT_MODULE); + old_style = SCE_ERLANG_COMMENT_MODULE; + parse_state = COMMENT_MODULE; + sc.Forward(); + } + } + // V--- Falling through! + case COMMENT_MODULE : { + if (parse_state != COMMENT) { + // Search for comment documentation + if (sc.chNext == '@') { + old_parse_state = parse_state; + parse_state = ('{' == sc.ch) + ? COMMENT_DOC_MACRO + : COMMENT_DOC; + sc.ForwardSetState(sc.state); + } + } + + // All comments types fall here. + if (sc.atLineEnd) { + to_late_to_comment = false; + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + case COMMENT_DOC : + // V--- Falling through! + case COMMENT_DOC_MACRO : { + + if (!isalnum(sc.ch)) { + // Try to match documentation comment + sc.GetCurrent(cur, sizeof(cur)); + + if (parse_state == COMMENT_DOC_MACRO + && erlangDocMacro.InList(cur)) { + sc.ChangeState(SCE_ERLANG_COMMENT_DOC_MACRO); + while (sc.ch != '}' && !sc.atLineEnd) + sc.Forward(); + } else if (erlangDoc.InList(cur)) { + sc.ChangeState(SCE_ERLANG_COMMENT_DOC); + } else { + sc.ChangeState(old_style); + } + + // Switch back to old state + sc.SetState(old_style); + parse_state = old_parse_state; + } + + if (sc.atLineEnd) { + to_late_to_comment = false; + sc.ChangeState(old_style); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + /* -------------------------------------------------------------- */ + /* Atoms ---------------------------------------------------------*/ + case ATOM_UNQUOTED : { + if ('@' == sc.ch){ + parse_state = NODE_NAME_UNQUOTED; + } else if (sc.ch == ':') { + // Searching for module name + if (sc.chNext == ' ') { + // error + sc.ChangeState(SCE_ERLANG_UNKNOWN); + parse_state = STATE_NULL; + } else { + sc.Forward(); + if (isalnum(sc.ch)) { + sc.GetCurrent(cur, sizeof(cur)); + sc.ChangeState(SCE_ERLANG_MODULES); + sc.SetState(SCE_ERLANG_MODULES); + } + } + } else if (!IsAWordChar(sc.ch)) { + + sc.GetCurrent(cur, sizeof(cur)); + if (reservedWords.InList(cur)) { + style = SCE_ERLANG_KEYWORD; + } else if (erlangBIFs.InList(cur) + && strcmp(cur,"erlang:")){ + style = SCE_ERLANG_BIFS; + } else if (sc.ch == '(' || '/' == sc.ch){ + style = SCE_ERLANG_FUNCTION_NAME; + } else { + style = SCE_ERLANG_ATOM; + } + + sc.ChangeState(style); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + + } break; + + case ATOM_QUOTED : { + if ( '@' == sc.ch ){ + parse_state = NODE_NAME_QUOTED; + } else if ('\'' == sc.ch && '\\' != sc.chPrev) { + sc.ChangeState(SCE_ERLANG_ATOM); + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + /* -------------------------------------------------------------- */ + /* Node names ----------------------------------------------------*/ + case NODE_NAME_UNQUOTED : { + if ('@' == sc.ch) { + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else if (!IsAWordChar(sc.ch)) { + sc.ChangeState(SCE_ERLANG_NODE_NAME); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + case NODE_NAME_QUOTED : { + if ('@' == sc.ch) { + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else if ('\'' == sc.ch && '\\' != sc.chPrev) { + sc.ChangeState(SCE_ERLANG_NODE_NAME_QUOTED); + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + /* -------------------------------------------------------------- */ + /* Records -------------------------------------------------------*/ + case RECORD_START : { + if ('\'' == sc.ch) { + parse_state = RECORD_QUOTED; + } else if (isalpha(sc.ch) && islower(sc.ch)) { + parse_state = RECORD_UNQUOTED; + } else { // error + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + case RECORD_UNQUOTED : { + if (!IsAWordChar(sc.ch)) { + sc.ChangeState(SCE_ERLANG_RECORD); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + case RECORD_QUOTED : { + if ('\'' == sc.ch && '\\' != sc.chPrev) { + sc.ChangeState(SCE_ERLANG_RECORD_QUOTED); + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + /* -------------------------------------------------------------- */ + /* Macros --------------------------------------------------------*/ + case MACRO_START : { + if ('\'' == sc.ch) { + parse_state = MACRO_QUOTED; + } else if (isalpha(sc.ch)) { + parse_state = MACRO_UNQUOTED; + } else { // error + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + case MACRO_UNQUOTED : { + if (!IsAWordChar(sc.ch)) { + sc.ChangeState(SCE_ERLANG_MACRO); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + case MACRO_QUOTED : { + if ('\'' == sc.ch && '\\' != sc.chPrev) { + sc.ChangeState(SCE_ERLANG_MACRO_QUOTED); + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + /* -------------------------------------------------------------- */ + /* Numerics ------------------------------------------------------*/ + /* Simple integer */ + case NUMERAL_START : { + if (isdigit(sc.ch)) { + radix_digits *= 10; + radix_digits += sc.ch - '0'; // Assuming ASCII here! + } else if ('#' == sc.ch) { + if (2 > radix_digits || 36 < radix_digits) { + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else { + parse_state = NUMERAL_BASE_VALUE; + } + } else if ('.' == sc.ch && isdigit(sc.chNext)) { + radix_digits = 0; + parse_state = NUMERAL_FLOAT; + } else if ('e' == sc.ch || 'E' == sc.ch) { + exponent_digits = 0; + parse_state = NUMERAL_EXPONENT; + } else { + radix_digits = 0; + sc.ChangeState(SCE_ERLANG_NUMBER); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + /* Integer in other base than 10 (x#yyy) */ + case NUMERAL_BASE_VALUE : { + if (!is_radix(radix_digits,sc.ch)) { + radix_digits = 0; + + if (!isalnum(sc.ch)) + sc.ChangeState(SCE_ERLANG_NUMBER); + + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + /* Float (x.yyy) */ + case NUMERAL_FLOAT : { + if ('e' == sc.ch || 'E' == sc.ch) { + exponent_digits = 0; + parse_state = NUMERAL_EXPONENT; + } else if (!isdigit(sc.ch)) { + sc.ChangeState(SCE_ERLANG_NUMBER); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + + /* Exponent, either integer or float (xEyy, x.yyEzzz) */ + case NUMERAL_EXPONENT : { + if (('-' == sc.ch || '+' == sc.ch) + && (isdigit(sc.chNext))) { + sc.Forward(); + } else if (!isdigit(sc.ch)) { + if (0 < exponent_digits) + sc.ChangeState(SCE_ERLANG_NUMBER); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } else { + ++exponent_digits; + } + } break; + + /* -------------------------------------------------------------- */ + /* Preprocessor --------------------------------------------------*/ + case PREPROCESSOR : { + if (!IsAWordChar(sc.ch)) { + + sc.GetCurrent(cur, sizeof(cur)); + if (erlangPreproc.InList(cur)) { + style = SCE_ERLANG_PREPROC; + } else if (erlangModulesAtt.InList(cur)) { + style = SCE_ERLANG_MODULES_ATT; + } + + sc.ChangeState(style); + sc.SetState(SCE_ERLANG_DEFAULT); + parse_state = STATE_NULL; + } + } break; + } - } else if (sc.state == SCE_ERLANG_COMMENT ) { - if (sc.atLineEnd) { - sc.SetState(SCE_ERLANG_DEFAULT); + + } /* End of : STATE_NULL != parse_state */ + else + { + switch (sc.state) { + case SCE_ERLANG_VARIABLE : { + if (!IsAWordChar(sc.ch)) + sc.SetState(SCE_ERLANG_DEFAULT); + } break; + case SCE_ERLANG_STRING : { + if (sc.ch == '\"' && sc.chPrev != '\\') + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + } break; + case SCE_ERLANG_COMMENT : { + if (sc.atLineEnd) + sc.SetState(SCE_ERLANG_DEFAULT); + } break; + case SCE_ERLANG_CHARACTER : { + if (sc.chPrev == '\\') { + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + } else if (sc.ch != '\\') { + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + } + } break; + case SCE_ERLANG_OPERATOR : { + if (sc.chPrev == '.') { + if (sc.ch == '*' || sc.ch == '/' || sc.ch == '\\' + || sc.ch == '^') { + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + } else if (sc.ch == '\'') { + sc.ForwardSetState(SCE_ERLANG_DEFAULT); + } else { + sc.SetState(SCE_ERLANG_DEFAULT); + } + } else { + sc.SetState(SCE_ERLANG_DEFAULT); + } + } break; } - } else if (sc.state == SCE_ERLANG_CHARACTER ) { - if ( sc.chPrev == '\\' ) { - sc.ForwardSetState(SCE_ERLANG_DEFAULT); - } else if ( sc.ch != '\\' ) { - sc.ForwardSetState(SCE_ERLANG_DEFAULT); - } - } + } if (sc.state == SCE_ERLANG_DEFAULT) { - if (sc.ch == '%') { - sc.SetState(SCE_ERLANG_COMMENT); - } else if (sc.ch == '\"') { - sc.SetState(SCE_ERLANG_STRING); - } else if (sc.ch == '#') { - parse_state = RECORD_START; - sc.SetState(SCE_ERLANG_UNKNOWN); - } else if (sc.ch == '?') { - parse_state = MACRO_START; - sc.SetState(SCE_ERLANG_UNKNOWN); - } else if (sc.ch == '$') { - sc.SetState(SCE_ERLANG_CHARACTER); - } else if (sc.ch == '\'') { - parse_state = ATOM_QUOTED; - sc.SetState(SCE_ERLANG_UNKNOWN); - } else if ( isdigit(sc.ch) ) { - parse_state = NUMERAL_START; - radix_digits = sc.ch - '0'; - sc.SetState(SCE_ERLANG_UNKNOWN); - } else if ( '.' == sc.ch ) { - parse_state = NUMERAL_SPECULATIVE_MANTISSA; - sc.SetState(SCE_ERLANG_UNKNOWN); - } else if (isalpha(sc.ch) && isupper(sc.ch)) { - sc.SetState(SCE_ERLANG_VARIABLE); - } else if (isalpha(sc.ch)) { - parse_state = ATOM_UNQUOTED; - sc.SetState(SCE_ERLANG_UNKNOWN); - } else if (isoperator(static_cast(sc.ch)) || sc.ch == '\\') { - sc.SetState(SCE_ERLANG_OPERATOR); + bool no_new_state = false; + + switch (sc.ch) { + case '\"' : sc.SetState(SCE_ERLANG_STRING); break; + case '$' : sc.SetState(SCE_ERLANG_CHARACTER); break; + case '%' : { + parse_state = COMMENT; + sc.SetState(SCE_ERLANG_COMMENT); + } break; + case '#' : { + parse_state = RECORD_START; + sc.SetState(SCE_ERLANG_UNKNOWN); + } break; + case '?' : { + parse_state = MACRO_START; + sc.SetState(SCE_ERLANG_UNKNOWN); + } break; + case '\'' : { + parse_state = ATOM_QUOTED; + sc.SetState(SCE_ERLANG_UNKNOWN); + } break; + case '+' : + case '-' : { + if (IsADigit(sc.chNext)) { + parse_state = NUMERAL_START; + radix_digits = 0; + sc.SetState(SCE_ERLANG_UNKNOWN); + } else if (sc.ch != '+') { + parse_state = PREPROCESSOR; + sc.SetState(SCE_ERLANG_UNKNOWN); + } + } break; + default : no_new_state = true; + } + + if (no_new_state) { + if (isdigit(sc.ch)) { + parse_state = NUMERAL_START; + radix_digits = sc.ch - '0'; + sc.SetState(SCE_ERLANG_UNKNOWN); + } else if (isupper(sc.ch) || '_' == sc.ch) { + sc.SetState(SCE_ERLANG_VARIABLE); + } else if (isalpha(sc.ch)) { + parse_state = ATOM_UNQUOTED; + sc.SetState(SCE_ERLANG_UNKNOWN); + } else if (isoperator(static_cast(sc.ch)) + || sc.ch == '\\') { + sc.SetState(SCE_ERLANG_OPERATOR); + } } } + } sc.Complete(); } -static int ClassifyFoldPointErlang( - Accessor &styler, - int styleNext, - int keyword_start +static int ClassifyErlangFoldPoint( + Accessor &styler, + int styleNext, + int keyword_start ) { int lev = 0; - if ( styler.Match(keyword_start,"case") - || ( - styler.Match(keyword_start,"fun") - && SCE_ERLANG_FUNCTION_NAME != styleNext) - || styler.Match(keyword_start,"if") - || styler.Match(keyword_start,"query") - || styler.Match(keyword_start,"receive") - ) { - ++lev; - } else if ( styler.Match(keyword_start,"end") ) { - --lev; - } + if (styler.Match(keyword_start,"case") + || ( + styler.Match(keyword_start,"fun") + && (SCE_ERLANG_FUNCTION_NAME != styleNext) + ) + || styler.Match(keyword_start,"if") + || styler.Match(keyword_start,"query") + || styler.Match(keyword_start,"receive") + ) { + ++lev; + } else if (styler.Match(keyword_start,"end")) { + --lev; + } + return lev; } - static void FoldErlangDoc( - unsigned int startPos, int length, int initStyle, - WordList** /*keywordlists*/, Accessor &styler + unsigned int startPos, int length, int initStyle, + WordList** /*keywordlists*/, Accessor &styler ) { unsigned int endPos = startPos + length; - //~ int visibleChars = 0; - int lineCurrent = styler.GetLine(startPos); - int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; - int levelCurrent = levelPrev; - char chNext = styler.SafeGetCharAt(startPos); + int currentLine = styler.GetLine(startPos); + int lev; + int previousLevel = styler.LevelAt(currentLine) & SC_FOLDLEVELNUMBERMASK; + int currentLevel = previousLevel; int styleNext = styler.StyleAt(startPos); int style = initStyle; + int stylePrev; int keyword_start = 0; - - bool fold_keywords = true; - bool fold_comments = true; - bool fold_braces = true; - bool fold_function_clauses = false; - bool fold_clauses = false; - - //int clause_level = 0; + char ch; + char chNext = styler.SafeGetCharAt(startPos); + bool atEOL; for (unsigned int i = startPos; i < endPos; i++) { - char ch = chNext; + ch = chNext; chNext = styler.SafeGetCharAt(i + 1); - int stylePrev = style; + + // Get styles + stylePrev = style; style = styleNext; styleNext = styler.StyleAt(i + 1); - bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); - - if ( (stylePrev != SCE_ERLANG_KEYWORD) && (style == SCE_ERLANG_KEYWORD) ) { - keyword_start = i; - } - if ( fold_keywords ) { - if ( (stylePrev == SCE_ERLANG_KEYWORD) - && (style != SCE_ERLANG_KEYWORD) - && (style != SCE_ERLANG_ATOM) - ) { - levelCurrent += ClassifyFoldPointErlang(styler,styleNext,keyword_start); - } - } - - if ( fold_comments ) { - if (style == SCE_ERLANG_COMMENT) { - if ((ch == '%') && (chNext == '{')) { - levelCurrent++; - } else if ((ch == '%') && (chNext == '}')) { - levelCurrent--; - } - } - } - - if ( fold_function_clauses ) { - if ( (SC_FOLDLEVELBASE == levelCurrent) /*&& (style == SCE_ERLANG_OPERATOR)*/ ) { - if ( (ch == '-') && (chNext == '>')) { - //~ fprintf(stderr,"levelCurrent=%d\n", levelCurrent); - //++clause_level; - //~ if ( 0 < clause_level ) - ++levelCurrent; - } - } - //~ if ( (stylePrev != SCE_ERLANG_RECORD) - //~ && (style != SCE_ERLANG_NUMBER) - //~ && (style != SCE_ERLANG_STRING) - //~ && (style != SCE_ERLANG_COMMENT) - //~ ) { - if ( (SC_FOLDLEVELBASE+1 == levelCurrent) && (ch == '.') ) { - //--clause_level; - //~ if ( 0 == clause_level ) - --levelCurrent; - } - //~ } - } - - if ( fold_clauses ) { - if ( (0 < levelCurrent) && (style == SCE_ERLANG_OPERATOR) ) { - if ((ch == '-') && (chNext == '>')) { - levelCurrent++; - } - if ( (ch == ';') ) { - levelCurrent--; - } - } - if ( (stylePrev != SCE_ERLANG_RECORD) - && (style != SCE_ERLANG_NUMBER) - && (style != SCE_ERLANG_STRING) - && (style != SCE_ERLANG_COMMENT) - ) { - if ( (ch == '.') ) { - levelCurrent--; - } - } - if ( (stylePrev == SCE_ERLANG_KEYWORD) - && (style != SCE_ERLANG_KEYWORD) - && (style != SCE_ERLANG_ATOM) - && ( - styler.Match(keyword_start,"end") // 'end' counted twice if fold_keywords too - || styler.Match(keyword_start,"after") ) - ) { - levelCurrent--; - } - } - - if ( fold_braces ) { - if (style == SCE_ERLANG_OPERATOR) { - if ( (ch == '{') || (ch == '(') || (ch == '[') ) { - levelCurrent++; - } else if ( (ch == '}') || (ch == ')') || (ch == ']') ) { - levelCurrent--; - } - } - } + atEOL = ((ch == '\r') && (chNext != '\n')) || (ch == '\n'); + + if (stylePrev != SCE_ERLANG_KEYWORD + && style == SCE_ERLANG_KEYWORD) { + keyword_start = i; + } + + // Fold on keywords + if (stylePrev == SCE_ERLANG_KEYWORD + && style != SCE_ERLANG_KEYWORD + && style != SCE_ERLANG_ATOM + ) { + currentLevel += ClassifyErlangFoldPoint(styler, + styleNext, + keyword_start); + } + + // Fold on comments + if (style == SCE_ERLANG_COMMENT + || style == SCE_ERLANG_COMMENT_MODULE + || style == SCE_ERLANG_COMMENT_FUNCTION) { + + if (ch == '%' && chNext == '{') { + currentLevel++; + } else if (ch == '%' && chNext == '}') { + currentLevel--; + } + } + + // Fold on braces + if (style == SCE_ERLANG_OPERATOR) { + if (ch == '{' || ch == '(' || ch == '[') { + currentLevel++; + } else if (ch == '}' || ch == ')' || ch == ']') { + currentLevel--; + } + } + if (atEOL) { - int lev = levelPrev; - //~ if (visibleChars == 0 && foldCompact) - //~ lev |= SC_FOLDLEVELWHITEFLAG; - //~ if ((levelCurrent > levelPrev) && (visibleChars > 0)) - if ((levelCurrent > levelPrev)) { + lev = previousLevel; + + if (currentLevel > previousLevel) lev |= SC_FOLDLEVELHEADERFLAG; - } - if (lev != styler.LevelAt(lineCurrent)) { - styler.SetLevel(lineCurrent, lev); - } - lineCurrent++; - levelPrev = levelCurrent; - //~ visibleChars = 0; + + if (lev != styler.LevelAt(currentLine)) + styler.SetLevel(currentLine, lev); + + currentLine++; + previousLevel = currentLevel; } - //~ if (!isspacechar(ch)) - //~ visibleChars++; } + // Fill in the real level of the next line, keeping the current flags as they will be filled in later - int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; - styler.SetLevel(lineCurrent, levelPrev | flagsNext); + styler.SetLevel(currentLine, + previousLevel + | (styler.LevelAt(currentLine) & ~SC_FOLDLEVELNUMBERMASK)); } static const char * const erlangWordListDesc[] = { - "Keywords", + "Erlang Reserved words", + "Erlang BIFs", + "Erlang Preprocessor", + "Erlang Module Attributes", + "Erlang Documentation", + "Erlang Documentation Macro", 0 }; LexerModule lmErlang( - SCLEX_ERLANG, - ColouriseErlangDoc, - "erlang", - FoldErlangDoc, - erlangWordListDesc); - + SCLEX_ERLANG, + ColouriseErlangDoc, + "erlang", + FoldErlangDoc, + erlangWordListDesc); diff --git a/src/stc/scintilla/src/LexForth.cxx b/src/stc/scintilla/src/LexForth.cxx index f097b0e00a..e52543fa55 100644 --- a/src/stc/scintilla/src/LexForth.cxx +++ b/src/stc/scintilla/src/LexForth.cxx @@ -1,10 +1,8 @@ // Scintilla source code edit control -/** @file LexCrontab.cxx - ** Lexer to use with extended crontab files used by a powerful - ** Windows scheduler/event monitor/automation manager nnCron. - ** (http://nemtsev.eserv.ru/) +/** @file LexForth.cxx + ** Lexer for FORTH **/ -// Copyright 1998-2001 by Neil Hodgson +// Copyright 1998-2003 by Neil Hodgson // The License.txt file describes the conditions under which this software may be distributed. #include @@ -17,6 +15,7 @@ #include "PropSet.h" #include "Accessor.h" +#include "StyleContext.h" #include "KeyWords.h" #include "Scintilla.h" #include "SciLexer.h" @@ -25,100 +24,29 @@ using namespace Scintilla; #endif -bool is_whitespace(int ch){ - return ch == '\n' || ch == '\r' || ch == '\t' || ch == ' '; +static inline bool IsAWordChar(int ch) { + return (ch < 0x80) && (isalnum(ch) || ch == '.' || + ch == '_' || ch == '?' || ch == '"' || ch == '@' || + ch == '!' || ch == '[' || ch == ']' || ch == '/' || + ch == '+' || ch == '-' || ch == '*' || ch == '<' || + ch == '>' || ch == '=' || ch == ';' || ch == '(' || + ch == ')' ); } -bool is_blank(int ch){ - return ch == '\t' || ch == ' '; +static inline bool IsAWordStart(int ch) { + return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '.'); } -//#define FORTH_DEBUG -#ifdef FORTH_DEBUG -static FILE *f_debug; -#define log(x) fputs(f_debug,x); -#else -#define log(x) -#endif - -#define STATE_LOCALE -#define BL ' ' -static Accessor *st; -static int cur_pos,pos1,pos2,pos0,lengthDoc; -char *buffer; - -char getChar(bool is_bl){ - char ch=st->SafeGetCharAt(cur_pos); - if(is_bl) if(is_whitespace(ch)) ch=BL; - return ch; +static inline bool IsANumChar(int ch) { + return (ch < 0x80) && (isxdigit(ch) || ch == '.' || ch == 'e' || ch == 'E' ); } -char getCharBL(){ - char ch=st->SafeGetCharAt(cur_pos); - return ch; -} -bool is_eol(char ch){ - return ch=='\n' || ch=='\r'; -} - -int parse(char ch, bool skip_eol){ -// pos1 - start pos of word -// pos2 - pos after of word -// pos0 - start pos - char c=0; - int len; - bool is_bl=ch==BL; - pos0=pos1=pos2=cur_pos; - for(;cur_pos9 && base>10) digit-=7; - if(digit<0) return false; - if(digit>=base) return false; - } - return true; -} - -bool is_number(char *s){ - if(strncmp(s,"0x",2)==0) return _is_number(s+2,16); - return _is_number(s,10); -} - -static void ColouriseForthDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler) -{ - st=&styler; - cur_pos=startPos; - lengthDoc = startPos + length; - buffer = new char[length]; - -#ifdef FORTH_DEBUG - f_debug=fopen("c:\\sci.log","at"); -#endif +static void ColouriseForthDoc(unsigned int startPos, int length, int initStyle, WordList *keywordLists[], + Accessor &styler) { WordList &control = *keywordLists[0]; WordList &keyword = *keywordLists[1]; @@ -127,226 +55,122 @@ static void ColouriseForthDoc(unsigned int startPos, int length, int, WordList * WordList &preword2 = *keywordLists[4]; WordList &strings = *keywordLists[5]; - // go through all provided text segment - // using the hand-written state machine shown below - styler.StartAt(startPos); - styler.StartSegment(startPos); - while(parse(BL,true)!=0){ - if(pos0!=pos1){ - styler.ColourTo(pos0,SCE_FORTH_DEFAULT); - styler.ColourTo(pos1-1,SCE_FORTH_DEFAULT); - } - if(strcmp("\\",buffer)==0){ - styler.ColourTo(pos1,SCE_FORTH_COMMENT); - parse(1,false); - styler.ColourTo(pos2,SCE_FORTH_COMMENT); - }else if(strcmp("(",buffer)==0){ - styler.ColourTo(pos1,SCE_FORTH_COMMENT); - parse(')',true); - if(cur_pos 72)) { - if (toLineStart == 0 && (tolower(sc.ch) == 'c' || sc.ch == '*') || sc.ch == '!') { - sc.SetState(SCE_F_COMMENT); + if ((toLineStart == 0 && (tolower(sc.ch) == 'c' || sc.ch == '*')) || sc.ch == '!') { + if (sc.MatchIgnoreCase("cdec$") || sc.MatchIgnoreCase("*dec$") || sc.MatchIgnoreCase("!dec$") || + sc.MatchIgnoreCase("cdir$") || sc.MatchIgnoreCase("*dir$") || sc.MatchIgnoreCase("!dir$") || + sc.MatchIgnoreCase("cms$") || sc.MatchIgnoreCase("*ms$") || sc.MatchIgnoreCase("!ms$") || + sc.chNext == '$') { + sc.SetState(SCE_F_PREPROCESSOR); + } else { + sc.SetState(SCE_F_COMMENT); + } + while (!sc.atLineEnd && sc.More()) sc.Forward(); // Until line end } else if (toLineStart > 72) { sc.SetState(SCE_F_COMMENT); @@ -198,7 +206,8 @@ static void ColouriseFortranDoc(unsigned int startPos, int length, int initStyle // Determine if a new state should be entered. if (sc.state == SCE_F_DEFAULT) { if (sc.ch == '!') { - if (sc.chNext == '$') { + if (sc.MatchIgnoreCase("!dec$") || sc.MatchIgnoreCase("!dir$") || + sc.MatchIgnoreCase("!ms$") || sc.chNext == '$') { sc.SetState(SCE_F_PREPROCESSOR); } else { sc.SetState(SCE_F_COMMENT); @@ -243,7 +252,7 @@ static int classifyFoldPointFortran(const char* s, const char* prevWord, const c lev = 0; else lev = 1; - } else if (strcmp(s, "end") == 0 && chNextNonBlank != '=' + } else if ((strcmp(s, "end") == 0 && chNextNonBlank != '=') || strcmp(s, "endassociate") == 0 || strcmp(s, "endblock") == 0 || strcmp(s, "endblockdata") == 0 || strcmp(s, "endselect") == 0 || strcmp(s, "enddo") == 0 || strcmp(s, "endenum") ==0 diff --git a/src/stc/scintilla/src/LexGen.py b/src/stc/scintilla/src/LexGen.py new file mode 100644 index 0000000000..571332e6e3 --- /dev/null +++ b/src/stc/scintilla/src/LexGen.py @@ -0,0 +1,288 @@ +# LexGen.py - implemented 2002 by Neil Hodgson neilh@scintilla.org +# Released to the public domain. + +# Regenerate the Scintilla and SciTE source files that list +# all the lexers and all the properties files. +# Should be run whenever a new lexer is added or removed. +# Requires Python 2.4 or later +# Most files are regenerated in place with templates stored in comments. +# The VS .NET project file is generated into a different file as the +# VS .NET environment will not retain comments when modifying the file. +# The files are copied to a string apart from sections between a +# ++Autogenerated comment and a --Autogenerated comment which is +# generated by the CopyWithInsertion function. After the whole +# string is instantiated, it is compared with the target file and +# if different the file is rewritten. +# Does not regenerate the Visual C++ 6 project files but does the VS .NET +# project file. + +import string +import sys +import os +import glob + +# EOL constants +CR = "\r" +LF = "\n" +CRLF = "\r\n" +if sys.platform == "win32": + NATIVE = CRLF +else: + # Yes, LF is the native EOL even on Mac OS X. CR is just for + # Mac OS <=9 (a.k.a. "Mac Classic") + NATIVE = LF + +# Automatically generated sections contain start and end comments, +# a definition line and the results. +# The results are replaced by regenerating based on the definition line. +# The definition line is a comment prefix followed by "**". +# If there is a digit after the ** then this indicates which list to use +# and the digit and next character are not part of the definition +# Backslash is used as an escape within the definition line. +# The part between \( and \) is repeated for each item in the list. +# \* is replaced by each list item. \t, and \n are tab and newline. +def CopyWithInsertion(input, commentPrefix, retainDefs, eolType, *lists): + copying = 1 + listid = 0 + output = [] + for line in input.splitlines(0): + isStartGenerated = line.startswith(commentPrefix + "++Autogenerated") + if copying and not isStartGenerated: + output.append(line) + if isStartGenerated: + if retainDefs: + output.append(line) + copying = 0 + definition = "" + elif not copying and line.startswith(commentPrefix + "**"): + if retainDefs: + output.append(line) + definition = line[len(commentPrefix + "**"):] + if (commentPrefix == "" in definition): + definition = definition.replace(" -->", "") + listid = 0 + if definition[0] in string.digits: + listid = int(definition[:1]) + definition = definition[2:] + # Hide double slashes as a control character + definition = definition.replace("\\\\", "\001") + # Do some normal C style transforms + definition = definition.replace("\\n", "\n") + definition = definition.replace("\\t", "\t") + # Get the doubled backslashes back as single backslashes + definition = definition.replace("\001", "\\") + startRepeat = definition.find("\\(") + endRepeat = definition.find("\\)") + intro = definition[:startRepeat] + out = "" + if intro.endswith("\n"): + pos = 0 + else: + pos = len(intro) + out += intro + middle = definition[startRepeat+2:endRepeat] + for i in lists[listid]: + item = middle.replace("\\*", i) + if pos and (pos + len(item) >= 80): + out += "\\\n" + pos = 0 + out += item + pos += len(item) + if item.endswith("\n"): + pos = 0 + outro = definition[endRepeat+2:] + out += outro + out = out.replace("\n", eolType) # correct EOLs in generated content + output.append(out) + elif line.startswith(commentPrefix + "--Autogenerated"): + copying = 1 + if retainDefs: + output.append(line) + output = [line.rstrip(" \t") for line in output] # trim trailing whitespace + return eolType.join(output) + eolType + +def UpdateFile(filename, updated): + """ If the file is different to updated then copy updated + into the file else leave alone so CVS and make don't treat + it as modified. """ + try: + infile = open(filename, "rb") + except IOError: # File is not there yet + out = open(filename, "wb") + out.write(updated.encode('utf-8')) + out.close() + print("New %s" % filename) + return + original = infile.read() + infile.close() + original = original.decode('utf-8') + if updated != original: + os.unlink(filename) + out = open(filename, "wb") + out.write(updated.encode('utf-8')) + out.close() + print("Changed %s " % filename) + #~ else: + #~ print "Unchanged", filename + +def Generate(inpath, outpath, commentPrefix, eolType, *lists): + """Generate 'outpath' from 'inpath'. + + "eolType" indicates the type of EOLs to use in the generated + file. It should be one of following constants: LF, CRLF, + CR, or NATIVE. + """ + #print "generate '%s' -> '%s' (comment prefix: %r, eols: %r)"\ + # % (inpath, outpath, commentPrefix, eolType) + try: + infile = open(inpath, "rb") + except IOError: + print("Can not open %s" % inpath) + return + original = infile.read() + infile.close() + original = original.decode('utf-8') + updated = CopyWithInsertion(original, commentPrefix, + inpath == outpath, eolType, *lists) + UpdateFile(outpath, updated) + +def Regenerate(filename, commentPrefix, eolType, *lists): + """Regenerate the given file. + + "eolType" indicates the type of EOLs to use in the generated + file. It should be one of following constants: LF, CRLF, + CR, or NATIVE. + """ + Generate(filename, filename, commentPrefix, eolType, *lists) + +def FindModules(lexFile): + modules = [] + f = open(lexFile) + for l in f.readlines(): + if l.startswith("LexerModule"): + l = l.replace("(", " ") + modules.append(l.split()[1]) + return modules + +knownIrregularProperties = [ + "fold", + "styling.within.preprocessor", + "tab.timmy.whinge.level", + "asp.default.language", + "html.tags.case.sensitive", + "ps.level", + "ps.tokenize", + "sql.backslash.escapes", + "nsis.uservars", + "nsis.ignorecase" +] + +def FindProperties(lexFile): + properties = {} + f = open(lexFile) + for l in f.readlines(): + if "GetProperty" in l: + l = l.strip() + if not l.startswith("//"): # Drop comments + propertyName = l.split("\"")[1] + if propertyName.lower() == propertyName: + # Only allow lower case property names + if propertyName in knownIrregularProperties or \ + propertyName.startswith("fold.") or \ + propertyName.startswith("lexer."): + properties[propertyName] = 1 + return properties + +def FindPropertyDocumentation(lexFile): + documents = {} + f = open(lexFile) + name = "" + for l in f.readlines(): + l = l.strip() + if "// property " in l: + propertyName = l.split()[2] + if propertyName.lower() == propertyName: + # Only allow lower case property names + name = propertyName + documents[name] = "" + elif name: + if l.startswith("//"): + if documents[name]: + documents[name] += " " + documents[name] += l[2:].strip() + else: + name = "" + return documents + +def ciCompare(a,b): + return cmp(a.lower(), b.lower()) + +def ciKey(a): + return a.lower() + +def sortListInsensitive(l): + try: # Try key function + l.sort(key=ciKey) + except TypeError: # Earlier version of Python, so use comparison function + l.sort(ciCompare) + +def RegenerateAll(): + root="../../" + + # Find all the lexer source code files + lexFilePaths = glob.glob(root + "scintilla/src/Lex*.cxx") + sortListInsensitive(lexFilePaths) + lexFiles = [os.path.basename(f)[:-4] for f in lexFilePaths] + print(lexFiles) + lexerModules = [] + lexerProperties = {} + propertyDocuments = {} + for lexFile in lexFilePaths: + lexerModules.extend(FindModules(lexFile)) + for k in FindProperties(lexFile).keys(): + lexerProperties[k] = 1 + documents = FindPropertyDocumentation(lexFile) + for k in documents.keys(): + propertyDocuments[k] = documents[k] + sortListInsensitive(lexerModules) + del lexerProperties["fold.comment.python"] + lexerProperties = list(lexerProperties.keys()) + sortListInsensitive(lexerProperties) + + # Generate HTML to document each property + # This is done because tags can not be safely put inside comments in HTML + documentProperties = list(propertyDocuments.keys()) + sortListInsensitive(documentProperties) + propertiesHTML = [] + for k in documentProperties: + propertiesHTML.append("\t\n\t%s\n\t%s\n\t" % + (k, propertyDocuments[k])) + + # Find all the SciTE properties files + otherProps = ["abbrev.properties", "Embedded.properties", "SciTEGlobal.properties", "SciTE.properties"] + if os.path.exists(root + "scite"): + propFilePaths = glob.glob(root + "scite/src/*.properties") + sortListInsensitive(propFilePaths) + propFiles = [os.path.basename(f) for f in propFilePaths if os.path.basename(f) not in otherProps] + sortListInsensitive(propFiles) + print(propFiles) + + Regenerate(root + "scintilla/src/KeyWords.cxx", "//", NATIVE, lexerModules) + Regenerate(root + "scintilla/win32/makefile", "#", NATIVE, lexFiles) + Regenerate(root + "scintilla/win32/scintilla.mak", "#", NATIVE, lexFiles) + Regenerate(root + "scintilla/win32/scintilla_vc6.mak", "#", NATIVE, lexFiles) + # Use Unix EOLs for gtk Makefiles so they work for Linux users when + # extracted from the Scintilla source ZIP (typically created on + # Windows). + Regenerate(root + "scintilla/gtk/makefile", "#", LF, lexFiles) + Regenerate(root + "scintilla/gtk/scintilla.mak", "#", NATIVE, lexFiles) + Regenerate(root + "scintilla/macosx/makefile", "#", LF, lexFiles) + if os.path.exists(root + "scite"): + Regenerate(root + "scite/win32/makefile", "#", NATIVE, lexFiles, propFiles) + Regenerate(root + "scite/win32/scite.mak", "#", NATIVE, lexFiles, propFiles) + Regenerate(root + "scite/src/SciTEProps.cxx", "//", NATIVE, lexerProperties) + Regenerate(root + "scite/doc/SciTEDoc.html", "")) { - sc.Forward(); - sc.Forward(); - sc.ForwardSetState(SCE_H_DEFAULT); - } - } else if (sc.state == SCE_H_ENTITY) { - if (sc.ch == ';') { - sc.ForwardSetState(SCE_H_DEFAULT); - } else if (sc.ch != '#' && (sc.ch < 0x80) && !isalnum(sc.ch) // Should check that '#' follows '&', but it is unlikely anyway... - && sc.ch != '.' && sc.ch != '-' && sc.ch != '_' && sc.ch != ':') { // valid in XML - sc.ChangeState(SCE_H_TAGUNKNOWN); - sc.SetState(SCE_H_DEFAULT); - } - } else if (sc.state == SCE_H_TAGUNKNOWN) { - if (!ishtmlwordchar(sc.ch) && !((sc.ch == '/') && (sc.chPrev == '<')) && sc.ch != '[') { - char s[100]; - sc.GetCurrentLowered(s, sizeof(s)); - if (s[1] == '/') { - if (keywordsTags.InList(s + 2)) { - sc.ChangeState(SCE_H_TAG); - } - } else { - if (keywordsTags.InList(s + 1)) { - sc.ChangeState(SCE_H_TAG); - } - } - if (sc.ch == '>') { - sc.ForwardSetState(SCE_H_DEFAULT); - } else if (sc.Match('/', '>')) { - sc.SetState(SCE_H_TAGEND); - sc.Forward(); - sc.ForwardSetState(SCE_H_DEFAULT); - } else { - sc.SetState(SCE_H_OTHER); - } - } - } else if (sc.state == SCE_H_ATTRIBUTE) { - if (!ishtmlwordchar(sc.ch)) { - char s[100]; - sc.GetCurrentLowered(s, sizeof(s)); - if (!keywordsTags.InList(s)) { - sc.ChangeState(SCE_H_ATTRIBUTEUNKNOWN); - } - sc.SetState(SCE_H_OTHER); - } - } else if (sc.state == SCE_H_OTHER) { - if (sc.ch == '>') { - sc.SetState(SCE_H_TAG); - sc.ForwardSetState(SCE_H_DEFAULT); - } else if (sc.Match('/', '>')) { - sc.SetState(SCE_H_TAG); - sc.Forward(); - sc.ForwardSetState(SCE_H_DEFAULT); - } else if (sc.chPrev == '=') { - sc.SetState(SCE_H_VALUE); - } - } else if (sc.state == SCE_H_DOUBLESTRING) { - if (sc.ch == '\"') { - sc.ForwardSetState(SCE_H_OTHER); - } - } else if (sc.state == SCE_H_SINGLESTRING) { - if (sc.ch == '\'') { - sc.ForwardSetState(SCE_H_OTHER); - } - } else if (sc.state == SCE_H_NUMBER) { - if (!IsADigit(sc.ch)) { - sc.SetState(SCE_H_OTHER); - } - } - - if (sc.state == SCE_H_DEFAULT) { - if (sc.ch == '<') { - if (sc.Match("