wxscintilla_CellBuffer.o \
wxscintilla_CharClassify.o \
wxscintilla_ContractionState.o \
+ wxscintilla_Decoration.o \
wxscintilla_Document.o \
wxscintilla_DocumentAccessor.o \
wxscintilla_Editor.o \
wxscintilla_KeyWords.o \
wxscintilla_LexAPDL.o \
wxscintilla_LexAU3.o \
+ wxscintilla_LexASY.o \
wxscintilla_LexAVE.o \
+ wxscintilla_LexAbaqus.o \
wxscintilla_LexAda.o \
wxscintilla_LexAsm.o \
wxscintilla_LexAsn1.o \
wxscintilla_LexBasic.o \
wxscintilla_LexBullant.o \
wxscintilla_LexCLW.o \
+ wxscintilla_LexCmake.o \
wxscintilla_LexCPP.o \
wxscintilla_LexCSS.o \
wxscintilla_LexCaml.o \
wxscintilla_LexCsound.o \
wxscintilla_LexConf.o \
wxscintilla_LexCrontab.o \
+ wxscintilla_LexD.o \
wxscintilla_LexEScript.o \
wxscintilla_LexEiffel.o \
wxscintilla_LexErlang.o \
wxscintilla_LexFlagship.o \
wxscintilla_LexForth.o \
wxscintilla_LexFortran.o \
+ wxscintilla_LexGAP.o \
wxscintilla_LexGui4Cli.o \
wxscintilla_LexHTML.o \
wxscintilla_LexHaskell.o \
wxscintilla_LexOpal.o \
wxscintilla_LexOthers.o \
wxscintilla_LexPB.o \
+ wxscintilla_LexPLM.o \
wxscintilla_LexPOV.o \
+ wxscintilla_LexProgress.o \
wxscintilla_LexPS.o \
wxscintilla_LexPascal.o \
wxscintilla_LexPerl.o \
wxscintilla_LexPython.o \
+ wxscintilla_LexR.o \
wxscintilla_LexRebol.o \
wxscintilla_LexRuby.o \
wxscintilla_LexSQL.o \
wxscintilla_LexVerilog.o \
wxscintilla_LexYAML.o \
wxscintilla_LineMarker.o \
+ wxscintilla_PositionCache.o \
wxscintilla_PropSet.o \
wxscintilla_RESearch.o \
+ wxscintilla_RunStyles.o \
wxscintilla_ScintillaBase.o \
wxscintilla_Style.o \
wxscintilla_StyleContext.o \
wxscintilla_ContractionState.o: $(srcdir)/src/stc/scintilla/src/ContractionState.cxx
$(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/ContractionState.cxx
+wxscintilla_Decoration.o: $(srcdir)/src/stc/scintilla/src/Decoration.cxx
+ $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/Decoration.cxx
+
wxscintilla_Document.o: $(srcdir)/src/stc/scintilla/src/Document.cxx
$(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/Document.cxx
wxscintilla_LexAU3.o: $(srcdir)/src/stc/scintilla/src/LexAU3.cxx
$(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexAU3.cxx
+wxscintilla_LexASY.o: $(srcdir)/src/stc/scintilla/src/LexASY.cxx
+ $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexASY.cxx
+
wxscintilla_LexAVE.o: $(srcdir)/src/stc/scintilla/src/LexAVE.cxx
$(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexAVE.cxx
+wxscintilla_LexAbaqus.o: $(srcdir)/src/stc/scintilla/src/LexAbaqus.cxx
+ $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexAbaqus.cxx
+
wxscintilla_LexAda.o: $(srcdir)/src/stc/scintilla/src/LexAda.cxx
$(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexAda.cxx
wxscintilla_LexCLW.o: $(srcdir)/src/stc/scintilla/src/LexCLW.cxx
$(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexCLW.cxx
+wxscintilla_LexCmake.o: $(srcdir)/src/stc/scintilla/src/LexCmake.cxx
+ $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexCmake.cxx
+
wxscintilla_LexCPP.o: $(srcdir)/src/stc/scintilla/src/LexCPP.cxx
$(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexCPP.cxx
wxscintilla_LexCrontab.o: $(srcdir)/src/stc/scintilla/src/LexCrontab.cxx
$(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexCrontab.cxx
+wxscintilla_LexD.o: $(srcdir)/src/stc/scintilla/src/LexD.cxx
+ $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexD.cxx
+
wxscintilla_LexEScript.o: $(srcdir)/src/stc/scintilla/src/LexEScript.cxx
$(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexEScript.cxx
wxscintilla_LexFortran.o: $(srcdir)/src/stc/scintilla/src/LexFortran.cxx
$(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexFortran.cxx
+wxscintilla_LexGAP.o: $(srcdir)/src/stc/scintilla/src/LexGAP.cxx
+ $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexGAP.cxx
+
wxscintilla_LexGui4Cli.o: $(srcdir)/src/stc/scintilla/src/LexGui4Cli.cxx
$(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexGui4Cli.cxx
wxscintilla_LexPB.o: $(srcdir)/src/stc/scintilla/src/LexPB.cxx
$(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexPB.cxx
+wxscintilla_LexPLM.o: $(srcdir)/src/stc/scintilla/src/LexPLM.cxx
+ $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexPLM.cxx
+
wxscintilla_LexPOV.o: $(srcdir)/src/stc/scintilla/src/LexPOV.cxx
$(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexPOV.cxx
+wxscintilla_LexProgress.o: $(srcdir)/src/stc/scintilla/src/LexProgress.cxx
+ $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexProgress.cxx
+
wxscintilla_LexPS.o: $(srcdir)/src/stc/scintilla/src/LexPS.cxx
$(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexPS.cxx
wxscintilla_LexPython.o: $(srcdir)/src/stc/scintilla/src/LexPython.cxx
$(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexPython.cxx
+wxscintilla_LexR.o: $(srcdir)/src/stc/scintilla/src/LexR.cxx
+ $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexR.cxx
+
wxscintilla_LexRebol.o: $(srcdir)/src/stc/scintilla/src/LexRebol.cxx
$(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LexRebol.cxx
wxscintilla_LineMarker.o: $(srcdir)/src/stc/scintilla/src/LineMarker.cxx
$(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/LineMarker.cxx
+wxscintilla_PositionCache.o: $(srcdir)/src/stc/scintilla/src/PositionCache.cxx
+ $(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/PositionCache.cxx
+
wxscintilla_PropSet.o: $(srcdir)/src/stc/scintilla/src/PropSet.cxx
$(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/PropSet.cxx
wxscintilla_RESearch.o: $(srcdir)/src/stc/scintilla/src/RESearch.cxx
$(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(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_ScintillaBase.o: $(srcdir)/src/stc/scintilla/src/ScintillaBase.cxx
$(CXXC) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(srcdir)/src/stc/scintilla/src/ScintillaBase.cxx
src/stc/scintilla/src/CellBuffer.cxx
src/stc/scintilla/src/CharClassify.cxx
src/stc/scintilla/src/ContractionState.cxx
+ src/stc/scintilla/src/Decoration.cxx
src/stc/scintilla/src/Document.cxx
src/stc/scintilla/src/DocumentAccessor.cxx
src/stc/scintilla/src/Editor.cxx
src/stc/scintilla/src/KeyWords.cxx
src/stc/scintilla/src/LexAPDL.cxx
src/stc/scintilla/src/LexAU3.cxx
+ src/stc/scintilla/src/LexASY.cxx
src/stc/scintilla/src/LexAVE.cxx
+ src/stc/scintilla/src/LexAbaqus.cxx
src/stc/scintilla/src/LexAda.cxx
src/stc/scintilla/src/LexAsm.cxx
src/stc/scintilla/src/LexAsn1.cxx
src/stc/scintilla/src/LexBasic.cxx
src/stc/scintilla/src/LexBullant.cxx
src/stc/scintilla/src/LexCLW.cxx
+ src/stc/scintilla/src/LexCmake.cxx
src/stc/scintilla/src/LexCPP.cxx
src/stc/scintilla/src/LexCSS.cxx
src/stc/scintilla/src/LexCaml.cxx
src/stc/scintilla/src/LexCsound.cxx
src/stc/scintilla/src/LexConf.cxx
src/stc/scintilla/src/LexCrontab.cxx
+ src/stc/scintilla/src/LexD.cxx
src/stc/scintilla/src/LexEScript.cxx
src/stc/scintilla/src/LexEiffel.cxx
src/stc/scintilla/src/LexErlang.cxx
src/stc/scintilla/src/LexFlagship.cxx
src/stc/scintilla/src/LexForth.cxx
src/stc/scintilla/src/LexFortran.cxx
+ src/stc/scintilla/src/LexGAP.cxx
src/stc/scintilla/src/LexGui4Cli.cxx
src/stc/scintilla/src/LexHTML.cxx
src/stc/scintilla/src/LexHaskell.cxx
src/stc/scintilla/src/LexOpal.cxx
src/stc/scintilla/src/LexOthers.cxx
src/stc/scintilla/src/LexPB.cxx
+ src/stc/scintilla/src/LexPLM.cxx
src/stc/scintilla/src/LexPOV.cxx
+ src/stc/scintilla/src/LexProgress.cxx
src/stc/scintilla/src/LexPS.cxx
src/stc/scintilla/src/LexPascal.cxx
src/stc/scintilla/src/LexPerl.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/LexVerilog.cxx
src/stc/scintilla/src/LexYAML.cxx
src/stc/scintilla/src/LineMarker.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/ScintillaBase.cxx
src/stc/scintilla/src/Style.cxx
src/stc/scintilla/src/StyleContext.cxx
$(OBJS)\wxscintilla_CellBuffer.obj \
$(OBJS)\wxscintilla_CharClassify.obj \
$(OBJS)\wxscintilla_ContractionState.obj \
+ $(OBJS)\wxscintilla_Decoration.obj \
$(OBJS)\wxscintilla_Document.obj \
$(OBJS)\wxscintilla_DocumentAccessor.obj \
$(OBJS)\wxscintilla_Editor.obj \
$(OBJS)\wxscintilla_KeyWords.obj \
$(OBJS)\wxscintilla_LexAPDL.obj \
$(OBJS)\wxscintilla_LexAU3.obj \
+ $(OBJS)\wxscintilla_LexASY.obj \
$(OBJS)\wxscintilla_LexAVE.obj \
+ $(OBJS)\wxscintilla_LexAbaqus.obj \
$(OBJS)\wxscintilla_LexAda.obj \
$(OBJS)\wxscintilla_LexAsm.obj \
$(OBJS)\wxscintilla_LexAsn1.obj \
$(OBJS)\wxscintilla_LexBasic.obj \
$(OBJS)\wxscintilla_LexBullant.obj \
$(OBJS)\wxscintilla_LexCLW.obj \
+ $(OBJS)\wxscintilla_LexCmake.obj \
$(OBJS)\wxscintilla_LexCPP.obj \
$(OBJS)\wxscintilla_LexCSS.obj \
$(OBJS)\wxscintilla_LexCaml.obj \
$(OBJS)\wxscintilla_LexCsound.obj \
$(OBJS)\wxscintilla_LexConf.obj \
$(OBJS)\wxscintilla_LexCrontab.obj \
+ $(OBJS)\wxscintilla_LexD.obj \
$(OBJS)\wxscintilla_LexEScript.obj \
$(OBJS)\wxscintilla_LexEiffel.obj \
$(OBJS)\wxscintilla_LexErlang.obj \
$(OBJS)\wxscintilla_LexFlagship.obj \
$(OBJS)\wxscintilla_LexForth.obj \
$(OBJS)\wxscintilla_LexFortran.obj \
+ $(OBJS)\wxscintilla_LexGAP.obj \
$(OBJS)\wxscintilla_LexGui4Cli.obj \
$(OBJS)\wxscintilla_LexHTML.obj \
$(OBJS)\wxscintilla_LexHaskell.obj \
$(OBJS)\wxscintilla_LexOpal.obj \
$(OBJS)\wxscintilla_LexOthers.obj \
$(OBJS)\wxscintilla_LexPB.obj \
+ $(OBJS)\wxscintilla_LexPLM.obj \
$(OBJS)\wxscintilla_LexPOV.obj \
+ $(OBJS)\wxscintilla_LexProgress.obj \
$(OBJS)\wxscintilla_LexPS.obj \
$(OBJS)\wxscintilla_LexPascal.obj \
$(OBJS)\wxscintilla_LexPerl.obj \
$(OBJS)\wxscintilla_LexPython.obj \
+ $(OBJS)\wxscintilla_LexR.obj \
$(OBJS)\wxscintilla_LexRebol.obj \
$(OBJS)\wxscintilla_LexRuby.obj \
$(OBJS)\wxscintilla_LexSQL.obj \
$(OBJS)\wxscintilla_LexVerilog.obj \
$(OBJS)\wxscintilla_LexYAML.obj \
$(OBJS)\wxscintilla_LineMarker.obj \
+ $(OBJS)\wxscintilla_PositionCache.obj \
$(OBJS)\wxscintilla_PropSet.obj \
$(OBJS)\wxscintilla_RESearch.obj \
+ $(OBJS)\wxscintilla_RunStyles.obj \
$(OBJS)\wxscintilla_ScintillaBase.obj \
$(OBJS)\wxscintilla_Style.obj \
$(OBJS)\wxscintilla_StyleContext.obj \
$(OBJS)\wxscintilla_ContractionState.obj: ..\..\src\stc\scintilla\src\ContractionState.cxx
$(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
+$(OBJS)\wxscintilla_Decoration.obj: ..\..\src\stc\scintilla\src\Decoration.cxx
+ $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
+
$(OBJS)\wxscintilla_Document.obj: ..\..\src\stc\scintilla\src\Document.cxx
$(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
$(OBJS)\wxscintilla_LexAU3.obj: ..\..\src\stc\scintilla\src\LexAU3.cxx
$(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
+$(OBJS)\wxscintilla_LexASY.obj: ..\..\src\stc\scintilla\src\LexASY.cxx
+ $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
+
$(OBJS)\wxscintilla_LexAVE.obj: ..\..\src\stc\scintilla\src\LexAVE.cxx
$(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
+$(OBJS)\wxscintilla_LexAbaqus.obj: ..\..\src\stc\scintilla\src\LexAbaqus.cxx
+ $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
+
$(OBJS)\wxscintilla_LexAda.obj: ..\..\src\stc\scintilla\src\LexAda.cxx
$(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
$(OBJS)\wxscintilla_LexCLW.obj: ..\..\src\stc\scintilla\src\LexCLW.cxx
$(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
+$(OBJS)\wxscintilla_LexCmake.obj: ..\..\src\stc\scintilla\src\LexCmake.cxx
+ $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
+
$(OBJS)\wxscintilla_LexCPP.obj: ..\..\src\stc\scintilla\src\LexCPP.cxx
$(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
$(OBJS)\wxscintilla_LexCrontab.obj: ..\..\src\stc\scintilla\src\LexCrontab.cxx
$(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
+$(OBJS)\wxscintilla_LexD.obj: ..\..\src\stc\scintilla\src\LexD.cxx
+ $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
+
$(OBJS)\wxscintilla_LexEScript.obj: ..\..\src\stc\scintilla\src\LexEScript.cxx
$(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
$(OBJS)\wxscintilla_LexFortran.obj: ..\..\src\stc\scintilla\src\LexFortran.cxx
$(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
+$(OBJS)\wxscintilla_LexGAP.obj: ..\..\src\stc\scintilla\src\LexGAP.cxx
+ $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
+
$(OBJS)\wxscintilla_LexGui4Cli.obj: ..\..\src\stc\scintilla\src\LexGui4Cli.cxx
$(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
$(OBJS)\wxscintilla_LexPB.obj: ..\..\src\stc\scintilla\src\LexPB.cxx
$(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
+$(OBJS)\wxscintilla_LexPLM.obj: ..\..\src\stc\scintilla\src\LexPLM.cxx
+ $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
+
$(OBJS)\wxscintilla_LexPOV.obj: ..\..\src\stc\scintilla\src\LexPOV.cxx
$(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
+$(OBJS)\wxscintilla_LexProgress.obj: ..\..\src\stc\scintilla\src\LexProgress.cxx
+ $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
+
$(OBJS)\wxscintilla_LexPS.obj: ..\..\src\stc\scintilla\src\LexPS.cxx
$(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
$(OBJS)\wxscintilla_LexPython.obj: ..\..\src\stc\scintilla\src\LexPython.cxx
$(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
+$(OBJS)\wxscintilla_LexR.obj: ..\..\src\stc\scintilla\src\LexR.cxx
+ $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
+
$(OBJS)\wxscintilla_LexRebol.obj: ..\..\src\stc\scintilla\src\LexRebol.cxx
$(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
$(OBJS)\wxscintilla_LineMarker.obj: ..\..\src\stc\scintilla\src\LineMarker.cxx
$(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
+$(OBJS)\wxscintilla_PositionCache.obj: ..\..\src\stc\scintilla\src\PositionCache.cxx
+ $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
+
$(OBJS)\wxscintilla_PropSet.obj: ..\..\src\stc\scintilla\src\PropSet.cxx
$(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
$(OBJS)\wxscintilla_RESearch.obj: ..\..\src\stc\scintilla\src\RESearch.cxx
$(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
+$(OBJS)\wxscintilla_RunStyles.obj: ..\..\src\stc\scintilla\src\RunStyles.cxx
+ $(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
+
$(OBJS)\wxscintilla_ScintillaBase.obj: ..\..\src\stc\scintilla\src\ScintillaBase.cxx
$(CXX) -q -c -P -o$@ $(WXSCINTILLA_CXXFLAGS) $**
$(OBJS)\wxscintilla_CellBuffer.o \
$(OBJS)\wxscintilla_CharClassify.o \
$(OBJS)\wxscintilla_ContractionState.o \
+ $(OBJS)\wxscintilla_Decoration.o \
$(OBJS)\wxscintilla_Document.o \
$(OBJS)\wxscintilla_DocumentAccessor.o \
$(OBJS)\wxscintilla_Editor.o \
$(OBJS)\wxscintilla_KeyWords.o \
$(OBJS)\wxscintilla_LexAPDL.o \
$(OBJS)\wxscintilla_LexAU3.o \
+ $(OBJS)\wxscintilla_LexASY.o \
$(OBJS)\wxscintilla_LexAVE.o \
+ $(OBJS)\wxscintilla_LexAbaqus.o \
$(OBJS)\wxscintilla_LexAda.o \
$(OBJS)\wxscintilla_LexAsm.o \
$(OBJS)\wxscintilla_LexAsn1.o \
$(OBJS)\wxscintilla_LexBasic.o \
$(OBJS)\wxscintilla_LexBullant.o \
$(OBJS)\wxscintilla_LexCLW.o \
+ $(OBJS)\wxscintilla_LexCmake.o \
$(OBJS)\wxscintilla_LexCPP.o \
$(OBJS)\wxscintilla_LexCSS.o \
$(OBJS)\wxscintilla_LexCaml.o \
$(OBJS)\wxscintilla_LexCsound.o \
$(OBJS)\wxscintilla_LexConf.o \
$(OBJS)\wxscintilla_LexCrontab.o \
+ $(OBJS)\wxscintilla_LexD.o \
$(OBJS)\wxscintilla_LexEScript.o \
$(OBJS)\wxscintilla_LexEiffel.o \
$(OBJS)\wxscintilla_LexErlang.o \
$(OBJS)\wxscintilla_LexFlagship.o \
$(OBJS)\wxscintilla_LexForth.o \
$(OBJS)\wxscintilla_LexFortran.o \
+ $(OBJS)\wxscintilla_LexGAP.o \
$(OBJS)\wxscintilla_LexGui4Cli.o \
$(OBJS)\wxscintilla_LexHTML.o \
$(OBJS)\wxscintilla_LexHaskell.o \
$(OBJS)\wxscintilla_LexOpal.o \
$(OBJS)\wxscintilla_LexOthers.o \
$(OBJS)\wxscintilla_LexPB.o \
+ $(OBJS)\wxscintilla_LexPLM.o \
$(OBJS)\wxscintilla_LexPOV.o \
+ $(OBJS)\wxscintilla_LexProgress.o \
$(OBJS)\wxscintilla_LexPS.o \
$(OBJS)\wxscintilla_LexPascal.o \
$(OBJS)\wxscintilla_LexPerl.o \
$(OBJS)\wxscintilla_LexPython.o \
+ $(OBJS)\wxscintilla_LexR.o \
$(OBJS)\wxscintilla_LexRebol.o \
$(OBJS)\wxscintilla_LexRuby.o \
$(OBJS)\wxscintilla_LexSQL.o \
$(OBJS)\wxscintilla_LexVerilog.o \
$(OBJS)\wxscintilla_LexYAML.o \
$(OBJS)\wxscintilla_LineMarker.o \
+ $(OBJS)\wxscintilla_PositionCache.o \
$(OBJS)\wxscintilla_PropSet.o \
$(OBJS)\wxscintilla_RESearch.o \
+ $(OBJS)\wxscintilla_RunStyles.o \
$(OBJS)\wxscintilla_ScintillaBase.o \
$(OBJS)\wxscintilla_Style.o \
$(OBJS)\wxscintilla_StyleContext.o \
$(OBJS)\wxscintilla_ContractionState.o: ../../src/stc/scintilla/src/ContractionState.cxx
$(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
+$(OBJS)\wxscintilla_Decoration.o: ../../src/stc/scintilla/src/Decoration.cxx
+ $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
+
$(OBJS)\wxscintilla_Document.o: ../../src/stc/scintilla/src/Document.cxx
$(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\wxscintilla_LexAU3.o: ../../src/stc/scintilla/src/LexAU3.cxx
$(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
+$(OBJS)\wxscintilla_LexASY.o: ../../src/stc/scintilla/src/LexASY.cxx
+ $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
+
$(OBJS)\wxscintilla_LexAVE.o: ../../src/stc/scintilla/src/LexAVE.cxx
$(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
+$(OBJS)\wxscintilla_LexAbaqus.o: ../../src/stc/scintilla/src/LexAbaqus.cxx
+ $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
+
$(OBJS)\wxscintilla_LexAda.o: ../../src/stc/scintilla/src/LexAda.cxx
$(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\wxscintilla_LexCLW.o: ../../src/stc/scintilla/src/LexCLW.cxx
$(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
+$(OBJS)\wxscintilla_LexCmake.o: ../../src/stc/scintilla/src/LexCmake.cxx
+ $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
+
$(OBJS)\wxscintilla_LexCPP.o: ../../src/stc/scintilla/src/LexCPP.cxx
$(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\wxscintilla_LexCrontab.o: ../../src/stc/scintilla/src/LexCrontab.cxx
$(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
+$(OBJS)\wxscintilla_LexD.o: ../../src/stc/scintilla/src/LexD.cxx
+ $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
+
$(OBJS)\wxscintilla_LexEScript.o: ../../src/stc/scintilla/src/LexEScript.cxx
$(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\wxscintilla_LexFortran.o: ../../src/stc/scintilla/src/LexFortran.cxx
$(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
+$(OBJS)\wxscintilla_LexGAP.o: ../../src/stc/scintilla/src/LexGAP.cxx
+ $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
+
$(OBJS)\wxscintilla_LexGui4Cli.o: ../../src/stc/scintilla/src/LexGui4Cli.cxx
$(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\wxscintilla_LexPB.o: ../../src/stc/scintilla/src/LexPB.cxx
$(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
+$(OBJS)\wxscintilla_LexPLM.o: ../../src/stc/scintilla/src/LexPLM.cxx
+ $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
+
$(OBJS)\wxscintilla_LexPOV.o: ../../src/stc/scintilla/src/LexPOV.cxx
$(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
+$(OBJS)\wxscintilla_LexProgress.o: ../../src/stc/scintilla/src/LexProgress.cxx
+ $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
+
$(OBJS)\wxscintilla_LexPS.o: ../../src/stc/scintilla/src/LexPS.cxx
$(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\wxscintilla_LexPython.o: ../../src/stc/scintilla/src/LexPython.cxx
$(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
+$(OBJS)\wxscintilla_LexR.o: ../../src/stc/scintilla/src/LexR.cxx
+ $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
+
$(OBJS)\wxscintilla_LexRebol.o: ../../src/stc/scintilla/src/LexRebol.cxx
$(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\wxscintilla_LineMarker.o: ../../src/stc/scintilla/src/LineMarker.cxx
$(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
+$(OBJS)\wxscintilla_PositionCache.o: ../../src/stc/scintilla/src/PositionCache.cxx
+ $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
+
$(OBJS)\wxscintilla_PropSet.o: ../../src/stc/scintilla/src/PropSet.cxx
$(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\wxscintilla_RESearch.o: ../../src/stc/scintilla/src/RESearch.cxx
$(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
+$(OBJS)\wxscintilla_RunStyles.o: ../../src/stc/scintilla/src/RunStyles.cxx
+ $(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
+
$(OBJS)\wxscintilla_ScintillaBase.o: ../../src/stc/scintilla/src/ScintillaBase.cxx
$(CXX) -c -o $@ $(WXSCINTILLA_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\wxscintilla_CellBuffer.obj \
$(OBJS)\wxscintilla_CharClassify.obj \
$(OBJS)\wxscintilla_ContractionState.obj \
+ $(OBJS)\wxscintilla_Decoration.obj \
$(OBJS)\wxscintilla_Document.obj \
$(OBJS)\wxscintilla_DocumentAccessor.obj \
$(OBJS)\wxscintilla_Editor.obj \
$(OBJS)\wxscintilla_KeyWords.obj \
$(OBJS)\wxscintilla_LexAPDL.obj \
$(OBJS)\wxscintilla_LexAU3.obj \
+ $(OBJS)\wxscintilla_LexASY.obj \
$(OBJS)\wxscintilla_LexAVE.obj \
+ $(OBJS)\wxscintilla_LexAbaqus.obj \
$(OBJS)\wxscintilla_LexAda.obj \
$(OBJS)\wxscintilla_LexAsm.obj \
$(OBJS)\wxscintilla_LexAsn1.obj \
$(OBJS)\wxscintilla_LexBasic.obj \
$(OBJS)\wxscintilla_LexBullant.obj \
$(OBJS)\wxscintilla_LexCLW.obj \
+ $(OBJS)\wxscintilla_LexCmake.obj \
$(OBJS)\wxscintilla_LexCPP.obj \
$(OBJS)\wxscintilla_LexCSS.obj \
$(OBJS)\wxscintilla_LexCaml.obj \
$(OBJS)\wxscintilla_LexCsound.obj \
$(OBJS)\wxscintilla_LexConf.obj \
$(OBJS)\wxscintilla_LexCrontab.obj \
+ $(OBJS)\wxscintilla_LexD.obj \
$(OBJS)\wxscintilla_LexEScript.obj \
$(OBJS)\wxscintilla_LexEiffel.obj \
$(OBJS)\wxscintilla_LexErlang.obj \
$(OBJS)\wxscintilla_LexFlagship.obj \
$(OBJS)\wxscintilla_LexForth.obj \
$(OBJS)\wxscintilla_LexFortran.obj \
+ $(OBJS)\wxscintilla_LexGAP.obj \
$(OBJS)\wxscintilla_LexGui4Cli.obj \
$(OBJS)\wxscintilla_LexHTML.obj \
$(OBJS)\wxscintilla_LexHaskell.obj \
$(OBJS)\wxscintilla_LexOpal.obj \
$(OBJS)\wxscintilla_LexOthers.obj \
$(OBJS)\wxscintilla_LexPB.obj \
+ $(OBJS)\wxscintilla_LexPLM.obj \
$(OBJS)\wxscintilla_LexPOV.obj \
+ $(OBJS)\wxscintilla_LexProgress.obj \
$(OBJS)\wxscintilla_LexPS.obj \
$(OBJS)\wxscintilla_LexPascal.obj \
$(OBJS)\wxscintilla_LexPerl.obj \
$(OBJS)\wxscintilla_LexPython.obj \
+ $(OBJS)\wxscintilla_LexR.obj \
$(OBJS)\wxscintilla_LexRebol.obj \
$(OBJS)\wxscintilla_LexRuby.obj \
$(OBJS)\wxscintilla_LexSQL.obj \
$(OBJS)\wxscintilla_LexVerilog.obj \
$(OBJS)\wxscintilla_LexYAML.obj \
$(OBJS)\wxscintilla_LineMarker.obj \
+ $(OBJS)\wxscintilla_PositionCache.obj \
$(OBJS)\wxscintilla_PropSet.obj \
$(OBJS)\wxscintilla_RESearch.obj \
+ $(OBJS)\wxscintilla_RunStyles.obj \
$(OBJS)\wxscintilla_ScintillaBase.obj \
$(OBJS)\wxscintilla_Style.obj \
$(OBJS)\wxscintilla_StyleContext.obj \
-if exist $(LIBDIRNAME)\wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gl.lib del $(LIBDIRNAME)\wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gl.lib
cd ..\..\samples
$(MAKE) -f makefile.vc $(MAKEARGS) clean
- cd "$(MAKEDIR)"
+ cd $(MAKEDIR)
setup_h: $(SETUPHDIR)\wx ..\..\include\wx\$(__SETUP_H_SUBDIR_FILENAMES)\setup.h $(SETUPHDIR)\wx\setup.h $(SETUPHDIR)\wx\msw\rcdefs.h
sub_samples:
cd ..\..\samples
$(MAKE) -f makefile.vc $(MAKEARGS) all
- cd "$(MAKEDIR)"
+ cd $(MAKEDIR)
$(LIBDIRNAME):
if not exist $(LIBDIRNAME) mkdir $(LIBDIRNAME)
$(OBJS)\wxscintilla_ContractionState.obj: ..\..\src\stc\scintilla\src\ContractionState.cxx
$(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
+$(OBJS)\wxscintilla_Decoration.obj: ..\..\src\stc\scintilla\src\Decoration.cxx
+ $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
+
$(OBJS)\wxscintilla_Document.obj: ..\..\src\stc\scintilla\src\Document.cxx
$(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
$(OBJS)\wxscintilla_LexAU3.obj: ..\..\src\stc\scintilla\src\LexAU3.cxx
$(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
+$(OBJS)\wxscintilla_LexASY.obj: ..\..\src\stc\scintilla\src\LexASY.cxx
+ $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
+
$(OBJS)\wxscintilla_LexAVE.obj: ..\..\src\stc\scintilla\src\LexAVE.cxx
$(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
+$(OBJS)\wxscintilla_LexAbaqus.obj: ..\..\src\stc\scintilla\src\LexAbaqus.cxx
+ $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
+
$(OBJS)\wxscintilla_LexAda.obj: ..\..\src\stc\scintilla\src\LexAda.cxx
$(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
$(OBJS)\wxscintilla_LexCLW.obj: ..\..\src\stc\scintilla\src\LexCLW.cxx
$(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
+$(OBJS)\wxscintilla_LexCmake.obj: ..\..\src\stc\scintilla\src\LexCmake.cxx
+ $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
+
$(OBJS)\wxscintilla_LexCPP.obj: ..\..\src\stc\scintilla\src\LexCPP.cxx
$(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
$(OBJS)\wxscintilla_LexCrontab.obj: ..\..\src\stc\scintilla\src\LexCrontab.cxx
$(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
+$(OBJS)\wxscintilla_LexD.obj: ..\..\src\stc\scintilla\src\LexD.cxx
+ $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
+
$(OBJS)\wxscintilla_LexEScript.obj: ..\..\src\stc\scintilla\src\LexEScript.cxx
$(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
$(OBJS)\wxscintilla_LexFortran.obj: ..\..\src\stc\scintilla\src\LexFortran.cxx
$(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
+$(OBJS)\wxscintilla_LexGAP.obj: ..\..\src\stc\scintilla\src\LexGAP.cxx
+ $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
+
$(OBJS)\wxscintilla_LexGui4Cli.obj: ..\..\src\stc\scintilla\src\LexGui4Cli.cxx
$(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
$(OBJS)\wxscintilla_LexPB.obj: ..\..\src\stc\scintilla\src\LexPB.cxx
$(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
+$(OBJS)\wxscintilla_LexPLM.obj: ..\..\src\stc\scintilla\src\LexPLM.cxx
+ $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
+
$(OBJS)\wxscintilla_LexPOV.obj: ..\..\src\stc\scintilla\src\LexPOV.cxx
$(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
+$(OBJS)\wxscintilla_LexProgress.obj: ..\..\src\stc\scintilla\src\LexProgress.cxx
+ $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
+
$(OBJS)\wxscintilla_LexPS.obj: ..\..\src\stc\scintilla\src\LexPS.cxx
$(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
$(OBJS)\wxscintilla_LexPython.obj: ..\..\src\stc\scintilla\src\LexPython.cxx
$(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
+$(OBJS)\wxscintilla_LexR.obj: ..\..\src\stc\scintilla\src\LexR.cxx
+ $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
+
$(OBJS)\wxscintilla_LexRebol.obj: ..\..\src\stc\scintilla\src\LexRebol.cxx
$(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
$(OBJS)\wxscintilla_LineMarker.obj: ..\..\src\stc\scintilla\src\LineMarker.cxx
$(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
+$(OBJS)\wxscintilla_PositionCache.obj: ..\..\src\stc\scintilla\src\PositionCache.cxx
+ $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
+
$(OBJS)\wxscintilla_PropSet.obj: ..\..\src\stc\scintilla\src\PropSet.cxx
$(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
$(OBJS)\wxscintilla_RESearch.obj: ..\..\src\stc\scintilla\src\RESearch.cxx
$(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
+$(OBJS)\wxscintilla_RunStyles.obj: ..\..\src\stc\scintilla\src\RunStyles.cxx
+ $(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
+
$(OBJS)\wxscintilla_ScintillaBase.obj: ..\..\src\stc\scintilla\src\ScintillaBase.cxx
$(CXX) /c /nologo /TP /Fo$@ $(WXSCINTILLA_CXXFLAGS) $**
$(OBJS)\wxscintilla_CellBuffer.obj &
$(OBJS)\wxscintilla_CharClassify.obj &
$(OBJS)\wxscintilla_ContractionState.obj &
+ $(OBJS)\wxscintilla_Decoration.obj &
$(OBJS)\wxscintilla_Document.obj &
$(OBJS)\wxscintilla_DocumentAccessor.obj &
$(OBJS)\wxscintilla_Editor.obj &
$(OBJS)\wxscintilla_KeyWords.obj &
$(OBJS)\wxscintilla_LexAPDL.obj &
$(OBJS)\wxscintilla_LexAU3.obj &
+ $(OBJS)\wxscintilla_LexASY.obj &
$(OBJS)\wxscintilla_LexAVE.obj &
+ $(OBJS)\wxscintilla_LexAbaqus.obj &
$(OBJS)\wxscintilla_LexAda.obj &
$(OBJS)\wxscintilla_LexAsm.obj &
$(OBJS)\wxscintilla_LexAsn1.obj &
$(OBJS)\wxscintilla_LexBasic.obj &
$(OBJS)\wxscintilla_LexBullant.obj &
$(OBJS)\wxscintilla_LexCLW.obj &
+ $(OBJS)\wxscintilla_LexCmake.obj &
$(OBJS)\wxscintilla_LexCPP.obj &
$(OBJS)\wxscintilla_LexCSS.obj &
$(OBJS)\wxscintilla_LexCaml.obj &
$(OBJS)\wxscintilla_LexCsound.obj &
$(OBJS)\wxscintilla_LexConf.obj &
$(OBJS)\wxscintilla_LexCrontab.obj &
+ $(OBJS)\wxscintilla_LexD.obj &
$(OBJS)\wxscintilla_LexEScript.obj &
$(OBJS)\wxscintilla_LexEiffel.obj &
$(OBJS)\wxscintilla_LexErlang.obj &
$(OBJS)\wxscintilla_LexFlagship.obj &
$(OBJS)\wxscintilla_LexForth.obj &
$(OBJS)\wxscintilla_LexFortran.obj &
+ $(OBJS)\wxscintilla_LexGAP.obj &
$(OBJS)\wxscintilla_LexGui4Cli.obj &
$(OBJS)\wxscintilla_LexHTML.obj &
$(OBJS)\wxscintilla_LexHaskell.obj &
$(OBJS)\wxscintilla_LexOpal.obj &
$(OBJS)\wxscintilla_LexOthers.obj &
$(OBJS)\wxscintilla_LexPB.obj &
+ $(OBJS)\wxscintilla_LexPLM.obj &
$(OBJS)\wxscintilla_LexPOV.obj &
+ $(OBJS)\wxscintilla_LexProgress.obj &
$(OBJS)\wxscintilla_LexPS.obj &
$(OBJS)\wxscintilla_LexPascal.obj &
$(OBJS)\wxscintilla_LexPerl.obj &
$(OBJS)\wxscintilla_LexPython.obj &
+ $(OBJS)\wxscintilla_LexR.obj &
$(OBJS)\wxscintilla_LexRebol.obj &
$(OBJS)\wxscintilla_LexRuby.obj &
$(OBJS)\wxscintilla_LexSQL.obj &
$(OBJS)\wxscintilla_LexVerilog.obj &
$(OBJS)\wxscintilla_LexYAML.obj &
$(OBJS)\wxscintilla_LineMarker.obj &
+ $(OBJS)\wxscintilla_PositionCache.obj &
$(OBJS)\wxscintilla_PropSet.obj &
$(OBJS)\wxscintilla_RESearch.obj &
+ $(OBJS)\wxscintilla_RunStyles.obj &
$(OBJS)\wxscintilla_ScintillaBase.obj &
$(OBJS)\wxscintilla_Style.obj &
$(OBJS)\wxscintilla_StyleContext.obj &
$(OBJS)\wxscintilla_ContractionState.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\ContractionState.cxx
$(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $<
+$(OBJS)\wxscintilla_Decoration.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\Decoration.cxx
+ $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $<
+
$(OBJS)\wxscintilla_Document.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\Document.cxx
$(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $<
$(OBJS)\wxscintilla_LexAU3.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexAU3.cxx
$(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $<
+$(OBJS)\wxscintilla_LexASY.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexASY.cxx
+ $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $<
+
$(OBJS)\wxscintilla_LexAVE.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexAVE.cxx
$(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $<
+$(OBJS)\wxscintilla_LexAbaqus.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexAbaqus.cxx
+ $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $<
+
$(OBJS)\wxscintilla_LexAda.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexAda.cxx
$(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $<
$(OBJS)\wxscintilla_LexCLW.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexCLW.cxx
$(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $<
+$(OBJS)\wxscintilla_LexCmake.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexCmake.cxx
+ $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $<
+
$(OBJS)\wxscintilla_LexCPP.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexCPP.cxx
$(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $<
$(OBJS)\wxscintilla_LexCrontab.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexCrontab.cxx
$(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $<
+$(OBJS)\wxscintilla_LexD.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexD.cxx
+ $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $<
+
$(OBJS)\wxscintilla_LexEScript.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexEScript.cxx
$(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $<
$(OBJS)\wxscintilla_LexFortran.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexFortran.cxx
$(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $<
+$(OBJS)\wxscintilla_LexGAP.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexGAP.cxx
+ $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $<
+
$(OBJS)\wxscintilla_LexGui4Cli.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexGui4Cli.cxx
$(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $<
$(OBJS)\wxscintilla_LexPB.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexPB.cxx
$(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $<
+$(OBJS)\wxscintilla_LexPLM.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexPLM.cxx
+ $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $<
+
$(OBJS)\wxscintilla_LexPOV.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexPOV.cxx
$(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $<
+$(OBJS)\wxscintilla_LexProgress.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexProgress.cxx
+ $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $<
+
$(OBJS)\wxscintilla_LexPS.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexPS.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) $<
+$(OBJS)\wxscintilla_LexR.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexR.cxx
+ $(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $<
+
$(OBJS)\wxscintilla_LexRebol.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LexRebol.cxx
$(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $<
$(OBJS)\wxscintilla_LineMarker.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\LineMarker.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) $<
+
$(OBJS)\wxscintilla_PropSet.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\PropSet.cxx
$(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $<
$(OBJS)\wxscintilla_RESearch.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\RESearch.cxx
$(CXX) -bt=nt -zq -fo=$^@ $(WXSCINTILLA_CXXFLAGS) $<
+$(OBJS)\wxscintilla_RunStyles.obj : .AUTODEPEND ..\..\src\stc\scintilla\src\RunStyles.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) $<
# End Source File\r
# Begin Source File\r
\r
+SOURCE=..\..\src\stc\scintilla\src\Decoration.cxx\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=..\..\src\stc\scintilla\src\Document.cxx\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
+SOURCE=..\..\src\stc\scintilla\src\LexASY.cxx\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=..\..\src\stc\scintilla\src\LexAU3.cxx\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
+SOURCE=..\..\src\stc\scintilla\src\LexAbaqus.cxx\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=..\..\src\stc\scintilla\src\LexAda.cxx\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
+SOURCE=..\..\src\stc\scintilla\src\LexCmake.cxx\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=..\..\src\stc\scintilla\src\LexConf.cxx\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
+SOURCE=..\..\src\stc\scintilla\src\LexD.cxx\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=..\..\src\stc\scintilla\src\LexEScript.cxx\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
+SOURCE=..\..\src\stc\scintilla\src\LexGAP.cxx\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=..\..\src\stc\scintilla\src\LexGui4Cli.cxx\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
+SOURCE=..\..\src\stc\scintilla\src\LexPLM.cxx\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=..\..\src\stc\scintilla\src\LexPOV.cxx\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
+SOURCE=..\..\src\stc\scintilla\src\LexProgress.cxx\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=..\..\src\stc\scintilla\src\LexPython.cxx\r
# End Source File\r
# Begin Source File\r
\r
+SOURCE=..\..\src\stc\scintilla\src\LexR.cxx\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=..\..\src\stc\scintilla\src\LexRebol.cxx\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
+SOURCE=..\..\src\stc\scintilla\src\PositionCache.cxx\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=..\..\src\stc\scintilla\src\PropSet.cxx\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
+SOURCE=..\..\src\stc\scintilla\src\RunStyles.cxx\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=..\..\src\stc\scintilla\src\ScintillaBase.cxx\r
# End Source File\r
# Begin Source File\r
#define wxSTC_STYLE_INDENTGUIDE 37
#define wxSTC_STYLE_CALLTIP 38
#define wxSTC_STYLE_LASTPREDEFINED 39
-#define wxSTC_STYLE_MAX 127
+#define wxSTC_STYLE_MAX 255
// Character set identifiers are used in StyleSetCharacterSet.
// The values are the same as the Windows *_CHARSET values.
#define wxSTC_CASE_MIXED 0
#define wxSTC_CASE_UPPER 1
#define wxSTC_CASE_LOWER 2
-#define wxSTC_INDIC_MAX 7
+
+// Indicator style enumeration and some constants
#define wxSTC_INDIC_PLAIN 0
#define wxSTC_INDIC_SQUIGGLE 1
#define wxSTC_INDIC_TT 2
#define wxSTC_INDIC_HIDDEN 5
#define wxSTC_INDIC_BOX 6
#define wxSTC_INDIC_ROUNDBOX 7
+#define wxSTC_INDIC_MAX 31
+#define wxSTC_INDIC_CONTAINER 8
#define wxSTC_INDIC0_MASK 0x20
#define wxSTC_INDIC1_MASK 0x40
#define wxSTC_INDIC2_MASK 0x80
#define wxSTC_INDICS_MASK 0xE0
+#define wxSTC_IV_NONE 0
+#define wxSTC_IV_REAL 1
+#define wxSTC_IV_LOOKFORWARD 2
+#define wxSTC_IV_LOOKBOTH 3
// PrintColourMode - use same colours as screen.
#define wxSTC_PRINT_NORMAL 0
// where most code reside, and the lines after the caret, eg. the body of a function.
#define wxSTC_CARET_EVEN 0x08
-// Selection modes
+// Selection Modes
#define wxSTC_SEL_STREAM 0
#define wxSTC_SEL_RECTANGLE 1
#define wxSTC_SEL_LINES 2
#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
+
// Maximum value of keywordSet parameter of SetKeyWords.
#define wxSTC_KEYWORDSET_MAX 8
#define wxSTC_MOD_BEFOREINSERT 0x400
#define wxSTC_MOD_BEFOREDELETE 0x800
#define wxSTC_MULTILINEUNDOREDO 0x1000
-#define wxSTC_MODEVENTMASKALL 0x1FFF
+#define wxSTC_STARTACTION 0x2000
+#define wxSTC_MOD_CHANGEINDICATOR 0x4000
+#define wxSTC_MOD_CHANGELINESTATE 0x8000
+#define wxSTC_MODEVENTMASKALL 0xFFFF
// Symbolic key codes and modifier flags.
// ASCII and other printable characters below 256.
#define wxSTC_KEY_ADD 310
#define wxSTC_KEY_SUBTRACT 311
#define wxSTC_KEY_DIVIDE 312
+#define wxSTC_KEY_WIN 313
+#define wxSTC_KEY_RWIN 314
+#define wxSTC_KEY_MENU 315
#define wxSTC_SCMOD_NORM 0
#define wxSTC_SCMOD_SHIFT 1
#define wxSTC_SCMOD_CTRL 2
#define wxSTC_LEX_INNOSETUP 76
#define wxSTC_LEX_OPAL 77
#define wxSTC_LEX_SPICE 78
+#define wxSTC_LEX_D 79
+#define wxSTC_LEX_CMAKE 80
+#define wxSTC_LEX_GAP 81
+#define wxSTC_LEX_PLM 82
+#define wxSTC_LEX_PROGRESS 83
+#define wxSTC_LEX_ABAQUS 84
+#define wxSTC_LEX_ASYMPTOTE 85
+#define wxSTC_LEX_R 86
// When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
// value assigned in sequence from SCLEX_AUTOMATIC+1.
#define wxSTC_C_COMMENTDOCKEYWORDERROR 18
#define wxSTC_C_GLOBALCLASS 19
+// Lexical states for SCLEX_D
+#define wxSTC_D_DEFAULT 0
+#define wxSTC_D_COMMENT 1
+#define wxSTC_D_COMMENTLINE 2
+#define wxSTC_D_COMMENTDOC 3
+#define wxSTC_D_COMMENTNESTED 4
+#define wxSTC_D_NUMBER 5
+#define wxSTC_D_WORD 6
+#define wxSTC_D_WORD2 7
+#define wxSTC_D_WORD3 8
+#define wxSTC_D_TYPEDEF 9
+#define wxSTC_D_STRING 10
+#define wxSTC_D_STRINGEOL 11
+#define wxSTC_D_CHARACTER 12
+#define wxSTC_D_OPERATOR 13
+#define wxSTC_D_IDENTIFIER 14
+#define wxSTC_D_COMMENTLINEDOC 15
+#define wxSTC_D_COMMENTDOCKEYWORD 16
+#define wxSTC_D_COMMENTDOCKEYWORDERROR 17
+
// Lexical states for SCLEX_TCL
#define wxSTC_TCL_DEFAULT 0
#define wxSTC_TCL_COMMENT 1
#define wxSTC_PL_STRING_QR 29
#define wxSTC_PL_STRING_QW 30
#define wxSTC_PL_POD_VERB 31
+#define wxSTC_PL_SUB_PROTOTYPE 40
+#define wxSTC_PL_FORMAT_IDENT 41
+#define wxSTC_PL_FORMAT 42
// Lexical states for SCLEX_RUBY
#define wxSTC_RB_DEFAULT 0
#define wxSTC_ERR_ABSF 18
#define wxSTC_ERR_TIDY 19
#define wxSTC_ERR_JAVA_STACK 20
+#define wxSTC_ERR_VALUE 21
// Lexical states for SCLEX_BATCH
#define wxSTC_BAT_DEFAULT 0
#define wxSTC_YAML_DOCUMENT 6
#define wxSTC_YAML_TEXT 7
#define wxSTC_YAML_ERROR 8
+#define wxSTC_YAML_OPERATOR 9
// Lexical states for SCLEX_TEX
#define wxSTC_TEX_DEFAULT 0
#define wxSTC_T3_USER1 17
#define wxSTC_T3_USER2 18
#define wxSTC_T3_USER3 19
+#define wxSTC_T3_BRACE 20
// Lexical states for SCLEX_REBOL
#define wxSTC_REBOL_DEFAULT 0
#define wxSTC_SPICE_VALUE 7
#define wxSTC_SPICE_COMMENTLINE 8
+// Lexical states for SCLEX_CMAKE
+#define wxSTC_CMAKE_DEFAULT 0
+#define wxSTC_CMAKE_COMMENT 1
+#define wxSTC_CMAKE_STRINGDQ 2
+#define wxSTC_CMAKE_STRINGLQ 3
+#define wxSTC_CMAKE_STRINGRQ 4
+#define wxSTC_CMAKE_COMMANDS 5
+#define wxSTC_CMAKE_PARAMETERS 6
+#define wxSTC_CMAKE_VARIABLE 7
+#define wxSTC_CMAKE_USERDEFINED 8
+#define wxSTC_CMAKE_WHILEDEF 9
+#define wxSTC_CMAKE_FOREACHDEF 10
+#define wxSTC_CMAKE_IFDEFINEDEF 11
+#define wxSTC_CMAKE_MACRODEF 12
+#define wxSTC_CMAKE_STRINGVAR 13
+#define wxSTC_CMAKE_NUMBER 14
+
+// Lexical states for SCLEX_GAP
+#define wxSTC_GAP_DEFAULT 0
+#define wxSTC_GAP_IDENTIFIER 1
+#define wxSTC_GAP_KEYWORD 2
+#define wxSTC_GAP_KEYWORD2 3
+#define wxSTC_GAP_KEYWORD3 4
+#define wxSTC_GAP_KEYWORD4 5
+#define wxSTC_GAP_STRING 6
+#define wxSTC_GAP_CHAR 7
+#define wxSTC_GAP_OPERATOR 8
+#define wxSTC_GAP_COMMENT 9
+#define wxSTC_GAP_NUMBER 10
+#define wxSTC_GAP_STRINGEOL 11
+
+// Lexical state for SCLEX_PLM
+#define wxSTC_PLM_DEFAULT 0
+#define wxSTC_PLM_COMMENT 1
+#define wxSTC_PLM_STRING 2
+#define wxSTC_PLM_NUMBER 3
+#define wxSTC_PLM_IDENTIFIER 4
+#define wxSTC_PLM_OPERATOR 5
+#define wxSTC_PLM_CONTROL 6
+#define wxSTC_PLM_KEYWORD 7
+
+// Lexical state for SCLEX_PROGRESS
+#define wxSTC_4GL_DEFAULT 0
+#define wxSTC_4GL_NUMBER 1
+#define wxSTC_4GL_WORD 2
+#define wxSTC_4GL_STRING 3
+#define wxSTC_4GL_CHARACTER 4
+#define wxSTC_4GL_PREPROCESSOR 5
+#define wxSTC_4GL_OPERATOR 6
+#define wxSTC_4GL_IDENTIFIER 7
+#define wxSTC_4GL_BLOCK 8
+#define wxSTC_4GL_END 9
+#define wxSTC_4GL_COMMENT1 10
+#define wxSTC_4GL_COMMENT2 11
+#define wxSTC_4GL_COMMENT3 12
+#define wxSTC_4GL_COMMENT4 13
+#define wxSTC_4GL_COMMENT5 14
+#define wxSTC_4GL_COMMENT6 15
+#define wxSTC_4GL_DEFAULT_ 16
+#define wxSTC_4GL_NUMBER_ 17
+#define wxSTC_4GL_WORD_ 18
+#define wxSTC_4GL_STRING_ 19
+#define wxSTC_4GL_CHARACTER_ 20
+#define wxSTC_4GL_PREPROCESSOR_ 21
+#define wxSTC_4GL_OPERATOR_ 22
+#define wxSTC_4GL_IDENTIFIER_ 23
+#define wxSTC_4GL_BLOCK_ 24
+#define wxSTC_4GL_END_ 25
+#define wxSTC_4GL_COMMENT1_ 26
+#define wxSTC_4GL_COMMENT2_ 27
+#define wxSTC_4GL_COMMENT3_ 28
+#define wxSTC_4GL_COMMENT4_ 29
+#define wxSTC_4GL_COMMENT5_ 30
+#define wxSTC_4GL_COMMENT6_ 31
+
+// Lexical states for SCLEX_ABAQUS
+#define wxSTC_ABAQUS_DEFAULT 0
+#define wxSTC_ABAQUS_COMMENT 1
+#define wxSTC_ABAQUS_COMMENTBLOCK 2
+#define wxSTC_ABAQUS_NUMBER 3
+#define wxSTC_ABAQUS_STRING 4
+#define wxSTC_ABAQUS_OPERATOR 5
+#define wxSTC_ABAQUS_WORD 6
+#define wxSTC_ABAQUS_PROCESSOR 7
+#define wxSTC_ABAQUS_COMMAND 8
+#define wxSTC_ABAQUS_SLASHCOMMAND 9
+#define wxSTC_ABAQUS_STARCOMMAND 10
+#define wxSTC_ABAQUS_ARGUMENT 11
+#define wxSTC_ABAQUS_FUNCTION 12
+
+// Lexical states for SCLEX_ASYMPTOTE
+#define wxSTC_ASY_DEFAULT 0
+#define wxSTC_ASY_COMMENT 1
+#define wxSTC_ASY_COMMENTLINE 2
+#define wxSTC_ASY_NUMBER 3
+#define wxSTC_ASY_WORD 4
+#define wxSTC_ASY_STRING 5
+#define wxSTC_ASY_CHARACTER 6
+#define wxSTC_ASY_OPERATOR 7
+#define wxSTC_ASY_IDENTIFIER 8
+#define wxSTC_ASY_STRINGEOL 9
+#define wxSTC_ASY_COMMENTLINEDOC 10
+#define wxSTC_ASY_WORD2 11
+
+// Lexical states for SCLEX_R
+#define wxSTC_R_DEFAULT 0
+#define wxSTC_R_COMMENT 1
+#define wxSTC_R_KWORD 2
+#define wxSTC_R_BASEKWORD 3
+#define wxSTC_R_OTHERKWORD 4
+#define wxSTC_R_NUMBER 5
+#define wxSTC_R_STRING 6
+#define wxSTC_R_STRING2 7
+#define wxSTC_R_OPERATOR 8
+#define wxSTC_R_IDENTIFIER 9
+#define wxSTC_R_INFIX 10
+#define wxSTC_R_INFIXEOL 11
+
//-----------------------------------------
// Commands that can be bound to keystrokes
// Delete the word to the right of the caret.
#define wxSTC_CMD_DELWORDRIGHT 2336
+// Delete the word to the right of the caret, but not the trailing non-word characters.
+#define wxSTC_CMD_DELWORDRIGHTEND 2518
+
// Cut the line containing the caret.
#define wxSTC_CMD_LINECUT 2337
#ifndef SWIG
extern WXDLLIMPEXP_STC const wxChar* wxSTCNameStr;
-class WXDLLIMPEXP_FWD_STC wxStyledTextCtrl;
-class WXDLLIMPEXP_FWD_STC wxStyledTextEvent;
+class WXDLLIMPEXP_FWD_STC wxStyledTextCtrl;
+class WXDLLIMPEXP_FWD_STC wxStyledTextEvent;
#endif
//----------------------------------------------------------------------
// Set a style to be underlined or not.
void StyleSetUnderline(int style, bool underline);
+ // Get the foreground colour of a style.
+ wxColour StyleGetForeground(int style);
+
+ // Get the background colour of a style.
+ wxColour StyleGetBackground(int style);
+
+ // Get is a style bold or not.
+ bool StyleGetBold(int style);
+
+ // Get is a style italic or not.
+ bool StyleGetItalic(int style);
+
+ // Get the size of characters of a style.
+ int StyleGetSize(int style);
+
+ // Get the font facename of a style
+ wxString StyleGetFaceName(int style);
+
+ // Get is a style to have its end of line filled or not.
+ bool StyleGetEOLFilled(int style);
+
+ // Get is a style underlined or not.
+ bool StyleGetUnderline(int style);
+
+ // Get is a style mixed case, or to force upper or lower case.
+ int StyleGetCase(int style);
+
+ // Get the character set of the font in a style.
+ int StyleGetCharacterSet(int style);
+
+ // Get is a style visible or not.
+ bool StyleGetVisible(int style);
+
+ // Get is a style changeable or not (read only).
+ // Experimental feature, currently buggy.
+ bool StyleGetChangeable(int style);
+
+ // Get is a style a hotspot or not.
+ bool StyleGetHotSpot(int style);
+
// Set a style to be mixed case, or to force upper or lower case.
void StyleSetCase(int style, int caseForce);
// Set the alpha of the selection.
void SetSelAlpha(int alpha);
+ // Is the selection end of line filled?
+ bool GetSelEOLFilled();
+
+ // Set the selection to have its end of line filled or not.
+ void SetSelEOLFilled(bool filled);
+
// Set the foreground colour of the caret.
void SetCaretForeground(const wxColour& fore);
// Retrieve the foreground colour of an indicator.
wxColour IndicatorGetForeground(int indic);
+ // Set an indicator to draw under text or over(default).
+ void IndicatorSetUnder(int indic, bool under);
+
+ // Retrieve whether indicator drawn under or over text.
+ bool IndicatorGetUnder(int indic);
+
// Set the foreground colour of all whitespace and whether to use this setting.
void SetWhitespaceForeground(bool useSetting, const wxColour& fore);
bool GetUseHorizontalScrollBar();
// Show or hide indentation guides.
- void SetIndentationGuides(bool show);
+ void SetIndentationGuides(int indentView);
// Are the indentation guides visible?
- bool GetIndentationGuides();
+ int GetIndentationGuides();
// Set the highlighted indentation guide column.
// 0 = no highlighted guide.
// Retrieve the document width assumed for scrolling.
int GetScrollWidth();
+ // Sets whether the maximum width line displayed is used to set scroll width.
+ void SetScrollWidthTracking(bool tracking);
+
+ // Retrieve whether the scroll width tracks wide lines.
+ bool GetScrollWidthTracking();
+
// Measure the pixel width of some text in a particular style.
// NUL terminated text argument.
// Does not handle tab or control characters.
// Delete the word to the right of the caret.
void DelWordRight();
+ // Delete the word to the right of the caret, but not the trailing non-word characters.
+ void DelWordRightEnd();
+
// Cut the line containing the caret.
void LineCut();
// Set a fore colour for active hotspots.
void SetHotspotActiveForeground(bool useSetting, const wxColour& fore);
+ // Get the fore colour for active hotspots.
+ wxColour GetHotspotActiveForeground();
+
// Set a back colour for active hotspots.
void SetHotspotActiveBackground(bool useSetting, const wxColour& back);
+ // Get the back colour for active hotspots.
+ wxColour GetHotspotActiveBackground();
+
// Enable / Disable underlining active hotspots.
void SetHotspotActiveUnderline(bool underline);
+ // Get whether underlining for active hotspots.
+ bool GetHotspotActiveUnderline();
+
// Limit hotspots to single line so hotspots on two lines don't merge.
void SetHotspotSingleLine(bool singleLine);
+ // Get the HotspotSingleLine property
+ bool GetHotspotSingleLine();
+
// Move caret between paragraphs (delimited by empty lines).
void ParaDown();
void ParaDownExtend();
// Get the background alpha of the caret line.
int GetCaretLineBackAlpha();
+ // Set the style of the caret to be drawn.
+ void SetCaretStyle(int caretStyle);
+
+ // Returns the current style of the caret.
+ int GetCaretStyle();
+
+ // Set the indicator used for IndicatorFillRange and IndicatorClearRange
+ void SetIndicatorCurrent(int indicator);
+
+ // Get the current indicator
+ int GetIndicatorCurrent();
+
+ // Set the value used for IndicatorFillRange
+ void SetIndicatorValue(int value);
+
+ // Get the current indicator vaue
+ int GetIndicatorValue();
+
+ // Turn a indicator on over a range.
+ void IndicatorFillRange(int position, int fillLength);
+
+ // Turn a indicator off over a range.
+ void IndicatorClearRange(int position, int clearLength);
+
+ // Are any indicators present at position?
+ int IndicatorAllOnFor(int position);
+
+ // What value does a particular indicator have at at a position?
+ int IndicatorValueAt(int indicator, int position);
+
+ // Where does a particular indicator start?
+ int IndicatorStart(int indicator, int position);
+
+ // Where does a particular indicator end?
+ int IndicatorEnd(int indicator, int position);
+
+ // Set number of entries in position cache
+ void SetPositionCacheSize(int size);
+
+ // How many entries are allocated to the position cache?
+ int GetPositionCacheSize();
+
// Start notifying the container of all key presses and commands.
void StartRecord();
void StyleSetSpec(int styleNum, const wxString& spec);
+ // Get the font of a style.
+ wxFont StyleGetFont(int style);
+
// Set style size, face, bold, italic, and underline attributes from
// a wxFont's attributes.
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_STC, wxEVT_STC_HOTSPOT_DCLICK, 1674)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_STC, wxEVT_STC_CALLTIP_CLICK, 1675)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_STC, wxEVT_STC_AUTOCOMP_SELECTION, 1676)
+ DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_STC, wxEVT_STC_INDICATOR_CLICK, 1677)
+ DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_STC, wxEVT_STC_INDICATOR_RELEASE, 1678)
END_DECLARE_EVENT_TYPES()
#else
enum {
wxEVT_STC_HOTSPOT_CLICK,
wxEVT_STC_HOTSPOT_DCLICK,
wxEVT_STC_CALLTIP_CLICK,
- wxEVT_STC_AUTOCOMP_SELECTION
+ wxEVT_STC_AUTOCOMP_SELECTION,
+ wxEVT_STC_INDICATOR_CLICK,
+ wxEVT_STC_INDICATOR_RELEASE
};
#endif
#define EVT_STC_HOTSPOT_DCLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_HOTSPOT_DCLICK, id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxStyledTextEventFunction, & fn ), (wxObject *) NULL ),
#define EVT_STC_CALLTIP_CLICK(id, fn)) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CALLTIP_CLICK id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxStyledTextEventFunction, & fn ), (wxObject *) NULL ),
#define EVT_STC_AUTOCOMP_SELECTION(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_AUTOCOMP_SELECTION id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxStyledTextEventFunction, & fn ), (wxObject *) NULL ),
+#define EVT_STC_INDICATOR_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_INDICATOR_CLICK id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxStyledTextEventFunction, & fn ), (wxObject *) NULL ),
+#define EVT_STC_INDICATOR_RELEASE(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_INDICATOR_RELEASE id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxStyledTextEventFunction, & fn ), (wxObject *) NULL ),
+
#endif
#endif // wxUSE_STC
#include <ctype.h>
+#if wxUSE_DISPLAY
+#include "wx/display.h"
+#endif
+
#include "wx/encconv.h"
#include "wx/listctrl.h"
#include "wx/mstream.h"
false,
stc2wx(faceName),
encoding);
- font->SetNoAntiAliasing(!extraFontFlag);
+ //font->SetNoAntiAliasing(!extraFontFlag);
id = font;
}
}
+// Returns rectangle of monitor pt is on
+PRectangle Window::GetMonitorRect(Point pt) {
+ wxRect rect;
+ if (! id) return PRectangle();
+#if wxUSE_DISPLAY
+ // Get the display the point is found on
+ int n = wxDisplay::GetFromPoint(wxPoint(pt.x, pt.y));
+ wxDisplay dpy(n == wxNOT_FOUND ? 0 : n);
+ rect = dpy.GetGeometry();
+#endif
+ return PRectangleFromwxRect(rect);
+}
+
//----------------------------------------------------------------------
// Helper classes for ListBox
if (!len)
return wxEmptyString;
- size_t wclen = UCS2Length(str, len);
+ size_t wclen = UTF16Length(str, len);
wxWCharBuffer buffer(wclen+1);
- size_t actualLen = UCS2FromUTF8(str, len, buffer.data(), wclen+1);
+ size_t actualLen = UTF16FromUTF8(str, len, buffer.data(), wclen+1);
return wxString(buffer.data(), actualLen);
}
size_t len = UTF8Length(wcstr, wclen);
wxCharBuffer buffer(len+1);
- UTF8FromUCS2(wcstr, wclen, buffer.data(), len);
+ UTF8FromUTF16(wcstr, wclen, buffer.data(), len);
// TODO check NULL termination!!
result = source.DoDragDrop(evt.GetDragAllowMove());
if (result == wxDragMove && dropWentOutside)
ClearSelection();
- inDragDrop = false;
+ inDragDrop = ddNone;
SetDragPosition(invalidPosition);
}
#endif // wxUSE_DRAG_AND_DROP
#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 "Style.h"
#include "ViewStyle.h"
#include "AutoComplete.h"
+#include "Decoration.h"
#include "Document.h"
+#include "PositionCache.h"
#include "Editor.h"
#include "ScintillaBase.h"
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 = os.path.abspath('../../wxPython/contrib/stc/_stc_gendocs.i')
+DOCSTR_DEST = os.path.abspath('../../../wxPython/contrib/stc/_stc_gendocs.i')
# Value prefixes to convert
]
# Message function values that should have a CMD_ constant generated
-cmdValues = [ (2300, 2349),
- 2011,
+cmdValues = [ 2011,
2013,
(2176, 2180),
+ (2300, 2349),
(2390, 2393),
(2395, 2396),
2404,
(2413, 2416),
(2426, 2442),
(2450, 2455),
+ 2518,
]
'SetMarginSensitiveN' : ('SetMarginSensitive', 0, 0, 0),
'GetMarginSensitiveN' : ('GetMarginSensitive', 0, 0, 0),
+
+ 'StyleGetFore' : ('StyleGetForeground', 0, 0, 0),
+ 'StyleGetBack' : ('StyleGetBackground', 0, 0, 0),
'StyleSetFore' : ('StyleSetForeground', 0, 0, 0),
'StyleSetBack' : ('StyleSetBackground', 0, 0, 0),
'SetSelFore' : ('SetSelForeground', 0, 0, 0),
'SetSelBack' : ('SetSelBackground', 0, 0, 0),
'SetCaretFore' : ('SetCaretForeground', 0, 0, 0),
+ 'StyleGetFont' :
+ ('StyleGetFaceName',
+ 'wxString %s(int style);',
+ '''wxString %s(int style) {
+ long msg = %s;
+ long len = SendMsg(msg, style, 0);
+ wxMemoryBuffer mbuf(len+1);
+ char* buf = (char*)mbuf.GetWriteBuf(len+1);
+ SendMsg(msg, style, (long)buf);
+ mbuf.UngetWriteBuf(len);
+ mbuf.AppendByte(0);
+ return stc2wx(buf);''',
+ ('Get the font facename of a style',)),
'StyleSetFont' : ('StyleSetFaceName', 0, 0, 0),
'StyleSetCharacterSet' : (None, 0, 0, 0),
'IndicGetStyle' : ('IndicatorGetStyle', 0, 0, 0),
'IndicSetFore' : ('IndicatorSetForeground', 0, 0, 0),
'IndicGetFore' : ('IndicatorGetForeground', 0, 0, 0),
-
+ 'IndicSetUnder': ('IndicatorSetUnder', 0, 0, 0),
+ 'IndicGetUnder': ('IndicatorGetUnder', 0, 0, 0),
+
'SetWhitespaceFore' : ('SetWhitespaceForeground', 0, 0, 0),
'SetWhitespaceBack' : ('SetWhitespaceBackground', 0, 0, 0),
'SetHotspotActiveFore' : ('SetHotspotActiveForeground', 0, 0, 0),
'SetHotspotActiveBack' : ('SetHotspotActiveBackground', 0, 0, 0),
+ 'GetHotspotActiveFore' : ('GetHotspotActiveForeground', 0, 0, 0),
+ 'GetHotspotActiveBack' : ('GetHotspotActiveBackground', 0, 0, 0),
'GetCaretLineBack' : ('GetCaretLineBackground', 0, 0, 0),
'SetCaretLineBack' : ('SetCaretLineBackground', 0, 0, 0),
'LoadLexerLibrary' : (None, 0,0,0),
+ 'SetPositionCache' : ('SetPositionCacheSize', 0, 0, 0),
+ 'GetPositionCache' : ('GetPositionCacheSize', 0, 0, 0),
+
'' : ('', 0, 0, 0),
distribution. All other code needed to implement Scintilla on top of
wxWindows is located in the directory above this one.
-The current version of the Scintilla code is 1.70
+The current version of the Scintilla code is 1.75
virtual void ColourTo(unsigned int pos, int chAttr)=0;
virtual void SetLevel(int line, int level)=0;
virtual int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0)=0;
+ virtual void IndicatorFill(int start, int end, int indicator, int value)=0;
};
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
typedef void (*LexerFunction)(unsigned int startPos, int lengthDoc, int initStyle,
WordList *keywordlists[], Accessor &styler);
static const LexerModule *Find(const char *languageName);
};
+#ifdef SCI_NAMESPACE
+}
+#endif
+
/**
* Check if a character is a space.
* This is ASCII specific but is safe with chars >= 0x80.
// Scintilla source code edit control
/** @file Platform.h
** Interface to platform facilities. Also includes some basic utilities.
- ** Implemented in PlatGTK.cxx for GTK+/Linux, PlatWin.cxx for Windows, and PlatWX.cxx for wxWidgets.
+ ** Implemented in PlatGTK.cxx for GTK+/Linux, PlatWin.cxx for Windows, and PlatWX.cxx for wxWindows.
**/
// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
// PLAT_GTK = GTK+ on Linux or Win32
// PLAT_GTK_WIN32 is defined additionally when running PLAT_GTK under Win32
// PLAT_WIN = Win32 API on Win32 OS
-// PLAT_WX is wxWidgets on any supported platform
+// PLAT_WX is wxWindows on any supported platform
#define PLAT_GTK 0
#define PLAT_GTK_WIN32 0
+#define PLAT_MACOSX 0
#define PLAT_WIN 0
#define PLAT_WX 0
#define PLAT_FOX 0
#define PLAT_GTK_WIN32 1
#endif
+#elif defined(MACOSX)
+#undef PLAT_MACOSX
+#define PLAT_MACOSX 1
+
#else
#undef PLAT_WIN
#define PLAT_WIN 1
#endif
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
// Underlying the implementation of the platform classes are platform specific types.
// Sometimes these need to be passed around by client code so they are defined here
}
int Width() { return right - left; }
int Height() { return bottom - top; }
+ bool Empty() {
+ return (Height() <= 0) || (Width() <= 0);
+ }
};
/**
Surface(const Surface &) {}
Surface &operator=(const Surface &) { return *this; }
public:
- Surface() {}
- virtual ~Surface() {}
+ Surface() {};
+ virtual ~Surface() {};
static Surface *Allocate();
virtual void Init(WindowID wid)=0;
class Window {
protected:
WindowID id;
+#if PLAT_MACOSX
+ void *windowRef;
+ void *control;
+#endif
public:
- Window() : id(0), cursorLast(cursorInvalid) {}
- Window(const Window &source) : id(source.id), cursorLast(cursorInvalid) {}
+ Window() : id(0), cursorLast(cursorInvalid) {
+#if PLAT_MACOSX
+ windowRef = 0;
+ control = 0;
+#endif
+ }
+ Window(const Window &source) : id(source.id), cursorLast(cursorInvalid) {
+#if PLAT_MACOSX
+ windowRef = 0;
+ control = 0;
+#endif
+ }
virtual ~Window();
Window &operator=(WindowID id_) {
id = id_;
enum Cursor { cursorInvalid, cursorText, cursorArrow, cursorUp, cursorWait, cursorHoriz, cursorVert, cursorReverseArrow, cursorHand };
void SetCursor(Cursor curs);
void SetTitle(const char *s);
+ PRectangle GetMonitorRect(Point pt);
+#if PLAT_MACOSX
+ void SetWindow(void *ref) { windowRef = ref; };
+ void SetControl(void *_control) { control = _control; };
+#endif
private:
Cursor cursorLast;
};
*/
class DynamicLibrary {
public:
- virtual ~DynamicLibrary() {}
+ virtual ~DynamicLibrary() {};
/// @return Pointer to function "name", or NULL on failure.
virtual Function FindFunction(const char *name) = 0;
#ifdef NDEBUG
#define PLATFORM_ASSERT(c) ((void)0)
#else
+#ifdef SCI_NAMESPACE
+#define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Scintilla::Platform::Assert(#c, __FILE__, __LINE__))
+#else
#define PLATFORM_ASSERT(c) ((c) ? (void)(0) : Platform::Assert(#c, __FILE__, __LINE__))
#endif
+#endif
+
+#ifdef SCI_NAMESPACE
+}
+#endif
// Shut up annoying Visual C++ warnings:
#ifdef _MSC_VER
bool isprefix(const char *target, const char *prefix);
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
struct Property {
unsigned int hash;
char *key;
Property *props[hashRoots];
Property *enumnext;
int enumhash;
- static bool caseSensitiveFilenames;
static unsigned int HashString(const char *s, size_t len) {
unsigned int ret = 0;
while (len--) {
}
return ret;
}
- static bool IncludesVar(const char *value, const char *key);
public:
PropSet *superPS;
void Set(const char *keyVal);
void Unset(const char *key, int lenKey=-1);
void SetMultiple(const char *s);
- SString Get(const char *key);
- SString GetExpanded(const char *key);
- SString Expand(const char *withVars, int maxExpands=100);
- int GetInt(const char *key, int defaultValue=0);
- SString GetWild(const char *keybase, const char *filename);
- SString GetNewExpand(const char *keybase, const char *filename="");
+ 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(); // Caller must delete[] the return value
- bool GetFirst(char **key, char **val);
- bool GetNext(char **key, char **val);
- static void SetCaseSensitiveFilenames(bool caseSensitiveFilenames_) {
- caseSensitiveFilenames = caseSensitiveFilenames_;
- }
+ char *ToString() const; // Caller must delete[] the return value
private:
// copy-value semantics not implemented
public:
// Each word contains at least one character - a empty word acts as sentinel at the end.
char **words;
- char **wordsNoCase;
char *list;
int len;
bool onlyLineEnds; ///< Delimited by any white space or only line ends
bool sorted;
- bool sortedNoCase;
int starts[256];
WordList(bool onlyLineEnds_ = false) :
- words(0), wordsNoCase(0), list(0), len(0), onlyLineEnds(onlyLineEnds_),
- sorted(false), sortedNoCase(false) {}
+ words(0), list(0), len(0), onlyLineEnds(onlyLineEnds_),
+ sorted(false)
+ {}
~WordList() { Clear(); }
operator bool() { return len ? true : false; }
- char *operator[](int ind) { return words[ind]; }
void Clear();
void Set(const char *s);
- char *Allocate(int size);
- void SetFromAllocated();
bool InList(const char *s);
bool InListAbbreviated(const char *s, const char marker);
- const char *GetNearestWord(const char *wordStart, int searchLen,
- bool ignoreCase = false, SString wordCharacters="", int wordIndex = -1);
- char *GetNearestWords(const char *wordStart, int searchLen,
- bool ignoreCase=false, char otherSeparator='\0', bool exactLen=false);
};
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
#ifndef SSTRING_H
#define SSTRING_H
+
// 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);
bool EqualCaseInsensitive(const char *a, const char *b);
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
// Define another string class.
// While it would be 'better' to use std::string, that doubles the executable size.
// An SString may contain embedded nul characters.
return SContainer::StringAllocate(s, len);
}
+#ifdef SCI_NAMESPACE
+}
+#endif
+
#endif
#define SCLEX_INNOSETUP 76
#define SCLEX_OPAL 77
#define SCLEX_SPICE 78
+#define SCLEX_D 79
+#define SCLEX_CMAKE 80
+#define SCLEX_GAP 81
+#define SCLEX_PLM 82
+#define SCLEX_PROGRESS 83
+#define SCLEX_ABAQUS 84
+#define SCLEX_ASYMPTOTE 85
+#define SCLEX_R 86
#define SCLEX_AUTOMATIC 1000
#define SCE_P_DEFAULT 0
#define SCE_P_COMMENTLINE 1
#define SCE_C_COMMENTDOCKEYWORD 17
#define SCE_C_COMMENTDOCKEYWORDERROR 18
#define SCE_C_GLOBALCLASS 19
+#define SCE_D_DEFAULT 0
+#define SCE_D_COMMENT 1
+#define SCE_D_COMMENTLINE 2
+#define SCE_D_COMMENTDOC 3
+#define SCE_D_COMMENTNESTED 4
+#define SCE_D_NUMBER 5
+#define SCE_D_WORD 6
+#define SCE_D_WORD2 7
+#define SCE_D_WORD3 8
+#define SCE_D_TYPEDEF 9
+#define SCE_D_STRING 10
+#define SCE_D_STRINGEOL 11
+#define SCE_D_CHARACTER 12
+#define SCE_D_OPERATOR 13
+#define SCE_D_IDENTIFIER 14
+#define SCE_D_COMMENTLINEDOC 15
+#define SCE_D_COMMENTDOCKEYWORD 16
+#define SCE_D_COMMENTDOCKEYWORDERROR 17
#define SCE_TCL_DEFAULT 0
#define SCE_TCL_COMMENT 1
#define SCE_TCL_COMMENTLINE 2
#define SCE_PL_STRING_QR 29
#define SCE_PL_STRING_QW 30
#define SCE_PL_POD_VERB 31
+#define SCE_PL_SUB_PROTOTYPE 40
+#define SCE_PL_FORMAT_IDENT 41
+#define SCE_PL_FORMAT 42
#define SCE_RB_DEFAULT 0
#define SCE_RB_ERROR 1
#define SCE_RB_COMMENTLINE 2
#define SCE_ERR_ABSF 18
#define SCE_ERR_TIDY 19
#define SCE_ERR_JAVA_STACK 20
+#define SCE_ERR_VALUE 21
#define SCE_BAT_DEFAULT 0
#define SCE_BAT_COMMENT 1
#define SCE_BAT_WORD 2
#define SCE_YAML_DOCUMENT 6
#define SCE_YAML_TEXT 7
#define SCE_YAML_ERROR 8
+#define SCE_YAML_OPERATOR 9
#define SCE_TEX_DEFAULT 0
#define SCE_TEX_SPECIAL 1
#define SCE_TEX_GROUP 2
#define SCE_T3_USER1 17
#define SCE_T3_USER2 18
#define SCE_T3_USER3 19
+#define SCE_T3_BRACE 20
#define SCE_REBOL_DEFAULT 0
#define SCE_REBOL_COMMENTLINE 1
#define SCE_REBOL_COMMENTBLOCK 2
#define SCE_SPICE_DELIMITER 6
#define SCE_SPICE_VALUE 7
#define SCE_SPICE_COMMENTLINE 8
+#define SCE_CMAKE_DEFAULT 0
+#define SCE_CMAKE_COMMENT 1
+#define SCE_CMAKE_STRINGDQ 2
+#define SCE_CMAKE_STRINGLQ 3
+#define SCE_CMAKE_STRINGRQ 4
+#define SCE_CMAKE_COMMANDS 5
+#define SCE_CMAKE_PARAMETERS 6
+#define SCE_CMAKE_VARIABLE 7
+#define SCE_CMAKE_USERDEFINED 8
+#define SCE_CMAKE_WHILEDEF 9
+#define SCE_CMAKE_FOREACHDEF 10
+#define SCE_CMAKE_IFDEFINEDEF 11
+#define SCE_CMAKE_MACRODEF 12
+#define SCE_CMAKE_STRINGVAR 13
+#define SCE_CMAKE_NUMBER 14
+#define SCE_GAP_DEFAULT 0
+#define SCE_GAP_IDENTIFIER 1
+#define SCE_GAP_KEYWORD 2
+#define SCE_GAP_KEYWORD2 3
+#define SCE_GAP_KEYWORD3 4
+#define SCE_GAP_KEYWORD4 5
+#define SCE_GAP_STRING 6
+#define SCE_GAP_CHAR 7
+#define SCE_GAP_OPERATOR 8
+#define SCE_GAP_COMMENT 9
+#define SCE_GAP_NUMBER 10
+#define SCE_GAP_STRINGEOL 11
+#define SCE_PLM_DEFAULT 0
+#define SCE_PLM_COMMENT 1
+#define SCE_PLM_STRING 2
+#define SCE_PLM_NUMBER 3
+#define SCE_PLM_IDENTIFIER 4
+#define SCE_PLM_OPERATOR 5
+#define SCE_PLM_CONTROL 6
+#define SCE_PLM_KEYWORD 7
+#define SCE_4GL_DEFAULT 0
+#define SCE_4GL_NUMBER 1
+#define SCE_4GL_WORD 2
+#define SCE_4GL_STRING 3
+#define SCE_4GL_CHARACTER 4
+#define SCE_4GL_PREPROCESSOR 5
+#define SCE_4GL_OPERATOR 6
+#define SCE_4GL_IDENTIFIER 7
+#define SCE_4GL_BLOCK 8
+#define SCE_4GL_END 9
+#define SCE_4GL_COMMENT1 10
+#define SCE_4GL_COMMENT2 11
+#define SCE_4GL_COMMENT3 12
+#define SCE_4GL_COMMENT4 13
+#define SCE_4GL_COMMENT5 14
+#define SCE_4GL_COMMENT6 15
+#define SCE_4GL_DEFAULT_ 16
+#define SCE_4GL_NUMBER_ 17
+#define SCE_4GL_WORD_ 18
+#define SCE_4GL_STRING_ 19
+#define SCE_4GL_CHARACTER_ 20
+#define SCE_4GL_PREPROCESSOR_ 21
+#define SCE_4GL_OPERATOR_ 22
+#define SCE_4GL_IDENTIFIER_ 23
+#define SCE_4GL_BLOCK_ 24
+#define SCE_4GL_END_ 25
+#define SCE_4GL_COMMENT1_ 26
+#define SCE_4GL_COMMENT2_ 27
+#define SCE_4GL_COMMENT3_ 28
+#define SCE_4GL_COMMENT4_ 29
+#define SCE_4GL_COMMENT5_ 30
+#define SCE_4GL_COMMENT6_ 31
+#define SCE_ABAQUS_DEFAULT 0
+#define SCE_ABAQUS_COMMENT 1
+#define SCE_ABAQUS_COMMENTBLOCK 2
+#define SCE_ABAQUS_NUMBER 3
+#define SCE_ABAQUS_STRING 4
+#define SCE_ABAQUS_OPERATOR 5
+#define SCE_ABAQUS_WORD 6
+#define SCE_ABAQUS_PROCESSOR 7
+#define SCE_ABAQUS_COMMAND 8
+#define SCE_ABAQUS_SLASHCOMMAND 9
+#define SCE_ABAQUS_STARCOMMAND 10
+#define SCE_ABAQUS_ARGUMENT 11
+#define SCE_ABAQUS_FUNCTION 12
+#define SCE_ASY_DEFAULT 0
+#define SCE_ASY_COMMENT 1
+#define SCE_ASY_COMMENTLINE 2
+#define SCE_ASY_NUMBER 3
+#define SCE_ASY_WORD 4
+#define SCE_ASY_STRING 5
+#define SCE_ASY_CHARACTER 6
+#define SCE_ASY_OPERATOR 7
+#define SCE_ASY_IDENTIFIER 8
+#define SCE_ASY_STRINGEOL 9
+#define SCE_ASY_COMMENTLINEDOC 10
+#define SCE_ASY_WORD2 11
+#define SCE_R_DEFAULT 0
+#define SCE_R_COMMENT 1
+#define SCE_R_KWORD 2
+#define SCE_R_BASEKWORD 3
+#define SCE_R_OTHERKWORD 4
+#define SCE_R_NUMBER 5
+#define SCE_R_STRING 6
+#define SCE_R_STRING2 7
+#define SCE_R_OPERATOR 8
+#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 STYLE_INDENTGUIDE 37
#define STYLE_CALLTIP 38
#define STYLE_LASTPREDEFINED 39
-#define STYLE_MAX 127
+#define STYLE_MAX 255
#define SC_CHARSET_ANSI 0
#define SC_CHARSET_DEFAULT 1
#define SC_CHARSET_BALTIC 186
#define SC_CASE_MIXED 0
#define SC_CASE_UPPER 1
#define SC_CASE_LOWER 2
+#define SCI_STYLEGETFORE 2481
+#define SCI_STYLEGETBACK 2482
+#define SCI_STYLEGETBOLD 2483
+#define SCI_STYLEGETITALIC 2484
+#define SCI_STYLEGETSIZE 2485
+#define SCI_STYLEGETFONT 2486
+#define SCI_STYLEGETEOLFILLED 2487
+#define SCI_STYLEGETUNDERLINE 2488
+#define SCI_STYLEGETCASE 2489
+#define SCI_STYLEGETCHARACTERSET 2490
+#define SCI_STYLEGETVISIBLE 2491
+#define SCI_STYLEGETCHANGEABLE 2492
+#define SCI_STYLEGETHOTSPOT 2493
#define SCI_STYLESETCASE 2060
#define SCI_STYLESETCHARACTERSET 2066
#define SCI_STYLESETHOTSPOT 2409
#define SCI_SETSELBACK 2068
#define SCI_GETSELALPHA 2477
#define SCI_SETSELALPHA 2478
+#define SCI_GETSELEOLFILLED 2479
+#define SCI_SETSELEOLFILLED 2480
#define SCI_SETCARETFORE 2069
#define SCI_ASSIGNCMDKEY 2070
#define SCI_CLEARCMDKEY 2071
#define SCI_SETWORDCHARS 2077
#define SCI_BEGINUNDOACTION 2078
#define SCI_ENDUNDOACTION 2079
-#define INDIC_MAX 7
#define INDIC_PLAIN 0
#define INDIC_SQUIGGLE 1
#define INDIC_TT 2
#define INDIC_HIDDEN 5
#define INDIC_BOX 6
#define INDIC_ROUNDBOX 7
+#define INDIC_MAX 31
+#define INDIC_CONTAINER 8
#define INDIC0_MASK 0x20
#define INDIC1_MASK 0x40
#define INDIC2_MASK 0x80
#define SCI_INDICGETSTYLE 2081
#define SCI_INDICSETFORE 2082
#define SCI_INDICGETFORE 2083
+#define SCI_INDICSETUNDER 2510
+#define SCI_INDICGETUNDER 2511
#define SCI_SETWHITESPACEFORE 2084
#define SCI_SETWHITESPACEBACK 2085
#define SCI_SETSTYLEBITS 2090
#define SCI_GETCOLUMN 2129
#define SCI_SETHSCROLLBAR 2130
#define SCI_GETHSCROLLBAR 2131
+#define SC_IV_NONE 0
+#define SC_IV_REAL 1
+#define SC_IV_LOOKFORWARD 2
+#define SC_IV_LOOKBOTH 3
#define SCI_SETINDENTATIONGUIDES 2132
#define SCI_GETINDENTATIONGUIDES 2133
#define SCI_SETHIGHLIGHTGUIDE 2134
#define SCI_GETLAYOUTCACHE 2273
#define SCI_SETSCROLLWIDTH 2274
#define SCI_GETSCROLLWIDTH 2275
+#define SCI_SETSCROLLWIDTHTRACKING 2516
+#define SCI_GETSCROLLWIDTHTRACKING 2517
#define SCI_TEXTWIDTH 2276
#define SCI_SETENDATLASTLINE 2277
#define SCI_GETENDATLASTLINE 2278
#define SCI_ZOOMOUT 2334
#define SCI_DELWORDLEFT 2335
#define SCI_DELWORDRIGHT 2336
+#define SCI_DELWORDRIGHTEND 2518
#define SCI_LINECUT 2337
#define SCI_LINEDELETE 2338
#define SCI_LINETRANSPOSE 2339
#define SCI_SETPRINTWRAPMODE 2406
#define SCI_GETPRINTWRAPMODE 2407
#define SCI_SETHOTSPOTACTIVEFORE 2410
+#define SCI_GETHOTSPOTACTIVEFORE 2494
#define SCI_SETHOTSPOTACTIVEBACK 2411
+#define SCI_GETHOTSPOTACTIVEBACK 2495
#define SCI_SETHOTSPOTACTIVEUNDERLINE 2412
+#define SCI_GETHOTSPOTACTIVEUNDERLINE 2496
#define SCI_SETHOTSPOTSINGLELINE 2421
+#define SCI_GETHOTSPOTSINGLELINE 2497
#define SCI_PARADOWN 2413
#define SCI_PARADOWNEXTEND 2414
#define SCI_PARAUP 2415
#define SC_ALPHA_NOALPHA 256
#define SCI_SETCARETLINEBACKALPHA 2470
#define SCI_GETCARETLINEBACKALPHA 2471
+#define CARETSTYLE_INVISIBLE 0
+#define CARETSTYLE_LINE 1
+#define CARETSTYLE_BLOCK 2
+#define SCI_SETCARETSTYLE 2512
+#define SCI_GETCARETSTYLE 2513
+#define SCI_SETINDICATORCURRENT 2500
+#define SCI_GETINDICATORCURRENT 2501
+#define SCI_SETINDICATORVALUE 2502
+#define SCI_GETINDICATORVALUE 2503
+#define SCI_INDICATORFILLRANGE 2504
+#define SCI_INDICATORCLEARRANGE 2505
+#define SCI_INDICATORALLONFOR 2506
+#define SCI_INDICATORVALUEAT 2507
+#define SCI_INDICATORSTART 2508
+#define SCI_INDICATOREND 2509
+#define SCI_SETPOSITIONCACHE 2514
+#define SCI_GETPOSITIONCACHE 2515
#define SCI_STARTRECORD 3001
#define SCI_STOPRECORD 3002
#define SCI_SETLEXER 4001
#define SC_MOD_BEFOREINSERT 0x400
#define SC_MOD_BEFOREDELETE 0x800
#define SC_MULTILINEUNDOREDO 0x1000
-#define SC_MODEVENTMASKALL 0x1FFF
+#define SC_STARTACTION 0x2000
+#define SC_MOD_CHANGEINDICATOR 0x4000
+#define SC_MOD_CHANGELINESTATE 0x8000
+#define SC_MODEVENTMASKALL 0xFFFF
#define SCEN_CHANGE 768
#define SCEN_SETFOCUS 512
#define SCEN_KILLFOCUS 256
#define SCK_ADD 310
#define SCK_SUBTRACT 311
#define SCK_DIVIDE 312
+#define SCK_WIN 313
+#define SCK_RWIN 314
+#define SCK_MENU 315
#define SCMOD_NORM 0
#define SCMOD_SHIFT 1
#define SCMOD_CTRL 2
#define SCN_HOTSPOTDOUBLECLICK 2020
#define SCN_CALLTIPCLICK 2021
#define SCN_AUTOCSELECTION 2022
+#define SCN_INDICATORCLICK 2023
+#define SCN_INDICATORRELEASE 2024
//--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.
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
struct CharacterRange {
long cpMin;
long cpMax;
int y; // SCN_DWELLSTART, SCN_DWELLEND
};
+#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
val STYLE_INDENTGUIDE=37
val STYLE_CALLTIP=38
val STYLE_LASTPREDEFINED=39
-val STYLE_MAX=127
+val STYLE_MAX=255
# Character set identifiers are used in StyleSetCharacterSet.
# The values are the same as the Windows *_CHARSET values.
val SC_CASE_MIXED=0
val SC_CASE_UPPER=1
val SC_CASE_LOWER=2
+
+# Get the foreground colour of a style.
+get colour StyleGetFore=2481(int style,)
+
+# Get the background colour of a style.
+get colour StyleGetBack=2482(int style,)
+
+# Get is a style bold or not.
+get bool StyleGetBold=2483(int style,)
+
+# Get is a style italic or not.
+get bool StyleGetItalic=2484(int style,)
+
+# Get the size of characters of a style.
+get int StyleGetSize=2485(int style,)
+
+# Get the font of a style.
+# Returns the length of the fontName
+fun int StyleGetFont=2486(int style, stringresult fontName)
+
+# Get is a style to have its end of line filled or not.
+get bool StyleGetEOLFilled=2487(int style,)
+
+# Get is a style underlined or not.
+get bool StyleGetUnderline=2488(int style,)
+
+# Get is a style mixed case, or to force upper or lower case.
+get int StyleGetCase=2489(int style,)
+
+# Get the character set of the font in a style.
+get int StyleGetCharacterSet=2490(int style,)
+
+# Get is a style visible or not.
+get bool StyleGetVisible=2491(int style,)
+
+# Get is a style changeable or not (read only).
+# Experimental feature, currently buggy.
+get bool StyleGetChangeable=2492(int style,)
+
+# Get is a style a hotspot or not.
+get bool StyleGetHotSpot=2493(int style,)
+
# Set a style to be mixed case, or to force upper or lower case.
set void StyleSetCase=2060(int style, int caseForce)
# Set the alpha of the selection.
set void SetSelAlpha=2478(int alpha,)
+# Is the selection end of line filled?
+get bool GetSelEOLFilled=2479(,)
+
+# Set the selection to have its end of line filled or not.
+set void SetSelEOLFilled=2480(bool filled,)
+
# Set the foreground colour of the caret.
set void SetCaretFore=2069(colour fore,)
# End a sequence of actions that is undone and redone as a unit.
fun void EndUndoAction=2079(,)
+# Indicator style enumeration and some constants
enu IndicatorStyle=INDIC_
-val INDIC_MAX=7
val INDIC_PLAIN=0
val INDIC_SQUIGGLE=1
val INDIC_TT=2
val INDIC_HIDDEN=5
val INDIC_BOX=6
val INDIC_ROUNDBOX=7
+val INDIC_MAX=31
+val INDIC_CONTAINER=8
val INDIC0_MASK=0x20
val INDIC1_MASK=0x40
val INDIC2_MASK=0x80
# Retrieve the foreground colour of an indicator.
get colour IndicGetFore=2083(int indic,)
+# Set an indicator to draw under text or over(default).
+set void IndicSetUnder=2510(int indic, bool under)
+
+# Retrieve whether indicator drawn under or over text.
+get bool IndicGetUnder=2511(int indic,)
+
# Set the foreground colour of all whitespace and whether to use this setting.
fun void SetWhitespaceFore=2084(bool useSetting, colour fore)
# Is the horizontal scroll bar visible?
get bool GetHScrollBar=2131(,)
+enu IndentView=SC_IV_
+val SC_IV_NONE=0
+val SC_IV_REAL=1
+val SC_IV_LOOKFORWARD=2
+val SC_IV_LOOKBOTH=3
+
# Show or hide indentation guides.
-set void SetIndentationGuides=2132(bool show,)
+set void SetIndentationGuides=2132(int indentView,)
# Are the indentation guides visible?
-get bool GetIndentationGuides=2133(,)
+get int GetIndentationGuides=2133(,)
# Set the highlighted indentation guide column.
# 0 = no highlighted guide.
# Retrieve the document width assumed for scrolling.
get int GetScrollWidth=2275(,)
+# Sets whether the maximum width line displayed is used to set scroll width.
+set void SetScrollWidthTracking=2516(bool tracking,)
+
+# Retrieve whether the scroll width tracks wide lines.
+get bool GetScrollWidthTracking=2517(,)
+
# Measure the pixel width of some text in a particular style.
# NUL terminated text argument.
# Does not handle tab or control characters.
# Delete the word to the right of the caret.
fun void DelWordRight=2336(,)
+# Delete the word to the right of the caret, but not the trailing non-word characters.
+fun void DelWordRightEnd=2518(,)
+
# Cut the line containing the caret.
fun void LineCut=2337(,)
# Set a fore colour for active hotspots.
set void SetHotspotActiveFore=2410(bool useSetting, colour fore)
+# Get the fore colour for active hotspots.
+get colour GetHotspotActiveFore=2494(,)
+
# Set a back colour for active hotspots.
set void SetHotspotActiveBack=2411(bool useSetting, colour back)
+# Get the back colour for active hotspots.
+get colour GetHotspotActiveBack=2495(,)
+
# Enable / Disable underlining active hotspots.
set void SetHotspotActiveUnderline=2412(bool underline,)
+# Get whether underlining for active hotspots.
+get bool GetHotspotActiveUnderline=2496(,)
+
# Limit hotspots to single line so hotspots on two lines don't merge.
set void SetHotspotSingleLine=2421(bool singleLine,)
+# Get the HotspotSingleLine property
+get bool GetHotspotSingleLine=2497(,)
+
# Move caret between paragraphs (delimited by empty lines).
fun void ParaDown=2413(,)
fun void ParaDownExtend=2414(,)
# Copy argument text to the clipboard.
fun void CopyText=2420(int length, string text)
-# Selection modes
+# Selection Modes
enu SelectionMode=SC_SEL_
val SC_SEL_STREAM=0
val SC_SEL_RECTANGLE=1
# 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
+val CARETSTYLE_BLOCK=2
+
+# Set the style of the caret to be drawn.
+set void SetCaretStyle=2512(int caretStyle,)
+
+# Returns the current style of the caret.
+get int GetCaretStyle=2513(,)
+
+# Set the indicator used for IndicatorFillRange and IndicatorClearRange
+set void SetIndicatorCurrent=2500(int indicator,)
+
+# Get the current indicator
+get int GetIndicatorCurrent=2501(,)
+
+# Set the value used for IndicatorFillRange
+set void SetIndicatorValue=2502(int value,)
+
+# Get the current indicator vaue
+get int GetIndicatorValue=2503(,)
+
+# Turn a indicator on over a range.
+fun void IndicatorFillRange=2504(int position, int fillLength)
+
+# Turn a indicator off over a range.
+fun void IndicatorClearRange=2505(int position, int clearLength)
+
+# Are any indicators present at position?
+fun int IndicatorAllOnFor=2506(int position,)
+
+# What value does a particular indicator have at at a position?
+fun int IndicatorValueAt=2507(int indicator, int position)
+
+# Where does a particular indicator start?
+fun int IndicatorStart=2508(int indicator, int position)
+
+# Where does a particular indicator end?
+fun int IndicatorEnd=2509(int indicator, int position)
+
+# Set number of entries in position cache
+set void SetPositionCache=2514(int size,)
+
+# How many entries are allocated to the position cache?
+get int GetPositionCache=2515(,)
+
# Start notifying the container of all key presses and commands.
fun void StartRecord=3001(,)
val SC_MOD_BEFOREINSERT=0x400
val SC_MOD_BEFOREDELETE=0x800
val SC_MULTILINEUNDOREDO=0x1000
-val SC_MODEVENTMASKALL=0x1FFF
+val SC_STARTACTION=0x2000
+val SC_MOD_CHANGEINDICATOR=0x4000
+val SC_MOD_CHANGELINESTATE=0x8000
+val SC_MODEVENTMASKALL=0xFFFF
# For compatibility, these go through the COMMAND notification rather than NOTIFY
# and should have had exactly the same values as the EN_* constants.
val SCK_ADD=310
val SCK_SUBTRACT=311
val SCK_DIVIDE=312
+val SCK_WIN=313
+val SCK_RWIN=314
+val SCK_MENU=315
enu KeyMod=SCMOD_
val SCMOD_NORM=0
val SCLEX_INNOSETUP=76
val SCLEX_OPAL=77
val SCLEX_SPICE=78
+val SCLEX_D=79
+val SCLEX_CMAKE=80
+val SCLEX_GAP=81
+val SCLEX_PLM=82
+val SCLEX_PROGRESS=83
+val SCLEX_ABAQUS=84
+val SCLEX_ASYMPTOTE=85
+val SCLEX_R=86
# When a lexer specifies its language as SCLEX_AUTOMATIC it receives a
# value assigned in sequence from SCLEX_AUTOMATIC+1.
val SCE_C_COMMENTDOCKEYWORD=17
val SCE_C_COMMENTDOCKEYWORDERROR=18
val SCE_C_GLOBALCLASS=19
+# Lexical states for SCLEX_D
+lex D=SCLEX_D SCE_D_
+val SCE_D_DEFAULT=0
+val SCE_D_COMMENT=1
+val SCE_D_COMMENTLINE=2
+val SCE_D_COMMENTDOC=3
+val SCE_D_COMMENTNESTED=4
+val SCE_D_NUMBER=5
+val SCE_D_WORD=6
+val SCE_D_WORD2=7
+val SCE_D_WORD3=8
+val SCE_D_TYPEDEF=9
+val SCE_D_STRING=10
+val SCE_D_STRINGEOL=11
+val SCE_D_CHARACTER=12
+val SCE_D_OPERATOR=13
+val SCE_D_IDENTIFIER=14
+val SCE_D_COMMENTLINEDOC=15
+val SCE_D_COMMENTDOCKEYWORD=16
+val SCE_D_COMMENTDOCKEYWORDERROR=17
# Lexical states for SCLEX_TCL
lex TCL=SCLEX_TCL SCE_TCL_
val SCE_TCL_DEFAULT=0
val SCE_PL_STRING_QR=29
val SCE_PL_STRING_QW=30
val SCE_PL_POD_VERB=31
+val SCE_PL_SUB_PROTOTYPE=40
+val SCE_PL_FORMAT_IDENT=41
+val SCE_PL_FORMAT=42
# Lexical states for SCLEX_RUBY
lex Ruby=SCLEX_RUBY SCE_RB_
val SCE_RB_DEFAULT=0
val SCE_ERR_ABSF=18
val SCE_ERR_TIDY=19
val SCE_ERR_JAVA_STACK=20
+val SCE_ERR_VALUE=21
# Lexical states for SCLEX_BATCH
lex Batch=SCLEX_BATCH SCE_BAT_
val SCE_BAT_DEFAULT=0
val SCE_YAML_DOCUMENT=6
val SCE_YAML_TEXT=7
val SCE_YAML_ERROR=8
+val SCE_YAML_OPERATOR=9
# Lexical states for SCLEX_TEX
lex TeX=SCLEX_TEX SCE_TEX_
val SCE_TEX_DEFAULT=0
val SCE_T3_USER1=17
val SCE_T3_USER2=18
val SCE_T3_USER3=19
+val SCE_T3_BRACE=20
# Lexical states for SCLEX_REBOL
lex Rebol=SCLEX_REBOL SCE_REBOL_
val SCE_REBOL_DEFAULT=0
val SCE_SPICE_DELIMITER=6
val SCE_SPICE_VALUE=7
val SCE_SPICE_COMMENTLINE=8
+# Lexical states for SCLEX_CMAKE
+lex CMAKE=SCLEX_CMAKE SCE_CMAKE_
+val SCE_CMAKE_DEFAULT=0
+val SCE_CMAKE_COMMENT=1
+val SCE_CMAKE_STRINGDQ=2
+val SCE_CMAKE_STRINGLQ=3
+val SCE_CMAKE_STRINGRQ=4
+val SCE_CMAKE_COMMANDS=5
+val SCE_CMAKE_PARAMETERS=6
+val SCE_CMAKE_VARIABLE=7
+val SCE_CMAKE_USERDEFINED=8
+val SCE_CMAKE_WHILEDEF=9
+val SCE_CMAKE_FOREACHDEF=10
+val SCE_CMAKE_IFDEFINEDEF=11
+val SCE_CMAKE_MACRODEF=12
+val SCE_CMAKE_STRINGVAR=13
+val SCE_CMAKE_NUMBER=14
+# Lexical states for SCLEX_GAP
+lex Gap=SCLEX_GAP SCE_GAP_
+val SCE_GAP_DEFAULT=0
+val SCE_GAP_IDENTIFIER=1
+val SCE_GAP_KEYWORD=2
+val SCE_GAP_KEYWORD2=3
+val SCE_GAP_KEYWORD3=4
+val SCE_GAP_KEYWORD4=5
+val SCE_GAP_STRING=6
+val SCE_GAP_CHAR=7
+val SCE_GAP_OPERATOR=8
+val SCE_GAP_COMMENT=9
+val SCE_GAP_NUMBER=10
+val SCE_GAP_STRINGEOL=11
+# Lexical state for SCLEX_PLM
+lex PLM=SCLEX_PLM SCE_PLM_
+val SCE_PLM_DEFAULT=0
+val SCE_PLM_COMMENT=1
+val SCE_PLM_STRING=2
+val SCE_PLM_NUMBER=3
+val SCE_PLM_IDENTIFIER=4
+val SCE_PLM_OPERATOR=5
+val SCE_PLM_CONTROL=6
+val SCE_PLM_KEYWORD=7
+# Lexical state for SCLEX_PROGRESS
+lex Progress=SCLEX_PROGRESS SCE_4GL_
+val SCE_4GL_DEFAULT=0
+val SCE_4GL_NUMBER=1
+val SCE_4GL_WORD=2
+val SCE_4GL_STRING=3
+val SCE_4GL_CHARACTER=4
+val SCE_4GL_PREPROCESSOR=5
+val SCE_4GL_OPERATOR=6
+val SCE_4GL_IDENTIFIER=7
+val SCE_4GL_BLOCK=8
+val SCE_4GL_END=9
+val SCE_4GL_COMMENT1=10
+val SCE_4GL_COMMENT2=11
+val SCE_4GL_COMMENT3=12
+val SCE_4GL_COMMENT4=13
+val SCE_4GL_COMMENT5=14
+val SCE_4GL_COMMENT6=15
+val SCE_4GL_DEFAULT_=16
+val SCE_4GL_NUMBER_=17
+val SCE_4GL_WORD_=18
+val SCE_4GL_STRING_=19
+val SCE_4GL_CHARACTER_=20
+val SCE_4GL_PREPROCESSOR_=21
+val SCE_4GL_OPERATOR_=22
+val SCE_4GL_IDENTIFIER_=23
+val SCE_4GL_BLOCK_=24
+val SCE_4GL_END_=25
+val SCE_4GL_COMMENT1_=26
+val SCE_4GL_COMMENT2_=27
+val SCE_4GL_COMMENT3_=28
+val SCE_4GL_COMMENT4_=29
+val SCE_4GL_COMMENT5_=30
+val SCE_4GL_COMMENT6_=31
+# Lexical states for SCLEX_ABAQUS
+lex ABAQUS=SCLEX_ABAQUS SCE_ABAQUS_
+val SCE_ABAQUS_DEFAULT=0
+val SCE_ABAQUS_COMMENT=1
+val SCE_ABAQUS_COMMENTBLOCK=2
+val SCE_ABAQUS_NUMBER=3
+val SCE_ABAQUS_STRING=4
+val SCE_ABAQUS_OPERATOR=5
+val SCE_ABAQUS_WORD=6
+val SCE_ABAQUS_PROCESSOR=7
+val SCE_ABAQUS_COMMAND=8
+val SCE_ABAQUS_SLASHCOMMAND=9
+val SCE_ABAQUS_STARCOMMAND=10
+val SCE_ABAQUS_ARGUMENT=11
+val SCE_ABAQUS_FUNCTION=12
+# Lexical states for SCLEX_ASYMPTOTE
+lex Asymptote=SCLEX_ASYMPTOTE SCE_ASY_
+val SCE_ASY_DEFAULT=0
+val SCE_ASY_COMMENT=1
+val SCE_ASY_COMMENTLINE=2
+val SCE_ASY_NUMBER=3
+val SCE_ASY_WORD=4
+val SCE_ASY_STRING=5
+val SCE_ASY_CHARACTER=6
+val SCE_ASY_OPERATOR=7
+val SCE_ASY_IDENTIFIER=8
+val SCE_ASY_STRINGEOL=9
+val SCE_ASY_COMMENTLINEDOC=10
+val SCE_ASY_WORD2=11
+# Lexical states for SCLEX_R
+lex R=SCLEX_R SCE_R_
+val SCE_R_DEFAULT=0
+val SCE_R_COMMENT=1
+val SCE_R_KWORD=2
+val SCE_R_BASEKWORD=3
+val SCE_R_OTHERKWORD=4
+val SCE_R_NUMBER=5
+val SCE_R_STRING=6
+val SCE_R_STRING2=7
+val SCE_R_OPERATOR=8
+val SCE_R_IDENTIFIER=9
+val SCE_R_INFIX=10
+val SCE_R_INFIXEOL=11
# Events
evt void HotSpotDoubleClick=2020(int modifiers, int position)
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
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
/**
*/
class WindowAccessor : public Accessor {
}
void StartAt(unsigned int start, char chMask=31);
- void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; }
+ void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; };
unsigned int GetStartSegment() { return startSeg; }
void StartSegment(unsigned int pos);
void ColourTo(unsigned int pos, int chAttr);
void SetLevel(int line, int level);
int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0);
+ void IndicatorFill(int start, int end, int indicator, int value);
};
+
+#ifdef SCI_NAMESPACE
+}
+#endif
#include "PropSet.h"
#include "AutoComplete.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
AutoComplete::AutoComplete() :
active(false),
separator(' '),
#ifndef AUTOCOMPLETE_H
#define AUTOCOMPLETE_H
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
/**
*/
class AutoComplete {
void Select(const char *word);
};
+#ifdef SCI_NAMESPACE
+}
+#endif
+
#endif
#include "Scintilla.h"
#include "CallTip.h"
+#include <stdio.h>
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
static const int insetX = 5; // text inset in x from calltip border
static const int widthArrow = 14;
tabSize = 0;
useStyleCallTip = false; // for backwards compatibility
+#ifdef __APPLE__
+ // proper apple colours for the default
+ colourBG.desired = ColourDesired(0xff, 0xff, 0xc6);
+ colourUnSel.desired = ColourDesired(0, 0, 0);
+#else
colourBG.desired = ColourDesired(0xff, 0xff, 0xff);
colourUnSel.desired = ColourDesired(0x80, 0x80, 0x80);
+#endif
colourSel.desired = ColourDesired(0, 0, 0x80);
colourShade.desired = ColourDesired(0, 0, 0);
colourLight.desired = ColourDesired(0xc0, 0xc0, 0xc0);
char *chunkVal = val;
bool moreChunks = true;
int maxWidth = 0;
+
while (moreChunks) {
char *chunkEnd = strchr(chunkVal, '\n');
if (chunkEnd == NULL) {
offsetMain = insetX; // initial alignment assuming no arrows
PaintContents(surfaceWindow, true);
+#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);
surfaceWindow->PenColour(colourShade.allocated);
surfaceWindow->PenColour(colourLight.allocated);
surfaceWindow->LineTo(0, 0);
surfaceWindow->LineTo(0, rcClientSize.bottom - 1);
+#endif
}
void CallTip::MouseClick(Point pt) {
#ifndef CALLTIP_H
#define CALLTIP_H
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
/**
*/
class CallTip {
void SetForeBack(const ColourPair &fore, const ColourPair &back);
};
+#ifdef SCI_NAMESPACE
+}
+#endif
+
#endif
#include "Platform.h"
#include "Scintilla.h"
-#include "SVector.h"
+#include "SplitVector.h"
+#include "Partitioning.h"
#include "CellBuffer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
MarkerHandleSet::MarkerHandleSet() {
root = 0;
}
root = 0;
}
-int MarkerHandleSet::Length() {
+int MarkerHandleSet::Length() const {
int c = 0;
MarkerHandleNumber *mhn = root;
while (mhn) {
return c;
}
-int MarkerHandleSet::NumberFromHandle(int handle) {
+int MarkerHandleSet::NumberFromHandle(int handle) const {
MarkerHandleNumber *mhn = root;
while (mhn) {
if (mhn->handle == handle) {
return - 1;
}
-int MarkerHandleSet::MarkValue() {
+int MarkerHandleSet::MarkValue() const {
unsigned int m = 0;
MarkerHandleNumber *mhn = root;
while (mhn) {
return m;
}
-bool MarkerHandleSet::Contains(int handle) {
+bool MarkerHandleSet::Contains(int handle) const {
MarkerHandleNumber *mhn = root;
while (mhn) {
if (mhn->handle == handle) {
if (mhn->handle == handle) {
*pmhn = mhn->next;
delete mhn;
- return ;
+ return;
}
pmhn = &((*pmhn)->next);
}
other->root = 0;
}
-LineVector::LineVector() {
- linesData = 0;
- lines = 0;
- size = 0;
- levels = 0;
- sizeLevels = 0;
+LineVector::LineVector() : starts(256) {
handleCurrent = 1;
- growSize = 1000;
Init();
}
LineVector::~LineVector() {
- for (int line = 0; line < lines; line++) {
- delete linesData[line].handleSet;
- linesData[line].handleSet = 0;
+ starts.DeleteAll();
+ for (int line = 0; line < markers.Length(); line++) {
+ delete markers[line];
+ markers[line] = 0;
}
- delete []linesData;
- linesData = 0;
- delete []levels;
- levels = 0;
+ markers.DeleteAll();
+ levels.DeleteAll();
}
void LineVector::Init() {
- for (int line = 0; line < lines; line++) {
- delete linesData[line].handleSet;
- linesData[line].handleSet = 0;
- }
- delete []linesData;
- linesData = new LineData[static_cast<int>(growSize)];
- size = growSize;
- lines = 1;
- delete []levels;
- levels = 0;
- sizeLevels = 0;
-}
-
-void LineVector::Expand(int sizeNew) {
- LineData *linesDataNew = new LineData[sizeNew];
- if (linesDataNew) {
- for (int i = 0; i < size; i++)
- linesDataNew[i] = linesData[i];
- // Do not delete handleSets here as they are transferred to new linesData
- delete []linesData;
- linesData = linesDataNew;
- size = sizeNew;
- } else {
- Platform::DebugPrintf("No memory available\n");
- // TODO: Blow up
+ starts.DeleteAll();
+ for (int line = 0; line < markers.Length(); line++) {
+ delete markers[line];
+ markers[line] = 0;
}
-
+ markers.DeleteAll();
+ levels.DeleteAll();
}
void LineVector::ExpandLevels(int sizeNew) {
- if (sizeNew == -1)
- sizeNew = size;
- int *levelsNew = new int[sizeNew];
- if (levelsNew) {
- int i = 0;
- for (; i < sizeLevels; i++)
- levelsNew[i] = levels[i];
- for (; i < sizeNew; i++)
- levelsNew[i] = SC_FOLDLEVELBASE;
- delete []levels;
- levels = levelsNew;
- sizeLevels = sizeNew;
- } else {
- Platform::DebugPrintf("No memory available\n");
- // TODO: Blow up
- }
-
+ levels.InsertValue(levels.Length(), sizeNew - levels.Length(), SC_FOLDLEVELBASE);
}
void LineVector::ClearLevels() {
- delete []levels;
- levels = 0;
- sizeLevels = 0;
-}
-
-void LineVector::InsertValue(int pos, int value) {
- //Platform::DebugPrintf("InsertValue[%d] = %d\n", pos, value);
- if ((lines + 2) >= size) {
- if (growSize * 6 < size)
- growSize *= 2;
- Expand(size + growSize);
- if (levels) {
- ExpandLevels(size + growSize);
- }
- }
- lines++;
- for (int i = lines; i > pos; i--) {
- linesData[i] = linesData[i - 1];
- }
- linesData[pos].startPosition = value;
- linesData[pos].handleSet = 0;
- if (levels) {
- for (int j = lines; j > pos; j--) {
- levels[j] = levels[j - 1];
+ levels.DeleteAll();
+}
+
+int LineVector::SetLevel(int line, int level) {
+ int prev = 0;
+ if ((line >= 0) && (line < Lines())) {
+ if (!levels.Length()) {
+ ExpandLevels(Lines() + 1);
}
- if (pos == 0) {
- levels[pos] = SC_FOLDLEVELBASE;
- } else if (pos == (lines - 1)) { // Last line will not be a folder
- levels[pos] = SC_FOLDLEVELBASE;
- } else {
- levels[pos] = levels[pos - 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::InsertText(int line, int delta) {
+ starts.InsertText(line, delta);
}
-void LineVector::SetValue(int pos, int value) {
- //Platform::DebugPrintf("SetValue[%d] = %d\n", pos, value);
- if ((pos + 2) >= size) {
- //Platform::DebugPrintf("Resize %d %d\n", size,pos);
- Expand(pos + growSize);
- //Platform::DebugPrintf("end Resize %d %d\n", size,pos);
- lines = pos;
- if (levels) {
- ExpandLevels(pos + growSize);
+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);
}
- linesData[pos].startPosition = value;
}
-void LineVector::Remove(int pos) {
- //Platform::DebugPrintf("Remove %d\n", pos);
+void LineVector::SetLineStart(int line, int position) {
+ starts.SetPartitionStartPosition(line, position);
+}
+
+void LineVector::RemoveLine(int line) {
+ starts.RemovePartition(line);
// Retain the markers from the deleted line by oring them into the previous line
- if (pos > 0) {
- MergeMarkers(pos - 1);
- }
- for (int i = pos; i < lines; i++) {
- linesData[i] = linesData[i + 1];
+ if (markers.Length()) {
+ if (line > 0) {
+ MergeMarkers(line - 1);
+ }
+ markers.Delete(line);
}
- if (levels) {
+ 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[pos] & SC_FOLDLEVELHEADERFLAG;
- for (int j = pos; j < lines; j++) {
- levels[j] = levels[j + 1];
- }
- if (pos > 0)
- levels[pos-1] |= firstHeader;
+ int firstHeader = levels[line] & SC_FOLDLEVELHEADERFLAG;
+ levels.Delete(line);
+ if (line > 0)
+ levels[line-1] |= firstHeader;
}
- lines--;
}
int LineVector::LineFromPosition(int pos) {
- //Platform::DebugPrintf("LineFromPostion %d lines=%d end = %d\n", pos, lines, linesData[lines].startPosition);
- if (lines == 0)
+ return starts.PartitionFromPosition(pos);
+}
+
+int LineVector::MarkValue(int line) {
+ if (markers.Length() && markers[line])
+ return markers[line]->MarkValue();
+ else
return 0;
- //Platform::DebugPrintf("LineFromPosition %d\n", pos);
- if (pos >= linesData[lines].startPosition)
- return lines - 1;
- int lower = 0;
- int upper = lines;
- do {
- int middle = (upper + lower + 1) / 2; // Round high
- if (pos < linesData[middle].startPosition) {
- upper = middle - 1;
- } else {
- lower = middle;
- }
- } while (lower < upper);
- //Platform::DebugPrintf("LineFromPostion %d %d %d\n", pos, lower, linesData[lower].startPosition, linesData[lower > 1 ? lower - 1 : 0].startPosition);
- return lower;
}
int LineVector::AddMark(int line, int markerNum) {
handleCurrent++;
- if (!linesData[line].handleSet) {
+ 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
- linesData[line].handleSet = new MarkerHandleSet;
- if (!linesData[line].handleSet)
+ markers[line] = new MarkerHandleSet();
+ if (!markers[line])
return - 1;
}
- linesData[line].handleSet->InsertHandle(handleCurrent, markerNum);
+ markers[line]->InsertHandle(handleCurrent, markerNum);
return handleCurrent;
}
void LineVector::MergeMarkers(int pos) {
- if (linesData[pos + 1].handleSet != NULL) {
- if (linesData[pos].handleSet == NULL )
- linesData[pos].handleSet = new MarkerHandleSet;
- linesData[pos].handleSet->CombineWith(linesData[pos + 1].handleSet);
- delete linesData[pos + 1].handleSet;
- linesData[pos + 1].handleSet = NULL;
+ 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 (linesData[line].handleSet) {
+ if (markers.Length() && markers[line]) {
if (markerNum == -1) {
- delete linesData[line].handleSet;
- linesData[line].handleSet = 0;
+ delete markers[line];
+ markers[line] = NULL;
} else {
- bool performedDeletion =
- linesData[line].handleSet->RemoveNumber(markerNum);
+ bool performedDeletion = markers[line]->RemoveNumber(markerNum);
while (all && performedDeletion) {
- performedDeletion =
- linesData[line].handleSet->RemoveNumber(markerNum);
+ performedDeletion = markers[line]->RemoveNumber(markerNum);
}
- if (linesData[line].handleSet->Length() == 0) {
- delete linesData[line].handleSet;
- linesData[line].handleSet = 0;
+ if (markers[line]->Length() == 0) {
+ delete markers[line];
+ markers[line] = NULL;
}
}
}
void LineVector::DeleteMarkFromHandle(int markerHandle) {
int line = LineFromHandle(markerHandle);
if (line >= 0) {
- linesData[line].handleSet->RemoveHandle(markerHandle);
- if (linesData[line].handleSet->Length() == 0) {
- delete linesData[line].handleSet;
- linesData[line].handleSet = 0;
+ markers[line]->RemoveHandle(markerHandle);
+ if (markers[line]->Length() == 0) {
+ delete markers[line];
+ markers[line] = NULL;
}
}
}
int LineVector::LineFromHandle(int markerHandle) {
- for (int line = 0; line < lines; line++) {
- if (linesData[line].handleSet) {
- if (linesData[line].handleSet->Contains(markerHandle)) {
- return line;
+ if (markers.Length()) {
+ for (int line = 0; line < Lines(); line++) {
+ if (markers[line]) {
+ if (markers[line]->Contains(markerHandle)) {
+ return line;
+ }
}
}
}
- return - 1;
+ return -1;
}
Action::Action() {
int lenActionsNew = lenActions * 2;
Action *actionsNew = new Action[lenActionsNew];
if (!actionsNew)
- return ;
+ return;
for (int act = 0; act <= currentAction; act++)
actionsNew[act].Grab(&actions[act]);
delete []actions;
}
}
-void UndoHistory::AppendAction(actionType at, int position, char *data, int lengthData) {
+void UndoHistory::AppendAction(actionType at, int position, char *data, int lengthData,
+ bool &startSequence) {
EnsureUndoRoom();
//Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, lengthData, currentAction);
//Platform::DebugPrintf("^ %d action %d %d\n", actions[currentAction - 1].at,
if (currentAction < savePoint) {
savePoint = -1;
}
+ int oldCurrentAction = currentAction;
if (currentAction >= 1) {
if (0 == undoSequenceDepth) {
// Top level actions may not always be coalesced
currentAction++;
}
} else {
- //Platform::DebugPrintf("action coalesced\n");
+ // Action coalesced.
}
} else {
} else {
currentAction++;
}
+ startSequence = oldCurrentAction != currentAction;
actions[currentAction].Create(at, position, data, lengthData);
currentAction++;
actions[currentAction].Create(startAction);
}
void UndoHistory::EndUndoAction() {
+ PLATFORM_ASSERT(undoSequenceDepth > 0);
EnsureUndoRoom();
undoSequenceDepth--;
if (0 == undoSequenceDepth) {
currentAction++;
}
-CellBuffer::CellBuffer(int initialLength) {
- body = new char[initialLength];
- size = initialLength;
- length = 0;
- part1len = 0;
- gaplen = initialLength;
- part2body = body + gaplen;
+CellBuffer::CellBuffer() {
readOnly = false;
collectingUndo = true;
- growSize = 4000;
}
CellBuffer::~CellBuffer() {
- delete []body;
- body = 0;
-}
-
-void CellBuffer::GapTo(int position) {
- if (position == part1len)
- return ;
- if (position < part1len) {
- int diff = part1len - position;
- //Platform::DebugPrintf("Move gap backwards to %d diff = %d part1len=%d length=%d \n", position,diff, part1len, length);
- for (int i = 0; i < diff; i++)
- body[part1len + gaplen - i - 1] = body[part1len - i - 1];
- } else { // position > part1len
- int diff = position - part1len;
- //Platform::DebugPrintf("Move gap forwards to %d diff =%d\n", position,diff);
- for (int i = 0; i < diff; i++)
- body[part1len + i] = body[part1len + gaplen + i];
- }
- part1len = position;
- part2body = body + gaplen;
-}
-
-void CellBuffer::RoomFor(int insertionLength) {
- //Platform::DebugPrintf("need room %d %d\n", gaplen, insertionLength);
- if (gaplen <= insertionLength) {
- //Platform::DebugPrintf("need room %d %d\n", gaplen, insertionLength);
- if (growSize * 6 < size)
- growSize *= 2;
- int newSize = size + insertionLength + growSize;
- Allocate(newSize);
- }
}
-// To make it easier to write code that uses ByteAt, a position outside the range of the buffer
-// can be retrieved. All characters outside the range have the value '\0'.
-char CellBuffer::ByteAt(int position) {
- if (position < part1len) {
- if (position < 0) {
- return '\0';
- } else {
- return body[position];
- }
- } else {
- if (position >= length) {
- return '\0';
- } else {
- return part2body[position];
- }
- }
-}
-
-void CellBuffer::SetByteAt(int position, char ch) {
-
- if (position < 0) {
- //Platform::DebugPrintf("Bad position %d\n",position);
- return ;
- }
- if (position >= length + 11) {
- Platform::DebugPrintf("Very Bad position %d of %d\n", position, length);
- //exit(2);
- return ;
- }
- if (position >= length) {
- //Platform::DebugPrintf("Bad position %d of %d\n",position,length);
- return ;
- }
-
- if (position < part1len) {
- body[position] = ch;
- } else {
- part2body[position] = ch;
- }
-}
-
-char CellBuffer::CharAt(int position) {
- return ByteAt(position*2);
+char CellBuffer::CharAt(int position) const {
+ return substance.ValueAt(position);
}
void CellBuffer::GetCharRange(char *buffer, int position, int lengthRetrieve) {
if (lengthRetrieve < 0)
- return ;
+ return;
if (position < 0)
- return ;
- int bytePos = position * 2;
- if ((bytePos + lengthRetrieve * 2) > length) {
- Platform::DebugPrintf("Bad GetCharRange %d for %d of %d\n", bytePos,
- lengthRetrieve, length);
- return ;
+ return;
+ if ((position + lengthRetrieve) > substance.Length()) {
+ Platform::DebugPrintf("Bad GetCharRange %d for %d of %d\n", position,
+ lengthRetrieve, substance.Length());
+ return;
}
- GapTo(0); // Move the buffer so its easy to subscript into it
- char *pb = part2body + bytePos;
- while (lengthRetrieve--) {
- *buffer++ = *pb;
- pb += 2;
+
+ for (int i=0; i<lengthRetrieve; i++) {
+ *buffer++ = substance.ValueAt(position + i);
}
}
char CellBuffer::StyleAt(int position) {
- return ByteAt(position*2 + 1);
+ return style.ValueAt(position);
}
-const char *CellBuffer::InsertString(int position, char *s, int insertLength) {
+// 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;
// InsertString and DeleteChars are the bottleneck though which all changes occur
if (!readOnly) {
if (collectingUndo) {
// Save into the undo/redo stack, but only the characters - not the formatting
// This takes up about half load time
- data = new char[insertLength / 2];
- for (int i = 0; i < insertLength / 2; i++) {
- data[i] = s[i * 2];
+ data = new char[insertLength];
+ for (int i = 0; i < insertLength; i++) {
+ data[i] = s[i];
}
- uh.AppendAction(insertAction, position / 2, data, insertLength / 2);
+ uh.AppendAction(insertAction, position, data, insertLength, startSequence);
}
BasicInsertString(position, s, insertLength);
return data;
}
-bool CellBuffer::SetStyleAt(int position, char style, char mask) {
- style &= mask;
- char curVal = ByteAt(position * 2 + 1);
- if ((curVal & mask) != style) {
- SetByteAt(position*2 + 1, static_cast<char>((curVal & ~mask) | style));
+bool CellBuffer::SetStyleAt(int position, char styleValue, char mask) {
+ styleValue &= mask;
+ char curVal = style.ValueAt(position);
+ if ((curVal & mask) != styleValue) {
+ style.SetValueAt(position, static_cast<char>((curVal & ~mask) | styleValue));
return true;
} else {
return false;
}
}
-bool CellBuffer::SetStyleFor(int position, int lengthStyle, char style, char mask) {
- int bytePos = position * 2 + 1;
+bool CellBuffer::SetStyleFor(int position, int lengthStyle, char styleValue, char mask) {
bool changed = false;
PLATFORM_ASSERT(lengthStyle == 0 ||
- (lengthStyle > 0 && lengthStyle + position < length));
+ (lengthStyle > 0 && lengthStyle + position <= style.Length()));
while (lengthStyle--) {
- char curVal = ByteAt(bytePos);
- if ((curVal & mask) != style) {
- SetByteAt(bytePos, static_cast<char>((curVal & ~mask) | style));
+ char curVal = style.ValueAt(position);
+ if ((curVal & mask) != styleValue) {
+ style.SetValueAt(position, static_cast<char>((curVal & ~mask) | styleValue));
changed = true;
}
- bytePos += 2;
+ position++;
}
return changed;
}
-const char *CellBuffer::DeleteChars(int position, int deleteLength) {
+// The char* returned is to an allocation owned by the undo history
+const char *CellBuffer::DeleteChars(int position, int deleteLength, bool &startSequence) {
// InsertString and DeleteChars are the bottleneck though which all changes occur
PLATFORM_ASSERT(deleteLength > 0);
char *data = 0;
if (!readOnly) {
if (collectingUndo) {
// Save into the undo/redo stack, but only the characters - not the formatting
- data = new char[deleteLength / 2];
- for (int i = 0; i < deleteLength / 2; i++) {
- data[i] = ByteAt(position + i * 2);
+ data = new char[deleteLength];
+ for (int i = 0; i < deleteLength; i++) {
+ data[i] = substance.ValueAt(position + i);
}
- uh.AppendAction(removeAction, position / 2, data, deleteLength / 2);
+ uh.AppendAction(removeAction, position, data, deleteLength, startSequence);
}
BasicDeleteChars(position, deleteLength);
return data;
}
-int CellBuffer::ByteLength() {
- return length;
-}
-
-int CellBuffer::Length() {
- return ByteLength() / 2;
+int CellBuffer::Length() const {
+ return substance.Length();
}
void CellBuffer::Allocate(int newSize) {
- if (newSize > length) {
- GapTo(length);
- char *newBody = new char[newSize];
- memcpy(newBody, body, length);
- delete []body;
- body = newBody;
- gaplen += newSize - size;
- part2body = body + gaplen;
- size = newSize;
- }
+ substance.ReAllocate(newSize);
+ style.ReAllocate(newSize);
}
-int CellBuffer::Lines() {
- //Platform::DebugPrintf("Lines = %d\n", lv.lines);
- return lv.lines;
+int CellBuffer::Lines() const {
+ return lv.Lines();
}
-int CellBuffer::LineStart(int line) {
+int CellBuffer::LineStart(int line) const {
if (line < 0)
return 0;
- else if (line > lv.lines)
+ else if (line >= Lines())
return Length();
else
- return lv.linesData[line].startPosition;
+ return lv.LineStart(line);
}
bool CellBuffer::IsReadOnly() {
}
int CellBuffer::AddMark(int line, int markerNum) {
- if ((line >= 0) && (line < lv.lines)) {
+ if ((line >= 0) && (line < Lines())) {
return lv.AddMark(line, markerNum);
}
return - 1;
}
void CellBuffer::DeleteMark(int line, int markerNum) {
- if ((line >= 0) && (line < lv.lines)) {
+ if ((line >= 0) && (line < Lines())) {
lv.DeleteMark(line, markerNum, false);
}
}
}
int CellBuffer::GetMark(int line) {
- if ((line >= 0) && (line < lv.lines) && (lv.linesData[line].handleSet))
- return lv.linesData[line].handleSet->MarkValue();
+ if ((line >= 0) && (line < Lines()))
+ return lv.MarkValue(line);
return 0;
}
void CellBuffer::DeleteAllMarks(int markerNum) {
- for (int line = 0; line < lv.lines; line++) {
+ for (int line = 0; line < Lines(); line++) {
lv.DeleteMark(line, markerNum, true);
}
}
// Without undo
-void CellBuffer::BasicInsertString(int position, char *s, int insertLength) {
- //Platform::DebugPrintf("Inserting at %d for %d\n", position, insertLength);
+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) {
if (insertLength == 0)
- return ;
+ return;
PLATFORM_ASSERT(insertLength > 0);
- RoomFor(insertLength);
- GapTo(position);
- memcpy(body + part1len, s, insertLength);
- length += insertLength;
- part1len += insertLength;
- gaplen -= insertLength;
- part2body = body + gaplen;
+ substance.InsertFromArray(position, s, 0, insertLength);
+ style.InsertValue(position, insertLength, 0);
- int lineInsert = lv.LineFromPosition(position / 2) + 1;
+ int lineInsert = lv.LineFromPosition(position) + 1;
// Point all the lines after the insertion point further along in the buffer
- for (int lineAfter = lineInsert; lineAfter <= lv.lines; lineAfter++) {
- lv.linesData[lineAfter].startPosition += insertLength / 2;
- }
- char chPrev = ' ';
- if ((position - 2) >= 0)
- chPrev = ByteAt(position - 2);
- char chAfter = ' ';
- if ((position + insertLength) < length)
- chAfter = ByteAt(position + insertLength);
+ lv.InsertText(lineInsert-1, insertLength);
+ char chPrev = substance.ValueAt(position - 1);
+ char chAfter = substance.ValueAt(position + insertLength);
if (chPrev == '\r' && chAfter == '\n') {
- //Platform::DebugPrintf("Splitting a crlf pair at %d\n", lineInsert);
// Splitting up a crlf pair at position
- lv.InsertValue(lineInsert, position / 2);
+ InsertLine(lineInsert, position);
lineInsert++;
}
char ch = ' ';
- for (int i = 0; i < insertLength; i += 2) {
+ for (int i = 0; i < insertLength; i++) {
ch = s[i];
if (ch == '\r') {
- //Platform::DebugPrintf("Inserting cr at %d\n", lineInsert);
- lv.InsertValue(lineInsert, (position + i) / 2 + 1);
+ InsertLine(lineInsert, (position + i) + 1);
lineInsert++;
} else if (ch == '\n') {
if (chPrev == '\r') {
- //Platform::DebugPrintf("Patching cr before lf at %d\n", lineInsert-1);
// Patch up what was end of line
- lv.SetValue(lineInsert - 1, (position + i) / 2 + 1);
+ lv.SetLineStart(lineInsert - 1, (position + i) + 1);
} else {
- //Platform::DebugPrintf("Inserting lf at %d\n", lineInsert);
- lv.InsertValue(lineInsert, (position + i) / 2 + 1);
+ InsertLine(lineInsert, (position + i) + 1);
lineInsert++;
}
}
chPrev = ch;
}
- // Joining two lines where last insertion is cr and following text starts with lf
+ // Joining two lines where last insertion is cr and following substance starts with lf
if (chAfter == '\n') {
if (ch == '\r') {
- //Platform::DebugPrintf("Joining cr before lf at %d\n", lineInsert-1);
// End of line already in buffer so drop the newly created one
- lv.Remove(lineInsert - 1);
+ RemoveLine(lineInsert - 1);
}
}
}
void CellBuffer::BasicDeleteChars(int position, int deleteLength) {
- //Platform::DebugPrintf("Deleting at %d for %d\n", position, deleteLength);
if (deleteLength == 0)
- return ;
+ return;
- if ((position == 0) && (deleteLength == length)) {
+ if ((position == 0) && (deleteLength == substance.Length())) {
// If whole buffer is being deleted, faster to reinitialise lines data
// than to delete each line.
- //printf("Whole buffer being deleted\n");
lv.Init();
} else {
// Have to fix up line positions before doing deletion as looking at text in buffer
// to work out which lines have been removed
- int lineRemove = lv.LineFromPosition(position / 2) + 1;
- // Point all the lines after the insertion point further along in the buffer
- for (int lineAfter = lineRemove; lineAfter <= lv.lines; lineAfter++) {
- lv.linesData[lineAfter].startPosition -= deleteLength / 2;
- }
- char chPrev = ' ';
- if (position >= 2)
- chPrev = ByteAt(position - 2);
+ int lineRemove = lv.LineFromPosition(position) + 1;
+ lv.InsertText(lineRemove-1, - (deleteLength));
+ char chPrev = substance.ValueAt(position - 1);
char chBefore = chPrev;
- char chNext = ' ';
- if (position < length)
- chNext = ByteAt(position);
+ char chNext = substance.ValueAt(position);
bool ignoreNL = false;
if (chPrev == '\r' && chNext == '\n') {
- //Platform::DebugPrintf("Deleting lf after cr, move line end to cr at %d\n", lineRemove);
// Move back one
- lv.SetValue(lineRemove, position / 2);
+ lv.SetLineStart(lineRemove, position);
lineRemove++;
ignoreNL = true; // First \n is not real deletion
}
char ch = chNext;
- for (int i = 0; i < deleteLength; i += 2) {
- chNext = ' ';
- if ((position + i + 2) < length)
- chNext = ByteAt(position + i + 2);
- //Platform::DebugPrintf("Deleting %d %x\n", i, ch);
+ for (int i = 0; i < deleteLength; i++) {
+ chNext = substance.ValueAt(position + i + 1);
if (ch == '\r') {
if (chNext != '\n') {
- //Platform::DebugPrintf("Removing cr end of line\n");
- lv.Remove(lineRemove);
+ RemoveLine(lineRemove);
}
} else if (ch == '\n') {
if (ignoreNL) {
ignoreNL = false; // Further \n are real deletions
} else {
- //Platform::DebugPrintf("Removing lf end of line\n");
- lv.Remove(lineRemove);
+ RemoveLine(lineRemove);
}
}
}
// May have to fix up end if last deletion causes cr to be next to lf
// or removes one of a crlf pair
- char chAfter = ' ';
- if ((position + deleteLength) < length)
- chAfter = ByteAt(position + deleteLength);
+ char chAfter = substance.ValueAt(position + deleteLength);
if (chBefore == '\r' && chAfter == '\n') {
- //d.printf("Joining cr before lf at %d\n", lineRemove);
// Using lineRemove-1 as cr ended line before start of deletion
- lv.Remove(lineRemove - 1);
- lv.SetValue(lineRemove - 1, position / 2 + 1);
+ RemoveLine(lineRemove - 1);
+ lv.SetLineStart(lineRemove - 1, position + 1);
}
}
- GapTo(position);
- length -= deleteLength;
- gaplen += deleteLength;
- part2body = body + gaplen;
+ substance.DeleteRange(position, deleteLength);
+ style.DeleteRange(position, deleteLength);
}
bool CellBuffer::SetUndoCollection(bool collectUndo) {
void CellBuffer::PerformUndoStep() {
const Action &actionStep = uh.GetUndoStep();
if (actionStep.at == insertAction) {
- BasicDeleteChars(actionStep.position*2, actionStep.lenData*2);
+ BasicDeleteChars(actionStep.position, actionStep.lenData);
} else if (actionStep.at == removeAction) {
- char *styledData = new char[actionStep.lenData * 2];
- for (int i = 0; i < actionStep.lenData; i++) {
- styledData[i*2] = actionStep.data[i];
- styledData[i*2 + 1] = 0;
- }
- BasicInsertString(actionStep.position*2, styledData, actionStep.lenData*2);
- delete []styledData;
+ BasicInsertString(actionStep.position, actionStep.data, actionStep.lenData);
}
uh.CompletedUndoStep();
}
void CellBuffer::PerformRedoStep() {
const Action &actionStep = uh.GetRedoStep();
if (actionStep.at == insertAction) {
- char *styledData = new char[actionStep.lenData * 2];
- for (int i = 0; i < actionStep.lenData; i++) {
- styledData[i*2] = actionStep.data[i];
- styledData[i*2 + 1] = 0;
- }
- BasicInsertString(actionStep.position*2, styledData, actionStep.lenData*2);
- delete []styledData;
+ BasicInsertString(actionStep.position, actionStep.data, actionStep.lenData);
} else if (actionStep.at == removeAction) {
- BasicDeleteChars(actionStep.position*2, actionStep.lenData*2);
+ BasicDeleteChars(actionStep.position, actionStep.lenData);
}
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::SetLevel(int line, int level) {
- int prev = 0;
- if ((line >= 0) && (line < lv.lines)) {
- if (!lv.levels) {
- lv.ExpandLevels();
- }
- prev = lv.levels[line];
- if (lv.levels[line] != level) {
- lv.levels[line] = level;
- }
- }
- return prev;
+ return lv.SetLevel(line, level);
}
int CellBuffer::GetLevel(int line) {
- if (lv.levels && (line >= 0) && (line < lv.lines)) {
- return lv.levels[line];
- } else {
- return SC_FOLDLEVELBASE;
- }
+ return lv.GetLevel(line);
}
void CellBuffer::ClearLevels() {
#ifndef CELLBUFFER_H
#define CELLBUFFER_H
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
/**
* This holds the marker identifier and the marker type to display.
* MarkerHandleNumbers are members of lists.
public:
MarkerHandleSet();
~MarkerHandleSet();
- int Length();
- int NumberFromHandle(int handle);
- int MarkValue(); ///< Bit set of marker numbers.
- bool Contains(int handle);
+ 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);
};
-/**
- * Each line stores the starting position of the first character of the line in the cell buffer
- * and potentially a marker handle set. Often a line will not have any attached markers.
- */
-struct LineData {
- int startPosition;
- MarkerHandleSet *handleSet;
- LineData() : startPosition(0), handleSet(0) {
- }
-};
-
/**
* The line vector contains information about each of the lines in a cell buffer.
*/
class LineVector {
-public:
- int growSize;
- int lines;
- LineData *linesData;
- int size;
- int *levels;
- int sizeLevels;
+ Partitioning starts;
+ SplitVector<MarkerHandleSet *> markers;
+ SplitVector<int> levels;
/// Handles are allocated sequentially and should never have to be reused as 32 bit ints are very big.
int handleCurrent;
+public:
+
LineVector();
~LineVector();
void Init();
- void Expand(int sizeNew);
void ExpandLevels(int sizeNew=-1);
void ClearLevels();
- void InsertValue(int pos, int value);
- void SetValue(int pos, int value);
- void Remove(int pos);
+ int SetLevel(int line, int level);
+ int GetLevel(int line);
+
+ void InsertText(int line, int delta);
+ void InsertLine(int line, int position);
+ void SetLineStart(int line, int position);
+ void RemoveLine(int line);
+ int Lines() const {
+ return starts.Partitions();
+ }
int LineFromPosition(int pos);
+ int LineStart(int line) const {
+ return starts.PositionFromPartition(line);
+ }
+ int MarkValue(int line);
int AddMark(int line, int marker);
void MergeMarkers(int pos);
void DeleteMark(int line, int markerNum, bool all);
UndoHistory();
~UndoHistory();
- void AppendAction(actionType at, int position, char *data, int length);
+ void AppendAction(actionType at, int position, char *data, int length, bool &startSequence);
void BeginUndoAction();
void EndUndoAction();
*/
class CellBuffer {
private:
- char *body; ///< The cell buffer itself.
- int size; ///< Allocated size of the buffer.
- int length; ///< Total length of the data.
- int part1len; ///< Length of the first part.
- int gaplen; ///< Length of the gap between the two parts.
- char *part2body; ///< The second part of the cell buffer.
- ///< Doesn't point after the gap but set so that
- ///< part2body[position] is consistent with body[position].
+ SplitVector<char> substance;
+ SplitVector<char> style;
bool readOnly;
- int growSize;
bool collectingUndo;
UndoHistory uh;
LineVector lv;
- SVector lineStates;
-
- void GapTo(int position);
- void RoomFor(int insertionLength);
-
- inline char ByteAt(int position);
- void SetByteAt(int position, char ch);
+ SplitVector<int> lineStates;
public:
- CellBuffer(int initialLength = 4000);
+ CellBuffer();
~CellBuffer();
/// Retrieving positions outside the range of the buffer works and returns 0
- char CharAt(int position);
+ char CharAt(int position) const;
void GetCharRange(char *buffer, int position, int lengthRetrieve);
char StyleAt(int position);
- int ByteLength();
- int Length();
+ int Length() const;
void Allocate(int newSize);
- int Lines();
- int LineStart(int line);
+ int Lines() const;
+ int LineStart(int line) const;
int LineFromPosition(int pos) { return lv.LineFromPosition(pos); }
- const char *InsertString(int position, char *s, int insertLength);
+ void InsertLine(int line, int position);
+ void RemoveLine(int line);
+ const char *InsertString(int position, const char *s, int insertLength, bool &startSequence);
/// Setting styles for positions outside the range of the buffer is safe and has no effect.
/// @return true if the style of a character is changed.
- bool SetStyleAt(int position, char style, char mask='\377');
- bool SetStyleFor(int position, int length, char style, char mask);
+ bool SetStyleAt(int position, char styleValue, char mask='\377');
+ bool SetStyleFor(int position, int length, char styleValue, char mask);
- const char *DeleteChars(int position, int deleteLength);
+ const char *DeleteChars(int position, int deleteLength, bool &startSequence);
bool IsReadOnly();
void SetReadOnly(bool set);
int LineFromHandle(int markerHandle);
/// Actions without undo
- void BasicInsertString(int position, char *s, int insertLength);
+ void BasicInsertString(int position, const char *s, int insertLength);
void BasicDeleteChars(int position, int deleteLength);
bool SetUndoCollection(bool collectUndo);
void ClearLevels();
};
-#define CELL_SIZE 2
+#ifdef SCI_NAMESPACE
+}
+#endif
#endif
--- /dev/null
+// Scintilla source code edit control
+/** @file CharacterSet.h
+ ** Encapsulates a set of characters. Used to test if a character is within a set.
+ **/
+// Copyright 2007 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+class CharacterSet {
+ int size;
+ bool valueAfter;
+ bool *bset;
+public:
+ enum setBase {
+ setNone=0,
+ setLower=1,
+ setUpper=2,
+ setDigits=4,
+ setAlpha=setLower|setUpper,
+ setAlphaNum=setAlpha|setDigits
+ };
+ CharacterSet(setBase base=setNone, const char *initialSet="", int size_=0x80, bool valueAfter_=false) {
+ size = size_;
+ valueAfter = valueAfter_;
+ bset = new bool[size];
+ for (int i=0; i < size; i++) {
+ bset[i] = false;
+ }
+ AddString(initialSet);
+ if (base & setLower)
+ AddString("abcdefghijklmnopqrstuvwxyz");
+ if (base & setUpper)
+ AddString("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
+ if (base & setDigits)
+ AddString("0123456789");
+ }
+ ~CharacterSet() {
+ delete []bset;
+ bset = 0;
+ size = 0;
+ }
+ void Add(int val) {
+ PLATFORM_ASSERT(val >= 0);
+ PLATFORM_ASSERT(val < size);
+ bset[val] = true;
+ }
+ void AddString(const char *CharacterSet) {
+ for (const char *cp=CharacterSet; *cp; cp++) {
+ int val = static_cast<unsigned char>(*cp);
+ PLATFORM_ASSERT(val >= 0);
+ PLATFORM_ASSERT(val < size);
+ bset[val] = true;
+ }
+ }
+ bool Contains(int val) const {
+ PLATFORM_ASSERT(val >= 0);
+ return (val < size) ? bset[val] : valueAfter;
+ }
+};
// Scintilla source code edit control
/** @file ContractionState.cxx
- ** Manages visibility of lines for folding.
+ ** Manages visibility of lines for folding and wrapping.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2007 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
+#include <string.h>
+
#include "Platform.h"
+#include "SplitVector.h"
+#include "Partitioning.h"
+#include "RunStyles.h"
#include "ContractionState.h"
-OneLine::OneLine() {
- displayLine = 0;
- //docLine = 0;
- visible = true;
- height = 1;
- expanded = true;
-}
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
-ContractionState::ContractionState() {
- lines = 0;
- size = 0;
- linesInDoc = 1;
- linesInDisplay = 1;
- valid = false;
- docLines = 0;
- sizeDocLines = 0;
+ContractionState::ContractionState() : visible(0), expanded(0), heights(0), displayLines(0), linesInDocument(1) {
+ //InsertLine(0);
}
ContractionState::~ContractionState() {
Clear();
}
-void ContractionState::MakeValid() const {
- if (!valid) {
- // Could be cleverer by keeping the index of the last still valid entry
- // rather than invalidating all.
- linesInDisplay = 0;
- for (int lineInDoc=0; lineInDoc<linesInDoc; lineInDoc++) {
- lines[lineInDoc].displayLine = linesInDisplay;
- if (lines[lineInDoc].visible) {
- linesInDisplay += lines[lineInDoc].height;
- }
- }
- if (sizeDocLines < linesInDisplay) {
- delete []docLines;
- int *docLinesNew = new int[linesInDisplay + growSize];
- if (!docLinesNew) {
- docLines = 0;
- sizeDocLines = 0;
- return;
- }
- docLines = docLinesNew;
- sizeDocLines = linesInDisplay + growSize;
- }
-
- int lineInDisplay=0;
- for (int line=0; line<linesInDoc; line++) {
- if (lines[line].visible) {
- for (int linePiece=0; linePiece<lines[line].height; linePiece++) {
- docLines[lineInDisplay] = line;
- lineInDisplay++;
- }
- }
- }
- valid = true;
+void ContractionState::EnsureData() {
+ if (OneToOne()) {
+ visible = new RunStyles();
+ expanded = new RunStyles();
+ heights = new RunStyles();
+ displayLines = new Partitioning(4);
+ InsertLines(0, linesInDocument);
}
}
void ContractionState::Clear() {
- delete []lines;
- lines = 0;
- size = 0;
- linesInDoc = 1;
- linesInDisplay = 1;
- delete []docLines;
- docLines = 0;
- sizeDocLines = 0;
+ delete visible;
+ visible = 0;
+ delete expanded;
+ expanded = 0;
+ delete heights;
+ heights = 0;
+ delete displayLines;
+ displayLines = 0;
+ linesInDocument = 1;
}
int ContractionState::LinesInDoc() const {
- return linesInDoc;
+ if (OneToOne()) {
+ return linesInDocument;
+ } else {
+ return displayLines->Partitions() - 1;
+ }
}
int ContractionState::LinesDisplayed() const {
- if (size != 0) {
- MakeValid();
+ if (OneToOne()) {
+ return linesInDocument;
+ } else {
+ return displayLines->PositionFromPartition(LinesInDoc());
}
- return linesInDisplay;
}
int ContractionState::DisplayFromDoc(int lineDoc) const {
- if (size == 0) {
+ if (OneToOne()) {
return lineDoc;
+ } else {
+ if (lineDoc > displayLines->Partitions())
+ lineDoc = displayLines->Partitions();
+ return displayLines->PositionFromPartition(lineDoc);
}
- MakeValid();
- if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
- return lines[lineDoc].displayLine;
- }
- return -1;
}
int ContractionState::DocFromDisplay(int lineDisplay) const {
- if (lineDisplay <= 0)
- return 0;
- if (lineDisplay >= linesInDisplay)
- return linesInDoc;
- if (size == 0)
+ if (OneToOne()) {
return lineDisplay;
- MakeValid();
- if (docLines) { // Valid allocation
- return docLines[lineDisplay];
} else {
- return 0;
+ if (lineDisplay <= 0) {
+ return 0;
+ }
+ if (lineDisplay > LinesDisplayed()) {
+ return displayLines->PartitionFromPosition(LinesDisplayed());
+ }
+ int lineDoc = displayLines->PartitionFromPosition(lineDisplay);
+ PLATFORM_ASSERT(GetVisible(lineDoc));
+ return lineDoc;
}
}
-void ContractionState::Grow(int sizeNew) {
- OneLine *linesNew = new OneLine[sizeNew];
- if (linesNew) {
- int i = 0;
- for (; i < size; i++) {
- linesNew[i] = lines[i];
- }
- for (; i < sizeNew; i++) {
- linesNew[i].displayLine = i;
- }
- delete []lines;
- lines = linesNew;
- size = sizeNew;
- valid = false;
+void ContractionState::InsertLine(int lineDoc) {
+ if (OneToOne()) {
+ linesInDocument++;
} else {
- Platform::DebugPrintf("No memory available\n");
- // TODO: Blow up
+ visible->InsertSpace(lineDoc, 1);
+ visible->SetValueAt(lineDoc, 1);
+ expanded->InsertSpace(lineDoc, 1);
+ expanded->SetValueAt(lineDoc, 1);
+ heights->InsertSpace(lineDoc, 1);
+ heights->SetValueAt(lineDoc, 1);
+ int lineDisplay = DisplayFromDoc(lineDoc);
+ displayLines->InsertPartition(lineDoc, lineDisplay);
+ displayLines->InsertText(lineDoc, 1);
}
}
void ContractionState::InsertLines(int lineDoc, int lineCount) {
- if (size == 0) {
- linesInDoc += lineCount;
- linesInDisplay += lineCount;
- return;
- }
- //Platform::DebugPrintf("InsertLine[%d] = %d\n", lineDoc);
- if ((linesInDoc + lineCount + 2) >= size) {
- Grow(linesInDoc + lineCount + growSize);
+ for (int l = 0; l < lineCount; l++) {
+ InsertLine(lineDoc + l);
}
- linesInDoc += lineCount;
- for (int i = linesInDoc; i >= lineDoc + lineCount; i--) {
- lines[i].visible = lines[i - lineCount].visible;
- lines[i].height = lines[i - lineCount].height;
- linesInDisplay += lines[i].height;
- lines[i].expanded = lines[i - lineCount].expanded;
- }
- for (int d=0;d<lineCount;d++) {
- lines[lineDoc+d].visible = true; // Should inherit visibility from context ?
- lines[lineDoc+d].height = 1;
- lines[lineDoc+d].expanded = true;
+ Check();
+}
+
+void ContractionState::DeleteLine(int lineDoc) {
+ if (OneToOne()) {
+ linesInDocument--;
+ } else {
+ if (GetVisible(lineDoc)) {
+ displayLines->InsertText(lineDoc, -heights->ValueAt(lineDoc));
+ }
+ displayLines->RemovePartition(lineDoc);
+ visible->DeleteRange(lineDoc, 1);
+ expanded->DeleteRange(lineDoc, 1);
+ heights->DeleteRange(lineDoc, 1);
}
- valid = false;
}
void ContractionState::DeleteLines(int lineDoc, int lineCount) {
- if (size == 0) {
- linesInDoc -= lineCount;
- linesInDisplay -= lineCount;
- return;
- }
- int deltaDisplayed = 0;
- for (int d=0;d<lineCount;d++) {
- if (lines[lineDoc+d].visible)
- deltaDisplayed -= lines[lineDoc+d].height;
+ for (int l = 0; l < lineCount; l++) {
+ DeleteLine(lineDoc);
}
- for (int i = lineDoc; i < linesInDoc-lineCount; i++) {
- if (i != 0) // Line zero is always visible
- lines[i].visible = lines[i + lineCount].visible;
- lines[i].expanded = lines[i + lineCount].expanded;
- lines[i].height = lines[i + lineCount].height;
- }
- linesInDoc -= lineCount;
- linesInDisplay += deltaDisplayed;
- valid = false;
+ Check();
}
bool ContractionState::GetVisible(int lineDoc) const {
- if (size == 0)
+ if (OneToOne()) {
return true;
- if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
- return lines[lineDoc].visible;
} else {
- return false;
+ if (lineDoc >= visible->Length())
+ return true;
+ return visible->ValueAt(lineDoc) == 1;
}
}
-bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible) {
- if (lineDocStart == 0)
- lineDocStart++;
- if (lineDocStart > lineDocEnd)
+bool ContractionState::SetVisible(int lineDocStart, int lineDocEnd, bool visible_) {
+ if (OneToOne() && visible_) {
return false;
- if (size == 0) {
- Grow(linesInDoc + growSize);
- }
- // TODO: modify docLine members to mirror displayLine
- int delta = 0;
- // Change lineDocs
- if ((lineDocStart <= lineDocEnd) && (lineDocStart >= 0) && (lineDocEnd < linesInDoc)) {
- for (int line=lineDocStart; line <= lineDocEnd; line++) {
- if (lines[line].visible != visible) {
- delta += visible ? lines[line].height : -lines[line].height;
- lines[line].visible = visible;
+ } else {
+ EnsureData();
+ int delta = 0;
+ Check();
+ if ((lineDocStart <= lineDocEnd) && (lineDocStart >= 0) && (lineDocEnd < LinesInDoc())) {
+ for (int line = lineDocStart; line <= lineDocEnd; line++) {
+ if (GetVisible(line) != visible_) {
+ int difference = visible_ ? heights->ValueAt(line) : -heights->ValueAt(line);
+ visible->SetValueAt(line, visible_ ? 1 : 0);
+ displayLines->InsertText(line, difference);
+ delta += difference;
+ }
}
+ } else {
+ return false;
}
+ Check();
+ return delta != 0;
}
- linesInDisplay += delta;
- valid = false;
- return delta != 0;
}
bool ContractionState::GetExpanded(int lineDoc) const {
- if (size == 0)
+ if (OneToOne()) {
return true;
- if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
- return lines[lineDoc].expanded;
} else {
- return false;
+ Check();
+ return expanded->ValueAt(lineDoc) == 1;
}
}
-bool ContractionState::SetExpanded(int lineDoc, bool expanded) {
- if (size == 0) {
- if (expanded) {
- // If in completely expanded state then setting
- // one line to expanded has no effect.
- return false;
- }
- Grow(linesInDoc + growSize);
- }
- if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
- if (lines[lineDoc].expanded != expanded) {
- lines[lineDoc].expanded = expanded;
+bool ContractionState::SetExpanded(int lineDoc, bool expanded_) {
+ if (OneToOne() && expanded_) {
+ return false;
+ } else {
+ EnsureData();
+ if (expanded_ != (expanded->ValueAt(lineDoc) == 1)) {
+ expanded->SetValueAt(lineDoc, expanded_ ? 1 : 0);
+ Check();
return true;
+ } else {
+ Check();
+ return false;
}
}
- return false;
}
int ContractionState::GetHeight(int lineDoc) const {
- if (size == 0)
+ if (OneToOne()) {
return 1;
- if ((lineDoc >= 0) && (lineDoc < linesInDoc)) {
- return lines[lineDoc].height;
} else {
- return 1;
+ return heights->ValueAt(lineDoc);
}
}
// Set the number of display lines needed for this line.
// Return true if this is a change.
bool ContractionState::SetHeight(int lineDoc, int height) {
- if (lineDoc > linesInDoc)
+ if (OneToOne() && (height == 1)) {
return false;
- if (size == 0) {
- if (height == 1) {
- // If in completely expanded state then all lines
- // assumed to have height of one so no effect here.
+ } else {
+ EnsureData();
+ if (GetHeight(lineDoc) != height) {
+ if (GetVisible(lineDoc)) {
+ displayLines->InsertText(lineDoc, height - GetHeight(lineDoc));
+ }
+ heights->SetValueAt(lineDoc, height);
+ Check();
+ return true;
+ } else {
+ Check();
return false;
}
- Grow(linesInDoc + growSize);
- }
- if (lines[lineDoc].height != height) {
- lines[lineDoc].height = height;
- valid = false;
- return true;
- } else {
- return false;
}
}
void ContractionState::ShowAll() {
- delete []lines;
- lines = 0;
- size = 0;
-
- delete []docLines;
- docLines = 0;
- sizeDocLines = 0;
-
- linesInDisplay = linesInDoc;
+ int lines = LinesInDoc();
+ Clear();
+ linesInDocument = lines;
+}
+
+// Debugging checks
+
+void ContractionState::Check() const {
+#ifdef CHECK_CORRECTNESS
+ for (int vline = 0;vline < LinesDisplayed(); vline++) {
+ const int lineDoc = DocFromDisplay(vline);
+ PLATFORM_ASSERT(GetVisible(lineDoc));
+ }
+ for (int lineDoc = 0;lineDoc < LinesInDoc(); lineDoc++) {
+ const int displayThis = DisplayFromDoc(lineDoc);
+ const int displayNext = DisplayFromDoc(lineDoc + 1);
+ const int height = displayNext - displayThis;
+ PLATFORM_ASSERT(height >= 0);
+ if (GetVisible(lineDoc)) {
+ PLATFORM_ASSERT(GetHeight(lineDoc) == height);
+ } else {
+ PLATFORM_ASSERT(0 == height);
+ }
+ }
+#endif
}
// Scintilla source code edit control
/** @file ContractionState.h
- ** Manages visibility of lines for folding.
+ ** Manages visibility of lines for folding and wrapping.
**/
-// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2007 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#ifndef CONTRACTIONSTATE_H
#define CONTRACTIONSTATE_H
-/**
- */
-class OneLine {
-public:
- int displayLine; ///< Position within set of visible lines
- //int docLine; ///< Inverse of @a displayLine
- int height; ///< Number of display lines needed to show all of the line
- bool visible;
- bool expanded;
-
- OneLine();
- virtual ~OneLine() {}
-};
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
/**
*/
class ContractionState {
- void Grow(int sizeNew);
- enum { growSize = 4000 };
- int linesInDoc;
- mutable int linesInDisplay;
- mutable OneLine *lines;
- int size;
- mutable int *docLines;
- mutable int sizeDocLines;
- mutable bool valid;
- void MakeValid() const;
+ // These contain 1 element for every document line.
+ RunStyles *visible;
+ RunStyles *expanded;
+ RunStyles *heights;
+ Partitioning *displayLines;
+ int linesInDocument;
+
+ void EnsureData();
+
+ bool OneToOne() const {
+ // True when each document line is exactly one display line so need for
+ // complex data structures.
+ return visible == 0;
+ }
public:
ContractionState();
int DisplayFromDoc(int lineDoc) const;
int DocFromDisplay(int lineDisplay) const;
+ void InsertLine(int lineDoc);
void InsertLines(int lineDoc, int lineCount);
+ void DeleteLine(int lineDoc);
void DeleteLines(int lineDoc, int lineCount);
bool GetVisible(int lineDoc) const;
bool SetHeight(int lineDoc, int height);
void ShowAll();
+ void Check() const;
};
+#ifdef SCI_NAMESPACE
+}
+#endif
+
#endif
--- /dev/null
+/** @file Decoration.cxx
+ ** Visual elements added over text.
+ **/
+// Copyright 1998-2007 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "Scintilla.h"
+#include "SplitVector.h"
+#include "Partitioning.h"
+#include "RunStyles.h"
+#include "Decoration.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+Decoration::Decoration(int indicator_) : next(0), indicator(indicator_) {
+}
+
+Decoration::~Decoration() {
+}
+
+bool Decoration::Empty() {
+ return rs.starts->Partitions() == 1;
+}
+
+DecorationList::DecorationList() : currentIndicator(0), currentValue(1), current(0),
+ lengthDocument(0), root(0), clickNotified(false) {
+}
+
+DecorationList::~DecorationList() {
+ Decoration *deco = root;
+ while (deco) {
+ Decoration *decoNext = deco->next;
+ delete deco;
+ deco = decoNext;
+ }
+ root = 0;
+ current = 0;
+}
+
+Decoration *DecorationList::DecorationFromIndicator(int indicator) {
+ for (Decoration *deco=root; deco; deco = deco->next) {
+ if (deco->indicator == indicator) {
+ return deco;
+ }
+ }
+ return 0;
+}
+
+Decoration *DecorationList::Create(int indicator, int length) {
+ currentIndicator = indicator;
+ Decoration *decoNew = new Decoration(indicator);
+ decoNew->rs.InsertSpace(0, length);
+
+ Decoration *decoPrev = 0;
+ Decoration *deco = root;
+
+ while (deco && (deco->indicator < indicator)) {
+ decoPrev = deco;
+ deco = deco->next;
+ }
+ if (decoPrev == 0) {
+ decoNew->next = root;
+ root = decoNew;
+ } else {
+ decoNew->next = deco;
+ decoPrev->next = decoNew;
+ }
+ return decoNew;
+}
+
+void DecorationList::Delete(int indicator) {
+ Decoration *decoToDelete = 0;
+ if (root) {
+ if (root->indicator == indicator) {
+ decoToDelete = root;
+ root = root->next;
+ } else {
+ Decoration *deco=root;
+ while (deco->next && !decoToDelete) {
+ if (deco->next && deco->next->indicator == indicator) {
+ decoToDelete = deco->next;
+ deco->next = decoToDelete->next;
+ } else {
+ deco = deco->next;
+ }
+ }
+ }
+ }
+ if (decoToDelete) {
+ delete decoToDelete;
+ current = 0;
+ }
+}
+
+void DecorationList::SetCurrentIndicator(int indicator) {
+ currentIndicator = indicator;
+ current = DecorationFromIndicator(indicator);
+ currentValue = 1;
+}
+
+void DecorationList::SetCurrentValue(int value) {
+ currentValue = value ? value : 1;
+}
+
+bool DecorationList::FillRange(int &position, int value, int &fillLength) {
+ if (!current) {
+ current = DecorationFromIndicator(currentIndicator);
+ if (!current) {
+ current = Create(currentIndicator, lengthDocument);
+ }
+ }
+ bool changed = current->rs.FillRange(position, value, fillLength);
+ if (current->Empty()) {
+ Delete(currentIndicator);
+ }
+ return changed;
+}
+
+void DecorationList::InsertSpace(int position, int insertLength) {
+ lengthDocument += insertLength;
+ for (Decoration *deco=root; deco; deco = deco->next) {
+ deco->rs.InsertSpace(position, insertLength);
+ }
+}
+
+void DecorationList::DeleteRange(int position, int deleteLength) {
+ lengthDocument -= deleteLength;
+ Decoration *deco;
+ for (deco=root; deco; deco = deco->next) {
+ deco->rs.DeleteRange(position, deleteLength);
+ }
+ DeleteAnyEmpty();
+}
+
+void DecorationList::DeleteAnyEmpty() {
+ Decoration *deco = root;
+ while (deco) {
+ if (deco->Empty()) {
+ Delete(deco->indicator);
+ deco = root;
+ } else {
+ deco = deco->next;
+ }
+ }
+}
+
+int DecorationList::AllOnFor(int position) {
+ int mask = 0;
+ for (Decoration *deco=root; deco; deco = deco->next) {
+ if (deco->rs.ValueAt(position)) {
+ mask |= 1 << deco->indicator;
+ }
+ }
+ return mask;
+}
+
+int DecorationList::ValueAt(int indicator, int position) {
+ Decoration *deco = DecorationFromIndicator(indicator);
+ if (deco) {
+ return deco->rs.ValueAt(position);
+ }
+ return 0;
+}
+
+int DecorationList::Start(int indicator, int position) {
+ Decoration *deco = DecorationFromIndicator(indicator);
+ if (deco) {
+ return deco->rs.StartRun(position);
+ }
+ return 0;
+}
+
+int DecorationList::End(int indicator, int position) {
+ Decoration *deco = DecorationFromIndicator(indicator);
+ if (deco) {
+ return deco->rs.EndRun(position);
+ }
+ return 0;
+}
--- /dev/null
+/** @file Decoration.h
+ ** Visual elements added over text.
+ **/
+// Copyright 1998-2007 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#ifndef DECORATION_H
+#define DECORATION_H
+
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
+class Decoration {
+public:
+ Decoration *next;
+ RunStyles rs;
+ int indicator;
+
+ Decoration(int indicator_);
+ ~Decoration();
+
+ bool Empty();
+};
+
+class DecorationList {
+ int currentIndicator;
+ int currentValue;
+ Decoration *current;
+ int lengthDocument;
+ Decoration *DecorationFromIndicator(int indicator);
+ Decoration *Create(int indicator, int length);
+ void Delete(int indicator);
+ void DeleteAnyEmpty();
+public:
+ Decoration *root;
+ bool clickNotified;
+
+ DecorationList();
+ ~DecorationList();
+
+ void SetCurrentIndicator(int indicator);
+ int GetCurrentIndicator() { return currentIndicator; }
+
+ void SetCurrentValue(int value);
+ int GetCurrentValue() { return currentValue; }
+
+ // Returns true if some values may have changed
+ bool FillRange(int &position, int value, int &fillLength);
+
+ void InsertSpace(int position, int insertLength);
+ void DeleteRange(int position, int deleteLength);
+
+ int AllOnFor(int position);
+ int ValueAt(int indicator, int position);
+ int Start(int indicator, int position);
+ int End(int indicator, int position);
+};
+
+#ifdef SCI_NAMESPACE
+}
+#endif
+
+#endif
#include "Platform.h"
#include "Scintilla.h"
-#include "SVector.h"
+#include "SplitVector.h"
+#include "Partitioning.h"
+#include "RunStyles.h"
#include "CellBuffer.h"
#include "CharClassify.h"
+#include "Decoration.h"
#include "Document.h"
#include "RESearch.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
// This is ASCII specific but is safe with chars >= 0x80
static inline bool isspacechar(unsigned char ch) {
return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
stylingMask = 0;
endStyled = 0;
styleClock = 0;
- enteredCount = 0;
+ enteredModification = 0;
+ enteredStyling = 0;
enteredReadOnlyCount = 0;
tabInChars = 8;
indentInChars = 0;
int Document::AddMark(int line, int markerNum) {
int prev = cb.AddMark(line, markerNum);
DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line);
- mh.line = line;
NotifyModified(mh);
return prev;
}
if (m & 1)
cb.AddMark(line, i);
DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line);
- mh.line = line;
NotifyModified(mh);
}
void Document::DeleteMark(int line, int markerNum) {
cb.DeleteMark(line, markerNum);
DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line);
- mh.line = line;
NotifyModified(mh);
}
NotifyModified(mh);
}
-int Document::LineStart(int line) {
+int Document::LineStart(int line) const {
return cb.LineStart(line);
}
-int Document::LineEnd(int line) {
+int Document::LineEnd(int line) const {
if (line == LinesTotal() - 1) {
return LineStart(line + 1);
} else {
int prev = cb.SetLevel(line, level);
if (prev != level) {
DocModification mh(SC_MOD_CHANGEFOLD | SC_MOD_CHANGEMARKER,
- LineStart(line), 0, 0, 0);
- mh.line = line;
+ LineStart(line), 0, 0, 0, line);
mh.foldLevelNow = level;
mh.foldLevelPrev = prev;
NotifyModified(mh);
if (ch < 0x80)
return 1;
int len = 2;
- if (ch >= (0x80 + 0x40 + 0x20))
+ if (ch >= (0x80 + 0x40 + 0x20 + 0x10))
+ len = 4;
+ else if (ch >= (0x80 + 0x40 + 0x20))
len = 3;
int lengthDoc = Length();
if ((pos + len) > lengthDoc)
}
}
+static bool IsTrailByte(int ch) {
+ return (ch >= 0x80) && (ch < (0x80 + 0x40));
+}
+
+static int BytesFromLead(int leadByte) {
+ if (leadByte > 0xF4) {
+ // Characters longer than 4 bytes not possible in current UTF-8
+ return 0;
+ } else if (leadByte >= 0xF0) {
+ return 4;
+ } else if (leadByte >= 0xE0) {
+ return 3;
+ } else if (leadByte >= 0xC2) {
+ return 2;
+ }
+ return 0;
+}
+
+bool Document::InGoodUTF8(int pos, int &start, int &end) {
+ int lead = pos;
+ while ((lead>0) && (pos-lead < 4) && IsTrailByte(static_cast<unsigned char>(cb.CharAt(lead-1))))
+ lead--;
+ start = 0;
+ if (lead > 0) {
+ start = lead-1;
+ }
+ int leadByte = static_cast<unsigned char>(cb.CharAt(start));
+ int bytes = BytesFromLead(leadByte);
+ if (bytes == 0) {
+ return false;
+ } else {
+ int trailBytes = bytes - 1;
+ int len = pos - lead + 1;
+ if (len > trailBytes)
+ // pos too far from lead
+ return false;
+ // Check that there are enough trails for this lead
+ int trail = pos + 1;
+ while ((trail-lead<trailBytes) && (trail < Length())) {
+ if (!IsTrailByte(static_cast<unsigned char>(cb.CharAt(trail)))) {
+ return false;
+ }
+ trail++;
+ }
+ end = start + bytes;
+ return true;
+ }
+}
+
// Normalise a position so that it is not halfway through a two byte character.
// This can occur in two situations -
// When lines are terminated with \r\n pairs which should be treated as one character.
if (dbcsCodePage) {
if (SC_CP_UTF8 == dbcsCodePage) {
unsigned char ch = static_cast<unsigned char>(cb.CharAt(pos));
- while ((pos > 0) && (pos < Length()) && (ch >= 0x80) && (ch < (0x80 + 0x40))) {
- // ch is a trail byte
+ int startUTF = pos;
+ int endUTF = pos;
+ if (IsTrailByte(ch) && InGoodUTF8(pos, startUTF, endUTF)) {
+ // ch is a trail byte within a UTF-8 character
if (moveDir > 0)
- pos++;
+ pos = endUTF;
else
- pos--;
- ch = static_cast<unsigned char>(cb.CharAt(pos));
+ pos = startUTF;
}
} else {
// Anchor DBCS calculations at start of line because start of line can
}
}
-// Document only modified by gateways DeleteChars, InsertStyledString, Undo, Redo, and SetStyleAt.
+// Document only modified by gateways DeleteChars, InsertString, Undo, Redo, and SetStyleAt.
// SetStyleAt does not change the persistent state of a document
-// Unlike Undo, Redo, and InsertStyledString, the pos argument is a cell number not a char number
bool Document::DeleteChars(int pos, int len) {
if (len == 0)
return false;
if ((pos + len) > Length())
return false;
CheckReadOnly();
- if (enteredCount != 0) {
+ if (enteredModification != 0) {
return false;
} else {
- enteredCount++;
+ enteredModification++;
if (!cb.IsReadOnly()) {
NotifyModified(
DocModification(
0, 0));
int prevLinesTotal = LinesTotal();
bool startSavePoint = cb.IsSavePoint();
- const char *text = cb.DeleteChars(pos * 2, len * 2);
+ bool startSequence = false;
+ const char *text = cb.DeleteChars(pos, len, startSequence);
if (startSavePoint && cb.IsCollectingUndo())
NotifySavePoint(!startSavePoint);
if ((pos < Length()) || (pos == 0))
ModifiedAt(pos-1);
NotifyModified(
DocModification(
- SC_MOD_DELETETEXT | SC_PERFORMED_USER,
+ SC_MOD_DELETETEXT | SC_PERFORMED_USER | (startSequence?SC_STARTACTION:0),
pos, len,
LinesTotal() - prevLinesTotal, text));
}
- enteredCount--;
+ enteredModification--;
}
return !cb.IsReadOnly();
}
/**
- * Insert a styled string (char/style pairs) with a length.
+ * Insert a string with a length.
*/
-bool Document::InsertStyledString(int position, char *s, int insertLength) {
+bool Document::InsertString(int position, const char *s, int insertLength) {
+ if (insertLength <= 0) {
+ return false;
+ }
CheckReadOnly();
- if (enteredCount != 0) {
+ if (enteredModification != 0) {
return false;
} else {
- enteredCount++;
+ enteredModification++;
if (!cb.IsReadOnly()) {
NotifyModified(
DocModification(
SC_MOD_BEFOREINSERT | SC_PERFORMED_USER,
- position / 2, insertLength / 2,
+ position, insertLength,
0, s));
int prevLinesTotal = LinesTotal();
bool startSavePoint = cb.IsSavePoint();
- const char *text = cb.InsertString(position, s, insertLength);
+ bool startSequence = false;
+ const char *text = cb.InsertString(position, s, insertLength, startSequence);
if (startSavePoint && cb.IsCollectingUndo())
NotifySavePoint(!startSavePoint);
- ModifiedAt(position / 2);
+ ModifiedAt(position);
NotifyModified(
DocModification(
- SC_MOD_INSERTTEXT | SC_PERFORMED_USER,
- position / 2, insertLength / 2,
+ SC_MOD_INSERTTEXT | SC_PERFORMED_USER | (startSequence?SC_STARTACTION:0),
+ position, insertLength,
LinesTotal() - prevLinesTotal, text));
}
- enteredCount--;
+ enteredModification--;
}
return !cb.IsReadOnly();
}
int Document::Undo() {
int newPos = -1;
CheckReadOnly();
- if (enteredCount == 0) {
- enteredCount++;
+ if (enteredModification == 0) {
+ enteredModification++;
if (!cb.IsReadOnly()) {
bool startSavePoint = cb.IsSavePoint();
bool multiLine = false;
if (startSavePoint != endSavePoint)
NotifySavePoint(endSavePoint);
}
- enteredCount--;
+ enteredModification--;
}
return newPos;
}
int Document::Redo() {
int newPos = -1;
CheckReadOnly();
- if (enteredCount == 0) {
- enteredCount++;
+ if (enteredModification == 0) {
+ enteredModification++;
if (!cb.IsReadOnly()) {
bool startSavePoint = cb.IsSavePoint();
bool multiLine = false;
if (startSavePoint != endSavePoint)
NotifySavePoint(endSavePoint);
}
- enteredCount--;
+ enteredModification--;
}
return newPos;
}
* Insert a single character.
*/
bool Document::InsertChar(int pos, char ch) {
- char chs[2];
+ char chs[1];
chs[0] = ch;
- chs[1] = 0;
- return InsertStyledString(pos*2, chs, 2);
+ return InsertString(pos, chs, 1);
}
/**
* Insert a null terminated string.
*/
-bool Document::InsertString(int position, const char *s) {
+bool Document::InsertCString(int position, const char *s) {
return InsertString(position, s, strlen(s));
}
-/**
- * Insert a string with a length.
- */
-bool Document::InsertString(int position, const char *s, size_t insertLength) {
- bool changed = false;
- if (insertLength > 0) {
- char *sWithStyle = new char[insertLength * 2];
- if (sWithStyle) {
- for (size_t i = 0; i < insertLength; i++) {
- sWithStyle[i*2] = s[i];
- sWithStyle[i*2 + 1] = 0;
- }
- changed = InsertStyledString(position*2, sWithStyle,
- static_cast<int>(insertLength*2));
- delete []sWithStyle;
- }
- }
- return changed;
-}
-
void Document::ChangeChar(int pos, char ch) {
DeleteChars(pos, 1);
InsertChar(pos, ch);
int indentPos = GetLineIndentPosition(line);
BeginUndoAction();
DeleteChars(thisLineStart, indentPos - thisLineStart);
- InsertString(thisLineStart, linebuf);
+ InsertCString(thisLineStart, linebuf);
EndUndoAction();
}
}
-int Document::GetLineIndentPosition(int line) {
+int Document::GetLineIndentPosition(int line) const {
if (line < 0)
return 0;
int pos = LineStart(line);
return column;
} else if (ch == '\n') {
return column;
+ } else if (i >= Length()) {
+ return column;
} else {
column++;
- i = MovePositionOutsideChar(i + 1, 1);
+ i = MovePositionOutsideChar(i + 1, 1, false);
}
}
}
return position;
} else {
columnCurrent++;
- position = MovePositionOutsideChar(position + 1, 1);
+ position = MovePositionOutsideChar(position + 1, 1, false);
}
}
}
EndUndoAction();
}
-bool Document::IsWhiteLine(int line) {
+bool Document::IsWhiteLine(int line) const {
int currentChar = LineStart(line);
int endLine = LineEnd(line);
while (currentChar < endLine) {
while (pos > 0 && (WordCharClass(cb.CharAt(pos - 1)) == ccStart))
pos--;
} else {
- if (!onlyWordCharacters)
+ if (!onlyWordCharacters && pos < Length())
ccStart = WordCharClass(cb.CharAt(pos));
while (pos < (Length()) && (WordCharClass(cb.CharAt(pos)) == ccStart))
pos++;
return substituted;
}
-int Document::LinesTotal() {
+int Document::LinesTotal() const {
return cb.Lines();
}
void Document::SetStylingBits(int bits) {
stylingBits = bits;
- stylingBitsMask = 0;
- for (int bit = 0; bit < stylingBits; bit++) {
- stylingBitsMask <<= 1;
- stylingBitsMask |= 1;
- }
+ stylingBitsMask = (1 << stylingBits) - 1;
}
void Document::StartStyling(int position, char mask) {
}
bool Document::SetStyleFor(int length, char style) {
- if (enteredCount != 0) {
+ if (enteredStyling != 0) {
return false;
} else {
- enteredCount++;
+ enteredStyling++;
style &= stylingMask;
int prevEndStyled = endStyled;
if (cb.SetStyleFor(endStyled, length, style, stylingMask)) {
NotifyModified(mh);
}
endStyled += length;
- enteredCount--;
+ enteredStyling--;
return true;
}
}
bool Document::SetStyles(int length, char *styles) {
- if (enteredCount != 0) {
+ if (enteredStyling != 0) {
return false;
} else {
- enteredCount++;
+ enteredStyling++;
bool didChange = false;
int startMod = 0;
int endMod = 0;
startMod, endMod - startMod + 1);
NotifyModified(mh);
}
- enteredCount--;
+ enteredStyling--;
return true;
}
}
-bool Document::EnsureStyledTo(int pos) {
- if (pos > GetEndStyled()) {
+void Document::EnsureStyledTo(int pos) {
+ if ((enteredStyling == 0) && (pos > GetEndStyled())) {
IncrementStyleClock();
// Ask the watchers to style, and stop as soon as one responds.
for (int i = 0; pos > GetEndStyled() && i < lenWatchers; i++) {
watchers[i].watcher->NotifyStyleNeeded(this, watchers[i].userData, pos);
}
}
- return pos <= GetEndStyled();
+}
+
+int Document::SetLineState(int line, int state) {
+ int statePrevious = cb.SetLineState(line, state);
+ if (state != statePrevious) {
+ DocModification mh(SC_MOD_CHANGELINESTATE, 0, 0, 0, 0, line);
+ NotifyModified(mh);
+ }
+ return statePrevious;
}
void Document::IncrementStyleClock() {
- styleClock++;
- if (styleClock > 0x100000) {
- styleClock = 0;
+ styleClock = (styleClock + 1) % 0x100000;
+}
+
+void Document::DecorationFillRange(int position, int value, int fillLength) {
+ if (decorations.FillRange(position, value, fillLength)) {
+ DocModification mh(SC_MOD_CHANGEINDICATOR | SC_PERFORMED_USER,
+ position, fillLength);
+ NotifyModified(mh);
}
}
}
void Document::NotifyModified(DocModification mh) {
+ if (mh.modificationType & SC_MOD_INSERTTEXT) {
+ decorations.InsertSpace(mh.position, mh.length);
+ } else if (mh.modificationType & SC_MOD_DELETETEXT) {
+ decorations.DeleteRange(mh.position, mh.length);
+ }
for (int i = 0; i < lenWatchers; i++) {
watchers[i].watcher->NotifyModified(this, mh, watchers[i].userData);
}
#ifndef DOCUMENT_H
#define DOCUMENT_H
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
/**
* A Position is a position within a document between two characters or at the beginning or end.
* Sometimes used as a character index where it identifies the character after the position.
Range(Position pos=0) :
start(pos), end(pos) {
- }
+ };
Range(Position start_, Position end_) :
start(start_), end(end_) {
- }
+ };
bool Valid() const {
return (start != invalidPosition) && (end != invalidPosition);
char stylingMask;
int endStyled;
int styleClock;
- int enteredCount;
+ int enteredModification;
+ int enteredStyling;
int enteredReadOnlyCount;
WatcherWithUserData *watchers;
bool tabIndents;
bool backspaceUnindents;
+ DecorationList decorations;
+
Document();
virtual ~Document();
int ClampPositionIntoDocument(int pos);
bool IsCrLf(int pos);
int LenChar(int pos);
+ bool InGoodUTF8(int pos, int &start, int &end);
int MovePositionOutsideChar(int pos, int moveDir, bool checkLineEnd=true);
// Gateways to modifying document
void ModifiedAt(int pos);
+ void CheckReadOnly();
bool DeleteChars(int pos, int len);
- bool InsertStyledString(int position, char *s, int insertLength);
+ bool InsertString(int position, const char *s, int insertLength);
int Undo();
int Redo();
bool CanUndo() { return cb.CanUndo(); }
int GetLineIndentation(int line);
void SetLineIndentation(int line, int indent);
- int GetLineIndentPosition(int line);
+ int GetLineIndentPosition(int line) const;
int GetColumn(int position);
int FindColumn(int line, int column);
void Indent(bool forwards, int lineBottom, int lineTop);
bool IsReadOnly() { return cb.IsReadOnly(); }
bool InsertChar(int pos, char ch);
- bool InsertString(int position, const char *s);
- bool InsertString(int position, const char *s, size_t insertLength);
+ bool InsertCString(int position, const char *s);
void ChangeChar(int pos, char ch);
void DelChar(int pos);
void DelCharBack(int pos);
void DeleteMarkFromHandle(int markerHandle);
void DeleteAllMarks(int markerNum);
int LineFromHandle(int markerHandle) { return cb.LineFromHandle(markerHandle); }
- int LineStart(int line);
- int LineEnd(int line);
+ int LineStart(int line) const;
+ int LineEnd(int line) const;
int LineEndPosition(int position);
int VCHomePosition(int position);
int ExtendWordSelect(int pos, int delta, bool onlyWordCharacters=false);
int NextWordStart(int pos, int delta);
int NextWordEnd(int pos, int delta);
- int Length() { return cb.Length(); }
- void Allocate(int newSize) { cb.Allocate(newSize*2); }
+ 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);
long FindText(int iMessage, unsigned long wParam, long lParam);
const char *SubstituteByPosition(const char *text, int *length);
- int LinesTotal();
+ int LinesTotal() const;
void ChangeCase(Range r, bool makeUpperCase);
bool SetStyleFor(int length, char style);
bool SetStyles(int length, char *styles);
int GetEndStyled() { return endStyled; }
- bool EnsureStyledTo(int pos);
+ void EnsureStyledTo(int pos);
int GetStyleClock() { return styleClock; }
void IncrementStyleClock();
+ void DecorationFillRange(int position, int value, int fillLength);
- int SetLineState(int line, int state) { return cb.SetLineState(line, state); }
+ int SetLineState(int line, int state);
int GetLineState(int line) { return cb.GetLineState(line); }
int GetMaxLineState() { return cb.GetMaxLineState(); }
int WordPartLeft(int pos);
int WordPartRight(int pos);
int ExtendStyleRange(int pos, int delta, bool singleLine = false);
- bool IsWhiteLine(int line);
+ bool IsWhiteLine(int line) const;
int ParaUp(int pos);
int ParaDown(int pos);
int IndentSize() { return actualIndentInChars; }
int BraceMatch(int position, int maxReStyle);
private:
- void CheckReadOnly();
-
CharClassify::cc WordCharClass(unsigned char ch);
bool IsWordStartAt(int pos);
bool IsWordEndAt(int pos);
virtual void NotifyStyleNeeded(Document *doc, void *userData, int endPos) = 0;
};
+#ifdef SCI_NAMESPACE
+}
+#endif
+
#endif
#include "Platform.h"
#include "PropSet.h"
-#include "SVector.h"
#include "Accessor.h"
#include "DocumentAccessor.h"
+#include "SplitVector.h"
+#include "Partitioning.h"
+#include "RunStyles.h"
#include "CellBuffer.h"
#include "Scintilla.h"
#include "CharClassify.h"
+#include "Decoration.h"
#include "Document.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
DocumentAccessor::~DocumentAccessor() {
}
void DocumentAccessor::ColourTo(unsigned int pos, int chAttr) {
// Only perform styling if non empty range
if (pos != startSeg - 1) {
+ PLATFORM_ASSERT(pos >= startSeg);
if (pos < startSeg) {
- Platform::DebugPrintf("Bad colour positions %d - %d\n", startSeg, pos);
+ return;
}
if (validLen + (pos - startSeg + 1) >= bufferSize)
return indent;
}
+void DocumentAccessor::IndicatorFill(int start, int end, int indicator, int value) {
+ pdoc->decorations.SetCurrentIndicator(indicator);
+ pdoc->DecorationFillRange(start, value, end - start);
+}
// Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
class Document;
/**
WindowID GetWindow() { return id; }
void StartAt(unsigned int start, char chMask=31);
- void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; }
+ void SetFlags(char chFlags_, char chWhile_) {chFlags = chFlags_; chWhile = chWhile_; };
unsigned int GetStartSegment() { return startSeg; }
void StartSegment(unsigned int pos);
void ColourTo(unsigned int pos, int chAttr);
void SetLevel(int line, int level);
int IndentAmount(int line, int *flags, PFNIsCommentLeader pfnIsCommentLeader = 0);
+ void IndicatorFill(int start, int end, int indicator, int value);
};
+
+#ifdef SCI_NAMESPACE
+}
+#endif
#endif
#include "Scintilla.h"
+#include "SplitVector.h"
+#include "Partitioning.h"
+#include "RunStyles.h"
#include "ContractionState.h"
-#include "SVector.h"
#include "CellBuffer.h"
#include "KeyMap.h"
#include "Indicator.h"
#include "Style.h"
#include "ViewStyle.h"
#include "CharClassify.h"
+#include "Decoration.h"
#include "Document.h"
+#include "PositionCache.h"
#include "Editor.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
/*
return whether this modification represents an operation that
may reasonably be deferred (not done now OR [possibly] at all)
*/
static bool CanDeferToLastStep(const DocModification& mh) {
- if (mh.modificationType & (SC_MOD_BEFOREINSERT|SC_MOD_BEFOREDELETE))
+ if (mh.modificationType & (SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE))
return true; // CAN skip
- if (!(mh.modificationType & (SC_PERFORMED_UNDO|SC_PERFORMED_REDO)))
+ if (!(mh.modificationType & (SC_PERFORMED_UNDO | SC_PERFORMED_REDO)))
return false; // MUST do
if (mh.modificationType & SC_MULTISTEPUNDOREDO)
return true; // CAN skip
static bool CanEliminate(const DocModification& mh) {
return
- (mh.modificationType & (SC_MOD_BEFOREINSERT|SC_MOD_BEFOREDELETE)) != 0;
+ (mh.modificationType & (SC_MOD_BEFOREINSERT | SC_MOD_BEFOREDELETE)) != 0;
}
/*
*/
static bool IsLastStep(const DocModification& mh) {
return
- (mh.modificationType & (SC_PERFORMED_UNDO|SC_PERFORMED_REDO)) != 0
- && (mh.modificationType & SC_MULTISTEPUNDOREDO) != 0
- && (mh.modificationType & SC_LASTSTEPINUNDOREDO) != 0
- && (mh.modificationType & SC_MULTILINEUNDOREDO) != 0;
+ (mh.modificationType & (SC_PERFORMED_UNDO | SC_PERFORMED_REDO)) != 0
+ && (mh.modificationType & SC_MULTISTEPUNDOREDO) != 0
+ && (mh.modificationType & SC_LASTSTEPINUNDOREDO) != 0
+ && (mh.modificationType & SC_MULTILINEUNDOREDO) != 0;
}
Caret::Caret() :
-active(false), on(false), period(500) {}
+ active(false), on(false), period(500) {}
Timer::Timer() :
-ticking(false), ticksToWait(0), tickerID(0) {}
+ ticking(false), ticksToWait(0), tickerID(0) {}
Idler::Idler() :
-state(false), idlerID(0) {}
-
-LineLayout::LineLayout(int maxLineLength_) :
- lineStarts(0),
- lenLineStarts(0),
- lineNumber(-1),
- inCache(false),
- maxLineLength(-1),
- numCharsInLine(0),
- validity(llInvalid),
- xHighlightGuide(0),
- highlightColumn(0),
- selStart(0),
- selEnd(0),
- containsCaret(false),
- edgeColumn(0),
- chars(0),
- styles(0),
- styleBitsSet(0),
- indicators(0),
- positions(0),
- hsStart(0),
- hsEnd(0),
- widthLine(wrapWidthInfinite),
- lines(1) {
- Resize(maxLineLength_);
-}
-
-LineLayout::~LineLayout() {
- Free();
-}
-
-void LineLayout::Resize(int maxLineLength_) {
- if (maxLineLength_ > maxLineLength) {
- Free();
- chars = new char[maxLineLength_ + 1];
- styles = new unsigned char[maxLineLength_ + 1];
- indicators = new char[maxLineLength_ + 1];
- // Extra position allocated as sometimes the Windows
- // GetTextExtentExPoint API writes an extra element.
- positions = new int[maxLineLength_ + 1 + 1];
- maxLineLength = maxLineLength_;
- }
-}
-
-void LineLayout::Free() {
- delete []chars;
- chars = 0;
- delete []styles;
- styles = 0;
- delete []indicators;
- indicators = 0;
- delete []positions;
- positions = 0;
- delete []lineStarts;
- lineStarts = 0;
-}
-
-void LineLayout::Invalidate(validLevel validity_) {
- if (validity > validity_)
- validity = validity_;
-}
-
-void LineLayout::SetLineStart(int line, int start) {
- if ((line >= lenLineStarts) && (line != 0)) {
- int newMaxLines = line + 20;
- int *newLineStarts = new int[newMaxLines];
- if (!newLineStarts)
- return;
- for (int i = 0; i < newMaxLines; i++) {
- if (i < lenLineStarts)
- newLineStarts[i] = lineStarts[i];
- else
- newLineStarts[i] = 0;
- }
- delete []lineStarts;
- lineStarts = newLineStarts;
- lenLineStarts = newMaxLines;
- }
- lineStarts[line] = start;
-}
-
-void LineLayout::SetBracesHighlight(Range rangeLine, Position braces[],
- char bracesMatchStyle, int xHighlight) {
- if (rangeLine.ContainsCharacter(braces[0])) {
- int braceOffset = braces[0] - rangeLine.start;
- if (braceOffset < numCharsInLine) {
- bracePreviousStyles[0] = styles[braceOffset];
- styles[braceOffset] = bracesMatchStyle;
- }
- }
- if (rangeLine.ContainsCharacter(braces[1])) {
- int braceOffset = braces[1] - rangeLine.start;
- if (braceOffset < numCharsInLine) {
- bracePreviousStyles[1] = styles[braceOffset];
- styles[braceOffset] = bracesMatchStyle;
- }
- }
- if ((braces[0] >= rangeLine.start && braces[1] <= rangeLine.end) ||
- (braces[1] >= rangeLine.start && braces[0] <= rangeLine.end)) {
- xHighlightGuide = xHighlight;
- }
-}
-
-void LineLayout::RestoreBracesHighlight(Range rangeLine, Position braces[]) {
- if (rangeLine.ContainsCharacter(braces[0])) {
- int braceOffset = braces[0] - rangeLine.start;
- if (braceOffset < numCharsInLine) {
- styles[braceOffset] = bracePreviousStyles[0];
- }
- }
- if (rangeLine.ContainsCharacter(braces[1])) {
- int braceOffset = braces[1] - rangeLine.start;
- if (braceOffset < numCharsInLine) {
- styles[braceOffset] = bracePreviousStyles[1];
- }
- }
- xHighlightGuide = 0;
-}
-
-LineLayoutCache::LineLayoutCache() :
- level(0), length(0), size(0), cache(0),
- allInvalidated(false), styleClock(-1), useCount(0) {
- Allocate(0);
-}
-
-LineLayoutCache::~LineLayoutCache() {
- Deallocate();
-}
-
-void LineLayoutCache::Allocate(int length_) {
- PLATFORM_ASSERT(cache == NULL);
- allInvalidated = false;
- length = length_;
- size = length;
- if (size > 1) {
- size = (size / 16 + 1) * 16;
- }
- if (size > 0) {
- cache = new LineLayout * [size];
- }
- for (int i = 0; i < size; i++)
- cache[i] = 0;
-}
-
-void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) {
- PLATFORM_ASSERT(useCount == 0);
- int lengthForLevel = 0;
- if (level == llcCaret) {
- lengthForLevel = 1;
- } else if (level == llcPage) {
- lengthForLevel = linesOnScreen + 1;
- } else if (level == llcDocument) {
- lengthForLevel = linesInDoc;
- }
- if (lengthForLevel > size) {
- Deallocate();
- Allocate(lengthForLevel);
- } else {
- if (lengthForLevel < length) {
- for (int i = lengthForLevel; i < length; i++) {
- delete cache[i];
- cache[i] = 0;
- }
- }
- length = lengthForLevel;
- }
- PLATFORM_ASSERT(length == lengthForLevel);
- PLATFORM_ASSERT(cache != NULL || length == 0);
-}
-
-void LineLayoutCache::Deallocate() {
- PLATFORM_ASSERT(useCount == 0);
- for (int i = 0; i < length; i++)
- delete cache[i];
- delete []cache;
- cache = 0;
- length = 0;
- size = 0;
-}
-
-void LineLayoutCache::Invalidate(LineLayout::validLevel validity_) {
- if (cache && !allInvalidated) {
- for (int i = 0; i < length; i++) {
- if (cache[i]) {
- cache[i]->Invalidate(validity_);
- }
- }
- if (validity_ == LineLayout::llInvalid) {
- allInvalidated = true;
- }
- }
-}
-
-void LineLayoutCache::SetLevel(int level_) {
- allInvalidated = false;
- if ((level_ != -1) && (level != level_)) {
- level = level_;
- Deallocate();
- }
-}
-
-LineLayout *LineLayoutCache::Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_,
- int linesOnScreen, int linesInDoc) {
- AllocateForLevel(linesOnScreen, linesInDoc);
- if (styleClock != styleClock_) {
- Invalidate(LineLayout::llCheckTextAndStyle);
- styleClock = styleClock_;
- }
- allInvalidated = false;
- int pos = -1;
- LineLayout *ret = 0;
- if (level == llcCaret) {
- pos = 0;
- } else if (level == llcPage) {
- if (lineNumber == lineCaret) {
- pos = 0;
- } else if (length > 1) {
- pos = 1 + (lineNumber % (length - 1));
- }
- } else if (level == llcDocument) {
- pos = lineNumber;
- }
- if (pos >= 0) {
- PLATFORM_ASSERT(useCount == 0);
- if (cache && (pos < length)) {
- if (cache[pos]) {
- if ((cache[pos]->lineNumber != lineNumber) ||
- (cache[pos]->maxLineLength < maxChars)) {
- delete cache[pos];
- cache[pos] = 0;
- }
- }
- if (!cache[pos]) {
- cache[pos] = new LineLayout(maxChars);
- }
- if (cache[pos]) {
- cache[pos]->lineNumber = lineNumber;
- cache[pos]->inCache = true;
- ret = cache[pos];
- useCount++;
- }
- }
- }
-
- if (!ret) {
- ret = new LineLayout(maxChars);
- ret->lineNumber = lineNumber;
- }
+ state(false), idlerID(0) {}
- return ret;
-}
-
-void LineLayoutCache::Dispose(LineLayout *ll) {
- allInvalidated = false;
- if (ll) {
- if (!ll->inCache) {
- delete ll;
- } else {
- useCount--;
- }
- }
+static inline bool IsControlCharacter(int ch) {
+ // iscntrl returns true for lots of chars > 127 which are displayable
+ return ch >= 0 && ch < ' ';
}
Editor::Editor() {
dwelling = false;
ptMouseLast.x = 0;
ptMouseLast.y = 0;
- inDragDrop = false;
+ inDragDrop = ddNone;
dropWentOutside = false;
posDrag = invalidPosition;
posDrop = invalidPosition;
xCaretMargin = 50;
horizontalScrollBarVisible = true;
scrollWidth = 2000;
+ trackLineWidth = false;
+ lineWidthMaxSeen = 0;
verticalScrollBarVisible = true;
endAtLastLine = true;
caretSticky = false;
hsEnd = -1;
llc.SetLevel(LineLayoutCache::llcCaret);
+ posCache.SetSize(0x400);
}
Editor::~Editor() {
palette.Release();
DropGraphics();
llc.Invalidate(LineLayout::llInvalid);
+ posCache.Clear();
if (selType == selRectangle) {
xStartSelect = XFromPosition(anchor);
xEndSelect = XFromPosition(currentPos);
PRectangle rcClient = GetClientRectangle();
int htClient = rcClient.bottom - rcClient.top;
//Platform::DebugPrintf("lines on screen = %d\n", htClient / lineHeight + 1);
- int n = htClient / vs.lineHeight;
- if (n < 0)
- n = 0;
- return n;
+ return htClient / vs.lineHeight;
}
int Editor::LinesToScroll() {
}
}
-static inline bool IsControlCharacter(int ch) {
- // iscntrl returns true for lots of chars > 127 which are displayable
- return ch >= 0 && ch < ' ';
-}
-
const char *ControlCharacterString(unsigned char ch) {
const char *reps[] = {
"NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL",
}
};
+#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
}
};
+#ifdef SCI_NAMESPACE
+}
+#endif
+
Point Editor::LocationFromPosition(int pos) {
Point pt;
RefreshStyleData();
posTopLine = pdoc->LineStart(cs.DocFromDisplay(topLine));
}
-static inline bool IsEOLChar(char ch) {
- return (ch == '\r') || (ch == '\n');
-}
-
int Editor::PositionFromLocation(Point pt) {
RefreshStyleData();
pt.x = pt.x - vs.fixedColumnWidth + xOffset;
int subLine = visibleLine - lineStartSet;
if (subLine < ll->lines) {
int lineStart = ll->LineStart(subLine);
- int lineEnd = ll->LineStart(subLine + 1);
+ int lineEnd = ll->LineLastVisible(subLine);
int subLineStart = ll->positions[lineStart];
if (actualWrapVisualStartIndent != 0) {
if (lineStart != 0) // Wrapped
pt.x -= actualWrapVisualStartIndent * vs.aveCharWidth;
}
- for (int i = lineStart; i < lineEnd; i++) {
- if (pt.x < (((ll->positions[i] + ll->positions[i + 1]) / 2) - subLineStart) ||
- IsEOLChar(ll->chars[i])) {
+ 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++;
}
return lineEnd + posLineStart;
}
int subLine = visibleLine - lineStartSet;
if (subLine < ll->lines) {
int lineStart = ll->LineStart(subLine);
- int lineEnd = ll->LineStart(subLine + 1);
+ int lineEnd = ll->LineLastVisible(subLine);
int subLineStart = ll->positions[lineStart];
if (actualWrapVisualStartIndent != 0) {
if (lineStart != 0) // Wrapped
pt.x -= actualWrapVisualStartIndent * vs.aveCharWidth;
}
- for (int i = lineStart; i < lineEnd; i++) {
- if (pt.x < (((ll->positions[i] + ll->positions[i + 1]) / 2) - subLineStart) ||
- IsEOLChar(ll->chars[i])) {
+ 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);
retVal = ll->numCharsInLine + posLineStart;
int subLine = 0;
int lineStart = ll->LineStart(subLine);
- int lineEnd = ll->LineStart(subLine + 1);
+ int lineEnd = ll->LineLastVisible(subLine);
int subLineStart = ll->positions[lineStart];
if (actualWrapVisualStartIndent != 0) {
if (lineStart != 0) // Wrapped
x -= actualWrapVisualStartIndent * vs.aveCharWidth;
}
- for (int i = lineStart; i < lineEnd; i++) {
- if (x < (((ll->positions[i] + ll->positions[i + 1]) / 2) - subLineStart) ||
- IsEOLChar(ll->chars[i])) {
+ 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 retVal;
ShowCaretAtCurrentPosition();
// Perform redraw rather than scroll if many lines would be redrawn anyway.
#ifndef UNDER_CE
- if (abs(linesToMove) <= 10) {
+ if ((abs(linesToMove) <= 10) && (paintState == notPainting)) {
ScrollText(linesToMove);
} else {
Redraw();
Point pt = LocationFromPosition(currentPos);
if (pt.y < rcClient.top) {
MovePositionTo(PositionFromLocation(
- Point(lastXChosen, rcClient.top)),
- noSel, ensureVisible);
+ Point(lastXChosen, rcClient.top)),
+ noSel, ensureVisible);
} else if ((pt.y + vs.lineHeight - 1) > rcClient.bottom) {
int yOfLastLineFullyDisplayed = rcClient.top + (LinesOnScreen() - 1) * vs.lineHeight;
MovePositionTo(PositionFromLocation(
- Point(lastXChosen, rcClient.top + yOfLastLineFullyDisplayed)),
- noSel, ensureVisible);
+ Point(lastXChosen, rcClient.top + yOfLastLineFullyDisplayed)),
+ noSel, ensureVisible);
}
}
xOffsetNew = pt.x + xOffset - rcClient.left;
} else if (pt.x + xOffset >= rcClient.right + xOffsetNew) {
xOffsetNew = pt.x + xOffset - rcClient.right + 1;
+ if (vs.caretStyle == CARETSTYLE_BLOCK) {
+ // Ensure we can see a good portion of the block caret
+ xOffsetNew += vs.aveCharWidth;
+ }
}
if (xOffsetNew < 0) {
xOffsetNew = 0;
xOffset = xOffsetNew;
if (xOffsetNew > 0) {
PRectangle rcText = GetTextRectangle();
- if (horizontalScrollBarVisible == true &&
+ if (horizontalScrollBarVisible &&
rcText.Width() + xOffset > scrollWidth) {
scrollWidth = xOffset + rcText.Width();
SetScrollBars();
}
}
+bool Editor::WrapOneLine(Surface *surface, int lineToWrap) {
+ AutoLineLayout ll(llc, RetrieveLineLayout(lineToWrap));
+ int linesWrapped = 1;
+ if (ll) {
+ LayoutLine(lineToWrap, surface, vs, ll, wrapWidth);
+ linesWrapped = ll->lines;
+ }
+ return cs.SetHeight(lineToWrap, linesWrapped);
+}
+
// Check if wrapping needed and perform any needed wrapping.
// fullwrap: if true, all lines which need wrapping will be done,
// in this single call.
}
}
if (!fullWrap && priorityWrapLineStart >= 0 &&
- // .. and if the paint window is outside pending wraps
- (((priorityWrapLineStart + linesInOneCall) < wrapStart) ||
- (priorityWrapLineStart > wrapEnd))) {
+ // .. and if the paint window is outside pending wraps
+ (((priorityWrapLineStart + linesInOneCall) < wrapStart) ||
+ (priorityWrapLineStart > wrapEnd))) {
// No priority wrap pending
return false;
}
// Platform::DebugPrintf("Wraplines: full = %d, priorityStart = %d (wrapping: %d to %d)\n", fullWrap, priorityWrapLineStart, lineToWrap, lastLineToWrap);
// Platform::DebugPrintf("Pending wraps: %d to %d\n", wrapStart, wrapEnd);
while (lineToWrap < lastLineToWrap) {
- AutoLineLayout ll(llc, RetrieveLineLayout(lineToWrap));
- int linesWrapped = 1;
- if (ll) {
- LayoutLine(lineToWrap, surface, vs, ll, wrapWidth);
- linesWrapped = ll->lines;
- }
- if (cs.SetHeight(lineToWrap, linesWrapped)) {
+ if (WrapOneLine(surface, lineToWrap)) {
wrapOccurred = true;
}
lineToWrap++;
if (prevNonWS) {
// Ensure at least one space separating previous lines
pdoc->InsertChar(pos, ' ');
+ targetEnd++;
}
} else {
prevNonWS = pdoc->CharAt(pos) != ' ';
unsigned int posLineStart = pdoc->LineStart(line);
LayoutLine(line, surface, vs, ll, pixelWidth);
for (int subLine = 1; subLine < ll->lines; subLine++) {
- pdoc->InsertString(posLineStart + (subLine - 1) * strlen(eol) +
- ll->LineStart(subLine), eol);
+ pdoc->InsertCString(posLineStart + (subLine - 1) * strlen(eol) +
+ ll->LineStart(subLine), eol);
targetEnd += static_cast<int>(strlen(eol));
}
}
// Old code does not know about new markers needed to distinguish all cases
int folderOpenMid = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEROPENMID,
- SC_MARKNUM_FOLDEROPEN);
+ SC_MARKNUM_FOLDEROPEN);
int folderEnd = SubstituteMarkerIfEmpty(SC_MARKNUM_FOLDEREND,
- SC_MARKNUM_FOLDER);
+ SC_MARKNUM_FOLDER);
while ((visibleLine < cs.LinesDisplayed()) && yposScreen < rcMargin.bottom) {
if (foldFlags & SC_FOLDFLAG_LEVELNUMBERS) {
int lev = pdoc->GetLevel(lineDoc);
sprintf(number, "%c%c %03X %03X",
- (lev & SC_FOLDLEVELHEADERFLAG) ? 'H' : '_',
- (lev & SC_FOLDLEVELWHITEFLAG) ? 'W' : '_',
- lev & SC_FOLDLEVELNUMBERMASK,
- lev >> 16
- );
+ (lev & SC_FOLDLEVELHEADERFLAG) ? 'H' : '_',
+ (lev & SC_FOLDLEVELWHITEFLAG) ? 'W' : '_',
+ lev & SC_FOLDLEVELNUMBERMASK,
+ lev >> 16
+ );
}
PRectangle rcNumber = rcMarker;
// Right justify
int xpos = rcNumber.right - width - 3;
rcNumber.left = xpos;
surface->DrawTextNoClip(rcNumber, vs.styles[STYLE_LINENUMBER].font,
- rcNumber.top + vs.maxAscent, number, istrlen(number),
- vs.styles[STYLE_LINENUMBER].fore.allocated,
- vs.styles[STYLE_LINENUMBER].back.allocated);
+ rcNumber.top + vs.maxAscent, number, istrlen(number),
+ vs.styles[STYLE_LINENUMBER].fore.allocated,
+ vs.styles[STYLE_LINENUMBER].back.allocated);
}
if (marks) {
surface->LineTo(xhead, ymid + ydiff);
}
-static bool IsSpaceOrTab(char ch) {
- return ch == ' ' || ch == '\t';
-}
-
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);
return llc.Retrieve(lineNumber, lineCaret,
- posLineEnd - posLineStart, pdoc->GetStyleClock(),
- LinesOnScreen() + 1, pdoc->LinesTotal());
+ posLineEnd - posLineStart, pdoc->GetStyleClock(),
+ LinesOnScreen() + 1, pdoc->LinesTotal());
+}
+
+static bool GoodTrailByte(int v) {
+ return (v >= 0x80) && (v < 0xc0);
+}
+
+bool BadUTF(const char *s, int len, int &trailBytes) {
+ if (trailBytes) {
+ trailBytes--;
+ return false;
+ }
+ const unsigned char *us = reinterpret_cast<const unsigned char *>(s);
+ if (*us < 0x80) {
+ // Single bytes easy
+ return false;
+ } else if (*us > 0xF4) {
+ // Characters longer than 4 bytes not possible in current UTF-8
+ return true;
+ } else if (*us >= 0xF0) {
+ // 4 bytes
+ if (len < 4)
+ return true;
+ if (GoodTrailByte(us[1]) && GoodTrailByte(us[2]) && GoodTrailByte(us[3])) {
+ trailBytes = 3;
+ return false;
+ } else {
+ return true;
+ }
+ } else if (*us >= 0xE0) {
+ // 3 bytes
+ if (len < 3)
+ return true;
+ if (GoodTrailByte(us[1]) && GoodTrailByte(us[2])) {
+ trailBytes = 2;
+ return false;
+ } else {
+ return true;
+ }
+ } else if (*us >= 0xC2) {
+ // 2 bytes
+ if (len < 2)
+ return true;
+ if (GoodTrailByte(us[1])) {
+ trailBytes = 1;
+ return false;
+ } else {
+ return true;
+ }
+ } else if (*us >= 0xC0) {
+ // Overlong encoding
+ return true;
+ } else {
+ // Trail byte
+ return true;
+ }
}
/**
void Editor::LayoutLine(int line, Surface *surface, ViewStyle &vstyle, LineLayout *ll, int width) {
if (!ll)
return;
+
PLATFORM_ASSERT(line < pdoc->LinesTotal());
+ PLATFORM_ASSERT(ll->chars != NULL);
int posLineStart = pdoc->LineStart(line);
int posLineEnd = pdoc->LineStart(line + 1);
// If the line is very long, limit the treatment to a length that should fit in the viewport
char chDoc = pdoc->CharAt(charInDoc);
styleByte = pdoc->StyleAt(charInDoc);
allSame = allSame &&
- (ll->styles[numCharsInLine] == static_cast<unsigned char>(styleByte & styleMask));
+ (ll->styles[numCharsInLine] == static_cast<unsigned char>(styleByte & styleMask));
allSame = allSame &&
- (ll->indicators[numCharsInLine] == static_cast<char>(styleByte & ~styleMask));
+ (ll->indicators[numCharsInLine] == static_cast<char>(styleByte & ~styleMask));
if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseMixed)
allSame = allSame &&
- (ll->chars[numCharsInLine] == chDoc);
+ (ll->chars[numCharsInLine] == chDoc);
else if (vstyle.styles[ll->styles[numCharsInLine]].caseForce == Style::caseLower)
allSame = allSame &&
- (ll->chars[numCharsInLine] == static_cast<char>(tolower(chDoc)));
+ (ll->chars[numCharsInLine] == static_cast<char>(tolower(chDoc)));
else // Style::caseUpper
allSame = allSame &&
- (ll->chars[numCharsInLine] == static_cast<char>(toupper(chDoc)));
+ (ll->chars[numCharsInLine] == static_cast<char>(toupper(chDoc)));
numCharsInLine++;
}
allSame = allSame && (ll->styles[numCharsInLine] == styleByte); // For eolFilled
int ctrlCharWidth[32] = {0};
bool isControlNext = IsControlCharacter(ll->chars[0]);
+ int trailBytes = 0;
+ bool isBadUTFNext = IsUnicodeMode() && BadUTF(ll->chars, numCharsInLine, trailBytes);
for (int charInLine = 0; charInLine < numCharsInLine; charInLine++) {
bool isControl = isControlNext;
isControlNext = IsControlCharacter(ll->chars[charInLine + 1]);
+ bool isBadUTF = isBadUTFNext;
+ isBadUTFNext = IsUnicodeMode() && BadUTF(ll->chars + charInLine + 1, numCharsInLine - charInLine - 1, trailBytes);
if ((ll->styles[charInLine] != ll->styles[charInLine + 1]) ||
- isControl || isControlNext) {
+ isControl || isControlNext || isBadUTF || isBadUTFNext) {
ll->positions[startseg] = 0;
if (vstyle.styles[ll->styles[charInLine]].visible) {
if (isControl) {
if (ll->chars[charInLine] == '\t') {
ll->positions[charInLine + 1] = ((((startsegx + 2) /
- tabWidth) + 1) * tabWidth) - startsegx;
+ tabWidth) + 1) * tabWidth) - startsegx;
} else if (controlCharSymbol < 32) {
if (ctrlCharWidth[ll->chars[charInLine]] == 0) {
const char *ctrlChar = ControlCharacterString(ll->chars[charInLine]);
// +3 For a blank on front and rounded edge each side:
ctrlCharWidth[ll->chars[charInLine]] =
- surface->WidthText(ctrlCharsFont, ctrlChar, istrlen(ctrlChar)) + 3;
+ surface->WidthText(ctrlCharsFont, ctrlChar, istrlen(ctrlChar)) + 3;
}
ll->positions[charInLine + 1] = ctrlCharWidth[ll->chars[charInLine]];
} else {
char cc[2] = { static_cast<char>(controlCharSymbol), '\0' };
surface->MeasureWidths(ctrlCharsFont, cc, 1,
- ll->positions + startseg + 1);
+ ll->positions + startseg + 1);
}
lastSegItalics = false;
+ } else if (isBadUTF) {
+ char hexits[3];
+ sprintf(hexits, "%2X", ll->chars[charInLine] & 0xff);
+ ll->positions[charInLine + 1] =
+ surface->WidthText(ctrlCharsFont, hexits, istrlen(hexits)) + 3;
} else { // Regular character
int lenSeg = charInLine - startseg + 1;
if ((lenSeg == 1) && (' ' == ll->chars[startseg])) {
ll->positions[charInLine + 1] = vstyle.styles[ll->styles[charInLine]].spaceWidth;
} else {
lastSegItalics = vstyle.styles[ll->styles[charInLine]].italic;
- surface->MeasureWidths(vstyle.styles[ll->styles[charInLine]].font, ll->chars + startseg,
- lenSeg, ll->positions + startseg + 1);
+ posCache.MeasureWidths(surface, vstyle, ll->styles[charInLine], ll->chars + startseg,
+ lenSeg, ll->positions + startseg + 1);
}
}
} else { // invisible
}
ll->lines = 0;
// Calculate line start positions based upon width.
- // For now this is simplistic - wraps on byte rather than character and
- // in the middle of words. Should search for spaces or style changes.
int lastGoodBreak = 0;
int lastLineStart = 0;
int startOffset = 0;
// Try moving to start of last character
if (p > 0) {
lastGoodBreak = pdoc->MovePositionOutsideChar(p + posLineStart, -1)
- - posLineStart;
+ - posLineStart;
}
if (lastGoodBreak == lastLineStart) {
// Ensure at least one character on line.
lastGoodBreak = pdoc->MovePositionOutsideChar(lastGoodBreak + posLineStart + 1, 1)
- - posLineStart;
+ - posLineStart;
}
}
lastLineStart = lastGoodBreak;
if (p > 0) {
if (wrapState == eWrapChar) {
lastGoodBreak = pdoc->MovePositionOutsideChar(p + posLineStart, -1)
- - posLineStart;
+ - posLineStart;
p = pdoc->MovePositionOutsideChar(p + 1 + posLineStart, 1) - posLineStart;
continue;
} else if (ll->styles[p] != ll->styles[p - 1]) {
}
ColourAllocated Editor::TextBackground(ViewStyle &vsDraw, bool overrideBackground,
- ColourAllocated background, bool inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) {
+ ColourAllocated background, bool inSelection, bool inHotspot, int styleMain, int i, LineLayout *ll) {
if (inSelection) {
if (vsDraw.selbackset && (vsDraw.selAlpha == SC_ALPHA_NOALPHA)) {
return SelectionBackground(vsDraw);
return vsDraw.edgecolour.allocated;
if (inHotspot && vsDraw.hotspotBackgroundSet)
return vsDraw.hotspotBackground.allocated;
- if (overrideBackground)
+ if (overrideBackground && (styleMain != STYLE_BRACELIGHT) && (styleMain != STYLE_BRACEBAD))
return background;
}
return vsDraw.styles[styleMain].back.allocated;
Point from(0, ((lineVisible & 1) && (lineHeight & 1)) ? 1 : 0);
PRectangle rcCopyArea(start + 1, rcSegment.top, start + 2, rcSegment.bottom);
surface->Copy(rcCopyArea, from,
- highlight ? *pixmapIndentGuideHighlight : *pixmapIndentGuide);
+ highlight ? *pixmapIndentGuideHighlight : *pixmapIndentGuide);
}
void Editor::DrawWrapMarker(Surface *surface, PRectangle rcPlace,
- bool isEndMarker, ColourAllocated wrapColour) {
+ bool isEndMarker, ColourAllocated wrapColour) {
surface->PenColour(wrapColour);
enum { xa = 1 }; // gap before start
int yBase;
int yDir;
void MoveTo(int xRelative, int yRelative) {
- surface->MoveTo(xBase + xDir * xRelative, yBase + yDir * yRelative);
+ surface->MoveTo(xBase + xDir * xRelative, yBase + yDir * yRelative);
}
void LineTo(int xRelative, int yRelative) {
- surface->LineTo(xBase + xDir * xRelative, yBase + yDir * yRelative);
+ surface->LineTo(xBase + xDir * xRelative, yBase + yDir * yRelative);
}
};
Relative rel = {surface, x0, xStraight ? 1 : -1, y0, yStraight ? 1 : -1};
rel.LineTo(xa + w, y);
rel.LineTo(xa + w, y - 2 * dy);
rel.LineTo(xa - 1, // on windows lineto is exclusive endpoint, perhaps GTK not...
- y - 2 * dy);
+ y - 2 * dy);
}
static void SimpleAlphaRectangle(Surface *surface, PRectangle rc, ColourAllocated fill, int alpha) {
}
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 line, int lineEnd, int xStart, int subLine, int subLineStart,
+ bool overrideBackground, ColourAllocated background,
+ bool drawWrapMarkEnd, ColourAllocated wrapColour) {
int styleMask = pdoc->stylingBitsMask;
PRectangle rcSegment = rcLine;
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);
+ (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));
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));
+ } else {
+ 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)) {
+ SimpleAlphaRectangle(surface, rcSegment, SelectionBackground(vsDraw), vsDraw.selAlpha);
+ }
+ }
+
if (drawWrapMarkEnd) {
PRectangle rcPlace = rcSegment;
}
}
+void Editor::DrawIndicators(Surface *surface, ViewStyle &vsDraw, int line, int xStart,
+ PRectangle rcLine, LineLayout *ll, int subLine, int lineEnd, bool under) {
+ // Draw decorators
+ const int posLineStart = pdoc->LineStart(line);
+ const int lineStart = ll->LineStart(subLine);
+ const int subLineStart = ll->positions[lineStart];
+ const int posLineEnd = posLineStart + lineEnd;
+
+ if (!under) {
+ // Draw indicators
+ // foreach indicator...
+ for (int indicnum = 0, mask = 1 << pdoc->stylingBits; mask < 0x100; indicnum++) {
+ if (!(mask & ll->styleBitsSet)) {
+ mask <<= 1;
+ continue;
+ }
+ int startPos = -1;
+ // foreach style pos in line...
+ for (int indicPos = lineStart; indicPos <= lineEnd; indicPos++) {
+ // look for starts...
+ if (startPos < 0) {
+ // NOT in indicator run, looking for START
+ if (indicPos < lineEnd && (ll->indicators[indicPos] & mask))
+ startPos = indicPos;
+ }
+ // ... or ends
+ if (startPos >= 0) {
+ // IN indicator run, looking for END
+ if (indicPos >= lineEnd || !(ll->indicators[indicPos] & mask)) {
+ // AT end of indicator run, DRAW it!
+ PRectangle rcIndic(
+ ll->positions[startPos] + xStart - subLineStart,
+ rcLine.top + vsDraw.maxAscent,
+ ll->positions[indicPos] + xStart - subLineStart,
+ rcLine.top + vsDraw.maxAscent + 3);
+ vsDraw.indicators[indicnum].Draw(surface, rcIndic, rcLine);
+ // RESET control var
+ startPos = -1;
+ }
+ }
+ }
+ mask <<= 1;
+ }
+ }
+
+ for (Decoration *deco = pdoc->decorations.root; deco; deco = deco->next) {
+ if (under == vsDraw.indicators[deco->indicator].under) {
+ int startPos = posLineStart + lineStart;
+ if (!deco->rs.ValueAt(startPos)) {
+ startPos = deco->rs.EndRun(startPos);
+ }
+ while ((startPos < posLineEnd) && (deco->rs.ValueAt(startPos))) {
+ int endPos = deco->rs.EndRun(startPos);
+ if (endPos > posLineEnd)
+ endPos = posLineEnd;
+ PRectangle rcIndic(
+ ll->positions[startPos - posLineStart] + xStart - subLineStart,
+ rcLine.top + vsDraw.maxAscent,
+ ll->positions[endPos - posLineStart] + xStart - subLineStart,
+ rcLine.top + vsDraw.maxAscent + 3);
+ vsDraw.indicators[deco->indicator].Draw(surface, rcIndic, rcLine);
+ startPos = deco->rs.EndRun(endPos);
+ }
+ }
+ }
+}
+
+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::DrawLine(Surface *surface, ViewStyle &vsDraw, int line, int lineVisible, int xStart,
- PRectangle rcLine, LineLayout *ll, int subLine) {
+ PRectangle rcLine, LineLayout *ll, int subLine) {
PRectangle rcSegment = rcLine;
int marks = pdoc->GetMark(line);
for (int markBit = 0; (markBit < 32) && marks; markBit++) {
if ((marks & 1) && (vsDraw.markers[markBit].markType == SC_MARK_BACKGROUND) &&
- (vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) {
+ (vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) {
background = vsDraw.markers[markBit].back.allocated;
overrideBackground = true;
}
if (marksMasked) {
for (int markBit = 0; (markBit < 32) && marksMasked; markBit++) {
if ((marksMasked & 1) && (vsDraw.markers[markBit].markType != SC_MARK_EMPTY) &&
- (vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) {
+ (vsDraw.markers[markBit].alpha == SC_ALPHA_NOALPHA)) {
overrideBackground = true;
background = vsDraw.markers[markBit].back.allocated;
}
}
bool drawWhitespaceBackground = (vsDraw.viewWhitespace != wsInvisible) &&
- (!overrideBackground) && (vsDraw.whitespaceBackgroundSet);
+ (!overrideBackground) && (vsDraw.whitespaceBackgroundSet);
bool inIndentation = subLine == 0; // Do not handle indentation except on first subline.
int indentWidth = pdoc->IndentSize() * vsDraw.spaceWidth;
lineEnd = ll->LineStart(subLine + 1);
}
+ ColourAllocated wrapColour = vsDraw.styles[STYLE_DEFAULT].fore.allocated;
+ if (vsDraw.whitespaceForegroundSet)
+ wrapColour = vsDraw.whitespaceForeground.allocated;
+
bool drawWrapMarkEnd = false;
if (wrapVisualFlags & SC_WRAPVISUALFLAG_END) {
rcPlace.right = rcPlace.left + actualWrapVisualStartIndent * vsDraw.aveCharWidth;
// default bgnd here..
- surface->FillRectangle(rcSegment, vsDraw.styles[STYLE_DEFAULT].back.allocated);
+ surface->FillRectangle(rcSegment, overrideBackground ? background :
+ vsDraw.styles[STYLE_DEFAULT].back.allocated);
// main line style would be below but this would be inconsistent with end markers
// also would possibly not be the style at wrap point
else
rcPlace.right = rcPlace.left + vsDraw.aveCharWidth;
- DrawWrapMarker(surface, rcPlace, false, vsDraw.whitespaceForeground.allocated);
+ DrawWrapMarker(surface, rcPlace, false, wrapColour);
}
xStart += actualWrapVisualStartIndent * vsDraw.aveCharWidth;
}
}
- int i;
+ // Does not take margin into account but not significant
+ int xStartVisible = subLineStart - xStart;
+
+ BreakFinder bfBack(ll, lineStart, lineEnd, posLineStart, IsUnicodeMode(), xStartVisible);
+ int next = bfBack.First();
// Background drawing loop
- for (i = lineStart; twoPhaseDraw && (i < lineEnd); i++) {
+ while (twoPhaseDraw && (next < lineEnd)) {
+ startseg = next;
+ next = bfBack.Next();
+ int i = next - 1;
int iDoc = i + posLineStart;
- // If there is the end of a style run for any reason
- if ((ll->styles[i] != ll->styles[i + 1]) ||
- i == (lineEnd - 1) ||
- IsControlCharacter(ll->chars[i]) || IsControlCharacter(ll->chars[i + 1]) ||
- ((ll->selStart != ll->selEnd) && ((iDoc + 1 == ll->selStart) || (iDoc + 1 == ll->selEnd))) ||
- (i == (ll->edgeColumn - 1))) {
- rcSegment.left = ll->positions[startseg] + xStart - subLineStart;
- rcSegment.right = ll->positions[i + 1] + xStart - subLineStart;
- // Only try to draw if really visible - enhances performance by not calling environment to
- // draw strings that are completely past the right side of the window.
- if ((rcSegment.left <= rcLine.right) && (rcSegment.right >= rcLine.left)) {
- int styleMain = ll->styles[i];
- bool inSelection = (iDoc >= ll->selStart) && (iDoc < ll->selEnd) && (ll->selStart != ll->selEnd);
- 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') {
- // Tab display
- if (drawWhitespaceBackground &&
- (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways))
- textBack = vsDraw.whitespaceBackground.allocated;
- surface->FillRectangle(rcSegment, textBack);
- } else if (IsControlCharacter(ll->chars[i])) {
- // Control character display
- inIndentation = false;
- surface->FillRectangle(rcSegment, textBack);
- } else {
- // Normal text display
- surface->FillRectangle(rcSegment, textBack);
- if (vsDraw.viewWhitespace != wsInvisible ||
- (inIndentation && vsDraw.viewIndentationGuides)) {
- for (int cpos = 0; cpos <= i - startseg; cpos++) {
- 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);
- surface->FillRectangle(rcSpace, vsDraw.whitespaceBackground.allocated);
- }
- } else {
- inIndentation = false;
+
+ rcSegment.left = ll->positions[startseg] + xStart - subLineStart;
+ rcSegment.right = ll->positions[i + 1] + xStart - subLineStart;
+ // Only try to draw if really visible - enhances performance by not calling environment to
+ // draw strings that are completely past the right side of the window.
+ if ((rcSegment.left <= rcLine.right) && (rcSegment.right >= rcLine.left)) {
+ // Clip to line rectangle, since may have a huge position which will not work with some platforms
+ rcSegment.left = Platform::Maximum(rcSegment.left, rcLine.left);
+ 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);
+ 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') {
+ // Tab display
+ if (drawWhitespaceBackground &&
+ (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways))
+ textBack = vsDraw.whitespaceBackground.allocated;
+ surface->FillRectangle(rcSegment, textBack);
+ } else if (IsControlCharacter(ll->chars[i])) {
+ // Control character display
+ inIndentation = false;
+ surface->FillRectangle(rcSegment, textBack);
+ } else {
+ // Normal text display
+ surface->FillRectangle(rcSegment, textBack);
+ if (vsDraw.viewWhitespace != wsInvisible ||
+ (inIndentation && vsDraw.viewIndentationGuides == ivReal)) {
+ for (int cpos = 0; cpos <= i - startseg; cpos++) {
+ 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);
+ surface->FillRectangle(rcSpace, vsDraw.whitespaceBackground.allocated);
}
+ } else {
+ inIndentation = false;
}
}
}
- } else if (rcSegment.left > rcLine.right) {
- break;
}
- startseg = i + 1;
+ } else if (rcSegment.left > rcLine.right) {
+ break;
}
}
if (twoPhaseDraw) {
DrawEOL(surface, vsDraw, rcLine, ll, line, lineEnd,
xStart, subLine, subLineStart, overrideBackground, background,
- drawWrapMarkEnd, vsDraw.whitespaceForeground.allocated);
+ drawWrapMarkEnd, wrapColour);
+ }
+
+ DrawIndicators(surface, vsDraw, line, xStart, rcLine, ll, subLine, lineEnd, true);
+
+ if (vsDraw.edgeState == EDGE_LINE) {
+ int edgeX = theEdge * vsDraw.spaceWidth;
+ rcSegment.left = edgeX + xStart;
+ rcSegment.right = rcSegment.left + 1;
+ surface->FillRectangle(rcSegment, vsDraw.edgecolour.allocated);
}
inIndentation = subLine == 0; // Do not handle indentation except on first subline.
- startseg = ll->LineStart(subLine);
// Foreground drawing loop
- for (i = lineStart; i < lineEnd; i++) {
+ BreakFinder bfFore(ll, lineStart, lineEnd, posLineStart, IsUnicodeMode(), xStartVisible);
+ next = bfFore.First();
+
+ while (next < lineEnd) {
+
+ startseg = next;
+ next = bfFore.Next();
+ int i = next - 1;
int iDoc = i + posLineStart;
- // If there is the end of a style run for any reason
- if ((ll->styles[i] != ll->styles[i + 1]) ||
- i == (lineEnd - 1) ||
- IsControlCharacter(ll->chars[i]) || IsControlCharacter(ll->chars[i + 1]) ||
- ((ll->selStart != ll->selEnd) && ((iDoc + 1 == ll->selStart) || (iDoc + 1 == ll->selEnd))) ||
- (i == (ll->edgeColumn - 1))) {
- rcSegment.left = ll->positions[startseg] + xStart - subLineStart;
- rcSegment.right = ll->positions[i + 1] + xStart - subLineStart;
- // Only try to draw if really visible - enhances performance by not calling environment to
- // draw strings that are completely past the right side of the window.
- if ((rcSegment.left <= rcLine.right) && (rcSegment.right >= rcLine.left)) {
- int styleMain = ll->styles[i];
- ColourAllocated textFore = vsDraw.styles[styleMain].fore.allocated;
- Font &textFont = vsDraw.styles[styleMain].font;
- //hotspot foreground
- if (ll->hsStart != -1 && iDoc >= ll->hsStart && iDoc < hsEnd) {
- if (vsDraw.hotspotForegroundSet)
- textFore = vsDraw.hotspotForeground.allocated;
+
+ rcSegment.left = ll->positions[startseg] + xStart - subLineStart;
+ rcSegment.right = ll->positions[i + 1] + xStart - subLineStart;
+ // Only try to draw if really visible - enhances performance by not calling environment to
+ // draw strings that are completely past the right side of the window.
+ if ((rcSegment.left <= rcLine.right) && (rcSegment.right >= rcLine.left)) {
+ int styleMain = ll->styles[i];
+ ColourAllocated textFore = vsDraw.styles[styleMain].fore.allocated;
+ Font &textFont = vsDraw.styles[styleMain].font;
+ //hotspot foreground
+ if (ll->hsStart != -1 && iDoc >= ll->hsStart && iDoc < hsEnd) {
+ if (vsDraw.hotspotForegroundSet)
+ textFore = vsDraw.hotspotForeground.allocated;
+ }
+ bool inSelection = (iDoc >= ll->selStart) && (iDoc < ll->selEnd) && (ll->selStart != ll->selEnd);
+ if (inSelection && (vsDraw.selforeset)) {
+ textFore = vsDraw.selforeground.allocated;
+ }
+ 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') {
+ // Tab display
+ if (!twoPhaseDraw) {
+ if (drawWhitespaceBackground &&
+ (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways))
+ textBack = vsDraw.whitespaceBackground.allocated;
+ surface->FillRectangle(rcSegment, textBack);
}
- bool inSelection = (iDoc >= ll->selStart) && (iDoc < ll->selEnd) && (ll->selStart != ll->selEnd);
- if (inSelection && (vsDraw.selforeset)) {
- textFore = vsDraw.selforeground.allocated;
+ if ((vsDraw.viewWhitespace != wsInvisible) ||
+ (inIndentation && vsDraw.viewIndentationGuides != ivNone)) {
+ if (vsDraw.whitespaceForegroundSet)
+ textFore = vsDraw.whitespaceForeground.allocated;
+ surface->PenColour(textFore);
}
- 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') {
- // Tab display
- if (!twoPhaseDraw) {
- if (drawWhitespaceBackground &&
- (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways))
- textBack = vsDraw.whitespaceBackground.allocated;
- surface->FillRectangle(rcSegment, textBack);
- }
- if ((vsDraw.viewWhitespace != wsInvisible) || ((inIndentation && vsDraw.viewIndentationGuides))) {
- if (vsDraw.whitespaceForegroundSet)
- textFore = vsDraw.whitespaceForeground.allocated;
- surface->PenColour(textFore);
- }
- if (inIndentation && vsDraw.viewIndentationGuides) {
- for (int xIG = ll->positions[i] / indentWidth * indentWidth; xIG < ll->positions[i + 1]; xIG += indentWidth) {
- if (xIG >= ll->positions[i] && xIG > 0) {
- DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIG + xStart, rcSegment,
- (ll->xHighlightGuide == xIG));
- }
- }
- }
- if (vsDraw.viewWhitespace != wsInvisible) {
- if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
- PRectangle rcTab(rcSegment.left + 1, rcSegment.top + 4,
- rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent);
- DrawTabArrow(surface, rcTab, rcSegment.top + vsDraw.lineHeight / 2);
+ if (inIndentation && vsDraw.viewIndentationGuides == ivReal) {
+ for (int xIG = ll->positions[i] / indentWidth * indentWidth; xIG < ll->positions[i + 1]; xIG += indentWidth) {
+ if (xIG >= ll->positions[i] && xIG > 0) {
+ DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, xIG + xStart, rcSegment,
+ (ll->xHighlightGuide == xIG));
}
}
- } else if (IsControlCharacter(ll->chars[i])) {
- // Control character display
- inIndentation = false;
- if (controlCharSymbol < 32) {
- // Draw the character
- const char *ctrlChar = ControlCharacterString(ll->chars[i]);
- if (!twoPhaseDraw) {
- surface->FillRectangle(rcSegment, textBack);
- }
- 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, ctrlChar, istrlen(ctrlChar),
- textBack, textFore);
- } else {
- char cc[2] = { static_cast<char>(controlCharSymbol), '\0' };
- surface->DrawTextNoClip(rcSegment, ctrlCharsFont,
- rcSegment.top + vsDraw.maxAscent,
- cc, 1, textBack, textFore);
+ }
+ if (vsDraw.viewWhitespace != wsInvisible) {
+ if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
+ PRectangle rcTab(rcSegment.left + 1, rcSegment.top + 4,
+ rcSegment.right - 1, rcSegment.bottom - vsDraw.maxDescent);
+ DrawTabArrow(surface, rcTab, rcSegment.top + vsDraw.lineHeight / 2);
}
+ }
+ } else if (IsControlCharacter(ll->chars[i])) {
+ // Control character display
+ inIndentation = false;
+ if (controlCharSymbol < 32) {
+ // Draw the character
+ const char *ctrlChar = ControlCharacterString(ll->chars[i]);
+ DrawTextBlob(surface, vsDraw, rcSegment, ctrlChar, textBack, textFore, twoPhaseDraw);
} else {
- // Normal text display
- if (vsDraw.styles[styleMain].visible) {
- if (twoPhaseDraw) {
- surface->DrawTextTransparent(rcSegment, textFont,
- rcSegment.top + vsDraw.maxAscent, ll->chars + startseg,
- i - startseg + 1, textFore);
- } else {
- surface->DrawTextNoClip(rcSegment, textFont,
- rcSegment.top + vsDraw.maxAscent, ll->chars + startseg,
- i - startseg + 1, textFore, textBack);
- }
+ char cc[2] = { static_cast<char>(controlCharSymbol), '\0' };
+ surface->DrawTextNoClip(rcSegment, ctrlCharsFont,
+ rcSegment.top + vsDraw.maxAscent,
+ cc, 1, textBack, textFore);
+ }
+ } else if ((i == startseg) && (static_cast<unsigned char>(ll->chars[i]) >= 0x80) && IsUnicodeMode()) {
+ char hexits[3];
+ sprintf(hexits, "%2X", ll->chars[i] & 0xff);
+ DrawTextBlob(surface, vsDraw, rcSegment, hexits, textBack, textFore, twoPhaseDraw);
+ } else {
+ // Normal text display
+ if (vsDraw.styles[styleMain].visible) {
+ if (twoPhaseDraw) {
+ surface->DrawTextTransparent(rcSegment, textFont,
+ rcSegment.top + vsDraw.maxAscent, ll->chars + startseg,
+ i - startseg + 1, textFore);
+ } else {
+ surface->DrawTextNoClip(rcSegment, textFont,
+ rcSegment.top + vsDraw.maxAscent, ll->chars + startseg,
+ i - startseg + 1, textFore, textBack);
}
- if (vsDraw.viewWhitespace != wsInvisible ||
- (inIndentation && vsDraw.viewIndentationGuides)) {
- for (int cpos = 0; cpos <= i - startseg; cpos++) {
- if (ll->chars[cpos + startseg] == ' ') {
- if (vsDraw.viewWhitespace != wsInvisible) {
- if (vsDraw.whitespaceForegroundSet)
- textFore = vsDraw.whitespaceForeground.allocated;
- if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
- int xmid = (ll->positions[cpos + startseg] + ll->positions[cpos + startseg + 1]) / 2;
- 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);
- 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;
- surface->FillRectangle(rcDot, textFore);
+ }
+ if (vsDraw.viewWhitespace != wsInvisible ||
+ (inIndentation && vsDraw.viewIndentationGuides != ivNone)) {
+ for (int cpos = 0; cpos <= i - startseg; cpos++) {
+ if (ll->chars[cpos + startseg] == ' ') {
+ if (vsDraw.viewWhitespace != wsInvisible) {
+ if (vsDraw.whitespaceForegroundSet)
+ textFore = vsDraw.whitespaceForeground.allocated;
+ if (!inIndentation || vsDraw.viewWhitespace == wsVisibleAlways) {
+ int xmid = (ll->positions[cpos + startseg] + ll->positions[cpos + startseg + 1]) / 2;
+ 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);
+ 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;
+ surface->FillRectangle(rcDot, textFore);
}
- if (inIndentation && vsDraw.viewIndentationGuides) {
- int startSpace = ll->positions[cpos + startseg];
- if (startSpace > 0 && (startSpace % indentWidth == 0)) {
- DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, startSpace + xStart, rcSegment,
- (ll->xHighlightGuide == ll->positions[cpos + startseg]));
- }
+ }
+ if (inIndentation && vsDraw.viewIndentationGuides == ivReal) {
+ int startSpace = ll->positions[cpos + startseg];
+ if (startSpace > 0 && (startSpace % indentWidth == 0)) {
+ DrawIndentGuide(surface, lineVisible, vsDraw.lineHeight, startSpace + xStart, rcSegment,
+ (ll->xHighlightGuide == ll->positions[cpos + startseg]));
}
- } else {
- inIndentation = false;
}
+ } else {
+ inIndentation = false;
}
}
}
- if (ll->hsStart != -1 && vsDraw.hotspotUnderline && iDoc >= ll->hsStart && iDoc < ll->hsEnd ) {
- PRectangle rcUL = rcSegment;
- rcUL.top = rcUL.top + vsDraw.maxAscent + 1;
- rcUL.bottom = rcUL.top + 1;
- if (vsDraw.hotspotForegroundSet)
- surface->FillRectangle(rcUL, vsDraw.hotspotForeground.allocated);
- else
- surface->FillRectangle(rcUL, textFore);
- } else if (vsDraw.styles[styleMain].underline) {
- PRectangle rcUL = rcSegment;
- rcUL.top = rcUL.top + vsDraw.maxAscent + 1;
- rcUL.bottom = rcUL.top + 1;
+ }
+ if (ll->hsStart != -1 && vsDraw.hotspotUnderline && iDoc >= ll->hsStart && iDoc < ll->hsEnd ) {
+ PRectangle rcUL = rcSegment;
+ rcUL.top = rcUL.top + vsDraw.maxAscent + 1;
+ rcUL.bottom = rcUL.top + 1;
+ if (vsDraw.hotspotForegroundSet)
+ surface->FillRectangle(rcUL, vsDraw.hotspotForeground.allocated);
+ else
surface->FillRectangle(rcUL, textFore);
- }
- } else if (rcSegment.left > rcLine.right) {
- break;
+ } else if (vsDraw.styles[styleMain].underline) {
+ PRectangle rcUL = rcSegment;
+ rcUL.top = rcUL.top + vsDraw.maxAscent + 1;
+ rcUL.bottom = rcUL.top + 1;
+ surface->FillRectangle(rcUL, textFore);
}
- startseg = i + 1;
+ } else if (rcSegment.left > rcLine.right) {
+ break;
}
}
+ if ((vsDraw.viewIndentationGuides == ivLookForward || vsDraw.viewIndentationGuides == ivLookBoth)
+ && (subLine == 0)) {
+ int indentSpace = pdoc->GetLineIndentation(line);
+ // Find the most recent line with some text
- // Draw indicators
- // foreach indicator...
- for (int indicnum = 0, mask = 1 << pdoc->stylingBits; mask < 0x100; indicnum++) {
- if (!(mask & ll->styleBitsSet)) {
- mask <<= 1;
- continue;
- }
- int startPos = -1;
- // foreach style pos in line...
- for (int indicPos = lineStart; indicPos <= lineEnd; indicPos++) {
- // look for starts...
- if (startPos < 0) {
- // NOT in indicator run, looking for START
- if (indicPos < lineEnd && (ll->indicators[indicPos] & mask))
- startPos = indicPos;
+ int lineLastWithText = line;
+ while (lineLastWithText > 0 && pdoc->IsWhiteLine(lineLastWithText)) {
+ lineLastWithText--;
+ }
+ if (lineLastWithText < 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;
+ if (isFoldHeader) {
+ // Level is one more level than parent
+ indentLastWithText += pdoc->IndentSize();
}
- // ... or ends
- if (startPos >= 0) {
- // IN indicator run, looking for END
- if (indicPos >= lineEnd || !(ll->indicators[indicPos] & mask)) {
- // AT end of indicator run, DRAW it!
- PRectangle rcIndic(
- ll->positions[startPos] + xStart - subLineStart,
- rcLine.top + vsDraw.maxAscent,
- ll->positions[indicPos] + xStart - subLineStart,
- rcLine.top + vsDraw.maxAscent + 3);
- vsDraw.indicators[indicnum].Draw(surface, rcIndic, rcLine);
- // RESET control var
- startPos = -1;
+ if (vsDraw.viewIndentationGuides == ivLookForward) {
+ // In viLookForward mode, previous line only used if it is a fold header
+ if (isFoldHeader) {
+ indentSpace = Platform::Maximum(indentSpace, indentLastWithText);
}
+ } else { // viLookBoth
+ indentSpace = Platform::Maximum(indentSpace, indentLastWithText);
}
}
- mask <<= 1;
+
+ int lineNextWithText = line;
+ while (lineNextWithText < pdoc->LinesTotal() && pdoc->IsWhiteLine(lineNextWithText)) {
+ lineNextWithText++;
+ }
+ if (lineNextWithText > line) {
+ // This line is empty, so use indentation of last line with text
+ indentSpace = Platform::Maximum(indentSpace,
+ pdoc->GetLineIndentation(lineNextWithText));
+ }
+
+ 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));
+ }
}
+
+ DrawIndicators(surface, vsDraw, line, xStart, rcLine, ll, subLine, lineEnd, false);
+
// End of the drawing of the current line
if (!twoPhaseDraw) {
DrawEOL(surface, vsDraw, rcLine, ll, line, lineEnd,
xStart, subLine, subLineStart, overrideBackground, background,
- drawWrapMarkEnd, vsDraw.whitespaceForeground.allocated);
+ drawWrapMarkEnd, wrapColour);
}
if ((vsDraw.selAlpha != SC_ALPHA_NOALPHA) && (ll->selStart >= 0) && (ll->selEnd >= 0)) {
int startPosSel = (ll->selStart < posLineStart) ? posLineStart : ll->selStart;
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 (vsDraw.edgeState == EDGE_LINE) {
- int edgeX = theEdge * vsDraw.spaceWidth;
- rcSegment.left = edgeX + xStart;
- rcSegment.right = rcSegment.left + 1;
- surface->FillRectangle(rcSegment, vsDraw.edgecolour.allocated);
- }
-
// Draw any translucent whole line states
rcSegment.left = xStart;
rcSegment.right = rcLine.right - 1;
}
}
+void Editor::DrawBlockCaret(Surface *surface, ViewStyle &vsDraw, LineLayout *ll, int subLine, int xStart, int offset, int posCaret, PRectangle rcCaret) {
+
+ int lineStart = ll->LineStart(subLine);
+ int posBefore = posCaret;
+ int posAfter = MovePositionOutsideChar(posCaret + 1, 1);
+ int numCharsToDraw = posAfter - posCaret;
+
+ // Work out where the starting and ending offsets are. We need to
+ // see if the previous character shares horizontal space, such as a
+ // glyph / combining character. If so we'll need to draw that too.
+ int offsetFirstChar = offset;
+ int offsetLastChar = offset + (posAfter - posCaret);
+ while ((offsetLastChar - numCharsToDraw) >= lineStart) {
+ if ((ll->positions[offsetLastChar] - ll->positions[offsetLastChar - numCharsToDraw]) > 0) {
+ // The char does not share horizontal space
+ break;
+ }
+ // Char shares horizontal space, update the numChars to draw
+ // Update posBefore to point to the prev char
+ posBefore = MovePositionOutsideChar(posBefore - 1, -1);
+ numCharsToDraw = posAfter - posBefore;
+ offsetFirstChar = offset - (posCaret - posBefore);
+ }
+
+ // See if the next character shares horizontal space, if so we'll
+ // need to draw that too.
+ numCharsToDraw = offsetLastChar - offsetFirstChar;
+ while ((offsetLastChar < ll->LineStart(subLine + 1)) && (offsetLastChar <= ll->numCharsInLine)) {
+ // Update posAfter to point to the 2nd next char, this is where
+ // the next character ends, and 2nd next begins. We'll need
+ // to compare these two
+ posBefore = posAfter;
+ posAfter = MovePositionOutsideChar(posAfter + 1, 1);
+ offsetLastChar = offset + (posAfter - posCaret);
+ if ((ll->positions[offsetLastChar] - ll->positions[offsetLastChar - (posAfter - posBefore)]) > 0) {
+ // The char does not share horizontal space
+ break;
+ }
+ // Char shares horizontal space, update the numChars to draw
+ numCharsToDraw = offsetLastChar - offsetFirstChar;
+ }
+
+ // 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;
+
+ // This character is where the caret block is, we override the colours
+ // (inversed) for drawing the caret here.
+ int styleMain = ll->styles[offsetFirstChar];
+ surface->DrawTextClipped(rcCaret, vsDraw.styles[styleMain].font,
+ rcCaret.top + vsDraw.maxAscent, ll->chars + offsetFirstChar,
+ numCharsToDraw, vsDraw.styles[styleMain].back.allocated,
+ vsDraw.caretcolour.allocated);
+}
+
void Editor::RefreshPixMaps(Surface *surfaceWindow) {
if (!pixmapSelPattern->Initialised()) {
const int patternSize = 8;
if (!pixmapLine->Initialised()) {
PRectangle rcClient = GetClientRectangle();
pixmapLine->InitPixMap(rcClient.Width(), vs.lineHeight,
- surfaceWindow, wMain.GetID());
+ surfaceWindow, wMain.GetID());
pixmapSelMargin->InitPixMap(vs.fixedColumnWidth,
- rcClient.Height(), surfaceWindow, wMain.GetID());
+ rcClient.Height(), surfaceWindow, wMain.GetID());
}
}
}
Range rangeLine(pdoc->LineStart(lineDoc), pdoc->LineStart(lineDoc + 1));
// Highlight the current braces if any
ll->SetBracesHighlight(rangeLine, braces, static_cast<char>(bracesMatchStyle),
- highlightGuideColumn * vs.spaceWidth);
+ highlightGuideColumn * vs.spaceWidth);
// Draw the line
DrawLine(surface, vs, lineDoc, visibleLine, xStart, rcLine, ll, subLine);
// Draw the Caret
if (lineDoc == lineCaret) {
int offset = Platform::Minimum(posCaret - rangeLine.start, ll->maxLineLength);
- if ((offset >= ll->LineStart(subLine)) &&
- ((offset < ll->LineStart(subLine + 1)) || offset == ll->numCharsInLine)) {
+ if (ll->InLine(offset, subLine)) {
int xposCaret = ll->positions[offset] - ll->positions[ll->LineStart(subLine)] + xStart;
if (actualWrapVisualStartIndent != 0) {
if (lineStart != 0) // Wrapped
xposCaret += actualWrapVisualStartIndent * vs.aveCharWidth;
}
- int widthOverstrikeCaret;
- if (posCaret == pdoc->Length()) { // At end of document
- widthOverstrikeCaret = vs.aveCharWidth;
- } else if ((posCaret - rangeLine.start) >= ll->numCharsInLine) { // At end of line
- widthOverstrikeCaret = vs.aveCharWidth;
- } else {
- widthOverstrikeCaret = ll->positions[offset + 1] - ll->positions[offset];
- }
- if (widthOverstrikeCaret < 3) // Make sure its visible
- widthOverstrikeCaret = 3;
- if (((caret.active && caret.on) || (posDrag >= 0)) && xposCaret >= 0) {
- PRectangle rcCaret = rcLine;
+ 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;
- if ((offset > 0) && (vs.caretWidth > 1))
+ 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) {
- rcCaret.top = rcCaret.bottom - 2;
- rcCaret.left = xposCaret + 1;
- rcCaret.right = rcCaret.left + widthOverstrikeCaret - 1;
+ } 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.left = xposCaret - caretWidthOffset;
- rcCaret.right = rcCaret.left + vs.caretWidth;
+ 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);
}
- surface->FillRectangle(rcCaret, vs.caretcolour.allocated);
}
}
}
if (bufferedDraw) {
Point from(vs.fixedColumnWidth, 0);
PRectangle rcCopyArea(vs.fixedColumnWidth, yposScreen,
- rcClient.right, yposScreen + vs.lineHeight);
+ rcClient.right, yposScreen + vs.lineHeight);
surfaceWindow->Copy(rcCopyArea, from, *pixmapLine);
}
//durCopy += et.Duration(true);
yposScreen += vs.lineHeight;
visibleLine++;
+
+ lineWidthMaxSeen = Platform::Maximum(
+ lineWidthMaxSeen, ll->positions[ll->numCharsInLine]);
//gdk_flush();
}
ll.Set(0);
return 0;
}
+ // Can't use measurements cached for screen
+ posCache.Clear();
+
ViewStyle vsPrint(vs);
// Modify the view style for printing as do not normally want any of the transient features to be printed
vsPrint.showMarkedLines = false;
vsPrint.fixedColumnWidth = 0;
vsPrint.zoomLevel = printMagnification;
- vsPrint.viewIndentationGuides = false;
+ vsPrint.viewIndentationGuides = ivNone;
// Don't show the selection when printing
vsPrint.selbackset = false;
vsPrint.selforeset = false;
vsPrint.showCaretLineBackground = false;
// Set colours for printing according to users settings
- for (int sty = 0;sty <= STYLE_MAX;sty++) {
+ for (size_t sty = 0;sty < vsPrint.stylesSize;sty++) {
if (printColourMode == SC_PRINT_INVERTLIGHT) {
vsPrint.styles[sty].fore.desired = InvertedLight(vsPrint.styles[sty].fore.desired);
vsPrint.styles[sty].back.desired = InvertedLight(vsPrint.styles[sty].back.desired);
vsPrint.styles[STYLE_LINENUMBER].back.desired = ColourDesired(0xff, 0xff, 0xff);
vsPrint.Refresh(*surfaceMeasure);
- // Ensure colours are set up
- vsPrint.RefreshColourPalette(palette, true);
- vsPrint.RefreshColourPalette(palette, false);
// Determining width must hapen after fonts have been realised in Refresh
int lineNumberWidth = 0;
if (lineNumberIndex >= 0) {
lineNumberWidth = surfaceMeasure->WidthText(vsPrint.styles[STYLE_LINENUMBER].font,
- "99999" lineNumberPrintSpace, 5 + istrlen(lineNumberPrintSpace));
+ "99999" lineNumberPrintSpace, 5 + istrlen(lineNumberPrintSpace));
vsPrint.ms[lineNumberIndex].width = lineNumberWidth;
+ vsPrint.Refresh(*surfaceMeasure); // Recalculate fixedColumnWidth
}
+ // Ensure colours are set up
+ vsPrint.RefreshColourPalette(palette, true);
+ vsPrint.RefreshColourPalette(palette, false);
int linePrintStart = pdoc->LineFromPosition(pfr->chrg.cpMin);
int linePrintLast = linePrintStart + (pfr->rc.bottom - pfr->rc.top) / vsPrint.lineHeight - 1;
// Ensure we are styled to where we are formatting.
pdoc->EnsureStyledTo(endPosPrint);
- int xStart = vsPrint.fixedColumnWidth + pfr->rc.left + lineNumberWidth;
+ int xStart = vsPrint.fixedColumnWidth + pfr->rc.left;
int ypos = pfr->rc.top;
int lineDoc = linePrintStart;
int nPrintPos = pfr->chrg.cpMin;
int visibleLine = 0;
- int widthPrint = pfr->rc.Width() - lineNumberWidth;
+ int widthPrint = pfr->rc.Width() - vsPrint.fixedColumnWidth;
if (printWrapState == eWrapNone)
widthPrint = LineLayout::wrapWidthInfinite;
ll.containsCaret = false;
PRectangle rcLine;
- rcLine.left = pfr->rc.left + lineNumberWidth;
+ rcLine.left = pfr->rc.left;
rcLine.top = ypos;
rcLine.right = pfr->rc.right - 1;
rcLine.bottom = ypos + vsPrint.lineHeight;
PRectangle rcNumber = rcLine;
rcNumber.right = rcNumber.left + lineNumberWidth;
// Right justify
- rcNumber.left -= surfaceMeasure->WidthText(
- vsPrint.styles[STYLE_LINENUMBER].font, number, istrlen(number));
+ rcNumber.left = rcNumber.right - surfaceMeasure->WidthText(
+ vsPrint.styles[STYLE_LINENUMBER].font, number, istrlen(number));
surface->FlushCachedState();
surface->DrawTextNoClip(rcNumber, vsPrint.styles[STYLE_LINENUMBER].font,
- ypos + vsPrint.maxAscent, number, istrlen(number),
- vsPrint.styles[STYLE_LINENUMBER].fore.allocated,
- vsPrint.styles[STYLE_LINENUMBER].back.allocated);
+ ypos + vsPrint.maxAscent, number, istrlen(number),
+ vsPrint.styles[STYLE_LINENUMBER].fore.allocated,
+ vsPrint.styles[STYLE_LINENUMBER].back.allocated);
}
// Draw the line
++lineDoc;
}
+ // Clear cache so measurements are not used for screen
+ posCache.Clear();
+
return nPrintPos;
}
AddCharUTF(s, 1);
}
+// 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();
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();
+ }
EnsureCaretVisible();
// Avoid blinking during rapid typing:
ShowCaretAtCurrentPosition();
if (treatAsDBCS) {
NotifyChar((static_cast<unsigned char>(s[0]) << 8) |
- static_cast<unsigned char>(s[1]));
+ static_cast<unsigned char>(s[1]));
} else {
int byte = static_cast<unsigned char>(s[0]);
if ((byte < 0xC0) || (1 == len)) {
}
void Editor::Cut() {
+ pdoc->CheckReadOnly();
if (!pdoc->IsReadOnly() && !SelectionContainsProtected()) {
Copy();
ClearSelection();
NotifyParent(scn);
}
-void Editor::NotifyDoubleClick(Point, bool) {
+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.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) |
+ (alt ? SCI_ALT : 0);
NotifyParent(scn);
}
scn.nmhdr.code = SCN_HOTSPOTDOUBLECLICK;
scn.position = position;
scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) |
- (alt ? SCI_ALT : 0);
+ (alt ? SCI_ALT : 0);
NotifyParent(scn);
}
scn.nmhdr.code = SCN_HOTSPOTCLICK;
scn.position = position;
scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) |
- (alt ? SCI_ALT : 0);
+ (alt ? SCI_ALT : 0);
NotifyParent(scn);
}
NotifyParent(scn);
}
+void Editor::NotifyIndicatorClick(bool click, int position, bool shift, bool ctrl, bool alt) {
+ int mask = pdoc->decorations.AllOnFor(position);
+ if ((click && mask) || pdoc->decorations.clickNotified) {
+ SCNotification scn = {0};
+ pdoc->decorations.clickNotified = click;
+ scn.nmhdr.code = click ? SCN_INDICATORCLICK : SCN_INDICATORRELEASE;
+ scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) | (alt ? SCI_ALT : 0);
+ scn.position = position;
+ NotifyParent(scn);
+ }
+}
+
bool Editor::NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt) {
int marginClicked = -1;
int x = 0;
SCNotification scn = {0};
scn.nmhdr.code = SCN_MARGINCLICK;
scn.modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) |
- (alt ? SCI_ALT : 0);
+ (alt ? SCI_ALT : 0);
scn.position = pdoc->LineStart(LineFromLocation(pt));
scn.margin = marginClicked;
NotifyParent(scn);
}
void Editor::CheckModificationForWrap(DocModification mh) {
- if (mh.modificationType & (SC_MOD_INSERTTEXT|SC_MOD_DELETETEXT)) {
+ if (mh.modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT)) {
llc.Invalidate(LineLayout::llCheckTextAndStyle);
if (wrapState != eWrapNone) {
int lineDoc = pdoc->LineFromPosition(mh.position);
if (paintState == painting) {
CheckForChangeOutsidePaint(Range(mh.position, mh.position + mh.length));
}
- if (mh.modificationType & SC_MOD_CHANGESTYLE) {
- pdoc->IncrementStyleClock();
+ if (mh.modificationType & SC_MOD_CHANGELINESTATE) {
+ if (paintState == painting) {
+ CheckForChangeOutsidePaint(
+ Range(pdoc->LineStart(mh.line), pdoc->LineStart(mh.line + 1)));
+ } else {
+ // Could check that change is before last visible line.
+ Redraw();
+ }
+ }
+ if (mh.modificationType & (SC_MOD_CHANGESTYLE | SC_MOD_CHANGEINDICATOR)) {
+ if (mh.modificationType & SC_MOD_CHANGESTYLE) {
+ pdoc->IncrementStyleClock();
+ }
if (paintState == notPainting) {
if (mh.position < pdoc->LineStart(topLine)) {
// Styling performed before this view
InvalidateRange(mh.position, mh.position + mh.length);
}
}
- llc.Invalidate(LineLayout::llCheckTextAndStyle);
+ if (mh.modificationType & SC_MOD_CHANGESTYLE) {
+ llc.Invalidate(LineLayout::llCheckTextAndStyle);
+ }
} else {
// Move selection and brace highlights
if (mh.modificationType & SC_MOD_INSERTTEXT) {
// If client wants to see this modification
if (mh.modificationType & modEventMask) {
- if ((mh.modificationType & SC_MOD_CHANGESTYLE) == 0) {
+ if ((mh.modificationType & (SC_MOD_CHANGESTYLE | SC_MOD_CHANGEINDICATOR)) == 0) {
// Real modification made to text of document.
NotifyChange(); // Send EN_CHANGE
}
case SCI_VCHOMEWRAPEXTEND:
case SCI_DELWORDLEFT:
case SCI_DELWORDRIGHT:
+ case SCI_DELWORDRIGHTEND:
case SCI_DELLINELEFT:
case SCI_DELLINERIGHT:
case SCI_LINECOPY:
case SCI_SELECTIONDUPLICATE:
break;
- // Filter out all others like display changes. Also, newlines are redundant
- // with char insert messages.
+ // Filter out all others like display changes. Also, newlines are redundant
+ // with char insert messages.
case SCI_NEWLINE:
default:
// printf("Filtered out %ld of macro recording\n", iMessage);
// I consider only the caretYSlop, and ignore the caretYPolicy-- is that a problem?
int currentLine = pdoc->LineFromPosition(currentPos);
int topStutterLine = topLine + caretYSlop;
- int bottomStutterLine = topLine + LinesToScroll() - caretYSlop;
+ int bottomStutterLine =
+ pdoc->LineFromPosition(PositionFromLocation(
+ Point(lastXChosen, direction * vs.lineHeight * LinesToScroll())))
+ - caretYSlop - 1;
if (stuttered && (direction < 0 && currentLine > topStutterLine)) {
topLineNew = topLine;
Point pt = LocationFromPosition(currentPos);
topLineNew = Platform::Clamp(
- topLine + direction * LinesToScroll(), 0, MaxScrollPos());
+ topLine + direction * LinesToScroll(), 0, MaxScrollPos());
newPos = PositionFromLocation(
- Point(lastXChosen, pt.y + direction * (vs.lineHeight * LinesToScroll())));
+ Point(lastXChosen, pt.y + direction * (vs.lineHeight * LinesToScroll())));
}
if (topLineNew != topLine) {
int startAnchor = anchor;
if (selType == selStream) {
pdoc->ChangeCase(Range(SelectionStart(), SelectionEnd()),
- makeUpperCase);
+ makeUpperCase);
SetSelection(startCurrent, startAnchor);
} else {
SelectionLineIterator lineIterator(this, false);
void Editor::LineTranspose() {
int line = pdoc->LineFromPosition(currentPos);
if (line > 0) {
+ pdoc->BeginUndoAction();
int startPrev = pdoc->LineStart(line - 1);
int endPrev = pdoc->LineEnd(line - 1);
int start = pdoc->LineStart(line);
int end = pdoc->LineEnd(line);
- int startNext = pdoc->LineStart(line + 1);
- if (end < pdoc->Length()) {
- end = startNext;
- char *thisLine = CopyRange(start, end);
- pdoc->DeleteChars(start, end - start);
- if (pdoc->InsertString(startPrev, thisLine, end - start)) {
- MovePositionTo(startPrev + end - start);
- }
- delete []thisLine;
- } else {
- // Last line so line has no line end
- char *thisLine = CopyRange(start, end);
- char *prevEnd = CopyRange(endPrev, start);
- pdoc->DeleteChars(endPrev, end - endPrev);
- pdoc->InsertString(startPrev, thisLine, end - start);
- if (pdoc->InsertString(startPrev + end - start, prevEnd, start - endPrev)) {
- MovePositionTo(startPrev + end - endPrev);
- }
- delete []thisLine;
- delete []prevEnd;
- }
-
+ char *line1 = CopyRange(startPrev, endPrev);
+ int len1 = endPrev - startPrev;
+ char *line2 = CopyRange(start, end);
+ int len2 = end - start;
+ pdoc->DeleteChars(start, len2);
+ pdoc->DeleteChars(startPrev, len1);
+ pdoc->InsertString(startPrev, line2, len2);
+ pdoc->InsertString(start - len1 + len2, line1, len1);
+ MovePositionTo(start - len1 + len2);
+ delete []line1;
+ delete []line2;
+ pdoc->EndUndoAction();
}
}
char *text = CopyRange(start, end);
if (forLine) {
const char *eol = StringFromEOLMode(pdoc->eolMode);
- pdoc->InsertString(end, eol);
+ pdoc->InsertCString(end, eol);
pdoc->InsertString(end + istrlen(eol), text, end - start);
} else {
pdoc->InsertString(end, text, end - start);
} else if (pdoc->eolMode == SC_EOL_CR) {
eol = "\r";
} // else SC_EOL_LF -> "\n" already set
- if (pdoc->InsertString(currentPos, eol)) {
+ if (pdoc->InsertCString(currentPos, eol)) {
SetEmptySelection(currentPos + istrlen(eol));
while (*eol) {
NotifyChar(*eol);
}
}
SetLastXChosen();
+ SetScrollBars();
EnsureCaretVisible();
// Avoid blinking during rapid typing:
ShowCaretAtCurrentPosition();
void Editor::CursorUpOrDown(int direction, selTypes sel) {
Point pt = LocationFromPosition(currentPos);
int posNew = PositionFromLocation(
- Point(lastXChosen, pt.y + direction * vs.lineHeight));
+ Point(lastXChosen, pt.y + direction * vs.lineHeight));
if (direction < 0) {
// Line wrapping may lead to a location on the same line, so
// seek back if that is the case.
int endPos = MovePositionSoVisible(StartEndDisplayLine(currentPos, false), 1);
int realEndPos = pdoc->LineEndPosition(currentPos);
if (endPos > realEndPos // if moved past visible EOLs
- || currentPos >= endPos) // if at end of display line already
+ || currentPos >= endPos) // if at end of display line already
endPos = realEndPos;
MovePositionTo(endPos);
SetLastXChosen();
int endPos = MovePositionSoVisible(StartEndDisplayLine(currentPos, false), 1);
int realEndPos = pdoc->LineEndPosition(currentPos);
if (endPos > realEndPos // if moved past visible EOLs
- || currentPos >= endPos) // if at end of display line already
+ || currentPos >= endPos) // if at end of display line already
endPos = realEndPos;
MovePositionTo(endPos, selStream);
SetLastXChosen();
pdoc->DeleteChars(currentPos, endWord - currentPos);
}
break;
+ case SCI_DELWORDRIGHTEND: {
+ int endWord = pdoc->NextWordEnd(currentPos, 1);
+ pdoc->DeleteChars(currentPos, endWord - currentPos);
+ }
+ break;
case SCI_DELLINELEFT: {
int line = pdoc->LineFromPosition(currentPos);
int start = pdoc->LineStart(line);
int lineStart = pdoc->LineFromPosition(SelectionStart());
int lineEnd = pdoc->LineFromPosition(SelectionEnd());
CopyRangeToClipboard(pdoc->LineStart(lineStart),
- pdoc->LineStart(lineEnd + 1));
+ pdoc->LineStart(lineEnd + 1));
}
break;
case SCI_LINECUT: {
break;
case SCI_HOMEDISPLAY:
MovePositionTo(MovePositionSoVisible(
- StartEndDisplayLine(currentPos, true), -1));
+ StartEndDisplayLine(currentPos, true), -1));
SetLastXChosen();
break;
case SCI_HOMEDISPLAYEXTEND:
MovePositionTo(MovePositionSoVisible(
- StartEndDisplayLine(currentPos, true), -1), selStream);
+ StartEndDisplayLine(currentPos, true), -1), selStream);
SetLastXChosen();
break;
case SCI_LINEENDDISPLAY:
MovePositionTo(MovePositionSoVisible(
- StartEndDisplayLine(currentPos, false), 1));
+ StartEndDisplayLine(currentPos, false), 1));
SetLastXChosen();
break;
case SCI_LINEENDDISPLAYEXTEND:
MovePositionTo(MovePositionSoVisible(
- StartEndDisplayLine(currentPos, false), 1), selStream);
+ StartEndDisplayLine(currentPos, false), 1), selStream);
SetLastXChosen();
break;
}
int Editor::KeyDown(int key, bool shift, bool ctrl, bool alt, bool *consumed) {
DwellEnd(false);
int modifiers = (shift ? SCI_SHIFT : 0) | (ctrl ? SCI_CTRL : 0) |
- (alt ? SCI_ALT : 0);
+ (alt ? SCI_ALT : 0);
int msg = kmap.Find(key, modifiers);
if (msg) {
if (consumed)
SetEmptySelection(currentPos + 1);
} else {
int numSpaces = (pdoc->tabInChars) -
- (pdoc->GetColumn(currentPos) % (pdoc->tabInChars));
+ (pdoc->GetColumn(currentPos) % (pdoc->tabInChars));
if (numSpaces < 1)
numSpaces = pdoc->tabInChars;
for (int i = 0; i < numSpaces; i++) {
pdoc->EndUndoAction();
} else {
int newColumn = ((pdoc->GetColumn(currentPos) - 1) / pdoc->tabInChars) *
- pdoc->tabInChars;
+ pdoc->tabInChars;
if (newColumn < 0)
newColumn = 0;
int newPos = currentPos;
* @return The position of the found text, -1 if not found.
*/
long Editor::FindText(
- uptr_t wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD,
- ///< @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.
+ uptr_t wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD,
+ ///< @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<TextToFind *>(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,
- &lengthFound);
+ (wParam & SCFIND_MATCHCASE) != 0,
+ (wParam & SCFIND_WHOLEWORD) != 0,
+ (wParam & SCFIND_WORDSTART) != 0,
+ (wParam & SCFIND_REGEXP) != 0,
+ (wParam & SCFIND_POSIX) != 0,
+ &lengthFound);
if (pos != -1) {
ft->chrgText.cpMin = pos;
ft->chrgText.cpMax = pos + lengthFound;
long Editor::SearchText(
unsigned int iMessage, ///< Accepts both @c SCI_SEARCHNEXT and @c SCI_SEARCHPREV.
uptr_t wParam, ///< Search modes : @c SCFIND_MATCHCASE, @c SCFIND_WHOLEWORD,
- ///< @c SCFIND_WORDSTART, @c SCFIND_REGEXP or @c SCFIND_POSIX.
+ ///< @c SCFIND_WORDSTART, @c SCFIND_REGEXP or @c SCFIND_POSIX.
sptr_t lParam) { ///< The text to search for.
const char *txt = reinterpret_cast<char *>(lParam);
int lengthFound = istrlen(txt);
if (iMessage == SCI_SEARCHNEXT) {
pos = pdoc->FindText(searchAnchor, pdoc->Length(), txt,
- (wParam & SCFIND_MATCHCASE) != 0,
- (wParam & SCFIND_WHOLEWORD) != 0,
- (wParam & SCFIND_WORDSTART) != 0,
- (wParam & SCFIND_REGEXP) != 0,
- (wParam & SCFIND_POSIX) != 0,
- &lengthFound);
+ (wParam & SCFIND_MATCHCASE) != 0,
+ (wParam & SCFIND_WHOLEWORD) != 0,
+ (wParam & SCFIND_WORDSTART) != 0,
+ (wParam & SCFIND_REGEXP) != 0,
+ (wParam & SCFIND_POSIX) != 0,
+ &lengthFound);
} else {
pos = pdoc->FindText(searchAnchor, 0, txt,
- (wParam & SCFIND_MATCHCASE) != 0,
- (wParam & SCFIND_WHOLEWORD) != 0,
- (wParam & SCFIND_WORDSTART) != 0,
- (wParam & SCFIND_REGEXP) != 0,
- (wParam & SCFIND_POSIX) != 0,
- &lengthFound);
+ (wParam & SCFIND_MATCHCASE) != 0,
+ (wParam & SCFIND_WHOLEWORD) != 0,
+ (wParam & SCFIND_WORDSTART) != 0,
+ (wParam & SCFIND_REGEXP) != 0,
+ (wParam & SCFIND_POSIX) != 0,
+ &lengthFound);
}
if (pos != -1) {
long Editor::SearchInTarget(const char *text, int length) {
int lengthFound = length;
int pos = pdoc->FindText(targetStart, targetEnd, text,
- (searchFlags & SCFIND_MATCHCASE) != 0,
- (searchFlags & SCFIND_WHOLEWORD) != 0,
- (searchFlags & SCFIND_WORDSTART) != 0,
- (searchFlags & SCFIND_REGEXP) != 0,
- (searchFlags & SCFIND_POSIX) != 0,
- &lengthFound);
+ (searchFlags & SCFIND_MATCHCASE) != 0,
+ (searchFlags & SCFIND_WHOLEWORD) != 0,
+ (searchFlags & SCFIND_WORDSTART) != 0,
+ (searchFlags & SCFIND_REGEXP) != 0,
+ (searchFlags & SCFIND_POSIX) != 0,
+ &lengthFound);
if (pos != -1) {
targetStart = pos;
targetEnd = pos + lengthFound;
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);
+ pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false);
}
void Editor::CopySelectionRange(SelectionText *ss) {
lineIterator.Reset();
while (lineIterator.Iterate()) {
for (int i = lineIterator.startPos;
- i < lineIterator.endPos;
- i++) {
+ i < lineIterator.endPos;
+ i++) {
text[j++] = pdoc->CharAt(i);
}
if (selType != selLines) {
}
}
ss->Set(text, size + 1, pdoc->dbcsCodePage,
- vs.styles[STYLE_DEFAULT].characterSet, selType == selRectangle);
+ vs.styles[STYLE_DEFAULT].characterSet, selType == selRectangle);
}
}
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);
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);
CopyToClipboard(selectedText);
}
wMain.SetCursor(static_cast<Window::Cursor>(cursorMode));
}
+bool Editor::DragThreshold(Point ptStart, Point ptNow) {
+ int xMove = ptStart.x - ptNow.x;
+ int yMove = ptStart.y - ptNow.y;
+ int distanceSquared = xMove * xMove + yMove * yMove;
+ return distanceSquared > 16;
+}
+
void Editor::StartDrag() {
// Always handled by subclasses
//SetMouseCapture(true);
}
void Editor::DropAt(int position, const char *value, bool moving, bool rectangular) {
- //Platform::DebugPrintf("DropAt %d\n", inDragDrop);
- if (inDragDrop)
+ //Platform::DebugPrintf("DropAt %d %d\n", inDragDrop, position);
+ if (inDragDrop == ddDragging)
dropWentOutside = false;
int positionWasInSelection = PositionInSelection(position);
bool positionOnEdgeOfSelection =
(position == SelectionStart()) || (position == SelectionEnd());
- if ((!inDragDrop) || !(0 == positionWasInSelection) ||
+ if ((inDragDrop != ddDragging) || !(0 == positionWasInSelection) ||
(positionOnEdgeOfSelection && !moving)) {
int selStart = SelectionStart();
pdoc->BeginUndoAction();
int positionAfterDeletion = position;
- if (inDragDrop && moving) {
+ if ((inDragDrop == ddDragging) && moving) {
// Remove dragged out text
if (rectangular || selType == selLines) {
SelectionLineIterator lineIterator(this);
SetEmptySelection(position);
} else {
position = MovePositionOutsideChar(position, currentPos - position);
- if (pdoc->InsertString(position, value)) {
+ if (pdoc->InsertCString(position, value)) {
SetSelection(position + istrlen(value), position);
}
pdoc->EndUndoAction();
}
- } else if (inDragDrop) {
+ } else if (inDragDrop == ddDragging) {
SetEmptySelection(position);
}
}
void Editor::LineSelection(int lineCurrent_, int lineAnchor_) {
if (lineAnchor_ < lineCurrent_) {
SetSelection(pdoc->LineStart(lineCurrent_ + 1),
- pdoc->LineStart(lineAnchor_));
+ pdoc->LineStart(lineAnchor_));
} else if (lineAnchor_ > lineCurrent_) {
SetSelection(pdoc->LineStart(lineCurrent_),
- pdoc->LineStart(lineAnchor_ + 1));
+ pdoc->LineStart(lineAnchor_ + 1));
} else { // Same line, select it
SetSelection(pdoc->LineStart(lineAnchor_ + 1),
- pdoc->LineStart(lineAnchor_));
+ pdoc->LineStart(lineAnchor_));
}
}
}
void Editor::ButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) {
- //Platform::DebugPrintf("Scintilla:ButtonDown %d %d = %d alt=%d\n", curTime, lastClickTime, curTime - lastClickTime, 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);
- inDragDrop = false;
+ inDragDrop = ddNone;
moveExtendsSelection = false;
bool processed = NotifyMarginClick(pt, shift, ctrl, alt);
if (processed)
return;
+ NotifyIndicatorClick(true, newPos, shift, ctrl, alt);
+
bool inSelMargin = PointInSelMargin(pt);
if (shift & !inSelMargin) {
SetSelection(newPos);
if (selectionType == selWord) {
if (currentPos >= originalAnchorPos) { // Moved forward
SetSelection(pdoc->ExtendWordSelect(currentPos, 1),
- pdoc->ExtendWordSelect(originalAnchorPos, -1));
+ pdoc->ExtendWordSelect(originalAnchorPos, -1));
} else { // Moved backward
SetSelection(pdoc->ExtendWordSelect(currentPos, -1),
- pdoc->ExtendWordSelect(originalAnchorPos, 1));
+ pdoc->ExtendWordSelect(originalAnchorPos, 1));
}
} else if (selectionType == selLine) {
lineAnchor = LineFromLocation(pt);
}
//Platform::DebugPrintf("Double click: %d - %d\n", anchor, currentPos);
if (doubleClick) {
- NotifyDoubleClick(pt, shift);
+ NotifyDoubleClick(pt, shift, ctrl, alt);
if (PositionIsHotspot(newPos))
NotifyHotSpotDoubleClicked(newPos, shift, ctrl, alt);
}
// Single click in margin: select whole line
LineSelection(lineAnchor, lineAnchor);
SetSelection(pdoc->LineStart(lineAnchor + 1),
- pdoc->LineStart(lineAnchor));
+ pdoc->LineStart(lineAnchor));
} else {
// Single shift+click in margin: select from line anchor to clicked line
if (anchor > currentPos)
NotifyHotSpotClicked(newPos, shift, ctrl, alt);
}
if (!shift) {
- inDragDrop = PointInSelection(pt) && !SelectionEmpty();
+ if (PointInSelection(pt) && !SelectionEmpty())
+ inDragDrop = ddInitial;
+ else
+ inDragDrop = ddNone;
}
- if (inDragDrop) {
- SetMouseCapture(false);
- SetDragPosition(newPos);
- CopySelectionRange(&drag);
- StartDrag();
- } else {
+ SetMouseCapture(true);
+ if (inDragDrop != ddInitial) {
SetDragPosition(invalidPosition);
- SetMouseCapture(true);
if (!shift) {
SetEmptySelection(newPos);
}
if ((ptMouseLast.x != pt.x) || (ptMouseLast.y != pt.y)) {
DwellEnd(true);
}
+
+ int movePos = PositionFromLocation(pt);
+ movePos = MovePositionOutsideChar(movePos, currentPos - movePos);
+
+ if (inDragDrop == ddInitial) {
+ if (DragThreshold(ptMouseLast, pt)) {
+ SetMouseCapture(false);
+ SetDragPosition(movePos);
+ CopySelectionRange(&drag);
+ StartDrag();
+ }
+ return;
+ }
+
ptMouseLast = pt;
//Platform::DebugPrintf("Move %d %d\n", pt.x, pt.y);
if (HaveMouseCapture()) {
autoScrollTimer.ticksToWait = autoScrollDelay;
// Adjust selection
- int movePos = PositionFromLocation(pt);
- movePos = MovePositionOutsideChar(movePos, currentPos - movePos);
if (posDrag >= 0) {
SetDragPosition(movePos);
} else {
// being unmade.
} else if (movePos > originalAnchorPos) { // Moved forward
SetSelection(pdoc->ExtendWordSelect(movePos, 1),
- pdoc->ExtendWordSelect(originalAnchorPos, -1));
+ pdoc->ExtendWordSelect(originalAnchorPos, -1));
} else { // Moved backward
SetSelection(pdoc->ExtendWordSelect(movePos, -1),
- pdoc->ExtendWordSelect(originalAnchorPos, 1));
+ pdoc->ExtendWordSelect(originalAnchorPos, 1));
}
} else {
// Continue selecting by line
}
void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) {
- //Platform::DebugPrintf("ButtonUp %d\n", HaveMouseCapture());
+ //Platform::DebugPrintf("ButtonUp %d %d\n", HaveMouseCapture(), inDragDrop);
+ int newPos = PositionFromLocation(pt);
+ newPos = MovePositionOutsideChar(newPos, currentPos - newPos);
+ if (inDragDrop == ddInitial) {
+ inDragDrop = ddNone;
+ SetEmptySelection(newPos);
+ }
if (HaveMouseCapture()) {
if (PointInSelMargin(pt)) {
DisplayCursor(Window::cursorReverseArrow);
SetMouseCapture(false);
int newPos = PositionFromLocation(pt);
newPos = MovePositionOutsideChar(newPos, currentPos - newPos);
- if (inDragDrop) {
+ NotifyIndicatorClick(false, newPos, false, false, false);
+ if (inDragDrop == ddDragging) {
int selStart = SelectionStart();
int selEnd = SelectionEnd();
if (selStart < selEnd) {
if (selType == selStream) {
SetLastXChosen();
}
- inDragDrop = false;
+ inDragDrop = ddNone;
EnsureCaretVisible(false);
}
}
}
}
}
+ if (horizontalScrollBarVisible && trackLineWidth && (lineWidthMaxSeen > scrollWidth)) {
+ scrollWidth = lineWidthMaxSeen;
+ SetScrollBars();
+ }
if ((dwellDelay < SC_TIME_FOREVER) &&
(ticksToDwell > 0) &&
(!HaveMouseCapture())) {
}
bool Editor::PaintContains(PRectangle rc) {
- return rcPaint.Contains(rc);
+ if (rc.Empty()) {
+ return true;
+ } else {
+ return rcPaint.Contains(rc);
+ }
}
bool Editor::PaintContainsMargin() {
SetVerticalScrollPos();
Redraw();
} else if ((lineDisplay > topLine + LinesOnScreen() - 1) ||
- ((visiblePolicy & VISIBLE_STRICT) && (lineDisplay > topLine + LinesOnScreen() - 1 - visibleSlop))) {
+ ((visiblePolicy & VISIBLE_STRICT) && (lineDisplay > topLine + LinesOnScreen() - 1 - visibleSlop))) {
SetTopLine(Platform::Clamp(lineDisplay - LinesOnScreen() + 1 + visibleSlop, 0, MaxScrollPos()));
SetVerticalScrollPos();
Redraw();
length = istrlen(text);
if (replacePatterns) {
text = pdoc->SubstituteByPosition(text, &length);
- if (!text)
+ if (!text) {
+ pdoc->EndUndoAction();
return 0;
+ }
}
if (targetStart != targetEnd)
pdoc->DeleteChars(targetStart, targetEnd - targetStart);
}
}
+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<char>(0xff));
+ pdoc->SetStyles(textLength, text);
+ delete []text;
+ }
+ SetEmptySelection(currentPos + textLength);
+}
+
static bool ValidMargin(unsigned long wParam) {
return wParam < ViewStyle::margins;
}
return reinterpret_cast<char *>(lParam);
}
+void Editor::StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
+ vs.EnsureStyle(wParam);
+ switch (iMessage) {
+ case SCI_STYLESETFORE:
+ vs.styles[wParam].fore.desired = ColourDesired(lParam);
+ break;
+ case SCI_STYLESETBACK:
+ vs.styles[wParam].back.desired = ColourDesired(lParam);
+ break;
+ case SCI_STYLESETBOLD:
+ vs.styles[wParam].bold = lParam != 0;
+ break;
+ case SCI_STYLESETITALIC:
+ vs.styles[wParam].italic = lParam != 0;
+ break;
+ case SCI_STYLESETEOLFILLED:
+ vs.styles[wParam].eolFilled = lParam != 0;
+ break;
+ case SCI_STYLESETSIZE:
+ vs.styles[wParam].size = lParam;
+ break;
+ case SCI_STYLESETFONT:
+ if (lParam != 0) {
+ vs.SetStyleFontName(wParam, CharPtrFromSPtr(lParam));
+ }
+ break;
+ case SCI_STYLESETUNDERLINE:
+ vs.styles[wParam].underline = lParam != 0;
+ break;
+ case SCI_STYLESETCASE:
+ vs.styles[wParam].caseForce = static_cast<Style::ecaseForced>(lParam);
+ break;
+ case SCI_STYLESETCHARACTERSET:
+ vs.styles[wParam].characterSet = lParam;
+ break;
+ case SCI_STYLESETVISIBLE:
+ vs.styles[wParam].visible = lParam != 0;
+ break;
+ case SCI_STYLESETCHANGEABLE:
+ vs.styles[wParam].changeable = lParam != 0;
+ break;
+ case SCI_STYLESETHOTSPOT:
+ vs.styles[wParam].hotspot = lParam != 0;
+ break;
+ }
+ InvalidateStyleRedraw();
+}
+
+sptr_t Editor::StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
+ vs.EnsureStyle(wParam);
+ switch (iMessage) {
+ case SCI_STYLEGETFORE:
+ return vs.styles[wParam].fore.desired.AsLong();
+ case SCI_STYLEGETBACK:
+ return vs.styles[wParam].back.desired.AsLong();
+ case SCI_STYLEGETBOLD:
+ return vs.styles[wParam].bold ? 1 : 0;
+ case SCI_STYLEGETITALIC:
+ return vs.styles[wParam].italic ? 1 : 0;
+ case SCI_STYLEGETEOLFILLED:
+ return vs.styles[wParam].eolFilled ? 1 : 0;
+ case SCI_STYLEGETSIZE:
+ return vs.styles[wParam].size;
+ case SCI_STYLEGETFONT:
+ if (lParam != 0)
+ strcpy(CharPtrFromSPtr(lParam), vs.styles[wParam].fontName);
+ return strlen(vs.styles[wParam].fontName);
+ case SCI_STYLEGETUNDERLINE:
+ return vs.styles[wParam].underline ? 1 : 0;
+ case SCI_STYLEGETCASE:
+ return static_cast<int>(vs.styles[wParam].caseForce);
+ case SCI_STYLEGETCHARACTERSET:
+ return vs.styles[wParam].characterSet;
+ case SCI_STYLEGETVISIBLE:
+ return vs.styles[wParam].visible ? 1 : 0;
+ case SCI_STYLEGETCHANGEABLE:
+ return vs.styles[wParam].changeable ? 1 : 0;
+ case SCI_STYLEGETHOTSPOT:
+ return vs.styles[wParam].hotspot ? 1 : 0;
+ }
+ return 0;
+}
+
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);
pdoc->BeginUndoAction();
pdoc->DeleteChars(0, pdoc->Length());
SetEmptySelection(0);
- pdoc->InsertString(0, CharPtrFromSPtr(lParam));
+ pdoc->InsertCString(0, CharPtrFromSPtr(lParam));
pdoc->EndUndoAction();
return 1;
}
pdoc->BeginUndoAction();
ClearSelection();
char *replacement = CharPtrFromSPtr(lParam);
- pdoc->InsertString(currentPos, replacement);
+ pdoc->InsertCString(currentPos, replacement);
pdoc->EndUndoAction();
SetEmptySelection(currentPos + istrlen(replacement));
EnsureCaretVisible();
return searchFlags;
case SCI_POSITIONBEFORE:
- return pdoc->MovePositionOutsideChar(wParam-1, -1, true);
+ return pdoc->MovePositionOutsideChar(wParam - 1, -1, true);
case SCI_POSITIONAFTER:
- return pdoc->MovePositionOutsideChar(wParam+1, 1, true);
+ return pdoc->MovePositionOutsideChar(wParam + 1, 1, true);
case SCI_LINESCROLL:
ScrollTo(topLine + lParam);
return 0;
}
- case SCI_ADDSTYLEDTEXT: {
- if (lParam == 0)
- return 0;
- pdoc->InsertStyledString(CurrentPosition() * 2, CharPtrFromSPtr(lParam), wParam);
- SetEmptySelection(currentPos + wParam / 2);
- return 0;
- }
+ case SCI_ADDSTYLEDTEXT:
+ if (lParam)
+ AddStyledText(CharPtrFromSPtr(lParam), wParam);
+ return 0;
case SCI_INSERTTEXT: {
if (lParam == 0)
insertPos = CurrentPosition();
int newCurrent = CurrentPosition();
char *sz = CharPtrFromSPtr(lParam);
- pdoc->InsertString(insertPos, sz);
+ pdoc->InsertCString(insertPos, sz);
if (newCurrent > insertPos)
newCurrent += istrlen(sz);
SetEmptySelection(newCurrent);
case SCI_GETLAYOUTCACHE:
return llc.GetLevel();
+ case SCI_SETPOSITIONCACHE:
+ posCache.SetSize(wParam);
+ break;
+
+ case SCI_GETPOSITIONCACHE:
+ return posCache.GetSize();
+
case SCI_SETSCROLLWIDTH:
PLATFORM_ASSERT(wParam > 0);
if ((wParam > 0) && (wParam != static_cast<unsigned int >(scrollWidth))) {
+ lineWidthMaxSeen = 0;
scrollWidth = wParam;
SetScrollBars();
}
case SCI_GETSCROLLWIDTH:
return scrollWidth;
+ case SCI_SETSCROLLWIDTHTRACKING:
+ trackLineWidth = wParam != 0;
+ break;
+
+ case SCI_GETSCROLLWIDTHTRACKING:
+ return trackLineWidth;
+
case SCI_LINESJOIN:
LinesJoin();
break;
break;
case SCI_TEXTWIDTH:
- PLATFORM_ASSERT(wParam <= STYLE_MAX);
+ PLATFORM_ASSERT(wParam < vs.stylesSize);
PLATFORM_ASSERT(lParam);
return TextWidth(wParam, CharPtrFromSPtr(lParam));
return verticalScrollBarVisible;
case SCI_SETINDENTATIONGUIDES:
- vs.viewIndentationGuides = wParam != 0;
+ vs.viewIndentationGuides = IndentView(wParam);
Redraw();
break;
break;
case SCI_STYLESETFORE:
- if (wParam <= STYLE_MAX) {
- vs.styles[wParam].fore.desired = ColourDesired(lParam);
- InvalidateStyleRedraw();
- }
- break;
case SCI_STYLESETBACK:
- if (wParam <= STYLE_MAX) {
- vs.styles[wParam].back.desired = ColourDesired(lParam);
- InvalidateStyleRedraw();
- }
- break;
case SCI_STYLESETBOLD:
- if (wParam <= STYLE_MAX) {
- vs.styles[wParam].bold = lParam != 0;
- InvalidateStyleRedraw();
- }
- break;
case SCI_STYLESETITALIC:
- if (wParam <= STYLE_MAX) {
- vs.styles[wParam].italic = lParam != 0;
- InvalidateStyleRedraw();
- }
- break;
case SCI_STYLESETEOLFILLED:
- if (wParam <= STYLE_MAX) {
- vs.styles[wParam].eolFilled = lParam != 0;
- InvalidateStyleRedraw();
- }
- break;
case SCI_STYLESETSIZE:
- if (wParam <= STYLE_MAX) {
- vs.styles[wParam].size = lParam;
- InvalidateStyleRedraw();
- }
- break;
case SCI_STYLESETFONT:
- if (lParam == 0)
- return 0;
- if (wParam <= STYLE_MAX) {
- vs.SetStyleFontName(wParam, CharPtrFromSPtr(lParam));
- InvalidateStyleRedraw();
- }
- break;
case SCI_STYLESETUNDERLINE:
- if (wParam <= STYLE_MAX) {
- vs.styles[wParam].underline = lParam != 0;
- InvalidateStyleRedraw();
- }
- break;
case SCI_STYLESETCASE:
- if (wParam <= STYLE_MAX) {
- vs.styles[wParam].caseForce = static_cast<Style::ecaseForced>(lParam);
- InvalidateStyleRedraw();
- }
- break;
case SCI_STYLESETCHARACTERSET:
- if (wParam <= STYLE_MAX) {
- vs.styles[wParam].characterSet = lParam;
- InvalidateStyleRedraw();
- }
- break;
case SCI_STYLESETVISIBLE:
- if (wParam <= STYLE_MAX) {
- vs.styles[wParam].visible = lParam != 0;
- InvalidateStyleRedraw();
- }
- break;
case SCI_STYLESETCHANGEABLE:
- if (wParam <= STYLE_MAX) {
- vs.styles[wParam].changeable = lParam != 0;
- InvalidateStyleRedraw();
- }
- break;
case SCI_STYLESETHOTSPOT:
- if (wParam <= STYLE_MAX) {
- vs.styles[wParam].hotspot = lParam != 0;
- InvalidateStyleRedraw();
- }
- break;
+ StyleSetMessage(iMessage, wParam, lParam);
+ break;
+
+ case SCI_STYLEGETFORE:
+ case SCI_STYLEGETBACK:
+ case SCI_STYLEGETBOLD:
+ case SCI_STYLEGETITALIC:
+ case SCI_STYLEGETEOLFILLED:
+ case SCI_STYLEGETSIZE:
+ case SCI_STYLEGETFONT:
+ case SCI_STYLEGETUNDERLINE:
+ case SCI_STYLEGETCASE:
+ case SCI_STYLEGETCHARACTERSET:
+ case SCI_STYLEGETVISIBLE:
+ case SCI_STYLEGETCHANGEABLE:
+ case SCI_STYLEGETHOTSPOT:
+ return StyleGetMessage(iMessage, wParam, lParam);
case SCI_STYLERESETDEFAULT:
vs.ResetDefaultStyle();
InvalidateStyleRedraw();
break;
case SCI_SETSTYLEBITS:
+ vs.EnsureStyle((1 << wParam) - 1);
pdoc->SetStylingBits(wParam);
break;
case SCI_GETSELALPHA:
return vs.selAlpha;
+ case SCI_GETSELEOLFILLED:
+ return vs.selEOLFilled;
+
+ case SCI_SETSELEOLFILLED:
+ vs.selEOLFilled = wParam != 0;
+ InvalidateStyleRedraw();
+ break;
+
case SCI_SETWHITESPACEFORE:
vs.whitespaceForegroundSet = wParam != 0;
vs.whitespaceForeground.desired = ColourDesired(lParam);
case SCI_GETCARETFORE:
return vs.caretcolour.desired.AsLong();
+ case SCI_SETCARETSTYLE:
+ if (wParam >= CARETSTYLE_INVISIBLE && wParam <= CARETSTYLE_BLOCK)
+ vs.caretStyle = wParam;
+ else
+ /* Default to the line caret */
+ vs.caretStyle = CARETSTYLE_LINE;
+ InvalidateStyleRedraw();
+ break;
+
+ case SCI_GETCARETSTYLE:
+ return vs.caretStyle;
+
case SCI_SETCARETWIDTH:
if (wParam <= 0)
vs.caretWidth = 0;
case SCI_ASSIGNCMDKEY:
kmap.AssignCmdKey(Platform::LowShortFromLong(wParam),
- Platform::HighShortFromLong(wParam), lParam);
+ Platform::HighShortFromLong(wParam), lParam);
break;
case SCI_CLEARCMDKEY:
kmap.AssignCmdKey(Platform::LowShortFromLong(wParam),
- Platform::HighShortFromLong(wParam), SCI_NULL);
+ Platform::HighShortFromLong(wParam), SCI_NULL);
break;
case SCI_CLEARALLCMDKEYS:
case SCI_INDICGETFORE:
return (wParam <= INDIC_MAX) ? vs.indicators[wParam].fore.desired.AsLong() : 0;
+ case SCI_INDICSETUNDER:
+ if (wParam <= INDIC_MAX) {
+ vs.indicators[wParam].under = lParam != 0;
+ InvalidateStyleRedraw();
+ }
+ break;
+
+ case SCI_INDICGETUNDER:
+ return (wParam <= INDIC_MAX) ? vs.indicators[wParam].under : 0;
+
+ case SCI_SETINDICATORCURRENT:
+ pdoc->decorations.SetCurrentIndicator(wParam);
+ break;
+ case SCI_GETINDICATORCURRENT:
+ return pdoc->decorations.GetCurrentIndicator();
+ case SCI_SETINDICATORVALUE:
+ pdoc->decorations.SetCurrentValue(wParam);
+ break;
+ case SCI_GETINDICATORVALUE:
+ return pdoc->decorations.GetCurrentValue();
+
+ case SCI_INDICATORFILLRANGE:
+ pdoc->DecorationFillRange(wParam, pdoc->decorations.GetCurrentValue(), lParam);
+ break;
+
+ case SCI_INDICATORCLEARRANGE:
+ pdoc->DecorationFillRange(wParam, 0, lParam);
+ break;
+
+ case SCI_INDICATORALLONFOR:
+ return pdoc->decorations.AllOnFor(wParam);
+
+ case SCI_INDICATORVALUEAT:
+ return pdoc->decorations.ValueAt(wParam, lParam);
+
+ case SCI_INDICATORSTART:
+ return pdoc->decorations.Start(wParam, lParam);
+
+ case SCI_INDICATOREND:
+ return pdoc->decorations.End(wParam, lParam);
+
case SCI_LINEDOWN:
case SCI_LINEDOWNEXTEND:
case SCI_PARADOWN:
case SCI_ZOOMOUT:
case SCI_DELWORDLEFT:
case SCI_DELWORDRIGHT:
+ case SCI_DELWORDRIGHTEND:
case SCI_DELLINELEFT:
case SCI_DELLINERIGHT:
case SCI_LINECOPY:
InvalidateStyleRedraw();
break;
+ case SCI_GETHOTSPOTACTIVEFORE:
+ return vs.hotspotForeground.desired.AsLong();
+
case SCI_SETHOTSPOTACTIVEBACK:
vs.hotspotBackgroundSet = wParam != 0;
vs.hotspotBackground.desired = ColourDesired(lParam);
InvalidateStyleRedraw();
break;
+ case SCI_GETHOTSPOTACTIVEBACK:
+ return vs.hotspotBackground.desired.AsLong();
+
case SCI_SETHOTSPOTACTIVEUNDERLINE:
vs.hotspotUnderline = wParam != 0;
InvalidateStyleRedraw();
break;
+ case SCI_GETHOTSPOTACTIVEUNDERLINE:
+ return vs.hotspotUnderline ? 1 : 0;
+
case SCI_SETHOTSPOTSINGLELINE:
vs.hotspotSingleLine = wParam != 0;
InvalidateStyleRedraw();
break;
+ case SCI_GETHOTSPOTSINGLELINE:
+ return vs.hotspotSingleLine ? 1 : 0;
+
case SCI_SETPASTECONVERTENDINGS:
convertPastes = wParam != 0;
break;
#ifndef EDITOR_H
#define EDITOR_H
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
/**
*/
class Caret {
Idler();
};
-/**
- */
-class LineLayout {
-private:
- friend class LineLayoutCache;
- int *lineStarts;
- int lenLineStarts;
- /// Drawing is only performed for @a maxLineLength characters on each line.
- int lineNumber;
- bool inCache;
-public:
- enum { wrapWidthInfinite = 0x7ffffff };
- int maxLineLength;
- int numCharsInLine;
- enum validLevel { llInvalid, llCheckTextAndStyle, llPositions, llLines } validity;
- int xHighlightGuide;
- bool highlightColumn;
- int selStart;
- int selEnd;
- bool containsCaret;
- int edgeColumn;
- char *chars;
- unsigned char *styles;
- int styleBitsSet;
- char *indicators;
- int *positions;
- char bracePreviousStyles[2];
-
- // Hotspot support
- int hsStart;
- int hsEnd;
-
- // Wrapped line support
- int widthLine;
- int lines;
-
- LineLayout(int maxLineLength_);
- virtual ~LineLayout();
- void Resize(int maxLineLength_);
- void Free();
- void Invalidate(validLevel validity_);
- int LineStart(int line) {
- if (line <= 0) {
- return 0;
- } else if ((line >= lines) || !lineStarts) {
- return numCharsInLine;
- } else {
- return lineStarts[line];
- }
- }
- void SetLineStart(int line, int start);
- void SetBracesHighlight(Range rangeLine, Position braces[],
- char bracesMatchStyle, int xHighlight);
- void RestoreBracesHighlight(Range rangeLine, Position braces[]);
-};
-
-/**
- */
-class LineLayoutCache {
- int level;
- int length;
- int size;
- LineLayout **cache;
- bool allInvalidated;
- int styleClock;
- int useCount;
- void Allocate(int length_);
- void AllocateForLevel(int linesOnScreen, int linesInDoc);
-public:
- LineLayoutCache();
- virtual ~LineLayoutCache();
- void Deallocate();
- enum {
- llcNone=SC_CACHE_NONE,
- llcCaret=SC_CACHE_CARET,
- llcPage=SC_CACHE_PAGE,
- llcDocument=SC_CACHE_DOCUMENT
- };
- void Invalidate(LineLayout::validLevel validity_);
- void SetLevel(int level_);
- int GetLevel() { return level; }
- LineLayout *Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_,
- int linesOnScreen, int linesInDoc);
- void Dispose(LineLayout *ll);
-};
-
/**
* Hold a piece of text selected for copying or dragging.
* The text is expected to hold a terminating '\0' and this is counted in len.
int xCaretMargin; ///< Ensure this many pixels visible on both sides of caret
bool horizontalScrollBarVisible;
int scrollWidth;
+ bool trackLineWidth;
+ int lineWidthMaxSeen;
bool verticalScrollBarVisible;
bool endAtLastLine;
bool caretSticky;
Surface *pixmapIndentGuideHighlight;
LineLayoutCache llc;
+ PositionCache posCache;
KeyMap kmap;
bool dwelling;
enum { selChar, selWord, selLine } selectionType;
Point ptMouseLast;
- bool inDragDrop;
+ enum { ddNone, ddInitial, ddDragging } inDragDrop;
bool dropWentOutside;
int posDrag;
int posDrop;
virtual void UpdateSystemCaret();
void NeedWrapping(int docLineStart = 0, int docLineEnd = wrapLineLarge);
+ bool WrapOneLine(Surface *surface, int lineToWrap);
bool WrapLines(bool fullWrap, int priorityWrapLineStart);
void LinesJoin();
void LinesSplit(int pixelWidth);
int line, int lineEnd, int xStart, int subLine, int subLineStart,
bool overrideBackground, ColourAllocated background,
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 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);
void RefreshPixMaps(Surface *surfaceWindow);
void Paint(Surface *surfaceWindow, PRectangle rcArea);
long FormatRange(bool draw, RangeToFormat *pfr);
virtual void AddCharUTF(char *s, unsigned int len, bool treatAsDBCS=false);
void ClearSelection();
void ClearAll();
- void ClearDocumentStyle();
+ void ClearDocumentStyle();
void Cut();
void PasteRectangular(int pos, const char *ptr, int len);
virtual void Copy() = 0;
void NotifyMove(int position);
void NotifySavePoint(bool isSavePoint);
void NotifyModifyAttempt();
- virtual void NotifyDoubleClick(Point pt, bool shift);
+ virtual void NotifyDoubleClick(Point pt, bool shift, bool ctrl, bool alt);
void NotifyHotSpotClicked(int position, bool shift, bool ctrl, bool alt);
void NotifyHotSpotDoubleClicked(int position, bool shift, bool ctrl, bool alt);
void NotifyUpdateUI();
void NotifyPainted();
+ void NotifyIndicatorClick(bool click, int position, bool shift, bool ctrl, bool alt);
bool NotifyMarginClick(Point pt, bool shift, bool ctrl, bool alt);
void NotifyNeedShown(int pos, int len);
void NotifyDwelling(Point pt, bool state);
void CopyText(int length, const char *text);
void SetDragPosition(int 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.
int CodePage() const;
virtual bool ValidCodePage(int /* codePage */) const { return true; }
int WrapCount(int line);
+ void AddStyledText(char *buffer, int appendLength);
virtual sptr_t DefWndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) = 0;
+ void StyleSetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
+ sptr_t StyleGetMessage(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
public:
// Public so the COM thunks can access it.
}
};
+#ifdef SCI_NAMESPACE
+}
+#endif
+
#endif
#include "KeyWords.h"
#include "ExternalLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
LexerManager *LexerManager::theInstance = NULL;
//------------------------------------------
#if PLAT_WIN
#define EXT_LEXER_DECL __stdcall
#else
-#define EXT_LEXER_DECL
+#define EXT_LEXER_DECL
+#endif
+
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
#endif
// External Lexer function definitions...
const char *languageName_=0, LexerFunction fnFolder_=0) : LexerModule(language_, fnLexer_, 0, fnFolder_){
strncpy(name, languageName_, sizeof(name));
languageName = name;
- }
+ };
virtual void Lex(unsigned int startPos, int lengthDoc, int initStyle,
WordList *keywordlists[], Accessor &styler) const;
virtual void Fold(unsigned int startPos, int lengthDoc, int initStyle,
~LMMinder();
};
+#ifdef SCI_NAMESPACE
+}
+#endif
+
#endif
#include "Scintilla.h"
#include "Indicator.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
void Indicator::Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine) {
surface->PenColour(fore.allocated);
int ymid = (rc.bottom + rc.top) / 2;
#ifndef INDICATOR_H
#define INDICATOR_H
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
/**
*/
class Indicator {
public:
int style;
+ bool under;
ColourPair fore;
- Indicator() : style(INDIC_PLAIN), fore(ColourDesired(0,0,0)) {
+ Indicator() : style(INDIC_PLAIN), under(false), fore(ColourDesired(0,0,0)) {
}
void Draw(Surface *surface, const PRectangle &rc, const PRectangle &rcLine);
};
+#ifdef SCI_NAMESPACE
+}
+#endif
+
#endif
#include "KeyMap.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
KeyMap::KeyMap() : kmap(0), len(0), alloc(0) {
for (int i = 0; MapDefault[i].key; i++) {
AssignCmdKey(MapDefault[i].key,
#ifndef KEYTOCOMMAND_H
#define KEYTOCOMMAND_H
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
#define SCI_NORM 0
#define SCI_SHIFT SCMOD_SHIFT
#define SCI_CTRL SCMOD_CTRL
unsigned int Find(int key, int modifiers); // 0 returned on failure
};
+#ifdef SCI_NAMESPACE
+}
+#endif
+
#endif
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
const LexerModule *LexerModule::base = 0;
int LexerModule::nextLanguage = SCLEX_AUTOMATIC+1;
//++Autogenerated -- run src/LexGen.py to regenerate
//**\(\tLINK_LEXER(\*);\n\)
+ LINK_LEXER(lmAbaqus);
LINK_LEXER(lmAda);
LINK_LEXER(lmAns1);
LINK_LEXER(lmAPDL);
LINK_LEXER(lmAsm);
LINK_LEXER(lmASP);
+ LINK_LEXER(lmASY);
LINK_LEXER(lmAU3);
LINK_LEXER(lmAVE);
LINK_LEXER(lmBaan);
LINK_LEXER(lmCaml);
LINK_LEXER(lmClw);
LINK_LEXER(lmClwNoCase);
+ LINK_LEXER(lmCmake);
LINK_LEXER(lmConf);
LINK_LEXER(lmCPP);
LINK_LEXER(lmCPPNoCase);
LINK_LEXER(lmCsound);
LINK_LEXER(lmCss);
+ LINK_LEXER(lmD);
LINK_LEXER(lmDiff);
LINK_LEXER(lmEiffel);
LINK_LEXER(lmEiffelkw);
LINK_LEXER(lmForth);
LINK_LEXER(lmFortran);
LINK_LEXER(lmFreeBasic);
+ LINK_LEXER(lmGAP);
LINK_LEXER(lmGui4Cli);
LINK_LEXER(lmHaskell);
LINK_LEXER(lmHTML);
LINK_LEXER(lmPerl);
LINK_LEXER(lmPHP);
LINK_LEXER(lmPHPSCRIPT);
+ LINK_LEXER(lmPLM);
LINK_LEXER(lmPOV);
+ LINK_LEXER(lmProgress);
LINK_LEXER(lmProps);
LINK_LEXER(lmPS);
LINK_LEXER(lmPureBasic);
LINK_LEXER(lmPython);
+ LINK_LEXER(lmR);
LINK_LEXER(lmREBOL);
LINK_LEXER(lmRuby);
LINK_LEXER(lmScriptol);
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
static inline bool IsAWordChar(const int ch) {
return (ch < 0x80 && (isalnum(ch) || ch == '_'));
sc.Complete();
}
+//------------------------------------------------------------------------------
+// 06-27-07 Sergio Lucato
+// - Included code folding for Ansys APDL lexer
+// - Copyied from LexBasic.cxx and modified for APDL
+//------------------------------------------------------------------------------
+
+/* Bits:
+ * 1 - whitespace
+ * 2 - operator
+ * 4 - identifier
+ * 8 - decimal digit
+ * 16 - hex digit
+ * 32 - bin digit
+ */
+static int character_classification[128] =
+{
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 6, 2, 2, 2, 10, 6,
+ 60, 60, 28, 28, 28, 28, 28, 28, 28, 28, 2, 2, 2, 2, 2, 2,
+ 2, 20, 20, 20, 20, 20, 20, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 4,
+ 2, 20, 20, 20, 20, 20, 20, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 0
+};
+
+static bool IsSpace(int c) {
+ return c < 128 && (character_classification[c] & 1);
+}
+
+static bool IsIdentifier(int c) {
+ return c < 128 && (character_classification[c] & 4);
+}
+
+static int LowerCase(int c)
+{
+ if (c >= 'A' && c <= 'Z')
+ return 'a' + c - 'A';
+ return c;
+}
+
+static int CheckAPDLFoldPoint(char const *token, int &level) {
+ if (!strcmp(token, "*if") ||
+ !strcmp(token, "*do") ||
+ !strcmp(token, "*dowhile") ) {
+ level |= SC_FOLDLEVELHEADERFLAG;
+ return 1;
+ }
+ if (!strcmp(token, "*endif") ||
+ !strcmp(token, "*enddo") ) {
+ return -1;
+ }
+ return 0;
+}
+
+static void FoldAPDLDoc(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<char>(LowerCase(c));
+ if (!IsIdentifier(c)) { // done with token
+ word[wordlen] = '\0';
+ go = CheckAPDLFoldPoint(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++;
+ }
+ } else { // start scanning at first non-whitespace character
+ if (!IsSpace(c)) {
+ if (IsIdentifier(c)) {
+ word[0] = static_cast<char>(LowerCase(c));
+ wordlen = 1;
+ } else // done with this line
+ done = 1;
+ }
+ }
+ }
+ 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;
+ }
+ }
+}
+
static const char * const apdlWordListDesc[] = {
"processors",
"commands",
0
};
-LexerModule lmAPDL(SCLEX_APDL, ColouriseAPDLDoc, "apdl", 0, apdlWordListDesc);
+LexerModule lmAPDL(SCLEX_APDL, ColouriseAPDLDoc, "apdl", FoldAPDLDoc, apdlWordListDesc);
--- /dev/null
+// Scintilla source code edit control
+//Author: instanton (email: soft_share<at>126<dot>com)
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#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
+
+static void ColouriseAsyDoc(unsigned int startPos, int length, int initStyle,
+ WordList *keywordlists[], Accessor &styler) {
+
+ WordList &keywords = *keywordlists[0];
+ WordList &keywords2 = *keywordlists[1];
+
+ CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true);
+ CharacterSet setWord(CharacterSet::setAlphaNum, "._", 0x80, true);
+
+ int visibleChars = 0;
+
+ StyleContext sc(startPos, length, initStyle, styler);
+
+ for (; sc.More(); sc.Forward()) {
+
+ if (sc.atLineStart) {
+ if (sc.state == SCE_ASY_STRING) {
+ sc.SetState(SCE_ASY_STRING);
+ }
+ visibleChars = 0;
+ }
+
+ if (sc.ch == '\\') {
+ if (sc.chNext == '\n' || sc.chNext == '\r') {
+ sc.Forward();
+ if (sc.ch == '\r' && sc.chNext == '\n') {
+ sc.Forward();
+ }
+// continuationLine = true;
+ continue;
+ }
+ }
+
+ // Determine if the current state should terminate.
+ switch (sc.state) {
+ case SCE_ASY_OPERATOR:
+ sc.SetState(SCE_ASY_DEFAULT);
+ break;
+ case SCE_ASY_NUMBER:
+ if (!setWord.Contains(sc.ch)) {
+ sc.SetState(SCE_ASY_DEFAULT);
+ }
+ break;
+ case SCE_ASY_IDENTIFIER:
+ if (!setWord.Contains(sc.ch) || (sc.ch == '.')) {
+ char s[1000];
+ sc.GetCurrentLowered(s, sizeof(s));
+ if (keywords.InList(s)) {
+ sc.ChangeState(SCE_ASY_WORD);
+ } else if (keywords2.InList(s)) {
+ sc.ChangeState(SCE_ASY_WORD2);
+ }
+ sc.SetState(SCE_ASY_DEFAULT);
+ }
+ break;
+ case SCE_ASY_COMMENT:
+ if (sc.Match('*', '/')) {
+ sc.Forward();
+ sc.ForwardSetState(SCE_ASY_DEFAULT);
+ }
+ break;
+ case SCE_ASY_COMMENTLINE:
+ if (sc.atLineStart) {
+ sc.SetState(SCE_ASY_DEFAULT);
+ }
+ break;
+ case SCE_ASY_STRING:
+ if (sc.atLineEnd) {
+ sc.ChangeState(SCE_ASY_STRINGEOL);
+ } else if (sc.ch == '\\') {
+ if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+ sc.Forward();
+ }
+ } else if (sc.ch == '\"') {
+ sc.ForwardSetState(SCE_ASY_DEFAULT);
+ }
+ break;
+ case SCE_ASY_CHARACTER:
+ if (sc.atLineEnd) {
+ sc.ChangeState(SCE_ASY_STRINGEOL);
+ } else if (sc.ch == '\\') {
+ if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+ sc.Forward();
+ }
+ } else if (sc.ch == '\'') {
+ sc.ForwardSetState(SCE_ASY_DEFAULT);
+ }
+ break;
+ }
+
+ // Determine if a new state should be entered.
+ if (sc.state == SCE_ASY_DEFAULT) {
+ if (setWordStart.Contains(sc.ch) || (sc.ch == '@')) {
+ sc.SetState(SCE_ASY_IDENTIFIER);
+ } else if (sc.Match('/', '*')) {
+ sc.SetState(SCE_ASY_COMMENT);
+ sc.Forward(); //
+ } else if (sc.Match('/', '/')) {
+ sc.SetState(SCE_ASY_COMMENTLINE);
+ } else if (sc.ch == '\"') {
+ sc.SetState(SCE_ASY_STRING);
+ } else if (sc.ch == '\'') {
+ sc.SetState(SCE_ASY_CHARACTER);
+ } else if (sc.ch == '#' && visibleChars == 0) {
+ do {
+ sc.Forward();
+ } while ((sc.ch == ' ' || sc.ch == '\t') && sc.More());
+ if (sc.atLineEnd) {
+ sc.SetState(SCE_ASY_DEFAULT);
+ }
+ } else if (isoperator(static_cast<char>(sc.ch))) {
+ sc.SetState(SCE_ASY_OPERATOR);
+ }
+ }
+
+ }
+ sc.Complete();
+}
+
+static bool IsAsyCommentStyle(int style) {
+ return style == SCE_ASY_COMMENT;
+}
+
+
+static inline bool isASYidentifier(int ch) {
+ return
+ ((ch >= 'a') && (ch <= 'z')) || ((ch >= 'A') && (ch <= 'Z')) ;
+}
+
+static int ParseASYWord(unsigned int pos, Accessor &styler, char *word)
+{
+ int length=0;
+ char ch=styler.SafeGetCharAt(pos);
+ *word=0;
+
+ while(isASYidentifier(ch) && length<100){
+ word[length]=ch;
+ length++;
+ ch=styler.SafeGetCharAt(pos+length);
+ }
+ word[length]=0;
+ return length;
+}
+
+static bool IsASYDrawingLine(int line, Accessor &styler) {
+ int pos = styler.LineStart(line);
+ int eol_pos = styler.LineStart(line + 1) - 1;
+
+ int startpos = pos;
+ char buffer[100]="";
+
+ while (startpos<eol_pos){
+ char ch = styler[startpos];
+ ParseASYWord(startpos,styler,buffer);
+ bool drawcommands = strncmp(buffer,"draw",4)==0||
+ strncmp(buffer,"pair",4)==0||strncmp(buffer,"label",5)==0;
+ if (!drawcommands && ch!=' ') return false;
+ else if (drawcommands) return true;
+ startpos++;
+ }
+ return false;
+}
+
+static void FoldAsyDoc(unsigned int startPos, int length, int initStyle,
+ WordList *[], Accessor &styler) {
+ bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
+ bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
+ bool foldAtElse = 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 && IsAsyCommentStyle(style)) {
+ if (!IsAsyCommentStyle(stylePrev) && (stylePrev != SCE_ASY_COMMENTLINEDOC)) {
+ levelNext++;
+ } else if (!IsAsyCommentStyle(styleNext) && (styleNext != SCE_ASY_COMMENTLINEDOC) && !atEOL) {
+ levelNext--;
+ }
+ }
+ if (style == SCE_ASY_OPERATOR) {
+ if (ch == '{') {
+ if (levelMinCurrent > levelNext) {
+ levelMinCurrent = levelNext;
+ }
+ levelNext++;
+ } else if (ch == '}') {
+ levelNext--;
+ }
+ }
+
+ if (atEOL && IsASYDrawingLine(lineCurrent, styler)){
+ if (lineCurrent==0 && IsASYDrawingLine(lineCurrent + 1, styler))
+ levelNext++;
+ else if (lineCurrent!=0 && !IsASYDrawingLine(lineCurrent - 1, styler)
+ && IsASYDrawingLine(lineCurrent + 1, styler)
+ )
+ levelNext++;
+ else if (lineCurrent!=0 && IsASYDrawingLine(lineCurrent - 1, styler) &&
+ !IsASYDrawingLine(lineCurrent+1, styler))
+ levelNext--;
+ }
+
+ if (atEOL) {
+ 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 const char * const asyWordLists[] = {
+ "Primary keywords and identifiers",
+ "Secondary keywords and identifiers",
+ 0,
+ };
+
+LexerModule lmASY(SCLEX_ASYMPTOTE, ColouriseAsyDoc, "asy", FoldAsyDoc, asyWordLists);
// Sep 27, 2005 - Fixed the SentKey lexing logic in case of multiple sentkeys.
// Mar 12, 2006 - Fixed issue with <> coloring as String in stead of Operator in rare occasions.
// Apr 8, 2006 - Added support for AutoIt3 Standard UDF library (SCE_AU3_UDF)
+// Mar 9, 2007 - Fixed bug with + following a String getting the wrong Color.
+// Jun 20, 2007 - Fixed Commentblock issue when LF's are used as EOL.
+// Jul 26, 2007 - Fixed #endregion undetected bug.
//
// Copyright for Scintilla: 1998-2001 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
static inline bool IsTypeCharacter(const int ch)
{
return ch == '$';
//Reset at line end
if (sc.atLineEnd) {
ci=0;
- sc.SetState(SCE_AU3_COMMENTBLOCK);
+ 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
if (sc.chPrev == ';') {
break;
}
if (!(IsAWordChar(sc.ch) || (sc.ch == '-' && strcmp(s, "#comments") == 0))) {
- if ((strcmp(s, "#ce")== 0 || strcmp(s, "#comments-end")== 0))
- sc.SetState(SCE_AU3_COMMENT); // set to comment line for the rest of the line
+ if ((strcmp(s, "#ce")== 0 || strcmp(s, "#comments-end")== 0))
+ sc.SetState(SCE_AU3_COMMENT); // set to comment line for the rest of the line
else
ci=2; // line doesn't begin with #CE so skip the rest of the line
}
- break;
+ break;
}
case SCE_AU3_COMMENT:
{
{
sc.ChangeState(SCE_AU3_COMMENTBLOCK);
sc.SetState(SCE_AU3_COMMENTBLOCK);
+ break;
}
else if (keywords.InList(s)) {
sc.ChangeState(SCE_AU3_KEYWORD);
{
sc.ForwardSetState(SCE_AU3_DEFAULT);
si=0;
+ break;
}
if (sc.atLineEnd)
{
if (!IsContinuationLine(lineCurrent,styler))
{
sc.SetState(SCE_AU3_DEFAULT);
+ break;
}
}
// find Sendkeys in a STRING
// vars for getting first word to check for keywords
bool FirstWordStart = false;
bool FirstWordEnd = false;
- char szKeyword[10]="";
+ char szKeyword[11]="";
int szKeywordlen = 0;
char szThen[5]="";
int szThenlen = 0;
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
static inline bool IsAWordChar(const int ch) {
--- /dev/null
+// Scintilla source code edit control
+/** @file LexABAQUS.cxx
+ ** Lexer for ABAQUS. Based on the lexer for APDL by Hadar Raz.
+ ** By Sergio Lucato.
+ **/
+// The License.txt file describes the conditions under which this software may be distributed.
+
+// Code folding copyied and modified from LexBasic.cxx
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+static inline bool IsAWordChar(const int ch) {
+ return (ch < 0x80 && (isalnum(ch) || ch == '_'));
+}
+
+static inline bool IsAnOperator(char ch) {
+ // '.' left out as it is used to make up numbers
+ if (ch == '*' || ch == '/' || ch == '-' || ch == '+' ||
+ ch == '(' || ch == ')' || ch == '=' || ch == '^' ||
+ ch == '[' || ch == ']' || ch == '<' || ch == '&' ||
+ ch == '>' || ch == ',' || ch == '|' || ch == '~' ||
+ ch == '$' || ch == ':' || ch == '%')
+ return true;
+ return false;
+}
+
+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];
+
+ // Do not leak onto next line
+ 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<char>(sc.ch))) {
+ sc.SetState(SCE_ABAQUS_DEFAULT);
+ }
+ }
+
+ // 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<char>(sc.ch))) {
+ sc.SetState(SCE_ABAQUS_OPERATOR);
+ }
+ }
+ }
+ sc.Complete();
+}
+
+//------------------------------------------------------------------------------
+// This copyied and modified from LexBasic.cxx
+//------------------------------------------------------------------------------
+
+/* Bits:
+ * 1 - whitespace
+ * 2 - operator
+ * 4 - identifier
+ * 8 - decimal digit
+ * 16 - hex digit
+ * 32 - bin digit
+ */
+static int character_classification[128] =
+{
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 6, 2, 2, 2, 10, 6,
+ 60, 60, 28, 28, 28, 28, 28, 28, 28, 28, 2, 2, 2, 2, 2, 2,
+ 2, 20, 20, 20, 20, 20, 20, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 4,
+ 2, 20, 20, 20, 20, 20, 20, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 0
+};
+
+static bool IsSpace(int c) {
+ return c < 128 && (character_classification[c] & 1);
+}
+
+static bool IsIdentifier(int c) {
+ return c < 128 && (character_classification[c] & 4);
+}
+
+static int LowerCase(int c)
+{
+ if (c >= 'A' && c <= 'Z')
+ return 'a' + c - 'A';
+ 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 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<char>(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++;
+ }
+ } else { // start scanning at first non-whitespace character
+ if (!IsSpace(c)) {
+ if (IsIdentifier(c)) {
+ word[0] = static_cast<char>(LowerCase(c));
+ wordlen = 1;
+ } else // done with this line
+ done = 1;
+ }
+ }
+ }
+ 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;
+ }
+ }
+}
+
+static const char * const abaqusWordListDesc[] = {
+ "processors",
+ "commands",
+ "slashommands",
+ "starcommands",
+ "arguments",
+ "functions",
+ 0
+};
+
+LexerModule lmAbaqus(SCLEX_ABAQUS, ColouriseABAQUSDoc, "abaqus", FoldABAQUSDoc, abaqusWordListDesc);
#include "SciLexer.h"
#include "SString.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
/*
* Interface
*/
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
static inline bool IsAWordChar(const int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '.' ||
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
// Some char test functions
static bool isAsn1Number(int ch)
{
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
static inline bool IsAWordChar(const int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_' || ch == '$' || ch == ':');
}
/** @file LexBash.cxx
** Lexer for Bash.
**/
-// Copyright 2004-2005 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 2004-2007 by Neil Hodgson <neilh@scintilla.org>
// Adapted from LexPerl by Kein-Hong Man <mkh@pl.jaring.my> 2004
// The License.txt file describes the conditions under which this software may be distributed.
#include "Scintilla.h"
#include "SciLexer.h"
+// define this if you want 'invalid octals' to be marked as errors
+// usually, this is not a good idea, permissive lexing is better
+#undef PEDANTIC_OCTAL
+
#define BASH_BASE_ERROR 65
#define BASH_BASE_DECIMAL 66
#define BASH_BASE_HEX 67
+#ifdef PEDANTIC_OCTAL
#define BASH_BASE_OCTAL 68
#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) {
if (ch >= '0' && ch <= '9') {
return ch - '0';
ch = chNext;
chNext = chNext2;
} else if (isdigit(chNext)) {
+#ifdef PEDANTIC_OCTAL
numBase = BASH_BASE_OCTAL;
+#else
+ numBase = BASH_BASE_HEX;
+#endif
}
}
} else if (iswordstart(ch)) {
HereDoc.Indent = false;
} else if (ch == '-' // file test operators
&& isSingleCharOp(chNext)
- && !isalnum((chNext2 = styler.SafeGetCharAt(i+2)))) {
+ && !isalnum((chNext2 = styler.SafeGetCharAt(i+2)))
+ && isspace(chPrev)) {
styler.ColourTo(i + 1, SCE_SH_WORD);
state = SCE_SH_DEFAULT;
i++;
// hex digit 0-9a-fA-F
} else
goto numAtEnd;
+#ifdef PEDANTIC_OCTAL
} else if (numBase == BASH_BASE_OCTAL ||
numBase == BASH_BASE_OCTAL_ERROR) {
if (digit > 7) {
if (digit <= 9) {
- numBase = BASH_BASE_OCTAL_ERROR;
+ numBase = BASH_BASE_OCTAL_ERROR;
} else
goto numAtEnd;
}
+#endif
} else if (numBase == BASH_BASE_ERROR) {
if (digit > 9)
goto numAtEnd;
}
} else {
numAtEnd:
- if (numBase == BASH_BASE_ERROR ||
- numBase == BASH_BASE_OCTAL_ERROR)
+ if (numBase == BASH_BASE_ERROR
+#ifdef PEDANTIC_OCTAL
+ || numBase == BASH_BASE_OCTAL_ERROR
+#endif
+ )
state = SCE_SH_ERROR;
styler.ColourTo(i - 1, state);
state = SCE_SH_DEFAULT;
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
/* Bits:
* 1 - whitespace
* 2 - operator
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
static int classifyWordBullant(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
char s[100];
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
// Is an end of line character
inline bool IsEOL(const int ch) {
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
+#include "CharacterSet.h"
-#define KEYWORD_BOXHEADER 1
-#define KEYWORD_FOLDCONTRACTED 2
-
-static bool IsOKBeforeRE(int ch) {
- return (ch == '(') || (ch == '=') || (ch == ',');
-}
-
-static inline bool IsAWordChar(int ch) {
- return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
-}
-
-static inline bool IsAWordStart(int ch) {
- return (ch < 0x80) && (isalpha(ch) || ch == '_');
-}
-
-static inline bool IsADoxygenChar(int ch) {
- return (ch < 0x80 && islower(ch)) || ch == '$' || ch == '@' ||
- ch == '\\' || ch == '&' || ch == '<' ||
- ch == '>' || ch == '#' || ch == '{' ||
- ch == '}' || ch == '[' || ch == ']';
-}
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
static bool IsSpaceEquiv(int state) {
return (state <= SCE_C_COMMENTDOC) ||
(state == SCE_C_COMMENTDOCKEYWORDERROR);
}
+// Preconditions: sc.currentPos points to a character after '+' or '-'.
+// The test for pos reaching 0 should be redundant,
+// and is in only for safety measures.
+// Limitation: this code will give the incorrect answer for code like
+// a = b+++/ptn/...
+// Putting a space between the '++' post-inc operator and the '+' binary op
+// fixes this, and is highly recommended for readability anyway.
+static bool FollowsPostfixOperator(StyleContext &sc, Accessor &styler) {
+ int pos = (int) sc.currentPos;
+ while (--pos > 0) {
+ char ch = styler[pos];
+ if (ch == '+' || ch == '-') {
+ return styler[pos - 1] == ch;
+ }
+ }
+ return false;
+}
+
static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
Accessor &styler, bool caseSensitive) {
bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor") != 0;
+ CharacterSet setOKBeforeRE(CharacterSet::setNone, "([{=,:;!%^&*|?~+-");
+ CharacterSet setCouldBePostOp(CharacterSet::setNone, "+-");
+
+ CharacterSet setDoxygen(CharacterSet::setLower, "$@\\&<>#{}[]");
+
+ CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true);
+ CharacterSet setWord(CharacterSet::setAlphaNum, "._", 0x80, true);
+ if (styler.GetPropertyInt("lexer.cpp.allow.dollars", 1) != 0) {
+ setWordStart.Add('$');
+ setWord.Add('$');
+ }
+
int chPrevNonWhite = ' ';
int visibleChars = 0;
bool lastWordWasUUID = false;
if (sc.atLineStart) {
if (sc.state == SCE_C_STRING) {
- // Prevent SCE_C_STRINGEOL from leaking back to previous line which
+ // Prevent SCE_C_STRINGEOL from leaking back to previous line which
// ends with a line continuation by locking in the state upto this position.
sc.SetState(SCE_C_STRING);
}
break;
case SCE_C_NUMBER:
// We accept almost anything because of hex. and number suffixes
- if (!IsAWordChar(sc.ch)) {
+ if (!setWord.Contains(sc.ch)) {
sc.SetState(SCE_C_DEFAULT);
}
break;
case SCE_C_IDENTIFIER:
- if (!IsAWordChar(sc.ch) || (sc.ch == '.')) {
+ if (!setWord.Contains(sc.ch) || (sc.ch == '.')) {
char s[1000];
if (caseSensitive) {
sc.GetCurrent(s, sizeof(s));
sc.ChangeState(SCE_C_COMMENTDOCKEYWORDERROR);
sc.Forward();
sc.ForwardSetState(SCE_C_DEFAULT);
- } else if (!IsADoxygenChar(sc.ch)) {
+ } else if (!setDoxygen.Contains(sc.ch)) {
char s[100];
if (caseSensitive) {
sc.GetCurrent(s, sizeof(s));
} else {
sc.GetCurrentLowered(s, sizeof(s));
}
- if (!isspace(sc.ch) || !keywords3.InList(s + 1)) {
+ if (!IsASpace(sc.ch) || !keywords3.InList(s + 1)) {
sc.ChangeState(SCE_C_COMMENTDOCKEYWORDERROR);
}
sc.SetState(styleBeforeDCKeyword);
} else {
sc.SetState(SCE_C_NUMBER);
}
- } else if (IsAWordStart(sc.ch) || (sc.ch == '@')) {
+ } else if (setWordStart.Contains(sc.ch) || (sc.ch == '@')) {
if (lastWordWasUUID) {
sc.SetState(SCE_C_UUID);
lastWordWasUUID = false;
sc.SetState(SCE_C_COMMENTLINEDOC);
else
sc.SetState(SCE_C_COMMENTLINE);
- } else if (sc.ch == '/' && IsOKBeforeRE(chPrevNonWhite)) {
+ } else if (sc.ch == '/' && setOKBeforeRE.Contains(chPrevNonWhite) &&
+ (!setCouldBePostOp.Contains(chPrevNonWhite) || !FollowsPostfixOperator(sc, styler))) {
sc.SetState(SCE_C_REGEX); // JavaScript's RegEx
} else if (sc.ch == '\"') {
sc.SetState(SCE_C_STRING);
// 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 FoldNoBoxCppDoc(unsigned int startPos, int length, int initStyle,
- Accessor &styler) {
+static void FoldCppDoc(unsigned int startPos, int length, int initStyle,
+ WordList *[], Accessor &styler) {
bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
bool foldPreprocessor = styler.GetPropertyInt("fold.preprocessor") != 0;
bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
styleNext = styler.StyleAt(i + 1);
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
if (foldComment && IsStreamCommentStyle(style)) {
- if (!IsStreamCommentStyle(stylePrev)) {
+ if (!IsStreamCommentStyle(stylePrev) && (stylePrev != SCE_C_COMMENTLINEDOC)) {
levelNext++;
- } else if (!IsStreamCommentStyle(styleNext) && !atEOL) {
+ } else if (!IsStreamCommentStyle(styleNext) && (styleNext != SCE_C_COMMENTLINEDOC) && !atEOL) {
// Comments don't end at end of line and the next character may be unstyled.
levelNext--;
}
levelMinCurrent = levelCurrent;
visibleChars = 0;
}
- if (!isspacechar(ch))
+ if (!IsASpace(ch))
visibleChars++;
}
}
-static void FoldCppDoc(unsigned int startPos, int length, int initStyle, WordList *[],
- Accessor &styler) {
- FoldNoBoxCppDoc(startPos, length, initStyle, styler);
-}
-
static const char * const cppWordLists[] = {
"Primary keywords and identifiers",
"Secondary keywords and identifiers",
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
static inline bool IsAWordChar(const unsigned int ch) {
return (isalnum(ch) || ch == '-' || ch == '_' || ch >= 161); // _ is not in fact correct CSS word-character
0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0,16 /* M - X */
};
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
#ifdef BUILD_AS_EXTERNAL_LEXER
/*
(actually seems to work!)
--- /dev/null
+// Scintilla source code edit control
+/** @file LexCmake.cxx
+ ** Lexer for Cmake
+ **/
+// Copyright 2007 by Cristian Adam <cristian [dot] adam [at] gmx [dot] net>
+// based on the NSIS lexer
+// The License.txt file describes the conditions under which this software may be distributed.
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+static bool isCmakeNumber(char ch)
+{
+ return(ch >= '0' && ch <= '9');
+}
+
+static bool isCmakeChar(char ch)
+{
+ return(ch == '.' ) || (ch == '_' ) || isCmakeNumber(ch) || (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z');
+}
+
+static bool isCmakeLetter(char ch)
+{
+ return(ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z');
+}
+
+static bool CmakeNextLineHasElse(unsigned int start, unsigned int end, Accessor &styler)
+{
+ int nNextLine = -1;
+ for ( unsigned int i = start; i < end; i++ ) {
+ char cNext = styler.SafeGetCharAt( i );
+ if ( cNext == '\n' ) {
+ nNextLine = i+1;
+ break;
+ }
+ }
+
+ if ( nNextLine == -1 ) // We never foudn the next line...
+ return false;
+
+ for ( unsigned int firstChar = nNextLine; firstChar < end; firstChar++ ) {
+ char cNext = styler.SafeGetCharAt( firstChar );
+ if ( cNext == ' ' )
+ continue;
+ if ( cNext == '\t' )
+ continue;
+ if ( styler.Match(firstChar, "ELSE") || styler.Match(firstChar, "else"))
+ return true;
+ break;
+ }
+
+ return false;
+}
+
+static int calculateFoldCmake(unsigned int start, unsigned int end, int foldlevel, Accessor &styler, bool bElse)
+{
+ // If the word is too long, it is not what we are looking for
+ if ( end - start > 20 )
+ return foldlevel;
+
+ int newFoldlevel = foldlevel;
+
+ char s[20]; // The key word we are looking for has atmost 13 characters
+ for (unsigned int i = 0; i < end - start + 1 && i < 19; i++) {
+ s[i] = static_cast<char>( styler[ start + i ] );
+ s[i + 1] = '\0';
+ }
+
+ if ( CompareCaseInsensitive(s, "IF") == 0 || CompareCaseInsensitive(s, "WHILE") == 0
+ || CompareCaseInsensitive(s, "MACRO") == 0 || CompareCaseInsensitive(s, "FOREACH") == 0
+ || CompareCaseInsensitive(s, "ELSEIF") == 0 )
+ newFoldlevel++;
+ else if ( CompareCaseInsensitive(s, "ENDIF") == 0 || CompareCaseInsensitive(s, "ENDWHILE") == 0
+ || CompareCaseInsensitive(s, "ENDMACRO") == 0 || CompareCaseInsensitive(s, "ENDFOREACH") == 0)
+ newFoldlevel--;
+ else if ( bElse && CompareCaseInsensitive(s, "ELSEIF") == 0 )
+ newFoldlevel++;
+ else if ( bElse && CompareCaseInsensitive(s, "ELSE") == 0 )
+ newFoldlevel++;
+
+ return newFoldlevel;
+}
+
+static int classifyWordCmake(unsigned int start, unsigned int end, WordList *keywordLists[], Accessor &styler )
+{
+ char word[100] = {0};
+ char lowercaseWord[100] = {0};
+
+ WordList &Commands = *keywordLists[0];
+ WordList &Parameters = *keywordLists[1];
+ WordList &UserDefined = *keywordLists[2];
+
+ for (unsigned int i = 0; i < end - start + 1 && i < 99; i++) {
+ word[i] = static_cast<char>( styler[ start + i ] );
+ lowercaseWord[i] = static_cast<char>(tolower(word[i]));
+ }
+
+ // Check for special words...
+ if ( CompareCaseInsensitive(word, "MACRO") == 0 || CompareCaseInsensitive(word, "ENDMACRO") == 0 )
+ return SCE_CMAKE_MACRODEF;
+
+ if ( CompareCaseInsensitive(word, "IF") == 0 || CompareCaseInsensitive(word, "ENDIF") == 0 )
+ return SCE_CMAKE_IFDEFINEDEF;
+
+ if ( CompareCaseInsensitive(word, "ELSEIF") == 0 || CompareCaseInsensitive(word, "ELSE") == 0 )
+ return SCE_CMAKE_IFDEFINEDEF;
+
+ if ( CompareCaseInsensitive(word, "WHILE") == 0 || CompareCaseInsensitive(word, "ENDWHILE") == 0)
+ return SCE_CMAKE_WHILEDEF;
+
+ if ( CompareCaseInsensitive(word, "FOREACH") == 0 || CompareCaseInsensitive(word, "ENDFOREACH") == 0)
+ return SCE_CMAKE_FOREACHDEF;
+
+ if ( Commands.InList(lowercaseWord) )
+ return SCE_CMAKE_COMMANDS;
+
+ if ( Parameters.InList(word) )
+ return SCE_CMAKE_PARAMETERS;
+
+
+ if ( UserDefined.InList(word) )
+ return SCE_CMAKE_USERDEFINED;
+
+ if ( strlen(word) > 3 ) {
+ if ( word[1] == '{' && word[strlen(word)-1] == '}' )
+ return SCE_CMAKE_VARIABLE;
+ }
+
+ // To check for numbers
+ if ( isCmakeNumber( word[0] ) ) {
+ bool bHasSimpleCmakeNumber = true;
+ for (unsigned int j = 1; j < end - start + 1 && j < 99; j++) {
+ if ( !isCmakeNumber( word[j] ) ) {
+ bHasSimpleCmakeNumber = false;
+ break;
+ }
+ }
+
+ if ( bHasSimpleCmakeNumber )
+ return SCE_CMAKE_NUMBER;
+ }
+
+ return SCE_CMAKE_DEFAULT;
+}
+
+static void ColouriseCmakeDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler)
+{
+ int state = SCE_CMAKE_DEFAULT;
+ if ( startPos > 0 )
+ state = styler.StyleAt(startPos-1); // Use the style from the previous line, usually default, but could be commentbox
+
+ styler.StartAt( startPos );
+ styler.GetLine( startPos );
+
+ unsigned int nLengthDoc = startPos + length;
+ styler.StartSegment( startPos );
+
+ char cCurrChar;
+ bool bVarInString = false;
+ bool bClassicVarInString = false;
+
+ unsigned int i;
+ for ( i = startPos; i < nLengthDoc; i++ ) {
+ cCurrChar = styler.SafeGetCharAt( i );
+ char cNextChar = styler.SafeGetCharAt(i+1);
+
+ switch (state) {
+ case SCE_CMAKE_DEFAULT:
+ if ( cCurrChar == '#' ) { // we have a comment line
+ styler.ColourTo(i-1, state );
+ state = SCE_CMAKE_COMMENT;
+ break;
+ }
+ if ( cCurrChar == '"' ) {
+ styler.ColourTo(i-1, state );
+ state = SCE_CMAKE_STRINGDQ;
+ bVarInString = false;
+ bClassicVarInString = false;
+ break;
+ }
+ if ( cCurrChar == '\'' ) {
+ styler.ColourTo(i-1, state );
+ state = SCE_CMAKE_STRINGRQ;
+ bVarInString = false;
+ bClassicVarInString = false;
+ break;
+ }
+ if ( cCurrChar == '`' ) {
+ styler.ColourTo(i-1, state );
+ state = SCE_CMAKE_STRINGLQ;
+ bVarInString = false;
+ bClassicVarInString = false;
+ break;
+ }
+
+ // CMake Variable
+ if ( cCurrChar == '$' || isCmakeChar(cCurrChar)) {
+ styler.ColourTo(i-1,state);
+ state = SCE_CMAKE_VARIABLE;
+
+ // If it is a number, we must check and set style here first...
+ if ( isCmakeNumber(cCurrChar) && (cNextChar == '\t' || cNextChar == ' ' || cNextChar == '\r' || cNextChar == '\n' ) )
+ styler.ColourTo( i, SCE_CMAKE_NUMBER);
+
+ break;
+ }
+
+ break;
+ case SCE_CMAKE_COMMENT:
+ if ( cNextChar == '\n' || cNextChar == '\r' ) {
+ // Special case:
+ if ( cCurrChar == '\\' ) {
+ styler.ColourTo(i-2,state);
+ styler.ColourTo(i,SCE_CMAKE_DEFAULT);
+ }
+ else {
+ styler.ColourTo(i,state);
+ state = SCE_CMAKE_DEFAULT;
+ }
+ }
+ break;
+ case SCE_CMAKE_STRINGDQ:
+ case SCE_CMAKE_STRINGLQ:
+ case SCE_CMAKE_STRINGRQ:
+
+ if ( styler.SafeGetCharAt(i-1) == '\\' && styler.SafeGetCharAt(i-2) == '$' )
+ break; // Ignore the next character, even if it is a quote of some sort
+
+ if ( cCurrChar == '"' && state == SCE_CMAKE_STRINGDQ ) {
+ styler.ColourTo(i,state);
+ state = SCE_CMAKE_DEFAULT;
+ break;
+ }
+
+ if ( cCurrChar == '`' && state == SCE_CMAKE_STRINGLQ ) {
+ styler.ColourTo(i,state);
+ state = SCE_CMAKE_DEFAULT;
+ break;
+ }
+
+ if ( cCurrChar == '\'' && state == SCE_CMAKE_STRINGRQ ) {
+ styler.ColourTo(i,state);
+ state = SCE_CMAKE_DEFAULT;
+ break;
+ }
+
+ if ( cNextChar == '\r' || cNextChar == '\n' ) {
+ int nCurLine = styler.GetLine(i+1);
+ int nBack = i;
+ // We need to check if the previous line has a \ in it...
+ bool bNextLine = false;
+
+ while ( nBack > 0 ) {
+ if ( styler.GetLine(nBack) != nCurLine )
+ break;
+
+ char cTemp = styler.SafeGetCharAt(nBack, 'a'); // Letter 'a' is safe here
+
+ if ( cTemp == '\\' ) {
+ bNextLine = true;
+ break;
+ }
+ if ( cTemp != '\r' && cTemp != '\n' && cTemp != '\t' && cTemp != ' ' )
+ break;
+
+ nBack--;
+ }
+
+ if ( bNextLine ) {
+ styler.ColourTo(i+1,state);
+ }
+ if ( bNextLine == false ) {
+ styler.ColourTo(i,state);
+ state = SCE_CMAKE_DEFAULT;
+ }
+ }
+ break;
+
+ case SCE_CMAKE_VARIABLE:
+
+ // CMake Variable:
+ if ( cCurrChar == '$' )
+ state = SCE_CMAKE_DEFAULT;
+ else if ( cCurrChar == '\\' && (cNextChar == 'n' || cNextChar == 'r' || cNextChar == 't' ) )
+ state = SCE_CMAKE_DEFAULT;
+ else if ( (isCmakeChar(cCurrChar) && !isCmakeChar( cNextChar) && cNextChar != '}') || cCurrChar == '}' ) {
+ state = classifyWordCmake( styler.GetStartSegment(), i, keywordLists, styler );
+ styler.ColourTo( i, state);
+ state = SCE_CMAKE_DEFAULT;
+ }
+ else if ( !isCmakeChar( cCurrChar ) && cCurrChar != '{' && cCurrChar != '}' ) {
+ if ( classifyWordCmake( styler.GetStartSegment(), i-1, keywordLists, styler) == SCE_CMAKE_NUMBER )
+ styler.ColourTo( i-1, SCE_CMAKE_NUMBER );
+
+ state = SCE_CMAKE_DEFAULT;
+
+ if ( cCurrChar == '"' ) {
+ state = SCE_CMAKE_STRINGDQ;
+ bVarInString = false;
+ bClassicVarInString = false;
+ }
+ else if ( cCurrChar == '`' ) {
+ state = SCE_CMAKE_STRINGLQ;
+ bVarInString = false;
+ bClassicVarInString = false;
+ }
+ else if ( cCurrChar == '\'' ) {
+ state = SCE_CMAKE_STRINGRQ;
+ bVarInString = false;
+ bClassicVarInString = false;
+ }
+ else if ( cCurrChar == '#' ) {
+ state = SCE_CMAKE_COMMENT;
+ }
+ }
+ break;
+ }
+
+ if ( state == SCE_CMAKE_COMMENT) {
+ styler.ColourTo(i,state);
+ }
+ else if ( state == SCE_CMAKE_STRINGDQ || state == SCE_CMAKE_STRINGLQ || state == SCE_CMAKE_STRINGRQ ) {
+ bool bIngoreNextDollarSign = false;
+
+ if ( bVarInString && cCurrChar == '$' ) {
+ bVarInString = false;
+ bIngoreNextDollarSign = true;
+ }
+ else if ( bVarInString && cCurrChar == '\\' && (cNextChar == 'n' || cNextChar == 'r' || cNextChar == 't' || cNextChar == '"' || cNextChar == '`' || cNextChar == '\'' ) ) {
+ styler.ColourTo( i+1, SCE_CMAKE_STRINGVAR);
+ bVarInString = false;
+ bIngoreNextDollarSign = false;
+ }
+
+ else if ( bVarInString && !isCmakeChar(cNextChar) ) {
+ int nWordState = classifyWordCmake( styler.GetStartSegment(), i, keywordLists, styler);
+ if ( nWordState == SCE_CMAKE_VARIABLE )
+ styler.ColourTo( i, SCE_CMAKE_STRINGVAR);
+ bVarInString = false;
+ }
+ // Covers "${TEST}..."
+ else if ( bClassicVarInString && cNextChar == '}' ) {
+ styler.ColourTo( i+1, SCE_CMAKE_STRINGVAR);
+ bClassicVarInString = false;
+ }
+
+ // Start of var in string
+ if ( !bIngoreNextDollarSign && cCurrChar == '$' && cNextChar == '{' ) {
+ styler.ColourTo( i-1, state);
+ bClassicVarInString = true;
+ bVarInString = false;
+ }
+ else if ( !bIngoreNextDollarSign && cCurrChar == '$' ) {
+ styler.ColourTo( i-1, state);
+ bVarInString = true;
+ bClassicVarInString = false;
+ }
+ }
+ }
+
+ // Colourise remaining document
+ styler.ColourTo(nLengthDoc-1,state);
+}
+
+static void FoldCmakeDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler)
+{
+ // No folding enabled, no reason to continue...
+ if ( styler.GetPropertyInt("fold") == 0 )
+ return;
+
+ bool foldAtElse = styler.GetPropertyInt("fold.at.else", 0) == 1;
+
+ int lineCurrent = styler.GetLine(startPos);
+ unsigned int safeStartPos = styler.LineStart( lineCurrent );
+
+ bool bArg1 = true;
+ int nWordStart = -1;
+
+ int levelCurrent = SC_FOLDLEVELBASE;
+ if (lineCurrent > 0)
+ levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
+ int levelNext = levelCurrent;
+
+ for (unsigned int i = safeStartPos; i < startPos + length; i++) {
+ char chCurr = styler.SafeGetCharAt(i);
+
+ if ( bArg1 ) {
+ if ( nWordStart == -1 && (isCmakeLetter(chCurr)) ) {
+ nWordStart = i;
+ }
+ else if ( isCmakeLetter(chCurr) == false && nWordStart > -1 ) {
+ int newLevel = calculateFoldCmake( nWordStart, i-1, levelNext, styler, foldAtElse);
+
+ if ( newLevel == levelNext ) {
+ if ( foldAtElse ) {
+ if ( CmakeNextLineHasElse(i, startPos + length, styler) )
+ levelNext--;
+ }
+ }
+ else
+ levelNext = newLevel;
+ bArg1 = false;
+ }
+ }
+
+ if ( chCurr == '\n' ) {
+ if ( bArg1 && foldAtElse) {
+ if ( CmakeNextLineHasElse(i, startPos + length, styler) )
+ levelNext--;
+ }
+
+ // If we are on a new line...
+ int levelUse = levelCurrent;
+ int lev = levelUse | levelNext << 16;
+ if (levelUse < levelNext )
+ lev |= SC_FOLDLEVELHEADERFLAG;
+ if (lev != styler.LevelAt(lineCurrent))
+ styler.SetLevel(lineCurrent, lev);
+
+ lineCurrent++;
+ levelCurrent = levelNext;
+ bArg1 = true; // New line, lets look at first argument again
+ nWordStart = -1;
+ }
+ }
+
+ int levelUse = levelCurrent;
+ int lev = levelUse | levelNext << 16;
+ if (levelUse < levelNext)
+ lev |= SC_FOLDLEVELHEADERFLAG;
+ if (lev != styler.LevelAt(lineCurrent))
+ styler.SetLevel(lineCurrent, lev);
+}
+
+static const char * const cmakeWordLists[] = {
+ "Commands",
+ "Parameters",
+ "UserDefined",
+ 0,
+ 0,};
+
+LexerModule lmCmake(SCLEX_CMAKE, ColouriseCmakeDoc, "cmake", FoldCmakeDoc, cmakeWordLists);
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
static void ColouriseConfDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler)
{
int state = SCE_CONF_DEFAULT;
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
static void ColouriseNncrontabDoc(unsigned int startPos, int length, int, WordList
*keywordLists[], Accessor &styler)
{
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
static inline bool IsAWordChar(const int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '.' ||
--- /dev/null
+/** @file LexD.cxx
+ ** Lexer for D.
+ **
+ ** Copyright (c) 2006 by Waldemar Augustyn <waldemar@wdmsys.com>
+ **/
+// Copyright 1998-2005 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+#ifdef SCI_NAMESPACE
+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.
+/*/
+
+// We use custom qualifiers since it is not clear what D allows.
+
+static bool IsWordStart(int ch) {
+ return isascii(ch) && (isalpha(ch) || ch == '_');
+}
+
+static bool IsWord(int ch) {
+ return isascii(ch) && (isalnum(ch) || ch == '_');
+}
+
+static bool IsDoxygen(int ch) {
+ if (isascii(ch) && islower(ch))
+ return true;
+ if (ch == '$' || ch == '@' || ch == '\\' ||
+ ch == '&' || ch == '#' || ch == '<' || ch == '>' ||
+ ch == '{' || ch == '}' || ch == '[' || ch == ']')
+ return true;
+ return false;
+}
+
+
+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];
+
+ int styleBeforeDCKeyword = SCE_D_DEFAULT;
+
+ StyleContext sc(startPos, length, initStyle, styler);
+
+ int curLine = styler.GetLine(startPos);
+ int curNcLevel = curLine > 0? styler.GetLineState(curLine-1): 0;
+
+ for (; sc.More(); sc.Forward()) {
+
+ 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);
+ }
+
+ // 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;
+ }
+ }
+
+ // 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 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<char>(sc.ch))) {
+ sc.SetState(SCE_D_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;
+}
+
+// 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",
+ 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++;
+ }
+}
+
+static void FoldDDoc(unsigned int startPos, int length, int initStyle,
+ WordList *[], Accessor &styler) {
+ FoldDoc(startPos, length, initStyle, styler);
+}
+
+static const char * const dWordLists[] = {
+ "Primary keywords and identifiers",
+ "Secondary keywords and identifiers",
+ "Documentation comment keywords",
+ "Type definitions and aliases",
+ 0,
+ };
+
+static void ColouriseDDoc(unsigned int startPos, int length,
+ int initStyle, WordList *keywordlists[], Accessor &styler) {
+ ColouriseDoc(startPos, length, initStyle, keywordlists, styler, true);
+}
+
+LexerModule lmD(SCLEX_D, ColouriseDDoc, "d", FoldDDoc, dWordLists);
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
static inline bool IsAWordChar(const int ch) {
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
static inline bool isEiffelOperator(unsigned int ch) {
// '.' left out as it is used to make up numbers
return ch == '*' || ch == '/' || ch == '\\' || ch == '-' || ch == '+' ||
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
/*
TODO:
o _Param should be a new lexical type
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
static bool IsFlagShipComment(Accessor &styler, int pos, int len) {
return len>0 && styler[pos]=='\'';
}
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
bool is_whitespace(int ch){
return ch == '\n' || ch == '\r' || ch == '\t' || ch == ' ';
}
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
/***********************************************/
static inline bool IsAWordChar(const int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '_' || ch == '%');
--- /dev/null
+// Scintilla source code edit control
+/** @file LexGAP.cxx
+ ** Lexer for the GAP language. (The GAP System for Computational Discrete Algebra)
+ ** http://www.gap-system.org
+ **/
+// Copyright 2007 by Istvan Szollosi ( szteven <at> gmail <dot> com )
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+static inline bool IsGAPOperator(char ch) {
+ if (isalnum(ch)) return false;
+ if (ch == '+' || ch == '-' || ch == '*' || ch == '/' ||
+ ch == '^' || ch == ',' || ch == '!' || ch == '.' ||
+ ch == '=' || ch == '<' || ch == '>' || ch == '(' ||
+ ch == ')' || ch == ';' || ch == '[' || ch == ']' ||
+ ch == '{' || ch == '}' || ch == ':' )
+ return true;
+ return false;
+}
+
+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<char>(styler[start + i]);
+ i++;
+ }
+ s[i] = '\0';
+}
+
+static void ColouriseGAPDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) {
+
+ WordList &keywords1 = *keywordlists[0];
+ WordList &keywords2 = *keywordlists[1];
+ WordList &keywords3 = *keywordlists[2];
+ WordList &keywords4 = *keywordlists[3];
+
+ // Do not leak onto next line
+ if (initStyle == SCE_GAP_STRINGEOL) initStyle = SCE_GAP_DEFAULT;
+
+ StyleContext sc(startPos, length, initStyle, styler);
+
+ for (; sc.More(); sc.Forward()) {
+
+ // Prevent SCE_GAP_STRINGEOL from leaking back to previous line
+ if ( sc.atLineStart ) {
+ if (sc.state == SCE_GAP_STRING) sc.SetState(SCE_GAP_STRING);
+ if (sc.state == SCE_GAP_CHAR) sc.SetState(SCE_GAP_CHAR);
+ }
+
+ // 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;
+ }
+ }
+
+ // Determine if the current state should terminate
+ switch (sc.state) {
+ case SCE_GAP_OPERATOR :
+ sc.SetState(SCE_GAP_DEFAULT);
+ break;
+
+ case SCE_GAP_NUMBER :
+ if (!IsADigit(sc.ch)) {
+ if (sc.ch == '\\') {
+ if (!sc.atLineEnd) {
+ if (!IsADigit(sc.chNext)) {
+ sc.Forward();
+ sc.ChangeState(SCE_GAP_IDENTIFIER);
+ }
+ }
+ } else if (isalpha(sc.ch) || sc.ch == '_') {
+ sc.ChangeState(SCE_GAP_IDENTIFIER);
+ }
+ else sc.SetState(SCE_GAP_DEFAULT);
+ }
+ break;
+
+ case SCE_GAP_IDENTIFIER :
+ if (!(iswordstart(static_cast<char>(sc.ch)) || sc.ch == '$')) {
+ if (sc.ch == '\\') sc.Forward();
+ else {
+ char s[1000];
+ sc.GetCurrent(s, sizeof(s));
+ if (keywords1.InList(s)) {
+ sc.ChangeState(SCE_GAP_KEYWORD);
+ } else if (keywords2.InList(s)) {
+ sc.ChangeState(SCE_GAP_KEYWORD2);
+ } else if (keywords3.InList(s)) {
+ sc.ChangeState(SCE_GAP_KEYWORD3);
+ } else if (keywords4.InList(s)) {
+ sc.ChangeState(SCE_GAP_KEYWORD4);
+ }
+ sc.SetState(SCE_GAP_DEFAULT);
+ }
+ }
+ break;
+
+ case SCE_GAP_COMMENT :
+ if (sc.atLineEnd) {
+ sc.SetState(SCE_GAP_DEFAULT);
+ }
+ break;
+
+ case SCE_GAP_STRING:
+ if (sc.atLineEnd) {
+ sc.ChangeState(SCE_GAP_STRINGEOL);
+ } else if (sc.ch == '\\') {
+ if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+ sc.Forward();
+ }
+ } else if (sc.ch == '\"') {
+ sc.ForwardSetState(SCE_GAP_DEFAULT);
+ }
+ break;
+
+ case SCE_GAP_CHAR:
+ if (sc.atLineEnd) {
+ sc.ChangeState(SCE_GAP_STRINGEOL);
+ } else if (sc.ch == '\\') {
+ if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+ sc.Forward();
+ }
+ } else if (sc.ch == '\'') {
+ sc.ForwardSetState(SCE_GAP_DEFAULT);
+ }
+ break;
+
+ case SCE_GAP_STRINGEOL:
+ if (sc.atLineStart) {
+ sc.SetState(SCE_GAP_DEFAULT);
+ }
+ break;
+ }
+
+ // Determine if a new state should be entered
+ if (sc.state == SCE_GAP_DEFAULT) {
+ if (IsGAPOperator(static_cast<char>(sc.ch))) {
+ sc.SetState(SCE_GAP_OPERATOR);
+ }
+ else if (IsADigit(sc.ch)) {
+ sc.SetState(SCE_GAP_NUMBER);
+ } else if (isalpha(sc.ch) || sc.ch == '_' || sc.ch == '\\' || sc.ch == '$' || sc.ch == '~') {
+ sc.SetState(SCE_GAP_IDENTIFIER);
+ if (sc.ch == '\\') sc.Forward();
+ } else if (sc.ch == '#') {
+ sc.SetState(SCE_GAP_COMMENT);
+ } else if (sc.ch == '\"') {
+ sc.SetState(SCE_GAP_STRING);
+ } else if (sc.ch == '\'') {
+ sc.SetState(SCE_GAP_CHAR);
+ }
+ }
+
+ }
+ sc.Complete();
+}
+
+static int ClassifyFoldPointGAP(const char* s) {
+ int level = 0;
+ if (strcmp(s, "function") == 0 ||
+ strcmp(s, "do") == 0 ||
+ strcmp(s, "if") == 0 ||
+ strcmp(s, "repeat") == 0 ) {
+ level = 1;
+ } else if (strcmp(s, "end") == 0 ||
+ strcmp(s, "od") == 0 ||
+ strcmp(s, "fi") == 0 ||
+ strcmp(s, "until") == 0 ) {
+ level = -1;
+ }
+ return level;
+}
+
+static void FoldGAPDoc( unsigned int startPos, int length, int initStyle, WordList** , 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[startPos];
+ int styleNext = styler.StyleAt(startPos);
+ int style = initStyle;
+
+ int lastStart = 0;
+
+ 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 (stylePrev != SCE_GAP_KEYWORD && style == SCE_GAP_KEYWORD) {
+ // Store last word start point.
+ lastStart = i;
+ }
+
+ if (stylePrev == SCE_GAP_KEYWORD) {
+ if(iswordchar(ch) && !iswordchar(chNext)) {
+ char s[100];
+ GetRange(lastStart, i, styler, s, sizeof(s));
+ levelCurrent += ClassifyFoldPointGAP(s);
+ }
+ }
+
+ if (atEOL) {
+ int lev = levelPrev;
+ if ((levelCurrent > levelPrev) && (visibleChars > 0))
+ lev |= SC_FOLDLEVELHEADERFLAG;
+ if (lev != styler.LevelAt(lineCurrent)) {
+ styler.SetLevel(lineCurrent, lev);
+ }
+ lineCurrent++;
+ levelPrev = levelCurrent;
+ visibleChars = 0;
+ }
+
+ if (!isspacechar(ch))
+ visibleChars++;
+ }
+
+ int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
+ styler.SetLevel(lineCurrent, levelPrev | flagsNext);
+}
+
+static const char * const GAPWordListDesc[] = {
+ "Keywords 1",
+ "Keywords 2",
+ "Keywords 3 (unused)",
+ "Keywords 4 (unused)",
+ 0
+};
+
+LexerModule lmGAP(
+ SCLEX_GAP,
+ ColouriseGAPDoc,
+ "gap",
+ FoldGAPDoc,
+ GAPWordListDesc);
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
#define debug Platform::DebugPrintf
static inline bool IsAWordChar(const int ch) {
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"
+#include "CharacterSet.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
#define SCE_HA_JS (SCE_HJA_START - SCE_HJ_START)
#define SCE_HA_VBS (SCE_HBA_START - SCE_HB_START)
return (ch < 0x80) && (isalnum(ch) || ch == '_');
}
+inline bool IsOperator(int ch) {
+ if (isascii(ch) && isalnum(ch))
+ return false;
+ // '.' left out as it is used to make up numbers
+ 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 == '~')
+ return true;
+ return false;
+}
+
static inline int MakeLowerCase(int ch) {
if (ch < 'A' || ch > 'Z')
return ch;
return eScriptJS;
if (strstr(s, "php"))
return eScriptPHP;
- if (strstr(s, "xml"))
+ if (strstr(s, "xml")) {
+ const char *xml = strstr(s, "xml");
+ for (const char *t=s; t<xml; t++) {
+ if (!IsASpace(*t)) {
+ return prevValue;
+ }
+ }
return eScriptXML;
+ }
return prevValue;
}
}
static int statePrintForState(int state, script_mode inScriptType) {
- int StateToPrint;
-
- if ((state >= SCE_HP_START) && (state <= SCE_HP_IDENTIFIER)) {
- StateToPrint = state + ((inScriptType == eNonHtmlScript) ? 0 : SCE_HA_PYTHON);
- } else if ((state >= SCE_HB_START) && (state <= SCE_HB_STRINGEOL)) {
- StateToPrint = state + ((inScriptType == eNonHtmlScript) ? 0 : SCE_HA_VBS);
- } else if ((state >= SCE_HJ_START) && (state <= SCE_HJ_REGEX)) {
- StateToPrint = state + ((inScriptType == eNonHtmlScript) ? 0 : SCE_HA_JS);
- } else {
- StateToPrint = state;
+ int StateToPrint = state;
+
+ if (state >= SCE_HJ_START) {
+ if ((state >= SCE_HP_START) && (state <= SCE_HP_IDENTIFIER)) {
+ StateToPrint = state + ((inScriptType == eNonHtmlScript) ? 0 : SCE_HA_PYTHON);
+ } else if ((state >= SCE_HB_START) && (state <= SCE_HB_STRINGEOL)) {
+ StateToPrint = state + ((inScriptType == eNonHtmlScript) ? 0 : SCE_HA_VBS);
+ } else if ((state >= SCE_HJ_START) && (state <= SCE_HJ_REGEX)) {
+ StateToPrint = state + ((inScriptType == eNonHtmlScript) ? 0 : SCE_HA_JS);
+ }
}
return StateToPrint;
bool allowTermination = !isStringState(state);
if (allowTermination) {
switch (state) {
+ case SCE_HB_COMMENTLINE:
case SCE_HPHP_COMMENT:
case SCE_HP_COMMENTLINE:
case SCE_HPA_COMMENTLINE:
static int classifyTagHTML(unsigned int start, unsigned int end,
WordList &keywords, Accessor &styler, bool &tagDontFold,
- bool caseSensitive) {
+ bool caseSensitive, bool isXml) {
char s[30 + 2];
// Copy after the '<'
unsigned int i = 0;
s[i] = ' ';
s[i+1] = '\0';
+ // if the current language is XML, I can fold any tag
+ // if the current language is HTML, I don't want to fold certain tags (input, meta, etc.)
//...to find it in the list of no-container-tags
- // (There are many more. We will need a keywordlist in the property file for this)
- tagDontFold = (NULL != strstr("meta link img area br hr input ",s));
+ tagDontFold = (!isXml) && (NULL != strstr("meta link img area br hr input ",s));
//now we can remove the trailing space
s[i] = '\0';
return Result;
}
-static inline bool ishtmlwordchar(char ch) {
+static inline bool ishtmlwordchar(int ch) {
return !isascii(ch) ||
(isalnum(ch) || ch == '.' || ch == '-' || ch == '_' || ch == ':' || ch == '!' || ch == '#');
}
-static inline bool issgmlwordchar(char ch) {
+static inline bool issgmlwordchar(int ch) {
return !isascii(ch) ||
(isalnum(ch) || ch == '.' || ch == '_' || ch == ':' || ch == '!' || ch == '#' || ch == '[');
}
-static inline bool IsPhpWordStart(const unsigned char ch) {
+static inline bool IsPhpWordStart(int ch) {
return (isascii(ch) && (isalpha(ch) || (ch == '_'))) || (ch >= 0x7f);
}
-static inline bool IsPhpWordChar(char ch) {
+static inline bool IsPhpWordChar(int ch) {
return IsADigit(ch) || IsPhpWordStart(ch);
}
state == SCE_HJA_COMMENTLINE || state == SCE_HB_COMMENTLINE || state == SCE_HBA_COMMENTLINE;
}
-static bool isLineEnd(char ch) {
+static bool isLineEnd(int ch) {
return ch == '\r' || ch == '\n';
}
-static bool isOKBeforeRE(char ch) {
+static bool isOKBeforeRE(int ch) {
return (ch == '(') || (ch == '=') || (ch == ',');
}
}
static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
- Accessor &styler) {
+ Accessor &styler, bool isXml) {
WordList &keywords = *keywordlists[0];
WordList &keywords2 = *keywordlists[1];
WordList &keywords3 = *keywordlists[2];
WordList &keywords5 = *keywordlists[4];
WordList &keywords6 = *keywordlists[5]; // SGML (DTD) keywords
- // Lexer for HTML requires more lexical states (7 bits worth) than most lexers
- styler.StartAt(startPos, STYLE_MAX);
+ // Lexer for HTML requires more lexical states (8 bits worth) than most lexers
+ styler.StartAt(startPos, static_cast<char>(STYLE_MAX));
char prevWord[200];
prevWord[0] = '\0';
char phpStringDelimiter[200]; // PHP is not limited in length, we are
length++;
state = styler.StyleAt(startPos);
}
- styler.StartAt(startPos, STYLE_MAX);
+ styler.StartAt(startPos, static_cast<char>(STYLE_MAX));
int lineCurrent = styler.GetLine(startPos);
int lineState;
const bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
const bool caseSensitive = styler.GetPropertyInt("html.tags.case.sensitive", 0) != 0;
+ const CharacterSet setHTMLWord(CharacterSet::setAlphaNum, ".-_:!#", 0x80, true);
+ const CharacterSet setTagContinue(CharacterSet::setAlphaNum, ".-_:!#[", 0x80, true);
+ const CharacterSet setAttributeContinue(CharacterSet::setAlphaNum, ".-_:!#/", 0x80, true);
+
int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
int levelCurrent = levelPrev;
int visibleChars = 0;
- char chPrev = ' ';
- char ch = ' ';
- char chPrevNonWhite = ' ';
+ int chPrev = ' ';
+ int ch = ' ';
+ int chPrevNonWhite = ' ';
// look back to set chPrevNonWhite properly for better regex colouring
if (scriptLanguage == eScriptJS && startPos > 0) {
int back = startPos;
break;
}
if (style == SCE_HJ_SYMBOLS) {
- chPrevNonWhite = styler.SafeGetCharAt(back);
+ chPrevNonWhite = static_cast<unsigned char>(styler.SafeGetCharAt(back));
}
}
styler.StartSegment(startPos);
const int lengthDoc = startPos + length;
for (int i = startPos; i < lengthDoc; i++) {
- const char chPrev2 = chPrev;
+ const int chPrev2 = chPrev;
chPrev = ch;
- if (!isspacechar(ch) && state != SCE_HJ_COMMENT &&
+ if (!IsASpace(ch) && state != SCE_HJ_COMMENT &&
state != SCE_HJ_COMMENTLINE && state != SCE_HJ_COMMENTDOC)
chPrevNonWhite = ch;
- ch = styler[i];
- char chNext = styler.SafeGetCharAt(i + 1);
- const char chNext2 = styler.SafeGetCharAt(i + 2);
+ ch = static_cast<unsigned char>(styler[i]);
+ int chNext = static_cast<unsigned char>(styler.SafeGetCharAt(i + 1));
+ const int chNext2 = static_cast<unsigned char>(styler.SafeGetCharAt(i + 2));
// Handle DBCS codepages
- if (styler.IsLeadByte(ch)) {
+ if (styler.IsLeadByte(static_cast<char>(ch))) {
chPrev = ' ';
i += 1;
continue;
}
- if ((!isspacechar(ch) || !foldCompact) && fold)
+ if ((!IsASpace(ch) || !foldCompact) && fold)
visibleChars++;
// decide what is the current state to print (depending of the script tag)
case SCE_HJ_COMMENTDOC:
//case SCE_HJ_COMMENTLINE: // removed as this is a common thing done to hide
// the end of script marker from some JS interpreters.
+ case SCE_HB_COMMENTLINE:
+ case SCE_HBA_COMMENTLINE:
case SCE_HJ_DOUBLESTRING:
case SCE_HJ_SINGLESTRING:
case SCE_HJ_REGEX:
case SCE_HB_STRING:
+ case SCE_HBA_STRING:
case SCE_HP_STRING:
case SCE_HP_TRIPLE:
case SCE_HP_TRIPLEDOUBLE:
break;
default :
// check if the closing tag is a script tag
- if (state == SCE_HJ_COMMENTLINE) {
+ if (state == SCE_HJ_COMMENTLINE || isXml) {
char tag[7]; // room for the <script> tag
- char chr; // current char
- int j=0;
- chr = styler.SafeGetCharAt(i+2);
- while (j < 6 && !isspacechar(chr)) {
+ int j = 0;
+ char chr = styler.SafeGetCharAt(i+2);
+ while (j < 6 && !IsASpace(chr)) {
tag[j++] = static_cast<char>(MakeLowerCase(chr));
chr = styler.SafeGetCharAt(i+2+j);
}
levelCurrent++;
}
// should be better
- ch = styler.SafeGetCharAt(i);
+ ch = static_cast<unsigned char>(styler.SafeGetCharAt(i));
continue;
}
if (foldHTMLPreprocessor)
levelCurrent++;
// should be better
- ch = styler.SafeGetCharAt(i);
+ ch = static_cast<unsigned char>(styler.SafeGetCharAt(i));
continue;
}
styler.ColourTo(i - 1, StateToPrint);
state = SCE_H_SGML_SIMPLESTRING;
} else if ((ch == '-') && (chPrev == '-')) {
- styler.ColourTo(i - 2, StateToPrint);
+ if (static_cast<int>(styler.GetStartSegment()) <= (i - 2)) {
+ styler.ColourTo(i - 2, StateToPrint);
+ }
state = SCE_H_SGML_COMMENT;
} else if (isascii(ch) && isalpha(ch) && (chPrev == '%')) {
styler.ColourTo(i - 2, StateToPrint);
}
// find the length of the word
int size = 1;
- while (ishtmlwordchar(styler.SafeGetCharAt(i + size)))
+ while (setHTMLWord.Contains(static_cast<unsigned char>(styler.SafeGetCharAt(i + size))))
size++;
styler.ColourTo(i + size - 1, StateToPrint);
i += size - 1;
visibleChars += size - 1;
- ch = styler.SafeGetCharAt(i);
+ ch = static_cast<unsigned char>(styler.SafeGetCharAt(i));
if (scriptLanguage == eScriptSGMLblock) {
state = SCE_H_SGML_BLOCK_DEFAULT;
} else {
}
break;
case SCE_H_TAGUNKNOWN:
- if (!ishtmlwordchar(ch) && !((ch == '/') && (chPrev == '<')) && ch != '[') {
+ if (!setTagContinue.Contains(ch) && !((ch == '/') && (chPrev == '<'))) {
int eClass = classifyTagHTML(styler.GetStartSegment(),
- i - 1, keywords, styler, tagDontFold, caseSensitive);
+ i - 1, keywords, styler, tagDontFold, caseSensitive, isXml);
if (eClass == SCE_H_SCRIPT) {
if (!tagClosing) {
inScriptType = eNonHtmlScript;
}
break;
case SCE_H_ATTRIBUTE:
- if (!ishtmlwordchar(ch) && ch != '/' && ch != '-') {
+ if (!setAttributeContinue.Contains(ch)) {
if (inScriptType == eNonHtmlScript) {
int scriptLanguagePrev = scriptLanguage;
clientScript = segIsScriptingIndicator(styler, styler.GetStartSegment(), i - 1, scriptLanguage);
i++;
ch = chNext;
state = SCE_H_DEFAULT;
- } else if (ishtmlwordchar(ch)) {
+ } else if (setHTMLWord.Contains(ch)) {
styler.ColourTo(i - 1, StateToPrint);
state = SCE_H_ATTRIBUTE;
}
}
break;
case SCE_H_VALUE:
- if (!ishtmlwordchar(ch)) {
+ if (!setHTMLWord.Contains(ch)) {
if (ch == '\"' && chPrev == '=') {
// Should really test for being first character
state = SCE_H_DOUBLESTRING;
case SCE_HJ_DEFAULT:
case SCE_HJ_START:
case SCE_HJ_SYMBOLS:
- if (iswordstart(ch)) {
+ if (IsAWordStart(ch)) {
styler.ColourTo(i - 1, StateToPrint);
state = SCE_HJ_WORD;
} else if (ch == '/' && chNext == '*') {
styler.ColourTo(i - 1, StateToPrint);
state = SCE_HJ_COMMENTLINE;
i += 2;
- } else if (isoperator(ch)) {
+ } else if (IsOperator(ch)) {
styler.ColourTo(i - 1, StateToPrint);
styler.ColourTo(i, statePrintForState(SCE_HJ_SYMBOLS, inScriptType));
state = SCE_HJ_DEFAULT;
}
break;
case SCE_HJ_WORD:
- if (!iswordchar(ch)) {
+ if (!IsAWordChar(ch)) {
classifyWordHTJS(styler.GetStartSegment(), i - 1, keywords2, styler, inScriptType);
//styler.ColourTo(i - 1, eHTJSKeyword);
state = SCE_HJ_DEFAULT;
styler.ColourTo(i - 1, StateToPrint);
state = SCE_HJ_COMMENTLINE;
i += 2;
- } else if (isoperator(ch)) {
+ } else if (IsOperator(ch)) {
styler.ColourTo(i, statePrintForState(SCE_HJ_SYMBOLS, inScriptType));
state = SCE_HJ_DEFAULT;
}
while (isascii(chNext) && islower(chNext)) { // gobble regex flags
i++;
ch = chNext;
- chNext = styler.SafeGetCharAt(i + 1);
+ chNext = static_cast<unsigned char>(styler.SafeGetCharAt(i + 1));
}
}
styler.ColourTo(i, StateToPrint);
if (chNext == '\\' || chNext == '/') {
i++;
ch = chNext;
- chNext = styler.SafeGetCharAt(i + 1);
+ chNext = static_cast<unsigned char>(styler.SafeGetCharAt(i + 1));
}
}
break;
case SCE_HB_DEFAULT:
case SCE_HB_START:
- if (iswordstart(ch)) {
+ if (IsAWordStart(ch)) {
styler.ColourTo(i - 1, StateToPrint);
state = SCE_HB_WORD;
} else if (ch == '\'') {
styler.SafeGetCharAt(i + 3) == '-') {
styler.ColourTo(i - 1, StateToPrint);
state = SCE_HB_COMMENTLINE;
- } else if (isoperator(ch)) {
+ } else if (IsOperator(ch)) {
styler.ColourTo(i - 1, StateToPrint);
styler.ColourTo(i, statePrintForState(SCE_HB_DEFAULT, inScriptType));
state = SCE_HB_DEFAULT;
}
break;
case SCE_HB_WORD:
- if (!iswordchar(ch)) {
+ if (!IsAWordChar(ch)) {
state = classifyWordHTVB(styler.GetStartSegment(), i - 1, keywords3, styler, inScriptType);
if (state == SCE_HB_DEFAULT) {
if (ch == '\"') {
state = SCE_HB_STRING;
} else if (ch == '\'') {
state = SCE_HB_COMMENTLINE;
- } else if (isoperator(ch)) {
+ } else if (IsOperator(ch)) {
styler.ColourTo(i, statePrintForState(SCE_HB_DEFAULT, inScriptType));
state = SCE_HB_DEFAULT;
}
break;
case SCE_HP_DEFAULT:
case SCE_HP_START:
- if (iswordstart(ch)) {
+ if (IsAWordStart(ch)) {
styler.ColourTo(i - 1, StateToPrint);
state = SCE_HP_WORD;
} else if ((ch == '<') && (chNext == '!') && (chNext2 == '-') &&
state = SCE_HP_TRIPLEDOUBLE;
ch = ' ';
chPrev = ' ';
- chNext = styler.SafeGetCharAt(i + 1);
+ chNext = static_cast<unsigned char>(styler.SafeGetCharAt(i + 1));
} else {
// state = statePrintForState(SCE_HP_STRING,inScriptType);
state = SCE_HP_STRING;
state = SCE_HP_TRIPLE;
ch = ' ';
chPrev = ' ';
- chNext = styler.SafeGetCharAt(i + 1);
+ chNext = static_cast<unsigned char>(styler.SafeGetCharAt(i + 1));
} else {
state = SCE_HP_CHARACTER;
}
- } else if (isoperator(ch)) {
+ } else if (IsOperator(ch)) {
styler.ColourTo(i - 1, StateToPrint);
styler.ColourTo(i, statePrintForState(SCE_HP_OPERATOR, inScriptType));
} else if ((ch == ' ') || (ch == '\t')) {
}
break;
case SCE_HP_WORD:
- if (!iswordchar(ch)) {
+ if (!IsAWordChar(ch)) {
classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType);
state = SCE_HP_DEFAULT;
if (ch == '#') {
state = SCE_HP_TRIPLEDOUBLE;
ch = ' ';
chPrev = ' ';
- chNext = styler.SafeGetCharAt(i + 1);
+ chNext = static_cast<unsigned char>(styler.SafeGetCharAt(i + 1));
} else {
state = SCE_HP_STRING;
}
state = SCE_HP_TRIPLE;
ch = ' ';
chPrev = ' ';
- chNext = styler.SafeGetCharAt(i + 1);
+ chNext = static_cast<unsigned char>(styler.SafeGetCharAt(i + 1));
} else {
state = SCE_HP_CHARACTER;
}
- } else if (isoperator(ch)) {
+ } else if (IsOperator(ch)) {
styler.ColourTo(i, statePrintForState(SCE_HP_OPERATOR, inScriptType));
}
}
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
ch = chNext;
- chNext = styler.SafeGetCharAt(i + 1);
+ chNext = static_cast<unsigned char>(styler.SafeGetCharAt(i + 1));
}
} else if (ch == '\"') {
styler.ColourTo(i, StateToPrint);
if (chNext == '\"' || chNext == '\'' || chNext == '\\') {
i++;
ch = chNext;
- chNext = styler.SafeGetCharAt(i + 1);
+ chNext = static_cast<unsigned char>(styler.SafeGetCharAt(i + 1));
}
} else if (ch == '\'') {
styler.ColourTo(i, StateToPrint);
break;
///////////// start - PHP state handling
case SCE_HPHP_WORD:
- if (!iswordchar(ch)) {
+ if (!IsAWordChar(ch)) {
classifyWordHTPHP(styler.GetStartSegment(), i - 1, keywords5, styler);
if (ch == '/' && chNext == '*') {
i++;
state = SCE_HPHP_SIMPLESTRING;
} else if (ch == '$' && IsPhpWordStart(chNext)) {
state = SCE_HPHP_VARIABLE;
- } else if (isoperator(ch)) {
+ } else if (IsOperator(ch)) {
state = SCE_HPHP_OPERATOR;
} else {
state = SCE_HPHP_DEFAULT;
&& strchr(".xXabcdefABCDEF", ch) == NULL
&& ((ch != '-' && ch != '+') || (chPrev != 'e' && chPrev != 'E'))) {
styler.ColourTo(i - 1, SCE_HPHP_NUMBER);
- if (isoperator(ch))
+ if (IsOperator(ch))
state = SCE_HPHP_OPERATOR;
else
state = SCE_HPHP_DEFAULT;
case SCE_HPHP_VARIABLE:
if (!IsPhpWordChar(ch)) {
styler.ColourTo(i - 1, SCE_HPHP_VARIABLE);
- if (isoperator(ch))
+ if (IsOperator(ch))
state = SCE_HPHP_OPERATOR;
else
state = SCE_HPHP_DEFAULT;
styler.ColourTo(i - 1, StateToPrint);
state = SCE_HPHP_HSTRING_VARIABLE;
} else if (styler.Match(i, phpStringDelimiter)) {
- if (strlen(phpStringDelimiter) > 1)
- i += strlen(phpStringDelimiter) - 1;
+ const int psdLength = strlen(phpStringDelimiter);
+ if ((psdLength > 1) && ((i + psdLength) < lengthDoc))
+ i += psdLength - 1;
styler.ColourTo(i, StateToPrint);
state = SCE_HPHP_DEFAULT;
}
styler.ColourTo(i - 1, StateToPrint);
if (IsADigit(ch) || (ch == '.' && IsADigit(chNext))) {
state = SCE_HPHP_NUMBER;
- } else if (iswordstart(ch)) {
+ } else if (IsAWordStart(ch)) {
state = SCE_HPHP_WORD;
} else if (ch == '/' && chNext == '*') {
i++;
state = SCE_HPHP_SIMPLESTRING;
} else if (ch == '$' && IsPhpWordStart(chNext)) {
state = SCE_HPHP_VARIABLE;
- } else if (isoperator(ch)) {
+ } else if (IsOperator(ch)) {
state = SCE_HPHP_OPERATOR;
- } else if ((state == SCE_HPHP_OPERATOR) && (isspacechar(ch))) {
+ } else if ((state == SCE_HPHP_OPERATOR) && (IsASpace(ch))) {
state = SCE_HPHP_DEFAULT;
}
break;
state = SCE_HB_STRING;
} else if (ch == '\'') {
state = SCE_HB_COMMENTLINE;
- } else if (iswordstart(ch)) {
+ } else if (IsAWordStart(ch)) {
state = SCE_HB_WORD;
- } else if (isoperator(ch)) {
+ } else if (IsOperator(ch)) {
styler.ColourTo(i, SCE_HB_DEFAULT);
}
} else if (state == SCE_HBA_DEFAULT) { // One of the above succeeded
state = SCE_HBA_STRING;
} else if (ch == '\'') {
state = SCE_HBA_COMMENTLINE;
- } else if (iswordstart(ch)) {
+ } else if (IsAWordStart(ch)) {
state = SCE_HBA_WORD;
- } else if (isoperator(ch)) {
+ } else if (IsOperator(ch)) {
styler.ColourTo(i, SCE_HBA_DEFAULT);
}
} else if (state == SCE_HJ_DEFAULT) { // One of the above succeeded
state = SCE_HJ_DOUBLESTRING;
} else if ((ch == '\'') && (nonEmptySegment)) {
state = SCE_HJ_SINGLESTRING;
- } else if (iswordstart(ch)) {
+ } else if (IsAWordStart(ch)) {
state = SCE_HJ_WORD;
- } else if (isoperator(ch)) {
+ } else if (IsOperator(ch)) {
styler.ColourTo(i, statePrintForState(SCE_HJ_SYMBOLS, inScriptType));
}
}
}
}
+static void ColouriseXMLDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
+ Accessor &styler) {
+ // Passing in true because we're lexing XML
+ ColouriseHyperTextDoc(startPos, length, initStyle, keywordlists,styler, true);
+}
+
+static void ColouriseHTMLDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
+ Accessor &styler) {
+ // Passing in false because we're notlexing XML
+ ColouriseHyperTextDoc(startPos, length, initStyle, keywordlists,styler, false);
+}
+
static bool isASPScript(int state) {
return
(state >= SCE_HJA_START && state <= SCE_HJA_REGEX) ||
sc.SetState(SCE_H_DEFAULT);
}
} else if (sc.state == SCE_H_TAGUNKNOWN) {
- if (!ishtmlwordchar(static_cast<char>(sc.ch)) && !((sc.ch == '/') && (sc.chPrev == '<')) && sc.ch != '[') {
+ if (!ishtmlwordchar(sc.ch) && !((sc.ch == '/') && (sc.chPrev == '<')) && sc.ch != '[') {
char s[100];
sc.GetCurrentLowered(s, sizeof(s));
if (s[1] == '/') {
}
}
} else if (sc.state == SCE_H_ATTRIBUTE) {
- if (!ishtmlwordchar(static_cast<char>(sc.ch))) {
+ if (!ishtmlwordchar(sc.ch)) {
char s[100];
sc.GetCurrentLowered(s, sizeof(s));
if (!keywordsTags.InList(s)) {
} else if (sc.ch == '>') {
sc.SetState(SCE_H_TAG);
sc.ForwardSetState(SCE_H_DEFAULT);
- } else if (ishtmlwordchar(static_cast<char>(sc.ch))) {
+ } else if (ishtmlwordchar(sc.ch)) {
sc.SetState(SCE_H_ATTRIBUTE);
}
}
static void ColouriseASPDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
Accessor &styler) {
- // Lexer for HTML requires more lexical states (7 bits worth) than most lexers
- StyleContext sc(startPos, length, initStyle, styler, 0x7f);
+ // Lexer for HTML requires more lexical states (8 bits worth) than most lexers
+ StyleContext sc(startPos, length, initStyle, styler, static_cast<char>(STYLE_MAX));
for (; sc.More(); sc.Forward()) {
ColouriseASPPiece(sc, keywordlists);
}
sc.SetState(SCE_HPHP_SIMPLESTRING);
} else if (sc.ch == '$' && IsPhpWordStart(static_cast<char>(sc.chNext))) {
sc.SetState(SCE_HPHP_VARIABLE);
- } else if (isoperator(static_cast<char>(sc.ch))) {
+ } else if (IsOperator(static_cast<char>(sc.ch))) {
sc.SetState(SCE_HPHP_OPERATOR);
}
}
static void ColourisePHPDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
Accessor &styler) {
- // Lexer for HTML requires more lexical states (7 bits worth) than most lexers
- StyleContext sc(startPos, length, initStyle, styler, 0x7f);
+ // Lexer for HTML requires more lexical states (8 bits worth) than most lexers
+ StyleContext sc(startPos, length, initStyle, styler, static_cast<char>(STYLE_MAX));
for (; sc.More(); sc.Forward()) {
ColourisePHPPiece(sc, keywordlists);
}
static void ColourisePHPScriptDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
Accessor &styler) {
if(startPos == 0) initStyle = SCE_HPHP_DEFAULT;
- ColouriseHyperTextDoc(startPos,length,initStyle,keywordlists,styler);
+ ColouriseHTMLDoc(startPos,length,initStyle,keywordlists,styler);
}
static const char * const htmlWordListDesc[] = {
0,
};
-LexerModule lmHTML(SCLEX_HTML, ColouriseHyperTextDoc, "hypertext", 0, htmlWordListDesc, 7);
-LexerModule lmXML(SCLEX_XML, ColouriseHyperTextDoc, "xml", 0, htmlWordListDesc, 7);
+LexerModule lmHTML(SCLEX_HTML, ColouriseHTMLDoc, "hypertext", 0, htmlWordListDesc, 8);
+LexerModule lmXML(SCLEX_XML, ColouriseXMLDoc, "xml", 0, htmlWordListDesc, 8);
// SCLEX_ASP and SCLEX_PHP should not be used in new code: use SCLEX_HTML instead.
-LexerModule lmASP(SCLEX_ASP, ColouriseASPDoc, "asp", 0, htmlWordListDesc, 7);
-LexerModule lmPHP(SCLEX_PHP, ColourisePHPDoc, "php", 0, htmlWordListDesc, 7);
-LexerModule lmPHPSCRIPT(SCLEX_PHPSCRIPT, ColourisePHPScriptDoc, "phpscript", 0, phpscriptWordListDesc, 7);
+LexerModule lmASP(SCLEX_ASP, ColouriseASPDoc, "asp", 0, htmlWordListDesc, 8);
+LexerModule lmPHP(SCLEX_PHP, ColourisePHPDoc, "php", 0, htmlWordListDesc, 8);
+LexerModule lmPHPSCRIPT(SCLEX_PHPSCRIPT, ColourisePHPScriptDoc, "phpscript", 0, phpscriptWordListDesc, 8);
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
#ifdef BUILD_AS_EXTERNAL_LEXER
#include "ExternalLexer.h"
else if (sc.state == SCE_HA_STRING) {
if (sc.ch == '\"') {
sc.ForwardSetState(SCE_HA_DEFAULT);
+ } else if (sc.ch == '\\') {
+ sc.Forward();
}
}
// Char
else if (sc.state == SCE_HA_CHARACTER) {
if (sc.ch == '\'') {
sc.ForwardSetState(SCE_HA_DEFAULT);
+ } else if (sc.ch == '\\') {
+ sc.Forward();
}
}
// Number
sc.SetState(SCE_HA_STRING);
}
// Character
- else if (sc.Match('\'') && IsWhitespace(sc.GetRelative(-1)) ) {
+ else if (sc.Match('\'')) {
sc.SetState(SCE_HA_CHARACTER);
}
// Stringstart
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
static void ColouriseInnoDoc(unsigned int startPos, int length, int, WordList *keywordLists[], Accessor &styler) {
int state = SCE_INNO_DEFAULT;
char chPrev;
case SCE_INNO_STRING_DOUBLE:
if (ch == '"' || isEOL) {
state = SCE_INNO_DEFAULT;
- styler.ColourTo(i,SCE_INNO_DEFAULT);
+ styler.ColourTo(i,SCE_INNO_STRING_DOUBLE);
}
break;
case SCE_INNO_STRING_SINGLE:
if (ch == '\'' || isEOL) {
state = SCE_INNO_DEFAULT;
- styler.ColourTo(i,SCE_INNO_DEFAULT);
+ styler.ColourTo(i,SCE_INNO_STRING_SINGLE);
}
break;
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
// Extended to accept accented characters
static inline bool IsAWordChar(int ch) {
return ch >= 0x80 || isalnum(ch) || ch == '_';
#include "SciLexer.h"
#include "StyleContext.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
#define SCE_LISP_CHARACTER 29
#define SCE_LISP_MACRO 30
#define SCE_LISP_MACRO_DISPATCH 31
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
static inline bool IsAWordChar(const int ch) {
return (ch < 0x80) && (isalpha(ch) || ch == '@' || ch == '_');
}
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
// Extended to accept accented characters
static inline bool IsAWordChar(int ch) {
return ch >= 0x80 ||
// We stop the number definition on non-numerical non-dot non-eE non-sign non-hexdigit char
if (!IsANumberChar(sc.ch)) {
sc.SetState(SCE_LUA_DEFAULT);
- }
+ } else if (sc.ch == '-' || sc.ch == '+') {
+ if (sc.chPrev != 'E' && sc.chPrev != 'e')
+ sc.SetState(SCE_LUA_DEFAULT);
+ }
} else if (sc.state == SCE_LUA_IDENTIFIER) {
if (!IsAWordChar(sc.ch) || sc.Match('.', '.')) {
char s[100];
sc.ChangeState(SCE_LUA_WORD5);
} else if (keywords6.InList(s)) {
sc.ChangeState(SCE_LUA_WORD6);
- } else if (keywords6.InList(s)) {
- sc.ChangeState(SCE_LUA_WORD6);
} else if (keywords7.InList(s)) {
sc.ChangeState(SCE_LUA_WORD7);
} else if (keywords8.InList(s)) {
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
static inline bool IsAWordChar(const int ch) {
#include "SciLexer.h"
#include "SString.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
static int GetLotLineState(SString &line) {
if (line.length()) {
// Most of the time the first non-blank character in line determines that line's type
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
#define KW_MSSQL_STATEMENTS 0
#define KW_MSSQL_DATA_TYPES 1
#define KW_MSSQL_SYSTEM_TABLES 2
inComment = (style == SCE_MSSQL_COMMENT);
}
if (style == SCE_MSSQL_STATEMENT) {
- // Folding between begin and end
- if (ch == 'b' || ch == 'e') {
+ // Folding between begin or case and end
+ if (ch == 'b' || ch == 'B' || ch == 'c' || ch == 'C' || ch == 'e' || ch == 'E') {
for (unsigned int j = 0; j < 5; j++) {
if (!iswordchar(styler[i + j])) {
break;
}
- s[j] = styler[i + j];
+ s[j] = static_cast<char>(tolower(styler[i + j]));
s[j + 1] = '\0';
}
- if (strcmp(s, "begin") == 0) {
+ if ((strcmp(s, "begin") == 0) || (strcmp(s, "case") == 0)) {
levelCurrent++;
}
if (strcmp(s, "end") == 0) {
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
static bool IsMatlabCommentChar(int c) {
return (c == '%') ;
transpose = true;
}
} else if (sc.state == SCE_MATLAB_STRING) {
- if (sc.ch == '\'' && sc.chPrev != '\\') {
+ if (sc.ch == '\\') {
+ if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+ sc.Forward();
+ }
+ } else if (sc.ch == '\'') {
sc.ForwardSetState(SCE_MATLAB_DEFAULT);
}
} else if (sc.state == SCE_MATLAB_DOUBLEQUOTESTRING) {
- if (sc.ch == '"' && sc.chPrev != '\\') {
+ if (sc.ch == '\\') {
+ if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+ sc.Forward();
+ }
+ } else if (sc.ch == '\"') {
sc.ForwardSetState(SCE_MATLAB_DEFAULT);
}
} else if (sc.state == SCE_MATLAB_COMMENT || sc.state == SCE_MATLAB_COMMAND) {
sc.SetState(SCE_MATLAB_STRING);
}
} else if (sc.ch == '"') {
- sc.SetState(SCE_MATLAB_DOUBLEQUOTESTRING);
+ sc.SetState(SCE_MATLAB_DOUBLEQUOTESTRING);
} else if (isdigit(sc.ch) || (sc.ch == '.' && isdigit(sc.chNext))) {
sc.SetState(SCE_MATLAB_NUMBER);
} else if (isalpha(sc.ch)) {
static void ColouriseMatlabDoc(unsigned int startPos, int length, int initStyle,
WordList *keywordlists[], Accessor &styler) {
- ColouriseMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsMatlabCommentChar);
+ ColouriseMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsMatlabCommentChar);
}
static void ColouriseOctaveDoc(unsigned int startPos, int length, int initStyle,
WordList *keywordlists[], Accessor &styler) {
- ColouriseMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsOctaveCommentChar);
+ ColouriseMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsOctaveCommentChar);
}
static void FoldMatlabOctaveDoc(unsigned int startPos, int length, int,
- WordList *[], Accessor &styler,
- bool (*IsComment)(Accessor&,int,int)) {
+ WordList *[], Accessor &styler,
+ bool (*IsComment)(Accessor&, int, int)) {
int endPos = startPos + length;
static void FoldMatlabDoc(unsigned int startPos, int length, int initStyle,
WordList *keywordlists[], Accessor &styler) {
- FoldMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsMatlabComment);
+ FoldMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsMatlabComment);
}
static void FoldOctaveDoc(unsigned int startPos, int length, int initStyle,
WordList *keywordlists[], Accessor &styler) {
- FoldMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsOctaveComment);
+ FoldMatlabOctaveDoc(startPos, length, initStyle, keywordlists, styler, IsOctaveComment);
}
static const char * const matlabWordListDesc[] = {
// File: LexMetapost.cxx - general context conformant metapost coloring scheme
// Author: Hans Hagen - PRAGMA ADE - Hasselt NL - www.pragma-ade.com
// Version: September 28, 2003
+// Modified by instanton: July 10, 2007
+// Folding based on keywordlists[]
// Copyright: 1998-2003 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.
#include "SciLexer.h"
#include "StyleContext.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
// val SCE_METAPOST_DEFAULT = 0
// val SCE_METAPOST_SPECIAL = 1
// val SCE_METAPOST_GROUP = 2
0
} ;
-LexerModule lmMETAPOST(SCLEX_METAPOST, ColouriseMETAPOSTDoc, "metapost", 0, metapostWordListDesc);
+static int classifyFoldPointMetapost(const char* s,WordList *keywordlists[]) {
+ WordList& keywordsStart=*keywordlists[3];
+ WordList& keywordsStop1=*keywordlists[4];
+
+ if (keywordsStart.InList(s)) {return 1;}
+ else if (keywordsStop1.InList(s)) {return -1;}
+ return 0;
+
+}
+
+static int ParseMetapostWord(unsigned int pos, Accessor &styler, char *word)
+{
+ int length=0;
+ char ch=styler.SafeGetCharAt(pos);
+ *word=0;
+
+ while(isMETAPOSTidentifier(ch) && isalpha(ch) && length<100){
+ word[length]=ch;
+ length++;
+ ch=styler.SafeGetCharAt(pos+length);
+ }
+ word[length]=0;
+ return length;
+}
+
+static void FoldMetapostDoc(unsigned int startPos, int length, int, WordList *keywordlists[], 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=styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
+ int levelCurrent=levelPrev;
+ char chNext=styler[startPos];
+
+ char buffer[100]="";
+
+ for (unsigned int i=startPos; i < endPos; i++) {
+ char ch=chNext;
+ chNext=styler.SafeGetCharAt(i+1);
+ char chPrev=styler.SafeGetCharAt(i-1);
+ bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
+
+ if(i==0 || chPrev == '\r' || chPrev=='\n'|| chPrev==' '|| chPrev=='(' || chPrev=='$')
+ {
+ ParseMetapostWord(i, styler, buffer);
+ levelCurrent += classifyFoldPointMetapost(buffer,keywordlists);
+ }
+
+ if (atEOL) {
+ int lev = levelPrev;
+ if (visibleChars == 0 && foldCompact)
+ lev |= SC_FOLDLEVELWHITEFLAG;
+ if ((levelCurrent > levelPrev) && (visibleChars > 0))
+ lev |= SC_FOLDLEVELHEADERFLAG;
+ if (lev != styler.LevelAt(lineCurrent)) {
+ styler.SetLevel(lineCurrent, lev);
+ }
+ lineCurrent++;
+ levelPrev = levelCurrent;
+ visibleChars = 0;
+ }
+
+ 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);
+
+}
+
+
+LexerModule lmMETAPOST(SCLEX_METAPOST, ColouriseMETAPOSTDoc, "metapost", FoldMetapostDoc, metapostWordListDesc);
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
/*
// located in SciLexer.h
#define SCLEX_NSIS 43
return false;
}
-static int NsisCmp( const char *s1, const char *s2, bool bIgnoreCase )
+static int NsisCmp( char *s1, char *s2, bool bIgnoreCase )
{
if( bIgnoreCase )
return CompareCaseInsensitive( s1, s2);
return foldlevel;
}
else
- {
+ {
if( style != SCE_NSIS_FUNCTIONDEF && style != SCE_NSIS_SECTIONDEF &&
style != SCE_NSIS_SUBSECTIONDEF && style != SCE_NSIS_SECTIONGROUP &&
style != SCE_NSIS_PAGEEX )
if( s[0] == '!' )
{
- if( NsisCmp(s, "!ifndef", bIgnoreCase) == 0 || NsisCmp(s, "!ifdef", bIgnoreCase ) == 0 || NsisCmp(s, "!macro", bIgnoreCase ) == 0 )
+ if( NsisCmp(s, "!ifndef", bIgnoreCase) == 0 || NsisCmp(s, "!ifdef", bIgnoreCase ) == 0 || NsisCmp(s, "!if", bIgnoreCase ) == 0 || NsisCmp(s, "!macro", bIgnoreCase ) == 0 )
newFoldlevel++;
else if( NsisCmp(s, "!endif", bIgnoreCase) == 0 || NsisCmp(s, "!macroend", bIgnoreCase ) == 0 )
newFoldlevel--;
else if( NsisCmp(s, "SectionGroupEnd", bIgnoreCase ) == 0 || NsisCmp(s, "SubSectionEnd", bIgnoreCase ) == 0 || NsisCmp(s, "FunctionEnd", bIgnoreCase) == 0 || NsisCmp(s, "SectionEnd", bIgnoreCase ) == 0 || NsisCmp(s, "PageExEnd", bIgnoreCase ) == 0 )
newFoldlevel--;
}
-
+
return newFoldlevel;
}
if( NsisCmp(s, "!else", bIgnoreCase ) == 0 ) // || NsisCmp(s, "!ifndef", bIgnoreCase) == 0 || NsisCmp(s, "!endif", bIgnoreCase) == 0 )
return SCE_NSIS_IFDEFINEDEF;
+ if( NsisCmp(s, "!if", bIgnoreCase ) == 0 )
+ return SCE_NSIS_IFDEFINEDEF;
+
if( NsisCmp(s, "SectionGroup", bIgnoreCase) == 0 || NsisCmp(s, "SectionGroupEnd", bIgnoreCase) == 0 ) // Covers SectionGroup and SectionGroupEnd
return SCE_NSIS_SECTIONGROUP;
#include "SciLexer.h"
#include "StyleContext.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
inline static void getRange( unsigned int start, unsigned int end, Accessor & styler, char * s, unsigned int len )
{
unsigned int i = 0;
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
static bool Is0To9(char ch) {
return (ch >= '0') && (ch <= '9');
}
styler.ColourTo(startLine + offset + 1, SCE_BAT_IDENTIFIER);
offset += 2;
// Check for External Command / Program
- if (!isspacechar(lineBuffer[offset])) {
+ if (offset < lengthLine && !isspacechar(lineBuffer[offset])) {
cmdLoc = offset;
}
// Check for Environment Variable (%x...%)
styler.ColourTo(startLine + offset, SCE_BAT_IDENTIFIER);
offset++;
// Check for External Command / Program
- if (!isspacechar(lineBuffer[offset])) {
+ if (offset < lengthLine && !isspacechar(lineBuffer[offset])) {
cmdLoc = offset;
}
}
offset -= (wbl - wbo);
// Check for Local Variable (%%a)
} else if (
+ (wbl > 2) &&
(wordBuffer[1] == '%') &&
(wordBuffer[2] != '%') &&
(!IsBOperator(wordBuffer[2])) &&
}
}
if (linePos > 0) { // Last line does not have ending characters
+ lineBuffer[linePos] = '\0';
ColouriseBatchLine(lineBuffer, linePos, startLine, startPos + length - 1,
keywordlists, styler);
}
int lastNonSpace = -1;
unsigned int state = SCE_MAKE_DEFAULT;
bool bSpecial = false;
+
+ // check for a tab character in column 0 indicating a command
+ bool bCommand = false;
+ if ((lengthLine > 0) && (lineBuffer[0] == '\t'))
+ bCommand = true;
+
// Skip initial spaces
while ((i < lengthLine) && isspacechar(lineBuffer[i])) {
i++;
styler.ColourTo(startLine + i, state);
state = SCE_MAKE_DEFAULT;
}
- if (!bSpecial) {
+
+ // skip identifier and target styling if this is a command line
+ if (!bSpecial && !bCommand) {
if (lineBuffer[i] == ':') {
- // We should check that no colouring was made since the beginning of the line,
- // to avoid colouring stuff like /OUT:file
- if (lastNonSpace >= 0)
- styler.ColourTo(startLine + lastNonSpace, SCE_MAKE_TARGET);
- styler.ColourTo(startLine + i - 1, SCE_MAKE_DEFAULT);
- styler.ColourTo(startLine + i, SCE_MAKE_OPERATOR);
+ if (((i + 1) < lengthLine) && (lineBuffer[i + 1] == '=')) {
+ // it's a ':=', so style as an identifier
+ if (lastNonSpace >= 0)
+ styler.ColourTo(startLine + lastNonSpace, SCE_MAKE_IDENTIFIER);
+ styler.ColourTo(startLine + i - 1, SCE_MAKE_DEFAULT);
+ styler.ColourTo(startLine + i + 1, SCE_MAKE_OPERATOR);
+ } else {
+ // We should check that no colouring was made since the beginning of the line,
+ // to avoid colouring stuff like /OUT:file
+ if (lastNonSpace >= 0)
+ styler.ColourTo(startLine + lastNonSpace, SCE_MAKE_TARGET);
+ styler.ColourTo(startLine + i - 1, SCE_MAKE_DEFAULT);
+ styler.ColourTo(startLine + i, SCE_MAKE_OPERATOR);
+ }
bSpecial = true; // Only react to the first ':' of the line
state = SCE_MAKE_DEFAULT;
} else if (lineBuffer[i] == '=') {
return strncmp(haystack, needle, strlen(needle)) == 0;
}
-static int RecogniseErrorListLine(const char *lineBuffer, unsigned int lengthLine) {
+static int RecogniseErrorListLine(const char *lineBuffer, unsigned int lengthLine, int &startValue) {
if (lineBuffer[0] == '>') {
// Command or return status
return SCE_ERR_CMD;
// Microsoft: <filename>(<line>,<column>)<message>
// CTags: \t<message>
// Lua 5 traceback: \t<filename>:<line>:<message>
+ // Lua 5.1: <exe>: <filename>:<line>:<message>
bool initialTab = (lineBuffer[0] == '\t');
+ bool initialColonPart = false;
enum { stInitial,
stGccStart, stGccDigit, stGcc,
stMsStart, stMsDigit, stMsBracket, stMsVc, stMsDigitComma, stMsDotNet,
if (state == stInitial) {
if (ch == ':') {
// May be GCC, or might be Lua 5 (Lua traceback same but with tab prefix)
- if ((chNext != '\\') && (chNext != '/')) {
+ if ((chNext != '\\') && (chNext != '/') && (chNext != ' ')) {
// This check is not completely accurate as may be on
// GTK+ with a file name that includes ':'.
- state = stGccStart;
+ state = stGccStart;
+ } else if (chNext == ' ') { // indicates a Lua 5.1 error message
+ initialColonPart = true;
}
} else if ((ch == '(') && Is1To9(chNext) && (!initialTab)) {
// May be Microsoft
} else if (state == stGccDigit) { // <filename>:<line>
if (ch == ':') {
state = stGcc; // :9.*: is GCC
+ startValue = i + 1;
break;
} else if (!Is0To9(ch)) {
state = stUnrecognized;
}
}
if (state == stGcc) {
- return SCE_ERR_GCC;
+ return initialColonPart ? SCE_ERR_LUA : SCE_ERR_GCC;
} else if ((state == stMsVc) || (state == stMsDotNet)) {
return SCE_ERR_MS;
} else if ((state == stCtagsStringDollar) || (state == stCtags)) {
char *lineBuffer,
unsigned int lengthLine,
unsigned int endPos,
- Accessor &styler) {
- styler.ColourTo(endPos, RecogniseErrorListLine(lineBuffer, lengthLine));
+ Accessor &styler,
+ bool valueSeparate) {
+ int startValue = -1;
+ int style = RecogniseErrorListLine(lineBuffer, lengthLine, startValue);
+ if (valueSeparate && (startValue >= 0)) {
+ styler.ColourTo(endPos - (lengthLine - startValue), style);
+ styler.ColourTo(endPos, SCE_ERR_VALUE);
+ } else {
+ styler.ColourTo(endPos, style);
+ }
}
static void ColouriseErrorListDoc(unsigned int startPos, int length, int, WordList *[], Accessor &styler) {
styler.StartAt(startPos);
styler.StartSegment(startPos);
unsigned int linePos = 0;
+ bool valueSeparate = styler.GetPropertyInt("lexer.errorlist.value.separate", 0) != 0;
for (unsigned int i = startPos; i < startPos + length; i++) {
lineBuffer[linePos++] = styler[i];
if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
// End of line (or of line buffer) met, colourise it
lineBuffer[linePos] = '\0';
- ColouriseErrorListLine(lineBuffer, linePos, i, styler);
+ ColouriseErrorListLine(lineBuffer, linePos, i, styler, valueSeparate);
linePos = 0;
}
}
if (linePos > 0) { // Last line does not have ending characters
- ColouriseErrorListLine(lineBuffer, linePos, startPos + length - 1, styler);
+ ColouriseErrorListLine(lineBuffer, linePos, startPos + length - 1, styler, valueSeparate);
}
}
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
static inline bool IsTypeCharacter(const int ch)
{
return ch == '%' || ch == '&' || ch == '@' || ch == '!' || ch == '#' || ch == '$' || ch == '?';
--- /dev/null
+// Copyright (c) 1990-2007, Scientific Toolworks, Inc.
+// Author: Jason Haslam
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#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
+
+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<char>(tolower(styler[start + i]));
+ i++;
+ }
+ s[i] = '\0';
+}
+
+static void ColourisePlmDoc(unsigned int startPos,
+ int length,
+ int initStyle,
+ WordList *keywordlists[],
+ Accessor &styler)
+{
+ unsigned int endPos = startPos + length;
+ int state = initStyle;
+
+ styler.StartAt(startPos);
+ styler.StartSegment(startPos);
+
+ for (unsigned int i = startPos; i < endPos; i++) {
+ char ch = styler.SafeGetCharAt(i);
+ char chNext = styler.SafeGetCharAt(i + 1);
+
+ if (state == SCE_PLM_DEFAULT) {
+ if (ch == '/' && chNext == '*') {
+ styler.ColourTo(i - 1, state);
+ state = SCE_PLM_COMMENT;
+ } else if (ch == '\'') {
+ styler.ColourTo(i - 1, state);
+ state = SCE_PLM_STRING;
+ } else if (isdigit(ch)) {
+ styler.ColourTo(i - 1, state);
+ state = SCE_PLM_NUMBER;
+ } else if (isalpha(ch)) {
+ styler.ColourTo(i - 1, state);
+ state = SCE_PLM_IDENTIFIER;
+ } else if (ch == '+' || ch == '-' || ch == '*' || ch == '/' ||
+ ch == '=' || ch == '<' || ch == '>' || ch == ':') {
+ styler.ColourTo(i - 1, state);
+ state = SCE_PLM_OPERATOR;
+ } else if (ch == '$') {
+ styler.ColourTo(i - 1, state);
+ state = SCE_PLM_CONTROL;
+ }
+ } else if (state == SCE_PLM_COMMENT) {
+ if (ch == '*' && chNext == '/') {
+ i++;
+ styler.ColourTo(i, state);
+ state = SCE_PLM_DEFAULT;
+ }
+ } else if (state == SCE_PLM_STRING) {
+ if (ch == '\'') {
+ if (chNext == '\'') {
+ i++;
+ } else {
+ styler.ColourTo(i, state);
+ state = SCE_PLM_DEFAULT;
+ }
+ }
+ } else if (state == SCE_PLM_NUMBER) {
+ if (!isdigit(ch) && !isalpha(ch) && ch != '$') {
+ i--;
+ styler.ColourTo(i, state);
+ state = SCE_PLM_DEFAULT;
+ }
+ } else if (state == SCE_PLM_IDENTIFIER) {
+ if (!isdigit(ch) && !isalpha(ch) && ch != '$') {
+ // Get the entire identifier.
+ char word[1024];
+ int segmentStart = styler.GetStartSegment();
+ GetRange(segmentStart, i - 1, styler, word, sizeof(word));
+
+ i--;
+ if (keywordlists[0]->InList(word))
+ styler.ColourTo(i, SCE_PLM_KEYWORD);
+ else
+ styler.ColourTo(i, state);
+ state = SCE_PLM_DEFAULT;
+ }
+ } else if (state == SCE_PLM_OPERATOR) {
+ if (ch != '=' && ch != '>') {
+ i--;
+ styler.ColourTo(i, state);
+ state = SCE_PLM_DEFAULT;
+ }
+ } else if (state == SCE_PLM_CONTROL) {
+ if (ch == '\r' || ch == '\n') {
+ styler.ColourTo(i - 1, state);
+ state = SCE_PLM_DEFAULT;
+ }
+ }
+ }
+ styler.ColourTo(endPos - 1, state);
+}
+
+static void FoldPlmDoc(unsigned int startPos,
+ int length,
+ int initStyle,
+ WordList *[],
+ Accessor &styler)
+{
+ bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
+ bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
+ 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[startPos];
+ int styleNext = styler.StyleAt(startPos);
+ int style = initStyle;
+ int startKeyword = 0;
+
+ 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 (stylePrev != SCE_PLM_KEYWORD && style == SCE_PLM_KEYWORD)
+ startKeyword = i;
+
+ if (style == SCE_PLM_KEYWORD && styleNext != SCE_PLM_KEYWORD) {
+ char word[1024];
+ GetRange(startKeyword, i, styler, word, sizeof(word));
+
+ if (strcmp(word, "procedure") == 0 || strcmp(word, "do") == 0)
+ levelCurrent++;
+ else if (strcmp(word, "end") == 0)
+ levelCurrent--;
+ }
+
+ if (foldComment) {
+ if (stylePrev != SCE_PLM_COMMENT && style == SCE_PLM_COMMENT)
+ levelCurrent++;
+ else if (stylePrev == SCE_PLM_COMMENT && style != SCE_PLM_COMMENT)
+ levelCurrent--;
+ }
+
+ if (atEOL) {
+ int lev = levelPrev;
+ if (visibleChars == 0 && foldCompact)
+ lev |= SC_FOLDLEVELWHITEFLAG;
+ if ((levelCurrent > levelPrev) && (visibleChars > 0))
+ lev |= SC_FOLDLEVELHEADERFLAG;
+ if (lev != styler.LevelAt(lineCurrent)) {
+ styler.SetLevel(lineCurrent, lev);
+ }
+ lineCurrent++;
+ levelPrev = levelCurrent;
+ visibleChars = 0;
+ }
+
+ if (!isspacechar(ch))
+ visibleChars++;
+ }
+
+ int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK;
+ styler.SetLevel(lineCurrent, levelPrev | flagsNext);
+}
+
+static const char *const plmWordListDesc[] = {
+ "Keywords",
+ 0
+};
+
+LexerModule lmPLM(SCLEX_PLM, ColourisePlmDoc, "PL/M", FoldPlmDoc, plmWordListDesc);
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
static inline bool IsAWordChar(int ch) {
return ch < 0x80 && (isalnum(ch) || ch == '_');
}
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
static inline bool IsASelfDelimitingChar(const int ch) {
return (ch == '[' || ch == ']' || ch == '{' || ch == '}' ||
ch == '/' || ch == '<' || ch == '>' ||
sc.SetState(SCE_C_DEFAULT);
} else if (sc.atLineEnd) {
sc.SetState(SCE_C_DEFAULT);
- } else if (IsAWhitespaceChar(sc.ch)) {
+ } else if (IsAWhitespaceChar(sc.ch) && sc.ch != '\r') {
sc.ChangeState(SCE_PS_COMMENT);
}
} else if (sc.state == SCE_PS_NUMBER) {
#include "SciLexer.h"
#include "StyleContext.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
static void getRange(unsigned int start,
unsigned int end,
Accessor &styler,
styleNext = styler.StyleAt(i + 1);
bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
- if (stylePrev == SCE_C_DEFAULT && style == SCE_C_WORD)
+ if (stylePrev != SCE_C_WORD && style == SCE_C_WORD)
{
// Store last word start point.
lastStart = i;
/** @file LexPerl.cxx
** Lexer for subset of Perl.
**/
-// Copyright 1998-2005 by Neil Hodgson <neilh@scintilla.org>
+// Copyright 1998-2007 by Neil Hodgson <neilh@scintilla.org>
// Lexical analysis fixes by Kein-Hong Man <mkh@pl.jaring.my>
// The License.txt file describes the conditions under which this software may be distributed.
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
#define PERLNUM_BINARY 1 // order is significant: 1-4 cannot have a dot
#define PERLNUM_HEX 2
#define PERLNUM_OCTAL 3
return keywords.InList(s);
}
+// Note: as lexer uses chars, UTF-8 bytes are considered as <0 values
+// Note: iswordchar() was used in only one place in LexPerl, it is
+// unnecessary as '.' is processed as the concatenation operator, so
+// only isWordStart() is used in LexPerl
+
+static inline bool isWordStart(char ch) {
+ return !isascii(ch) || isalnum(ch) || ch == '_';
+}
+
static inline bool isEndVar(char ch) {
- return !isalnum(ch) && ch != '#' && ch != '$' &&
+ return isascii(ch) && !isalnum(ch) && ch != '#' && ch != '$' &&
ch != '_' && ch != '\'';
}
-
static inline bool isNonQuote(char ch) {
- return isalnum(ch) || ch == '_';
+ return !isascii(ch) || isalnum(ch) || ch == '_';
}
static inline char actualNumStyle(int numberStyle) {
WordList &keywords = *keywordlists[0];
+ // keywords that forces /PATTERN/ at all times
+ WordList reWords;
+ reWords.Set("elsif if split while");
+
class HereDocCls {
public:
int State; // 0: '<<' encountered
//char sooked[100];
//sooked[sookedpos] = '\0';
+ styler.StartAt(startPos, static_cast<char>(STYLE_MAX));
// If in a long distance lexical state, seek to the beginning to find quote characters
// Perl strings can be multi-line with embedded newlines, so backtrack.
// Perl numbers have additional state during lexing, so backtrack too.
startPos = styler.LineStart(styler.GetLine(startPos));
state = styler.StyleAt(startPos - 1);
}
+ // Backtrack for format body.
+ if (state == SCE_PL_FORMAT) {
+ while ((startPos > 1) && (styler.StyleAt(startPos) != SCE_PL_FORMAT_IDENT)) {
+ startPos--;
+ }
+ startPos = styler.LineStart(styler.GetLine(startPos));
+ state = styler.StyleAt(startPos - 1);
+ }
if ( state == SCE_PL_STRING_Q
|| state == SCE_PL_STRING_QQ
|| state == SCE_PL_STRING_QX
|| state == SCE_PL_NUMBER
|| state == SCE_PL_IDENTIFIER
|| state == SCE_PL_ERROR
+ || state == SCE_PL_SUB_PROTOTYPE
) {
while ((startPos > 1) && (styler.StyleAt(startPos - 1) == state)) {
startPos--;
backflag = BACK_KEYWORD;
}
- styler.StartAt(startPos);
+ styler.StartAt(startPos, static_cast<char>(STYLE_MAX));
char chPrev = styler.SafeGetCharAt(startPos - 1);
if (startPos == 0)
chPrev = '\n';
}
}
}
+ if (HereDoc.State == 4 && isEOLChar(ch)) {
+ // Start of format body.
+ HereDoc.State = 0;
+ styler.ColourTo(i - 1, state);
+ state = SCE_PL_FORMAT;
+ }
if (state == SCE_PL_DEFAULT) {
- if (isdigit(ch) || (isdigit(chNext) &&
+ if ((isascii(ch) && isdigit(ch)) || (isascii(chNext) && isdigit(chNext) &&
(ch == '.' || ch == 'v'))) {
state = SCE_PL_NUMBER;
backflag = BACK_NONE;
numState = PERLNUM_HEX;
} else if (chNext == 'b') {
numState = PERLNUM_BINARY;
- } else if (isdigit(chNext)) {
+ } else if (isascii(chNext) && isdigit(chNext)) {
numState = PERLNUM_OCTAL;
}
if (numState != PERLNUM_DECIMAL) {
} else if (ch == 'v') { // vector
numState = PERLNUM_V_VECTOR;
}
- } else if (iswordstart(ch)) {
+ } else if (isWordStart(ch)) {
// if immediately prefixed by '::', always a bareword
state = SCE_PL_WORD;
if (chPrev == ':' && styler.SafeGetCharAt(i - 2) == ':') {
Quote.New(1);
kw++;
} else if (ch == 'x' && (chNext == '=' || // repetition
- (chNext != '_' && !isalnum(chNext)) ||
+ !isWordStart(chNext) ||
(isdigit(chPrev) && isdigit(chNext)))) {
state = SCE_PL_OPERATOR;
}
// otherwise it is always a bareword and we skip a lot of scanning
// note: keywords assumed to be limited to [_a-zA-Z] only
if (state == SCE_PL_WORD) {
- while (iswordstart(styler.SafeGetCharAt(kw))) kw++;
+ while (isWordStart(styler.SafeGetCharAt(kw))) kw++;
if (!isPerlKeyword(styler.GetStartSegment(), kw, keywords, styler)) {
state = SCE_PL_IDENTIFIER;
}
if (ch2 == '{' && !moreback) {
// {bareword: possible variable spec
brace = true;
- } else if ((ch2 == '&')
+ } else if ((ch2 == '&' && styler.SafeGetCharAt(j - 1) != '&')
// &bareword: subroutine call
|| (ch2 == '>' && styler.SafeGetCharAt(j - 1) == '-')
// ->bareword: part of variable spec
backflag = BACK_NONE;
// an identifier or bareword
if (state == SCE_PL_IDENTIFIER) {
- if ((!iswordchar(chNext) && chNext != '\'')
+ if ((!isWordStart(chNext) && chNext != '\'')
|| (chNext == '.' && chNext2 == '.')) {
// We need that if length of word == 1!
// This test is copied from the SCE_PL_WORD handler.
styler.ColourTo(i, SCE_PL_DATASECTION);
state = SCE_PL_DATASECTION;
} else {
+ if (isMatch(styler, lengthDoc, styler.GetStartSegment(), "format")) {
+ state = SCE_PL_FORMAT_IDENT;
+ HereDoc.State = 0;
+ } else {
+ state = SCE_PL_DEFAULT;
+ }
styler.ColourTo(i, SCE_PL_WORD);
- state = SCE_PL_DEFAULT;
backflag = BACK_KEYWORD;
backPos = i;
}
chNext = styler.SafeGetCharAt(i + 1);
// a repetition operator 'x'
} else if (state == SCE_PL_OPERATOR) {
- styler.ColourTo(i, SCE_PL_OPERATOR);
state = SCE_PL_DEFAULT;
+ goto handleOperator;
// quote-like delimiter, skip one char if double-char delimiter
} else {
i = kw - 1;
styler.ColourTo(i, SCE_PL_SCALAR);
} else {
state = SCE_PL_SCALAR;
- if (chNext == '`' && chNext2 == '`') {
+ if ((chNext == '`' && chNext2 == '`')
+ || (chNext == ':' && chNext2 == ':')) {
i += 2;
ch = styler.SafeGetCharAt(i);
chNext = styler.SafeGetCharAt(i + 1);
}
backflag = BACK_NONE;
} else if (ch == '@') {
- if (isalpha(chNext) || chNext == '#' || chNext == '$'
+ if (!isascii(chNext) || isalpha(chNext) || chNext == '#' || chNext == '$'
|| chNext == '_' || chNext == '+' || chNext == '-') {
state = SCE_PL_ARRAY;
+ } else if (chNext == ':' && chNext2 == ':') {
+ state = SCE_PL_ARRAY;
+ i += 2;
+ ch = styler.SafeGetCharAt(i);
+ chNext = styler.SafeGetCharAt(i + 1);
} else if (chNext != '{' && chNext != '[') {
styler.ColourTo(i, SCE_PL_ARRAY);
} else {
}
backflag = BACK_NONE;
} else if (ch == '%') {
- if (isalpha(chNext) || chNext == '#' || chNext == '$'
+ backflag = BACK_NONE;
+ if (!isascii(chNext) || isalpha(chNext) || chNext == '#' || chNext == '$'
|| chNext == '_' || chNext == '!' || chNext == '^') {
state = SCE_PL_HASH;
i++;
ch = chNext;
chNext = chNext2;
+ } else if (chNext == ':' && chNext2 == ':') {
+ state = SCE_PL_HASH;
+ i += 2;
+ ch = styler.SafeGetCharAt(i);
+ chNext = styler.SafeGetCharAt(i + 1);
} else if (chNext == '{') {
styler.ColourTo(i, SCE_PL_HASH);
} else {
- styler.ColourTo(i, SCE_PL_OPERATOR);
+ goto handleOperator;
}
- backflag = BACK_NONE;
} else if (ch == '*') {
+ backflag = BACK_NONE;
char strch[2];
strch[0] = chNext;
strch[1] = '\0';
- if (isalpha(chNext) || chNext == '_' ||
- NULL != strstr("^/|,\\\";#%^:?<>)[]", strch)) {
+ if (chNext == ':' && chNext2 == ':') {
+ state = SCE_PL_SYMBOLTABLE;
+ i += 2;
+ ch = styler.SafeGetCharAt(i);
+ chNext = styler.SafeGetCharAt(i + 1);
+ } else if (!isascii(chNext) || isalpha(chNext) || chNext == '_'
+ || NULL != strstr("^/|,\\\";#%^:?<>)[]", strch)) {
state = SCE_PL_SYMBOLTABLE;
i++;
ch = chNext;
ch = chNext;
chNext = chNext2;
}
- styler.ColourTo(i, SCE_PL_OPERATOR);
+ goto handleOperator;
}
- backflag = BACK_NONE;
} else if (ch == '/' || (ch == '<' && chNext == '<')) {
// Explicit backward peeking to set a consistent preferRE for
// any slash found, so no longer need to track preferRE state.
bool hereDocSpace = false; // these are for corner case:
bool hereDocScalar = false; // SCALAR [whitespace] '<<'
unsigned int bk = (i > 0)? i - 1: 0;
+ unsigned int bkend;
char bkch;
styler.Flush();
if (styler.StyleAt(bk) == SCE_PL_DEFAULT)
if (bkstyle == SCE_PL_DEFAULT ||
bkstyle == SCE_PL_COMMENTLINE) {
} else if (bkstyle == SCE_PL_OPERATOR) {
- // gcc 3.2.3 bloats if more compact form used
bkch = styler.SafeGetCharAt(bk);
- if (bkch == '>') { // "->"
- if (styler.SafeGetCharAt(bk - 1) == '-') {
- preferRE = false;
- break;
- }
- } else if (bkch == ':') { // "::"
- if (styler.SafeGetCharAt(bk - 1) == ':') {
- preferRE = false;
- break;
- }
- }
- } else {// bare identifier, usually a function call but Perl
- // optimizes them as pseudo-constants, then the next
- // '/' will be a divide; favour divide over regex
- // if there is a whitespace after the '/'
- if (isspacechar(chNext)) {
- preferRE = false;
+ // test for "->" and "::"
+ if ((bkch == '>' && styler.SafeGetCharAt(bk - 1) == '-')
+ || (bkch == ':' && styler.SafeGetCharAt(bk - 1) == ':')) {
+ preferRE = false;
+ break;
}
+ } else {
+ // bare identifier, if '/', /PATTERN/ unless digit/space immediately after '/'
+ if (!isHereDoc &&
+ (isspacechar(chNext) || isdigit(chNext)))
+ preferRE = false;
+ // HERE docs cannot have a space after the >>
+ if (isspacechar(chNext))
+ preferRE = false;
break;
}
bk--;
case SCE_PL_SCALAR: // for $var<< case
hereDocScalar = true;
break;
- // other styles uses the default, preferRE=false
+ // for HERE docs, always true for preferRE
case SCE_PL_WORD:
+ preferRE = true;
+ if (isHereDoc)
+ break;
+ // adopt heuristics similar to vim-style rules:
+ // keywords always forced as /PATTERN/: split, if, elsif, while
+ // everything else /PATTERN/ unless digit/space immediately after '/'
+ bkend = bk + 1;
+ while (bk > 0 && styler.StyleAt(bk-1) == SCE_PL_WORD) {
+ bk--;
+ }
+ if (isPerlKeyword(bk, bkend, reWords, styler))
+ break;
+ if (isspacechar(chNext) || isdigit(chNext))
+ preferRE = false;
+ break;
+ // other styles uses the default, preferRE=false
case SCE_PL_POD:
case SCE_PL_POD_VERB:
case SCE_PL_HERE_Q:
break;
}
}
+ backflag = BACK_NONE;
if (isHereDoc) { // handle HERE doc
// if SCALAR whitespace '<<', *always* a HERE doc
if (preferRE || (hereDocSpace && hereDocScalar)) {
i++;
ch = chNext;
chNext = chNext2;
- styler.ColourTo(i, SCE_PL_OPERATOR);
+ goto handleOperator;
}
} else { // handle regexp
if (preferRE) {
Quote.New(1);
Quote.Open(ch);
} else { // / operator
- styler.ColourTo(i, SCE_PL_OPERATOR);
+ goto handleOperator;
}
}
- backflag = BACK_NONE;
} else if (ch == '<') {
// looks forward for matching > on same line
unsigned int fw = i + 1;
if (fwch == ' ') {
if (styler.SafeGetCharAt(fw-1) != '\\' ||
styler.SafeGetCharAt(fw-2) != '\\')
- break;
+ goto handleOperator;
} else if (isEOLChar(fwch) || isspacechar(fwch)) {
- break;
+ goto handleOperator;
} else if (fwch == '>') {
if ((fw - i) == 2 && // '<=>' case
styler.SafeGetCharAt(fw-1) == '=') {
- styler.ColourTo(fw, SCE_PL_OPERATOR);
- } else {
- styler.ColourTo(fw, SCE_PL_IDENTIFIER);
+ goto handleOperator;
}
+ styler.ColourTo(fw, SCE_PL_IDENTIFIER);
i = fw;
ch = fwch;
chNext = styler.SafeGetCharAt(i+1);
}
fw++;
}
- styler.ColourTo(i, SCE_PL_OPERATOR);
- backflag = BACK_NONE;
+ if (fw == lengthDoc)
+ goto handleOperator;
} else if (ch == '=' // POD
&& isalpha(chNext)
&& (isEOLChar(chPrev))) {
ch = chNext;
chNext = chNext2;
backflag = BACK_NONE;
+ } else if (ch == '-' // bareword promotion (-FOO cases)
+ && ((isascii(chNext) && isalpha(chNext)) || chNext == '_')
+ && backflag != BACK_NONE) {
+ state = SCE_PL_IDENTIFIER;
+ backflag = BACK_NONE;
+ } else if (ch == '(' && i > 0) {
+ // backtrack to identify if we're starting a sub prototype
+ // for generality, we need to ignore whitespace/comments
+ unsigned int bk = i - 1; // i > 0 tested above
+ styler.Flush();
+ while (bk > 0 && (styler.StyleAt(bk) == SCE_PL_DEFAULT ||
+ styler.StyleAt(bk) == SCE_PL_COMMENTLINE)) {
+ bk--;
+ }
+ if (bk == 0 || styler.StyleAt(bk) != SCE_PL_IDENTIFIER) // check identifier
+ goto handleOperator;
+ while (bk > 0 && (styler.StyleAt(bk) == SCE_PL_IDENTIFIER)) {
+ bk--;
+ }
+ while (bk > 0 && (styler.StyleAt(bk) == SCE_PL_DEFAULT ||
+ styler.StyleAt(bk) == SCE_PL_COMMENTLINE)) {
+ bk--;
+ }
+ if (bk < 2 || styler.StyleAt(bk) != SCE_PL_WORD // check "sub" keyword
+ || !styler.Match(bk - 2, "sub")) // assume suffix is unique!
+ goto handleOperator;
+ state = SCE_PL_SUB_PROTOTYPE;
+ backflag = BACK_NONE;
+ backPos = i; // needed for restart
} else if (isPerlOperator(ch)) {
if (ch == '.' && chNext == '.') { // .. and ...
i++;
ch = styler.SafeGetCharAt(i);
chNext = styler.SafeGetCharAt(i + 1);
}
+ handleOperator:
styler.ColourTo(i, SCE_PL_OPERATOR);
backflag = BACK_OPERATOR;
backPos = i;
- } else {
+ } else if (ch == 4 || ch == 26) { // ^D and ^Z ends valid perl source
+ styler.ColourTo(i, SCE_PL_DATASECTION);
+ state = SCE_PL_DATASECTION;
+ } else {
// keep colouring defaults to make restart easier
styler.ColourTo(i, SCE_PL_DEFAULT);
}
} else if (numState <= PERLNUM_FLOAT) {
// non-decimal number or float exponent, consume next dot
styler.ColourTo(i - 1, SCE_PL_NUMBER);
- styler.ColourTo(i, SCE_PL_OPERATOR);
state = SCE_PL_DEFAULT;
+ goto handleOperator;
} else { // decimal or vectors allows dots
dotCount++;
if (numState == PERLNUM_DECIMAL) {
goto numAtEnd;
}
}
- } else if (ch == '_' && numState == PERLNUM_DECIMAL) {
- if (!isdigit(chNext)) {
- goto numAtEnd;
- }
- } else if (isalnum(ch)) {
+ } else if (ch == '_') {
+ // permissive underscoring for number and vector literals
+ } else if (!isascii(ch) || isalnum(ch)) {
if (numState == PERLNUM_VECTOR || numState == PERLNUM_V_VECTOR) {
- if (isalpha(ch)) {
+ if (!isascii(ch) || isalpha(ch)) {
if (dotCount == 0) { // change to word
state = SCE_PL_IDENTIFIER;
} else { // vector then word
ch = chNext;
chNext = chNext2;
}
- } else if (!isdigit(ch)) { // number then word
+ } else if (!isascii(ch) || !isdigit(ch)) { // number then word
goto numAtEnd;
}
} else if (numState == PERLNUM_FLOAT) {
goto restartLexer;
}
} else if (state == SCE_PL_IDENTIFIER) {
- if (!iswordstart(chNext) && chNext != '\'') {
+ if (!isWordStart(chNext) && chNext != '\'') {
styler.ColourTo(i, SCE_PL_IDENTIFIER);
state = SCE_PL_DEFAULT;
ch = ' ';
i = oldi;
styler.ColourTo(i, SCE_PL_OPERATOR);
state = SCE_PL_DEFAULT;
+ backflag = BACK_OPERATOR;
+ backPos = i;
HereDoc.State = 0;
goto restartLexer;
} else {
}
} else if (ch == Quote.Up /*&& chPrev != '\\'*/) {
Quote.Count++;
- } else if (!isalpha(chNext)) {
+ } else if (!isascii(chNext) || !isalpha(chNext)) {
if (Quote.Rep <= 0) {
styler.ColourTo(i, state);
state = SCE_PL_DEFAULT;
if (isspacechar(ch)) {
// Keep going
}
- else if (isalnum(ch)) {
+ else if (!isascii(ch) || isalnum(ch)) {
styler.ColourTo(i, state);
state = SCE_PL_DEFAULT;
ch = ' ';
if (Quote.Count == 0) {
Quote.Rep--;
}
- if (!isalpha(chNext)) {
+ if (!isascii(chNext) || !isalpha(chNext)) {
if (Quote.Rep <= 0) {
styler.ColourTo(i, state);
state = SCE_PL_DEFAULT;
}
} else if (ch == Quote.Up /*&& chPrev != '\\'*/) {
Quote.Count++;
- } else if (!isalpha(chNext)) {
+ } else if (!isascii(chNext) || !isalpha(chNext)) {
if (Quote.Rep <= 0) {
styler.ColourTo(i, state);
state = SCE_PL_DEFAULT;
} else if (ch == Quote.Up) {
Quote.Count++;
}
- }
+ } else if (state == SCE_PL_SUB_PROTOTYPE) {
+ char strch[2];
+ strch[0] = ch;
+ strch[1] = '\0';
+ if (NULL != strstr("\\[$@%&*];", strch)) {
+ // keep going
+ } else if (ch == ')') {
+ styler.ColourTo(i, state);
+ state = SCE_PL_DEFAULT;
+ } else {
+ // abandon prototype, restart from '('
+ i = backPos;
+ styler.ColourTo(i, SCE_PL_OPERATOR);
+ ch = styler.SafeGetCharAt(i);
+ chNext = styler.SafeGetCharAt(i + 1);
+ state = SCE_PL_DEFAULT;
+ }
+ } else if (state == SCE_PL_FORMAT_IDENT) {
+ // occupies different HereDoc states to avoid clashing with HERE docs
+ if (HereDoc.State == 0) {
+ if ((isascii(ch) && isalpha(ch)) || ch == '_' // probable identifier
+ || ch == '=') { // no identifier
+ HereDoc.State = 3;
+ HereDoc.Quoted = false; // whitespace flag
+ } else if (ch == ' ' || ch == '\t') {
+ styler.ColourTo(i, SCE_PL_DEFAULT);
+ } else {
+ state = SCE_PL_DEFAULT;
+ HereDoc.State = 0;
+ goto restartLexer;
+ }
+ }
+ if (HereDoc.State == 3) { // with just a '=', state goes 0->3->4
+ if (ch == '=') {
+ styler.ColourTo(i, SCE_PL_FORMAT_IDENT);
+ state = SCE_PL_DEFAULT;
+ HereDoc.State = 4;
+ } else if (ch == ' ' || ch == '\t') {
+ HereDoc.Quoted = true;
+ } else if (isEOLChar(ch) || (HereDoc.Quoted && ch != '=')) {
+ // abandon format, restart from after 'format'
+ i = backPos + 1;
+ ch = styler.SafeGetCharAt(i);
+ chNext = styler.SafeGetCharAt(i + 1);
+ state = SCE_PL_DEFAULT;
+ HereDoc.State = 0;
+ }
+ }
+ } else if (state == SCE_PL_FORMAT) {
+ if (isEOLChar(chPrev)) {
+ styler.ColourTo(i - 1, state);
+ if (ch == '.' && isEOLChar(chNext)) {
+ styler.ColourTo(i, state);
+ state = SCE_PL_DEFAULT;
+ }
+ }
+ }
}
if (state == SCE_PL_ERROR) {
break;
0
};
-LexerModule lmPerl(SCLEX_PERL, ColourisePerlDoc, "perl", FoldPerlDoc, perlWordListDesc);
+LexerModule lmPerl(SCLEX_PERL, ColourisePerlDoc, "perl", FoldPerlDoc, perlWordListDesc, 8);
--- /dev/null
+// Scintilla source code edit control
+/** @file LexProgress.cxx
+ ** Lexer for Progress 4GL.
+ ** Based on LexCPP.cxx of Neil Hodgson <neilh@scintilla.org>
+ **/
+// Copyright 2006-2007 by Yuval Papish <Yuval@YuvCom.com>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+/** TODO:
+WebSpeed support in html lexer
+Support "end triggers" expression of the triggers phrase
+change lmPS to lmProgress
+Support more than 6 comments levels
+**/
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+static inline bool IsAWordChar(int ch) {
+ return (ch < 0x80) && (isalnum(ch) || ch == '_');
+}
+
+static inline bool IsAWordStart(int ch) {
+ return (ch < 0x80) && (isalpha(ch) || ch == '_');
+}
+
+enum SentenceStart { SetSentenceStart = 0xf, ResetSentenceStart = 0x10}; // true -> bit = 0
+
+static void Colourise4glDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
+ Accessor &styler) {
+
+ WordList &keywords1 = *keywordlists[0];
+ WordList &keywords2 = *keywordlists[1];
+ WordList &keywords3 = *keywordlists[2];
+ //WordList &keywords4 = *keywordlists[3];
+ //WordList &keywords5 = *keywordlists[4];
+
+ int visibleChars = 0;
+ int mask;
+
+ StyleContext sc(startPos, length, initStyle, styler);
+
+ for (; sc.More(); sc.Forward()) {
+
+ if (sc.atLineStart) {
+ // Reset states to begining of colourise so no surprises
+ // if different sets of lines lexed.
+ visibleChars = 0;
+ }
+
+ // Handle line continuation generically.
+ if (sc.ch == '~') {
+ // Skip whitespace between ~ and EOL
+ /* do {
+ sc.Forward();
+ } */
+ while ((sc.chNext == ' ' || sc.chNext == '\t') ) {
+ sc.Forward();
+ sc.More();
+ }
+ if (sc.chNext == '\n' || sc.chNext == '\r') {
+ sc.Forward();
+ if (sc.ch == '\r' && sc.chNext == '\n') {
+ sc.Forward();
+ }
+ sc.Forward();
+ continue;
+ }
+ }
+ // Determine if a new state should be terminated.
+ mask = sc.state & 0x10;
+ switch (sc.state & 0xf) {
+ case SCE_4GL_OPERATOR:
+ sc.SetState(SCE_4GL_DEFAULT | mask);
+ break;
+ case SCE_4GL_NUMBER:
+ if (!(IsADigit(sc.ch))) {
+ sc.SetState(SCE_4GL_DEFAULT | mask);
+ }
+ break;
+ case SCE_4GL_IDENTIFIER:
+ if (!IsAWordChar(sc.ch) && sc.ch != '-') {
+ char s[1000];
+ sc.GetCurrentLowered(s, sizeof(s));
+ if (((sc.state & 0x10) == 0) && keywords2.InList(s) || keywords3.InList(s)) {
+ sc.ChangeState(SCE_4GL_BLOCK | ResetSentenceStart);
+ }
+ else if (keywords1.InList(s)) {
+ if ((s[0] == 'e' && s[1] =='n' && s[2] == 'd' && !isalnum(s[3]) && s[3] != '-') ||
+ (s[0] == 'f' && s[1] =='o' && s[2] == 'r' && s[3] == 'w' && s[4] =='a' && s[5] == 'r' && s[6] == 'd'&& !isalnum(s[7]))) {
+ sc.ChangeState(SCE_4GL_END | ResetSentenceStart);
+ }
+ else if ((s[0] == 'e' && s[1] =='l' && s[2] == 's' && s[3] == 'e') ||
+ (s[0] == 't' && s[1] =='h' && s[2] == 'e' && s[3] == 'n')) {
+ sc.ChangeState(SCE_4GL_WORD & SetSentenceStart);
+ }
+ else {
+ sc.ChangeState(SCE_4GL_WORD | ResetSentenceStart);
+ }
+ }
+ sc.SetState(SCE_4GL_DEFAULT | (sc.state & 0x10));
+ }
+ break;
+ case SCE_4GL_PREPROCESSOR:
+ if (sc.atLineStart) {
+ sc.SetState(SCE_4GL_DEFAULT & SetSentenceStart);
+ } else if (sc.ch == '*' && sc.chNext == '/') {
+ sc.ForwardSetState(SCE_4GL_DEFAULT | mask);
+ }
+ break;
+ case SCE_4GL_STRING:
+ if (sc.ch == '\"') {
+ sc.ForwardSetState(SCE_4GL_DEFAULT | mask);
+ }
+ break;
+ case SCE_4GL_CHARACTER:
+ if (sc.ch == '\'') {
+ sc.ForwardSetState(SCE_4GL_DEFAULT | mask);
+ }
+ break;
+ default:
+ if ((sc.state & 0xf) >= SCE_4GL_COMMENT1) {
+ if (sc.ch == '*' && sc.chNext == '/') {
+ sc.Forward();
+ if ((sc.state & 0xf) == SCE_4GL_COMMENT1) {
+ sc.ForwardSetState(SCE_4GL_DEFAULT | mask);
+ }
+ else
+ sc.SetState((sc.state & 0x1f) - 1);
+ } else if (sc.ch == '/' && sc.chNext == '*') {
+ sc.Forward();
+ sc.SetState((sc.state & 0x1f) + 1);
+ }
+ }
+ }
+
+ // Determine if a new state should be entered.
+ mask = sc.state & 0x10;
+ if ((sc.state & 0xf) == SCE_4GL_DEFAULT) {
+ if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
+ sc.SetState(SCE_4GL_NUMBER | ResetSentenceStart);
+ } else if (IsAWordStart(sc.ch) || (sc.ch == '@')) {
+ sc.SetState(SCE_4GL_IDENTIFIER | mask);
+ } else if (sc.ch == '/' && sc.chNext == '*') {
+ sc.SetState(SCE_4GL_COMMENT1 | mask);
+ sc.Forward();
+ } else if (sc.ch == '\"') {
+ sc.SetState(SCE_4GL_STRING | ResetSentenceStart);
+ } else if (sc.ch == '\'') {
+ sc.SetState(SCE_4GL_CHARACTER | ResetSentenceStart);
+ } else if (sc.ch == '&' && visibleChars == 0 && ((sc.state & 0x10) == 0)) {
+ sc.SetState(SCE_4GL_PREPROCESSOR | ResetSentenceStart);
+ // Skip whitespace between & and preprocessor word
+ do {
+ sc.Forward();
+ } while ((sc.ch == ' ' || sc.ch == '\t') && sc.More());
+ // Handle syntactical line termination
+ } else if ((sc.ch == '.' || sc.ch == ':' || sc.ch == '}') && (sc.chNext == ' ' || sc.chNext == '\t' || sc.chNext == '\n' || sc.chNext == '\r')) {
+ sc.SetState(sc.state & SetSentenceStart);
+ } else if (isoperator(static_cast<char>(sc.ch))) {
+ if (sc.ch == ':')
+ sc.SetState(SCE_4GL_OPERATOR & SetSentenceStart);
+ else
+ sc.SetState(SCE_4GL_OPERATOR | ResetSentenceStart);
+ }
+ }
+
+ if (!IsASpace(sc.ch)) {
+ visibleChars++;
+ }
+ }
+ sc.Complete();
+}
+
+static bool IsStreamCommentStyle(int style) {
+ return (style & 0xf) >= SCE_4GL_COMMENT1 ;
+}
+
+// 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 FoldNoBox4glDoc(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("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 = static_cast<char>(tolower(styler[startPos]));
+ int styleNext = styler.StyleAt(startPos);
+ int style = initStyle;
+ for (unsigned int i = startPos; i < endPos; i++) {
+ char ch = chNext;
+ chNext = static_cast<char>(tolower(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--;
+ }
+ }
+ else if ((style & 0xf) == SCE_4GL_BLOCK && !isalnum(chNext)) {
+ levelNext++;
+ }
+ else if ((style & 0xf) == SCE_4GL_END && (ch == 'e' || ch == 'f')) {
+ levelNext--;
+ }
+ if (atEOL) {
+ 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 (!isspacechar(ch))
+ visibleChars++;
+ }
+}
+
+static void Fold4glDoc(unsigned int startPos, int length, int initStyle, WordList *[],
+ Accessor &styler) {
+ FoldNoBox4glDoc(startPos, length, initStyle, styler);
+}
+
+static const char * const FglWordLists[] = {
+ "Primary keywords and identifiers",
+ "Secondary keywords and identifiers",
+ "Documentation comment keywords",
+ "Unused",
+ "Global classes and typedefs",
+ 0,
+ };
+
+LexerModule lmProgress(SCLEX_PS, Colourise4glDoc, "progress", Fold4glDoc, FglWordLists);
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
enum kwType { kwOther, kwClass, kwDef, kwImport };
+static const int indicatorWhitespace = 1;
static bool IsPyComment(Accessor &styler, int pos, int len) {
return len > 0 && styler[pos] == '#';
styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
bool hexadecimal = false;
- // Python uses a different mask because bad indentation is marked by oring with 32
- StyleContext sc(startPos, endPos - startPos, initStyle, styler, 0x7f);
+ StyleContext sc(startPos, endPos - startPos, initStyle, styler);
+
+ bool indentGood = true;
+ int startIndicator = sc.currentPos;
for (; sc.More(); sc.Forward()) {
if (sc.atLineStart) {
- const char chBad = static_cast<char>(64);
- const char chGood = static_cast<char>(0);
- char chFlags = chGood;
+ styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
+ indentGood = true;
if (whingeLevel == 1) {
- chFlags = (spaceFlags & wsInconsistent) ? chBad : chGood;
+ indentGood = (spaceFlags & wsInconsistent) == 0;
} else if (whingeLevel == 2) {
- chFlags = (spaceFlags & wsSpaceTab) ? chBad : chGood;
+ indentGood = (spaceFlags & wsSpaceTab) == 0;
} else if (whingeLevel == 3) {
- chFlags = (spaceFlags & wsSpace) ? chBad : chGood;
+ indentGood = (spaceFlags & wsSpace) == 0;
} else if (whingeLevel == 4) {
- chFlags = (spaceFlags & wsTab) ? chBad : chGood;
+ indentGood = (spaceFlags & wsTab) == 0;
+ }
+ if (!indentGood) {
+ styler.IndicatorFill(startIndicator, sc.currentPos, indicatorWhitespace, 0);
+ startIndicator = sc.currentPos;
}
- sc.SetState(sc.state);
- styler.SetFlags(chFlags, static_cast<char>(sc.state));
}
if (sc.atLineEnd) {
sc.SetState(sc.state);
}
lineCurrent++;
- styler.IndentAmount(lineCurrent, &spaceFlags, IsPyComment);
if ((sc.state == SCE_P_STRING) || (sc.state == SCE_P_CHARACTER)) {
sc.ChangeState(SCE_P_STRINGEOL);
sc.ForwardSetState(SCE_P_DEFAULT);
sc.SetState(SCE_P_DEFAULT);
}
} else if (sc.state == SCE_P_DECORATOR) {
- if (sc.ch == '\r' || sc.ch == '\n') {
+ if (!IsAWordChar(sc.ch)) {
sc.SetState(SCE_P_DEFAULT);
- } else if (sc.ch == '#') {
- sc.SetState((sc.chNext == '#') ? SCE_P_COMMENTBLOCK : SCE_P_COMMENTLINE);
}
} else if ((sc.state == SCE_P_STRING) || (sc.state == SCE_P_CHARACTER)) {
if (sc.ch == '\\') {
}
}
+ if (!indentGood && !IsASpaceOrTab(sc.ch)) {
+ styler.IndicatorFill(startIndicator, sc.currentPos, indicatorWhitespace, 1);
+ startIndicator = sc.currentPos;
+ indentGood = true;
+ }
+
// State exit code may have moved on to end of line
if (needEOLCheck && sc.atLineEnd) {
lineCurrent++;
}
}
}
+ styler.IndicatorFill(startIndicator, sc.currentPos, indicatorWhitespace, 0);
sc.Complete();
}
--- /dev/null
+// Scintilla source code edit control
+/** @file Lexr.cxx
+ ** Lexer for R, S, SPlus Statistics Program (Heavily derived from CPP Lexer).
+ **
+ **/
+// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "PropSet.h"
+#include "Accessor.h"
+#include "StyleContext.h"
+#include "KeyWords.h"
+#include "Scintilla.h"
+#include "SciLexer.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+static inline bool IsAWordChar(const int ch) {
+ return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
+}
+
+static inline bool IsAWordStart(const int ch) {
+ return (ch < 0x80) && (isalnum(ch) || ch == '_');
+}
+
+static inline bool IsAnOperator(const int ch) {
+ if (isascii(ch) && isalnum(ch))
+ return false;
+ // '.' left out as it is used to make up numbers
+ if (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 void ColouriseRDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
+ Accessor &styler) {
+
+ WordList &keywords = *keywordlists[0];
+ WordList &keywords2 = *keywordlists[1];
+ WordList &keywords3 = *keywordlists[2];
+
+
+ // Do not leak onto next line
+ if (initStyle == SCE_R_INFIXEOL)
+ initStyle = SCE_R_DEFAULT;
+
+
+ StyleContext sc(startPos, length, initStyle, styler);
+
+ for (; sc.More(); sc.Forward()) {
+
+ if (sc.atLineStart && (sc.state == SCE_R_STRING)) {
+ // Prevent SCE_R_STRINGEOL from leaking back to previous line
+ sc.SetState(SCE_R_STRING);
+ }
+
+ // Determine if the current state should terminate.
+ if (sc.state == SCE_R_OPERATOR) {
+ sc.SetState(SCE_R_DEFAULT);
+ } else if (sc.state == SCE_R_NUMBER) {
+ if (!IsADigit(sc.ch) && !(sc.ch == '.' && IsADigit(sc.chNext))) {
+ sc.SetState(SCE_R_DEFAULT);
+ }
+ } else if (sc.state == SCE_R_IDENTIFIER) {
+ if (!IsAWordChar(sc.ch) || (sc.ch == '.')) {
+ char s[100];
+ sc.GetCurrentLowered(s, sizeof(s));
+ if (keywords.InList(s)) {
+ sc.ChangeState(SCE_R_KWORD);
+ } else if (keywords2.InList(s)) {
+ sc.ChangeState(SCE_R_BASEKWORD);
+ } else if (keywords3.InList(s)) {
+ sc.ChangeState(SCE_R_OTHERKWORD);
+ }
+ sc.SetState(SCE_R_DEFAULT);
+ }
+ } else if (sc.state == SCE_R_COMMENT) {
+ if (sc.ch == '\r' || sc.ch == '\n') {
+ sc.SetState(SCE_R_DEFAULT);
+ }
+ } else if (sc.state == SCE_R_STRING) {
+ if (sc.ch == '\\') {
+ if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+ sc.Forward();
+ }
+ } else if (sc.ch == '\"') {
+ sc.ForwardSetState(SCE_R_DEFAULT);
+ }
+ } else if (sc.state == SCE_R_INFIX) {
+ if (sc.ch == '%') {
+ sc.ForwardSetState(SCE_R_DEFAULT);
+ } else if (sc.atLineEnd) {
+ sc.ChangeState(SCE_R_INFIXEOL);
+ sc.ForwardSetState(SCE_R_DEFAULT);
+ }
+ }else if (sc.state == SCE_R_STRING2) {
+ if (sc.ch == '\\') {
+ if (sc.chNext == '\"' || sc.chNext == '\'' || sc.chNext == '\\') {
+ sc.Forward();
+ }
+ } else if (sc.ch == '\'') {
+ sc.ForwardSetState(SCE_R_DEFAULT);
+ }
+ }
+
+ // Determine if a new state should be entered.
+ if (sc.state == SCE_R_DEFAULT) {
+ if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) {
+ sc.SetState(SCE_R_NUMBER);
+ } else if (IsAWordStart(sc.ch) ) {
+ sc.SetState(SCE_R_IDENTIFIER);
+ } else if (sc.Match('#')) {
+ sc.SetState(SCE_R_COMMENT);
+ } else if (sc.ch == '\"') {
+ sc.SetState(SCE_R_STRING);
+ } else if (sc.ch == '%') {
+ sc.SetState(SCE_R_INFIX);
+ } else if (sc.ch == '\'') {
+ sc.SetState(SCE_R_STRING2);
+ } else if (IsAnOperator(sc.ch)) {
+ sc.SetState(SCE_R_OPERATOR);
+ }
+ }
+ }
+ sc.Complete();
+}
+
+// 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 FoldRDoc(unsigned int startPos, int length, int, WordList *[],
+ Accessor &styler) {
+ bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0;
+ bool foldAtElse = 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);
+ for (unsigned int i = startPos; i < endPos; i++) {
+ char ch = chNext;
+ chNext = styler.SafeGetCharAt(i + 1);
+ int style = styleNext;
+ styleNext = styler.StyleAt(i + 1);
+ bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
+ if (style == SCE_R_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) {
+ 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 (!isspacechar(ch))
+ visibleChars++;
+ }
+}
+
+
+static const char * const RWordLists[] = {
+ "Language Keywords",
+ "Base / Default package function",
+ "Other Package Functions",
+ "Unused",
+ "Unused",
+ 0,
+ };
+
+
+
+LexerModule lmR(SCLEX_R, ColouriseRDoc, "r", FoldRDoc, RWordLists);
#include "SciLexer.h"
#include "StyleContext.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
static inline bool IsAWordChar(const int ch) {
return (isalnum(ch) || ch == '?' || ch == '!' || ch == '.' || ch == '\'' || ch == '+' || ch == '-' || ch == '*' || ch == '&' || ch == '|' || ch == '=' || ch == '_' || ch == '~');
}
static inline bool isSafeWordcharOrHigh(char ch) {
- return isHighBitChar(ch) || iswordchar(ch);
+ // Error: scintilla's KeyWords.h includes '.' as a word-char
+ // we want to separate things that can take methods from the
+ // methods.
+ return isHighBitChar(ch) || isalnum(ch) || ch == '_';
}
static bool inline iswhitespace(char ch) {
Accessor &styler);
static int ClassifyWordRb(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord) {
- char s[100];
+ char s[MAX_KEYWORD_LENGTH];
unsigned int i, j;
unsigned int lim = end - start + 1; // num chars to copy
if (lim >= MAX_KEYWORD_LENGTH) {
return true;
}
+// This class is used by the enter and exit methods, so it needs
+// to be hoisted out of the function.
+
+class QuoteCls {
+ public:
+ int Count;
+ char Up;
+ char Down;
+ QuoteCls() {
+ this->New();
+ }
+ void New() {
+ Count = 0;
+ Up = '\0';
+ Down = '\0';
+ }
+ void Open(char u) {
+ Count++;
+ Up = u;
+ Down = opposite(Up);
+ }
+ QuoteCls(const QuoteCls& q) {
+ // copy constructor -- use this for copying in
+ Count = q.Count;
+ Up = q.Up;
+ Down = q.Down;
+ }
+ QuoteCls& operator=(const QuoteCls& q) { // assignment constructor
+ if (this != &q) {
+ Count = q.Count;
+ Up = q.Up;
+ Down = q.Down;
+ }
+ return *this;
+ }
+
+};
+
+
+static void enterInnerExpression(int *p_inner_string_types,
+ int *p_inner_expn_brace_counts,
+ QuoteCls *p_inner_quotes,
+ int& inner_string_count,
+ int& state,
+ int& brace_counts,
+ QuoteCls curr_quote
+ ) {
+ p_inner_string_types[inner_string_count] = state;
+ state = SCE_RB_DEFAULT;
+ p_inner_expn_brace_counts[inner_string_count] = brace_counts;
+ brace_counts = 0;
+ p_inner_quotes[inner_string_count] = curr_quote;
+ ++inner_string_count;
+}
+
+static void exitInnerExpression(int *p_inner_string_types,
+ int *p_inner_expn_brace_counts,
+ QuoteCls *p_inner_quotes,
+ int& inner_string_count,
+ int& state,
+ int& brace_counts,
+ QuoteCls& curr_quote
+ ) {
+ --inner_string_count;
+ state = p_inner_string_types[inner_string_count];
+ brace_counts = p_inner_expn_brace_counts[inner_string_count];
+ curr_quote = p_inner_quotes[inner_string_count];
+}
static bool isEmptyLine(int pos,
Accessor &styler) {
//
// iPrev points to the start of <<
-static bool sureThisIsHeredoc(int iPrev,
+static bool sureThisIsHeredoc(int iPrev,
Accessor &styler,
char *prevWord) {
};
HereDocCls HereDoc;
- class QuoteCls {
- public:
- int Count;
- char Up;
- char Down;
- QuoteCls() {
- this->New();
- }
- void New() {
- Count = 0;
- Up = '\0';
- Down = '\0';
- }
- void Open(char u) {
- Count++;
- Up = u;
- Down = opposite(Up);
- }
- };
QuoteCls Quote;
int numDots = 0; // For numbers --
char chPrev = styler.SafeGetCharAt(startPos - 1);
char chNext = styler.SafeGetCharAt(startPos);
+ bool is_real_number = true; // Differentiate between constants and ?-sequences.
// Ruby uses a different mask because bad indentation is marked by oring with 32
styler.StartAt(startPos, 127);
styler.StartSegment(startPos);
SCE_RB_STRING_QW,
SCE_RB_STRING_QX};
static const char* q_chars = "qQrwWx";
-
- for (int i = startPos; i < lengthDoc; i++) {
+
+ // In most cases a value of 2 should be ample for the code in the
+ // Ruby library, and the code the user is likely to enter.
+ // For example,
+ // fu_output_message "mkdir #{options[:mode] ? ('-m %03o ' % options[:mode]) : ''}#{list.join ' '}"
+ // if options[:verbose]
+ // from fileutils.rb nests to a level of 2
+ // If the user actually hits a 6th occurrence of '#{' in a double-quoted
+ // string (including regex'es, %Q, %<sym>, %w, and other strings
+ // that interpolate), it will stay as a string. The problem with this
+ // is that quotes might flip, a 7th '#{' will look like a comment,
+ // and code-folding might be wrong.
+
+ // If anyone runs into this problem, I recommend raising this
+ // value slightly higher to replacing the fixed array with a linked
+ // list. Keep in mind this code will be called everytime the lexer
+ // is invoked.
+
+#define INNER_STRINGS_MAX_COUNT 5
+ // These vars track our instances of "...#{,,,%Q<..#{,,,}...>,,,}..."
+ int inner_string_types[INNER_STRINGS_MAX_COUNT];
+ // Track # braces when we push a new #{ thing
+ int inner_expn_brace_counts[INNER_STRINGS_MAX_COUNT];
+ QuoteCls inner_quotes[INNER_STRINGS_MAX_COUNT];
+ int inner_string_count = 0;
+ int brace_counts = 0; // Number of #{ ... } things within an expression
+
+ int i;
+ for (i = 0; i < INNER_STRINGS_MAX_COUNT; i++) {
+ inner_string_types[i] = 0;
+ inner_expn_brace_counts[i] = 0;
+ }
+ for (i = startPos; i < lengthDoc; i++) {
char ch = chNext;
chNext = styler.SafeGetCharAt(i + 1);
char chNext2 = styler.SafeGetCharAt(i + 2);
if (isSafeDigit(ch)) {
styler.ColourTo(i - 1, state);
state = SCE_RB_NUMBER;
+ is_real_number = true;
numDots = 0;
} else if (isHighBitChar(ch) || iswordstart(ch)) {
styler.ColourTo(i - 1, state);
chNext = styler.SafeGetCharAt(i + 1);
have_string = true;
}
- } else if (!isSafeWordcharOrHigh(chNext)) {
+ } else if (preferRE && !isSafeWordcharOrHigh(chNext)) {
// Ruby doesn't allow high bit chars here,
// but the editor host might
state = SCE_RB_STRING_QQ;
// stay in default
preferRE = true;
}
+ } else if (ch == '?') {
+ styler.ColourTo(i - 1, state);
+ if (iswhitespace(chNext) || chNext == '\n' || chNext == '\r') {
+ styler.ColourTo(i, SCE_RB_OPERATOR);
+ } else {
+ // It's the start of a character code escape sequence
+ // Color it as a number.
+ state = SCE_RB_NUMBER;
+ is_real_number = false;
+ }
} else if (isoperator(ch) || ch == '.') {
styler.ColourTo(i - 1, state);
styler.ColourTo(i, SCE_RB_OPERATOR);
// we aren't ending an object exp'n, and ops
// like : << / are unary operators.
- preferRE = (strchr(")}].", ch) == NULL);
+ if (ch == '{') {
+ ++brace_counts;
+ preferRE = true;
+ } else if (ch == '}' && --brace_counts < 0
+ && inner_string_count > 0) {
+ styler.ColourTo(i, SCE_RB_OPERATOR);
+ exitInnerExpression(inner_string_types,
+ inner_expn_brace_counts,
+ inner_quotes,
+ inner_string_count,
+ state, brace_counts, Quote);
+ } else {
+ preferRE = (strchr(")}].", ch) == NULL);
+ }
// Stay in default state
} else if (isEOLChar(ch)) {
// Make sure it's a true line-end, with no backslash
}
}
} else if (state == SCE_RB_NUMBER) {
- if (isSafeAlnumOrHigh(ch) || ch == '_') {
+ if (!is_real_number) {
+ if (ch != '\\') {
+ styler.ColourTo(i, state);
+ state = SCE_RB_DEFAULT;
+ preferRE = false;
+ } else if (strchr("\\ntrfvaebs", chNext)) {
+ // Terminal escape sequence -- handle it next time
+ // Nothing more to do this time through the loop
+ } else if (chNext == 'C' || chNext == 'M') {
+ if (chNext2 != '-') {
+ // \C or \M ends the sequence -- handle it next time
+ } else {
+ // Move from abc?\C-x
+ // ^
+ // to
+ // ^
+ i += 2;
+ ch = chNext2;
+ chNext = styler.SafeGetCharAt(i + 1);
+ }
+ } else if (chNext == 'c') {
+ // Stay here, \c is a combining sequence
+ advance_char(i, ch, chNext, chNext2); // pass by ref
+ } else {
+ // ?\x, including ?\\ is final.
+ styler.ColourTo(i + 1, state);
+ state = SCE_RB_DEFAULT;
+ preferRE = false;
+ advance_char(i, ch, chNext, chNext2);
+ }
+ } else if (isSafeAlnumOrHigh(ch) || ch == '_') {
// Keep going
} else if (ch == '.' && ++numDots == 1) {
// Keep going
Quote.Count++;
} else if (ch == '#' ) {
- //todo: distinguish comments from pound chars
- // for now, handle as comment
- styler.ColourTo(i - 1, state);
- bool inEscape = false;
- while (++i < lengthDoc) {
- ch = styler.SafeGetCharAt(i);
- if (ch == '\\') {
- inEscape = true;
- } else if (isEOLChar(ch)) {
- // Comment inside a regex
- styler.ColourTo(i - 1, SCE_RB_COMMENTLINE);
- break;
- } else if (inEscape) {
- inEscape = false; // don't look at char
- } else if (ch == Quote.Down) {
- // Have the regular handler deal with this
- // to get trailing modifiers.
- i--;
- ch = styler[i];
- break;
+ if (chNext == '{'
+ && inner_string_count < INNER_STRINGS_MAX_COUNT) {
+ // process #{ ... }
+ styler.ColourTo(i - 1, state);
+ styler.ColourTo(i + 1, SCE_RB_OPERATOR);
+ enterInnerExpression(inner_string_types,
+ inner_expn_brace_counts,
+ inner_quotes,
+ inner_string_count,
+ state,
+ brace_counts,
+ Quote);
+ preferRE = true;
+ // Skip one
+ advance_char(i, ch, chNext, chNext2);
+ } else {
+ //todo: distinguish comments from pound chars
+ // for now, handle as comment
+ styler.ColourTo(i - 1, state);
+ bool inEscape = false;
+ while (++i < lengthDoc) {
+ ch = styler.SafeGetCharAt(i);
+ if (ch == '\\') {
+ inEscape = true;
+ } else if (isEOLChar(ch)) {
+ // Comment inside a regex
+ styler.ColourTo(i - 1, SCE_RB_COMMENTLINE);
+ break;
+ } else if (inEscape) {
+ inEscape = false; // don't look at char
+ } else if (ch == Quote.Down) {
+ // Have the regular handler deal with this
+ // to get trailing modifiers.
+ i--;
+ ch = styler[i];
+ break;
+ }
}
+ chNext = styler.SafeGetCharAt(i + 1);
+ chNext2 = styler.SafeGetCharAt(i + 2);
}
- chNext = styler.SafeGetCharAt(i + 1);
- chNext2 = styler.SafeGetCharAt(i + 2);
}
// Quotes of all kinds...
} else if (state == SCE_RB_STRING_Q || state == SCE_RB_STRING_QQ ||
}
} else if (ch == Quote.Up) {
Quote.Count++;
+ } else if (ch == '#' && chNext == '{'
+ && inner_string_count < INNER_STRINGS_MAX_COUNT
+ && state != SCE_RB_CHARACTER
+ && state != SCE_RB_STRING_Q) {
+ // process #{ ... }
+ styler.ColourTo(i - 1, state);
+ styler.ColourTo(i + 1, SCE_RB_OPERATOR);
+ enterInnerExpression(inner_string_types,
+ inner_expn_brace_counts,
+ inner_quotes,
+ inner_string_count,
+ state,
+ brace_counts,
+ Quote);
+ preferRE = true;
+ // Skip one
+ advance_char(i, ch, chNext, chNext2);
}
}
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
static inline bool IsAWordChar(int ch) {
- return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_');
+ return (ch < 0x80) && (isalnum(ch) || ch == '_');
}
static inline bool IsAWordStart(int ch) {
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
static void ClassifyWordSol(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord)
{
char s[100];
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
/*
| lexTable classificationBlock charClasses |
charClasses := #(#DecDigit #Letter #Special #Upper #BinSel).
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
static inline bool IsAWordChar(const int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_' || ch == '\'');
#include "SciLexer.h"
#include "SString.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
/*
* Interface
*/
/** @file LexTADS3.cxx
** Lexer for TADS3.
**/
-/* Copyright 2005 by Michael Cartmell
- * Parts copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
- * In particular FoldTADS3Doc is derived from FoldCppDoc
- * The License.txt file describes the conditions under which this software may
- * be distributed.
- */
+// Copyright 1998-2006 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
/*
* TADS3 is a language designed by Michael J. Roberts for the writing of text
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
static const int T3_SINGLE_QUOTE = 1;
static const int T3_INT_EXPRESSION = 2;
+static const int T3_INT_EXPRESSION_IN_TAG = 4;
+static const int T3_HTML_SQUOTE = 8;
static inline bool IsEOL(const int ch, const int chNext) {
- return (ch == '\r' && chNext != '\n') || (ch == '\n');
+ return (ch == '\r' && chNext != '\n') || (ch == '\n');
+}
+
+/*
+ * Test the current character to see if it's the START of an EOL sequence;
+ * if so, skip ahead to the last character of the sequence and return true,
+ * and if not just return false. There are a few places where we want to
+ * check to see if a newline sequence occurs at a particular point, but
+ * where a caller expects a subroutine to stop only upon reaching the END
+ * of a newline sequence (in particular, CR-LF on Windows). That's why
+ * IsEOL() above only returns true on CR if the CR isn't followed by an LF
+ * - it doesn't want to admit that there's a newline until reaching the END
+ * of the sequence. We meet both needs by saying that there's a newline
+ * when we see the CR in a CR-LF, but skipping the CR before returning so
+ * that the caller's caller will see that we've stopped at the LF.
+ */
+static inline bool IsEOLSkip(StyleContext &sc)
+{
+ /* test for CR-LF */
+ if (sc.ch == '\r' && sc.chNext == '\n')
+ {
+ /* got CR-LF - skip the CR and indicate that we're at a newline */
+ sc.Forward();
+ return true;
+ }
+
+ /*
+ * in other cases, we have at most a 1-character newline, so do the
+ * normal IsEOL test
+ */
+ return IsEOL(sc.ch, sc.chNext);
}
static inline bool IsASpaceOrTab(const int ch) {
- return ch == ' ' || ch == '\t';
+ return ch == ' ' || ch == '\t';
}
static inline bool IsATADS3Operator(const int ch) {
- return ch == '=' || ch == '{' || ch == '}' || ch == '(' || ch == ')'
- || ch == '[' || ch == ']' || ch == ',' || ch == ':' || ch == ';'
- || ch == '+' || ch == '-' || ch == '*' || ch == '/' || ch == '%'
- || ch == '?' || ch == '!' || ch == '<' || ch == '>' || ch == '|'
- || ch == '@' || ch == '&' || ch == '~';
+ return ch == '=' || ch == '{' || ch == '}' || ch == '(' || ch == ')'
+ || ch == '[' || ch == ']' || ch == ',' || ch == ':' || ch == ';'
+ || ch == '+' || ch == '-' || ch == '*' || ch == '/' || ch == '%'
+ || ch == '?' || ch == '!' || ch == '<' || ch == '>' || ch == '|'
+ || ch == '@' || ch == '&' || ch == '~';
}
static inline bool IsAWordChar(const int ch) {
- return isalnum(ch) || ch == '_' || ch == '.';
+ return isalnum(ch) || ch == '_';
}
static inline bool IsAWordStart(const int ch) {
- return isalpha(ch) || ch == '_';
+ return isalpha(ch) || ch == '_';
}
static inline bool IsAHexDigit(const int ch) {
- int lch = tolower(ch);
- return isdigit(lch) || lch == 'a' || lch == 'b' || lch == 'c'
- || lch == 'd' || lch == 'e' || lch == 'f';
+ int lch = tolower(ch);
+ return isdigit(lch) || lch == 'a' || lch == 'b' || lch == 'c'
+ || lch == 'd' || lch == 'e' || lch == 'f';
}
static inline bool IsAnHTMLChar(int ch) {
- return isalnum(ch) || ch == '-' || ch == '_' || ch == '.';
+ return isalnum(ch) || ch == '-' || ch == '_' || ch == '.';
}
static inline bool IsADirectiveChar(int ch) {
- return isalnum(ch) || isspace(ch) || ch == '-' || ch == '/';
+ return isalnum(ch) || isspace(ch) || ch == '-' || ch == '/';
}
static inline bool IsANumberStart(StyleContext &sc) {
- return isdigit(sc.ch)
- || (!isdigit(sc.chPrev) && sc.ch == '.' && isdigit(sc.chNext));
+ return isdigit(sc.ch)
+ || (!isdigit(sc.chPrev) && sc.ch == '.' && isdigit(sc.chNext));
}
inline static void ColouriseTADS3Operator(StyleContext &sc) {
- int initState = sc.state;
- sc.SetState(SCE_T3_OPERATOR);
- sc.ForwardSetState(initState);
+ int initState = sc.state;
+ int c = sc.ch;
+ sc.SetState(c == '{' || c == '}' ? SCE_T3_BRACE : SCE_T3_OPERATOR);
+ sc.ForwardSetState(initState);
}
static void ColouriseTADSHTMLString(StyleContext &sc, int &lineState) {
- int endState = sc.state;
- int chQuote = sc.ch;
- if (endState == SCE_T3_HTML_STRING) {
- if (lineState&T3_SINGLE_QUOTE) {
- endState = SCE_T3_S_STRING;
- chQuote = '"';
- } else if (lineState&T3_INT_EXPRESSION) {
- endState = SCE_T3_X_STRING;
- chQuote = '\'';
- } else {
- endState = SCE_T3_D_STRING;
- chQuote = '\'';
- }
- } else {
- sc.SetState(SCE_T3_HTML_STRING);
- sc.Forward();
- }
- int chString = chQuote == '"'? '\'': '"';
-
- while (sc.More()) {
- if (IsEOL(sc.ch, sc.chNext)) {
- return;
- }
- if (sc.ch == chQuote) {
- sc.ForwardSetState(endState);
- return;
- }
- if (sc.ch == chString) {
- sc.SetState(endState);
- return;
- }
- if (sc.Match('\\', static_cast<char>(chQuote))
- || sc.Match('\\', static_cast<char>(chString))) {
- sc.Forward(2);
- } else {
- sc.Forward();
- }
- }
+ int endState = sc.state;
+ int chQuote = sc.ch;
+ int chString = (lineState & T3_SINGLE_QUOTE) ? '\'' : '"';
+ if (endState == SCE_T3_HTML_STRING) {
+ if (lineState&T3_SINGLE_QUOTE) {
+ endState = SCE_T3_S_STRING;
+ chString = '\'';
+ } else if (lineState&T3_INT_EXPRESSION) {
+ endState = SCE_T3_X_STRING;
+ chString = '"';
+ } else {
+ endState = SCE_T3_HTML_DEFAULT;
+ chString = '"';
+ }
+ chQuote = (lineState & T3_HTML_SQUOTE) ? '\'' : '"';
+ } else {
+ sc.SetState(SCE_T3_HTML_STRING);
+ sc.Forward();
+ }
+ if (chQuote == '"')
+ lineState &= ~T3_HTML_SQUOTE;
+ else
+ lineState |= T3_HTML_SQUOTE;
+
+ while (sc.More()) {
+ if (IsEOL(sc.ch, sc.chNext)) {
+ return;
+ }
+ if (sc.ch == chQuote) {
+ sc.ForwardSetState(endState);
+ return;
+ }
+ if (sc.Match('\\', static_cast<char>(chQuote))) {
+ sc.Forward(2);
+ sc.SetState(endState);
+ return;
+ }
+ if (sc.ch == chString) {
+ sc.SetState(SCE_T3_DEFAULT);
+ return;
+ }
+
+ if (sc.Match('<', '<')) {
+ lineState |= T3_INT_EXPRESSION | T3_INT_EXPRESSION_IN_TAG;
+ sc.SetState(SCE_T3_X_DEFAULT);
+ sc.Forward(2);
+ return;
+ }
+
+ if (sc.Match('\\', static_cast<char>(chQuote))
+ || sc.Match('\\', static_cast<char>(chString))
+ || sc.Match('\\', '\\')) {
+ sc.Forward(2);
+ } else {
+ sc.Forward();
+ }
+ }
}
static void ColouriseTADS3HTMLTagStart(StyleContext &sc) {
- sc.SetState(SCE_T3_HTML_TAG);
- sc.Forward();
- if (sc.ch == '/') {
- sc.Forward();
- }
- while (IsAnHTMLChar(sc.ch)) {
- sc.Forward();
- }
+ sc.SetState(SCE_T3_HTML_TAG);
+ sc.Forward();
+ if (sc.ch == '/') {
+ sc.Forward();
+ }
+ while (IsAnHTMLChar(sc.ch)) {
+ sc.Forward();
+ }
}
static void ColouriseTADS3HTMLTag(StyleContext &sc, int &lineState) {
- int endState = sc.state;
- int chQuote = '"';
- int chString = '\'';
- switch (endState) {
- case SCE_T3_S_STRING:
- ColouriseTADS3HTMLTagStart(sc);
- sc.SetState(SCE_T3_HTML_DEFAULT);
- chQuote = '\'';
- chString = '"';
- break;
- case SCE_T3_D_STRING:
- case SCE_T3_X_STRING:
- ColouriseTADS3HTMLTagStart(sc);
- sc.SetState(SCE_T3_HTML_DEFAULT);
- break;
- case SCE_T3_HTML_DEFAULT:
- if (lineState&T3_SINGLE_QUOTE) {
- endState = SCE_T3_S_STRING;
- chQuote = '\'';
- chString = '"';
- } else if (lineState&T3_INT_EXPRESSION) {
- endState = SCE_T3_X_STRING;
- } else {
- endState = SCE_T3_D_STRING;
- }
- break;
- }
-
- while (sc.More()) {
- if (IsEOL(sc.ch, sc.chNext)) {
- return;
- }
- if (sc.Match('/', '>')) {
- sc.SetState(SCE_T3_HTML_TAG);
- sc.Forward(2);
- sc.SetState(endState);
- return;
- }
- if (sc.ch == '>') {
- sc.SetState(SCE_T3_HTML_TAG);
- sc.ForwardSetState(endState);
- return;
- }
- if (sc.ch == chQuote) {
- sc.SetState(endState);
- return;
- }
- if (sc.ch == chString) {
- ColouriseTADSHTMLString(sc, lineState);
- } else if (sc.ch == '=') {
- ColouriseTADS3Operator(sc);
- } else {
- sc.Forward();
- }
- }
+ int endState = sc.state;
+ int chQuote = '"';
+ int chString = '\'';
+ switch (endState) {
+ case SCE_T3_S_STRING:
+ ColouriseTADS3HTMLTagStart(sc);
+ sc.SetState(SCE_T3_HTML_DEFAULT);
+ chQuote = '\'';
+ chString = '"';
+ break;
+ case SCE_T3_D_STRING:
+ case SCE_T3_X_STRING:
+ ColouriseTADS3HTMLTagStart(sc);
+ sc.SetState(SCE_T3_HTML_DEFAULT);
+ break;
+ case SCE_T3_HTML_DEFAULT:
+ if (lineState&T3_SINGLE_QUOTE) {
+ endState = SCE_T3_S_STRING;
+ chQuote = '\'';
+ chString = '"';
+ } else if (lineState&T3_INT_EXPRESSION) {
+ endState = SCE_T3_X_STRING;
+ } else {
+ endState = SCE_T3_D_STRING;
+ }
+ break;
+ }
+
+ while (sc.More()) {
+ if (IsEOL(sc.ch, sc.chNext)) {
+ return;
+ }
+ if (sc.Match('/', '>')) {
+ sc.SetState(SCE_T3_HTML_TAG);
+ sc.Forward(2);
+ sc.SetState(endState);
+ return;
+ }
+ if (sc.ch == '>') {
+ sc.SetState(SCE_T3_HTML_TAG);
+ sc.ForwardSetState(endState);
+ return;
+ }
+ if (sc.ch == chQuote) {
+ sc.SetState(endState);
+ return;
+ }
+ if (sc.Match('\\', static_cast<char>(chQuote))) {
+ sc.Forward();
+ ColouriseTADSHTMLString(sc, lineState);
+ if (sc.state == SCE_T3_X_DEFAULT)
+ break;
+ } else if (sc.ch == chString) {
+ ColouriseTADSHTMLString(sc, lineState);
+ } else if (sc.ch == '=') {
+ ColouriseTADS3Operator(sc);
+ } else {
+ sc.Forward();
+ }
+ }
}
static void ColouriseTADS3Keyword(StyleContext &sc,
- WordList *keywordlists[], unsigned int endPos) {
- char s[250];
- WordList &keywords = *keywordlists[0];
- WordList &userwords1 = *keywordlists[1];
- WordList &userwords2 = *keywordlists[2];
- WordList &userwords3 = *keywordlists[3];
- int initState = sc.state;
- sc.SetState(SCE_T3_IDENTIFIER);
- while (sc.More() && (IsAWordChar(sc.ch))) {
- sc.Forward();
- }
- sc.GetCurrent(s, sizeof(s));
- if ( strcmp(s, "is") == 0 || strcmp(s, "not") == 0) {
- // have to find if "in" is next
- int n = 1;
- while (n + sc.currentPos < endPos && IsASpaceOrTab(sc.GetRelative(n)))
- n++;
- if (sc.GetRelative(n) == 'i' && sc.GetRelative(n+1) == 'n') {
- sc.Forward(n+2);
- sc.ChangeState(SCE_T3_KEYWORD);
- }
- } else if (keywords.InList(s)) {
- sc.ChangeState(SCE_T3_KEYWORD);
- } else if (userwords3.InList(s)) {
- sc.ChangeState(SCE_T3_USER3);
- } else if (userwords2.InList(s)) {
- sc.ChangeState(SCE_T3_USER2);
- } else if (userwords1.InList(s)) {
- sc.ChangeState(SCE_T3_USER1);
- }
- sc.SetState(initState);
+ WordList *keywordlists[], unsigned int endPos) {
+ char s[250];
+ WordList &keywords = *keywordlists[0];
+ WordList &userwords1 = *keywordlists[1];
+ WordList &userwords2 = *keywordlists[2];
+ WordList &userwords3 = *keywordlists[3];
+ int initState = sc.state;
+ sc.SetState(SCE_T3_IDENTIFIER);
+ while (sc.More() && (IsAWordChar(sc.ch))) {
+ sc.Forward();
+ }
+ sc.GetCurrent(s, sizeof(s));
+ if ( strcmp(s, "is") == 0 || strcmp(s, "not") == 0) {
+ // have to find if "in" is next
+ int n = 1;
+ while (n + sc.currentPos < endPos && IsASpaceOrTab(sc.GetRelative(n)))
+ n++;
+ if (sc.GetRelative(n) == 'i' && sc.GetRelative(n+1) == 'n') {
+ sc.Forward(n+2);
+ sc.ChangeState(SCE_T3_KEYWORD);
+ }
+ } else if (keywords.InList(s)) {
+ sc.ChangeState(SCE_T3_KEYWORD);
+ } else if (userwords3.InList(s)) {
+ sc.ChangeState(SCE_T3_USER3);
+ } else if (userwords2.InList(s)) {
+ sc.ChangeState(SCE_T3_USER2);
+ } else if (userwords1.InList(s)) {
+ sc.ChangeState(SCE_T3_USER1);
+ }
+ sc.SetState(initState);
}
static void ColouriseTADS3MsgParam(StyleContext &sc, int &lineState) {
- int endState = sc.state;
- int chQuote = '"';
- switch (endState) {
- case SCE_T3_S_STRING:
- sc.SetState(SCE_T3_MSG_PARAM);
- sc.Forward();
- chQuote = '\'';
- break;
- case SCE_T3_D_STRING:
- case SCE_T3_X_STRING:
- sc.SetState(SCE_T3_MSG_PARAM);
- sc.Forward();
- break;
- case SCE_T3_MSG_PARAM:
- if (lineState&T3_SINGLE_QUOTE) {
- endState = SCE_T3_S_STRING;
- chQuote = '\'';
- } else if (lineState&T3_INT_EXPRESSION) {
- endState = SCE_T3_X_STRING;
- } else {
- endState = SCE_T3_D_STRING;
- }
- break;
- }
- while (sc.More() && sc.ch != '}' && sc.ch != chQuote) {
- if (IsEOL(sc.ch, sc.chNext)) {
- return;
- }
- if (sc.ch == '\\') {
- sc.Forward();
- }
- sc.Forward();
- }
- if (sc.ch == chQuote) {
- sc.SetState(endState);
- } else {
- sc.ForwardSetState(endState);
- }
+ int endState = sc.state;
+ int chQuote = '"';
+ switch (endState) {
+ case SCE_T3_S_STRING:
+ sc.SetState(SCE_T3_MSG_PARAM);
+ sc.Forward();
+ chQuote = '\'';
+ break;
+ case SCE_T3_D_STRING:
+ case SCE_T3_X_STRING:
+ sc.SetState(SCE_T3_MSG_PARAM);
+ sc.Forward();
+ break;
+ case SCE_T3_MSG_PARAM:
+ if (lineState&T3_SINGLE_QUOTE) {
+ endState = SCE_T3_S_STRING;
+ chQuote = '\'';
+ } else if (lineState&T3_INT_EXPRESSION) {
+ endState = SCE_T3_X_STRING;
+ } else {
+ endState = SCE_T3_D_STRING;
+ }
+ break;
+ }
+ while (sc.More() && sc.ch != '}' && sc.ch != chQuote) {
+ if (IsEOL(sc.ch, sc.chNext)) {
+ return;
+ }
+ if (sc.ch == '\\') {
+ sc.Forward();
+ }
+ sc.Forward();
+ }
+ if (sc.ch == chQuote) {
+ sc.SetState(endState);
+ } else {
+ sc.ForwardSetState(endState);
+ }
}
static void ColouriseTADS3LibDirective(StyleContext &sc, int &lineState) {
- int initState = sc.state;
- int chQuote = '"';
- switch (initState) {
- case SCE_T3_S_STRING:
- sc.SetState(SCE_T3_LIB_DIRECTIVE);
- sc.Forward(2);
- chQuote = '\'';
- break;
- case SCE_T3_D_STRING:
- sc.SetState(SCE_T3_LIB_DIRECTIVE);
- sc.Forward(2);
- break;
- case SCE_T3_LIB_DIRECTIVE:
- if (lineState&T3_SINGLE_QUOTE) {
- initState = SCE_T3_S_STRING;
- chQuote = '\'';
- } else {
- initState = SCE_T3_D_STRING;
- }
- break;
- }
- while (sc.More() && IsADirectiveChar(sc.ch)) {
- if (IsEOL(sc.ch, sc.chNext)) {
- return;
- }
- sc.Forward();
- };
- if (sc.ch == '>' || !sc.More()) {
- sc.ForwardSetState(initState);
- } else if (sc.ch == chQuote) {
- sc.SetState(initState);
- } else {
- sc.ChangeState(initState);
- sc.Forward();
- }
+ int initState = sc.state;
+ int chQuote = '"';
+ switch (initState) {
+ case SCE_T3_S_STRING:
+ sc.SetState(SCE_T3_LIB_DIRECTIVE);
+ sc.Forward(2);
+ chQuote = '\'';
+ break;
+ case SCE_T3_D_STRING:
+ sc.SetState(SCE_T3_LIB_DIRECTIVE);
+ sc.Forward(2);
+ break;
+ case SCE_T3_LIB_DIRECTIVE:
+ if (lineState&T3_SINGLE_QUOTE) {
+ initState = SCE_T3_S_STRING;
+ chQuote = '\'';
+ } else {
+ initState = SCE_T3_D_STRING;
+ }
+ break;
+ }
+ while (sc.More() && IsADirectiveChar(sc.ch)) {
+ if (IsEOL(sc.ch, sc.chNext)) {
+ return;
+ }
+ sc.Forward();
+ };
+ if (sc.ch == '>' || !sc.More()) {
+ sc.ForwardSetState(initState);
+ } else if (sc.ch == chQuote) {
+ sc.SetState(initState);
+ } else {
+ sc.ChangeState(initState);
+ sc.Forward();
+ }
}
static void ColouriseTADS3String(StyleContext &sc, int &lineState) {
- int chQuote = sc.ch;
- int endState = sc.state;
- switch (sc.state) {
- case SCE_T3_DEFAULT:
- case SCE_T3_X_DEFAULT:
- if (chQuote == '"') {
- if (sc.state == SCE_T3_DEFAULT) {
- sc.SetState(SCE_T3_D_STRING);
- } else {
- sc.SetState(SCE_T3_X_STRING);
- }
- lineState &= ~T3_SINGLE_QUOTE;
- } else {
- sc.SetState(SCE_T3_S_STRING);
- lineState |= T3_SINGLE_QUOTE;
- }
- sc.Forward();
- break;
- case SCE_T3_S_STRING:
- chQuote = '\'';
- endState = lineState&T3_INT_EXPRESSION ?
- SCE_T3_X_DEFAULT : SCE_T3_DEFAULT;
- break;
- case SCE_T3_D_STRING:
- chQuote = '"';
- endState = SCE_T3_DEFAULT;
- break;
- case SCE_T3_X_STRING:
- chQuote = '"';
- endState = SCE_T3_X_DEFAULT;
- break;
- }
- while (sc.More()) {
- if (IsEOL(sc.ch, sc.chNext)) {
- return;
- }
- if (sc.ch == chQuote) {
- sc.ForwardSetState(endState);
- return;
- }
- if (sc.state == SCE_T3_D_STRING && sc.Match('<', '<')) {
- lineState |= T3_INT_EXPRESSION;
- sc.SetState(SCE_T3_X_DEFAULT);
- sc.Forward(2);
- return;
- }
- if (sc.Match('\\', static_cast<char>(chQuote))) {
- sc.Forward(2);
- } else if (sc.ch == '{') {
- ColouriseTADS3MsgParam(sc, lineState);
- } else if (sc.Match('<', '.')) {
- ColouriseTADS3LibDirective(sc, lineState);
- } else if (sc.ch == '<') {
- ColouriseTADS3HTMLTag(sc, lineState);
- } else {
- sc.Forward();
- }
- }
+ int chQuote = sc.ch;
+ int endState = sc.state;
+ switch (sc.state) {
+ case SCE_T3_DEFAULT:
+ case SCE_T3_X_DEFAULT:
+ if (chQuote == '"') {
+ if (sc.state == SCE_T3_DEFAULT) {
+ sc.SetState(SCE_T3_D_STRING);
+ } else {
+ sc.SetState(SCE_T3_X_STRING);
+ }
+ lineState &= ~T3_SINGLE_QUOTE;
+ } else {
+ sc.SetState(SCE_T3_S_STRING);
+ lineState |= T3_SINGLE_QUOTE;
+ }
+ sc.Forward();
+ break;
+ case SCE_T3_S_STRING:
+ chQuote = '\'';
+ endState = lineState&T3_INT_EXPRESSION ?
+ SCE_T3_X_DEFAULT : SCE_T3_DEFAULT;
+ break;
+ case SCE_T3_D_STRING:
+ chQuote = '"';
+ endState = SCE_T3_DEFAULT;
+ break;
+ case SCE_T3_X_STRING:
+ chQuote = '"';
+ endState = SCE_T3_X_DEFAULT;
+ break;
+ }
+ while (sc.More()) {
+ if (IsEOL(sc.ch, sc.chNext)) {
+ return;
+ }
+ if (sc.ch == chQuote) {
+ sc.ForwardSetState(endState);
+ return;
+ }
+ if (sc.state == SCE_T3_D_STRING && sc.Match('<', '<')) {
+ lineState |= T3_INT_EXPRESSION;
+ sc.SetState(SCE_T3_X_DEFAULT);
+ sc.Forward(2);
+ return;
+ }
+ if (sc.Match('\\', static_cast<char>(chQuote))
+ || sc.Match('\\', '\\')) {
+ sc.Forward(2);
+ } else if (sc.ch == '{') {
+ ColouriseTADS3MsgParam(sc, lineState);
+ } else if (sc.Match('<', '.')) {
+ ColouriseTADS3LibDirective(sc, lineState);
+ } else if (sc.ch == '<') {
+ ColouriseTADS3HTMLTag(sc, lineState);
+ if (sc.state == SCE_T3_X_DEFAULT)
+ return;
+ } else {
+ sc.Forward();
+ }
+ }
}
static void ColouriseTADS3Comment(StyleContext &sc, int endState) {
- sc.SetState(SCE_T3_BLOCK_COMMENT);
- while (sc.More()) {
- if (IsEOL(sc.ch, sc.chNext)) {
- return;
- }
- if (sc.Match('*', '/')) {
- sc.Forward(2);
- sc.SetState(endState);
- return;
- }
- sc.Forward();
- }
+ sc.SetState(SCE_T3_BLOCK_COMMENT);
+ while (sc.More()) {
+ if (IsEOL(sc.ch, sc.chNext)) {
+ return;
+ }
+ if (sc.Match('*', '/')) {
+ sc.Forward(2);
+ sc.SetState(endState);
+ return;
+ }
+ sc.Forward();
+ }
}
static void ColouriseToEndOfLine(StyleContext &sc, int initState, int endState) {
- sc.SetState(initState);
- while (sc.More()) {
- if (sc.ch == '\\') {
- sc.Forward();
- if (IsEOL(sc.ch, sc.chNext)) {
- return;
- }
- }
- if (IsEOL(sc.ch, sc.chNext)) {
- sc.SetState(endState);
- return;
- }
- sc.Forward();
- }
+ sc.SetState(initState);
+ while (sc.More()) {
+ if (sc.ch == '\\') {
+ sc.Forward();
+ if (IsEOLSkip(sc)) {
+ return;
+ }
+ }
+ if (IsEOL(sc.ch, sc.chNext)) {
+ sc.SetState(endState);
+ return;
+ }
+ sc.Forward();
+ }
}
static void ColouriseTADS3Number(StyleContext &sc) {
- int endState = sc.state;
- bool inHexNumber = false;
- bool seenE = false;
- bool seenDot = sc.ch == '.';
- sc.SetState(SCE_T3_NUMBER);
- if (sc.More()) {
- sc.Forward();
- }
- if (sc.chPrev == '0' && tolower(sc.ch) == 'x') {
- inHexNumber = true;
- sc.Forward();
- }
- while (sc.More()) {
- if (inHexNumber) {
- if (!IsAHexDigit(sc.ch)) {
- break;
- }
- } else if (!isdigit(sc.ch)) {
- if (!seenE && tolower(sc.ch) == 'e') {
- seenE = true;
- seenDot = true;
- if (sc.chNext == '+' || sc.chNext == '-') {
- sc.Forward();
- }
- } else if (!seenDot && sc.ch == '.') {
- seenDot = true;
- } else {
- break;
- }
- }
- sc.Forward();
- }
- sc.SetState(endState);
+ int endState = sc.state;
+ bool inHexNumber = false;
+ bool seenE = false;
+ bool seenDot = sc.ch == '.';
+ sc.SetState(SCE_T3_NUMBER);
+ if (sc.More()) {
+ sc.Forward();
+ }
+ if (sc.chPrev == '0' && tolower(sc.ch) == 'x') {
+ inHexNumber = true;
+ sc.Forward();
+ }
+ while (sc.More()) {
+ if (inHexNumber) {
+ if (!IsAHexDigit(sc.ch)) {
+ break;
+ }
+ } else if (!isdigit(sc.ch)) {
+ if (!seenE && tolower(sc.ch) == 'e') {
+ seenE = true;
+ seenDot = true;
+ if (sc.chNext == '+' || sc.chNext == '-') {
+ sc.Forward();
+ }
+ } else if (!seenDot && sc.ch == '.') {
+ seenDot = true;
+ } else {
+ break;
+ }
+ }
+ sc.Forward();
+ }
+ sc.SetState(endState);
}
static void ColouriseTADS3Doc(unsigned int startPos, int length, int initStyle,
- WordList *keywordlists[], Accessor &styler) {
- int visibleChars = 0;
- int bracketLevel = 0;
- int lineState = 0;
- unsigned int endPos = startPos + length;
- int lineCurrent = styler.GetLine(startPos);
- if (lineCurrent > 0) {
- lineState = styler.GetLineState(lineCurrent-1);
- }
- StyleContext sc(startPos, length, initStyle, styler);
-
- while (sc.More()) {
-
- if (IsEOL(sc.ch, sc.chNext)) {
- styler.SetLineState(lineCurrent, lineState);
- lineCurrent++;
- visibleChars = 0;
- sc.Forward();
- if (sc.ch == '\n') {
- sc.Forward();
- }
- }
-
- switch(sc.state) {
- case SCE_T3_PREPROCESSOR:
- case SCE_T3_LINE_COMMENT:
- ColouriseToEndOfLine(sc, sc.state, lineState&T3_INT_EXPRESSION ?
- SCE_T3_X_DEFAULT : SCE_T3_DEFAULT);
- break;
- case SCE_T3_S_STRING:
- case SCE_T3_D_STRING:
- case SCE_T3_X_STRING:
- ColouriseTADS3String(sc, lineState);
- visibleChars++;
- break;
- case SCE_T3_MSG_PARAM:
- ColouriseTADS3MsgParam(sc, lineState);
- break;
- case SCE_T3_LIB_DIRECTIVE:
- ColouriseTADS3LibDirective(sc, lineState);
- break;
- case SCE_T3_HTML_DEFAULT:
- ColouriseTADS3HTMLTag(sc, lineState);
- break;
- case SCE_T3_HTML_STRING:
- ColouriseTADSHTMLString(sc, lineState);
- break;
- case SCE_T3_BLOCK_COMMENT:
- ColouriseTADS3Comment(sc, lineState&T3_INT_EXPRESSION ?
- SCE_T3_X_DEFAULT : SCE_T3_DEFAULT);
- break;
- case SCE_T3_DEFAULT:
- case SCE_T3_X_DEFAULT:
- if (IsASpaceOrTab(sc.ch)) {
- sc.Forward();
- } else if (sc.ch == '#' && visibleChars == 0) {
- ColouriseToEndOfLine(sc, SCE_T3_PREPROCESSOR, sc.state);
- } else if (sc.Match('/', '*')) {
- ColouriseTADS3Comment(sc, sc.state);
- visibleChars++;
- } else if (sc.Match('/', '/')) {
- ColouriseToEndOfLine(sc, SCE_T3_LINE_COMMENT, sc.state);
- } else if (sc.ch == '"') {
- bracketLevel = 0;
- ColouriseTADS3String(sc, lineState);
- visibleChars++;
- } else if (sc.ch == '\'') {
- ColouriseTADS3String(sc, lineState);
- visibleChars++;
- } else if (sc.state == SCE_T3_X_DEFAULT && bracketLevel == 0
- && sc.Match('>', '>')) {
- sc.Forward(2);
- sc.SetState(SCE_T3_D_STRING);
- lineState &= ~(T3_SINGLE_QUOTE|T3_INT_EXPRESSION);
- } else if (IsATADS3Operator(sc.ch)) {
- if (sc.state == SCE_T3_X_DEFAULT) {
- if (sc.ch == '(') {
- bracketLevel++;
- } else if (sc.ch == ')') {
- bracketLevel--;
- }
- }
- ColouriseTADS3Operator(sc);
- visibleChars++;
- } else if (IsANumberStart(sc)) {
- ColouriseTADS3Number(sc);
- visibleChars++;
- } else if (IsAWordStart(sc.ch)) {
- ColouriseTADS3Keyword(sc, keywordlists, endPos);
- visibleChars++;
- } else if (sc.Match("...")) {
- sc.SetState(SCE_T3_IDENTIFIER);
- sc.Forward(3);
- sc.SetState(SCE_T3_DEFAULT);
- } else {
- sc.Forward();
- visibleChars++;
- }
- break;
- default:
- sc.SetState(SCE_T3_DEFAULT);
- sc.Forward();
- }
- }
- sc.Complete();
+ WordList *keywordlists[], Accessor &styler) {
+ int visibleChars = 0;
+ int bracketLevel = 0;
+ int lineState = 0;
+ unsigned int endPos = startPos + length;
+ int lineCurrent = styler.GetLine(startPos);
+ if (lineCurrent > 0) {
+ lineState = styler.GetLineState(lineCurrent-1);
+ }
+ StyleContext sc(startPos, length, initStyle, styler);
+
+ while (sc.More()) {
+
+ if (IsEOL(sc.ch, sc.chNext)) {
+ styler.SetLineState(lineCurrent, lineState);
+ lineCurrent++;
+ visibleChars = 0;
+ sc.Forward();
+ if (sc.ch == '\n') {
+ sc.Forward();
+ }
+ }
+
+ switch(sc.state) {
+ case SCE_T3_PREPROCESSOR:
+ case SCE_T3_LINE_COMMENT:
+ ColouriseToEndOfLine(sc, sc.state, lineState&T3_INT_EXPRESSION ?
+ SCE_T3_X_DEFAULT : SCE_T3_DEFAULT);
+ break;
+ case SCE_T3_S_STRING:
+ case SCE_T3_D_STRING:
+ case SCE_T3_X_STRING:
+ ColouriseTADS3String(sc, lineState);
+ visibleChars++;
+ break;
+ case SCE_T3_MSG_PARAM:
+ ColouriseTADS3MsgParam(sc, lineState);
+ break;
+ case SCE_T3_LIB_DIRECTIVE:
+ ColouriseTADS3LibDirective(sc, lineState);
+ break;
+ case SCE_T3_HTML_DEFAULT:
+ ColouriseTADS3HTMLTag(sc, lineState);
+ break;
+ case SCE_T3_HTML_STRING:
+ ColouriseTADSHTMLString(sc, lineState);
+ break;
+ case SCE_T3_BLOCK_COMMENT:
+ ColouriseTADS3Comment(sc, lineState&T3_INT_EXPRESSION ?
+ SCE_T3_X_DEFAULT : SCE_T3_DEFAULT);
+ break;
+ case SCE_T3_DEFAULT:
+ case SCE_T3_X_DEFAULT:
+ if (IsASpaceOrTab(sc.ch)) {
+ sc.Forward();
+ } else if (sc.ch == '#' && visibleChars == 0) {
+ ColouriseToEndOfLine(sc, SCE_T3_PREPROCESSOR, sc.state);
+ } else if (sc.Match('/', '*')) {
+ ColouriseTADS3Comment(sc, sc.state);
+ visibleChars++;
+ } else if (sc.Match('/', '/')) {
+ ColouriseToEndOfLine(sc, SCE_T3_LINE_COMMENT, sc.state);
+ } else if (sc.ch == '"') {
+ bracketLevel = 0;
+ ColouriseTADS3String(sc, lineState);
+ visibleChars++;
+ } else if (sc.ch == '\'') {
+ ColouriseTADS3String(sc, lineState);
+ visibleChars++;
+ } else if (sc.state == SCE_T3_X_DEFAULT && bracketLevel == 0
+ && sc.Match('>', '>')) {
+ sc.Forward(2);
+ sc.SetState(SCE_T3_D_STRING);
+ if (lineState & T3_INT_EXPRESSION_IN_TAG)
+ sc.SetState(SCE_T3_HTML_STRING);
+ lineState &= ~(T3_SINGLE_QUOTE|T3_INT_EXPRESSION
+ |T3_INT_EXPRESSION_IN_TAG);
+ } else if (IsATADS3Operator(sc.ch)) {
+ if (sc.state == SCE_T3_X_DEFAULT) {
+ if (sc.ch == '(') {
+ bracketLevel++;
+ } else if (sc.ch == ')' && bracketLevel > 0) {
+ bracketLevel--;
+ }
+ }
+ ColouriseTADS3Operator(sc);
+ visibleChars++;
+ } else if (IsANumberStart(sc)) {
+ ColouriseTADS3Number(sc);
+ visibleChars++;
+ } else if (IsAWordStart(sc.ch)) {
+ ColouriseTADS3Keyword(sc, keywordlists, endPos);
+ visibleChars++;
+ } else if (sc.Match("...")) {
+ sc.SetState(SCE_T3_IDENTIFIER);
+ sc.Forward(3);
+ sc.SetState(SCE_T3_DEFAULT);
+ } else {
+ sc.Forward();
+ visibleChars++;
+ }
+ break;
+ default:
+ sc.SetState(SCE_T3_DEFAULT);
+ sc.Forward();
+ }
+ }
+ sc.Complete();
}
/*
// default style
silverKey : Key 'small silver key' 'small silver key'
- "A small key glints in the sunlight. "
+ "A small key glints in the sunlight. "
;
and
silverKey : Key {
- 'small silver key'
- 'small silver key'
- "A small key glints in the sunlight. "
+ 'small silver key'
+ 'small silver key'
+ "A small key glints in the sunlight. "
}
Some constructs mandate one or the other, but usually the author has may choose
static const int T3_EXPECTINGPUNCTUATION = 1 << 14;
static inline bool IsStringTransition(int s1, int s2) {
- return s1 != s2
- && (s1 == SCE_T3_S_STRING || s1 == SCE_T3_X_STRING
- || s1 == SCE_T3_D_STRING && s2 != SCE_T3_X_DEFAULT)
- && s2 != SCE_T3_LIB_DIRECTIVE
- && s2 != SCE_T3_MSG_PARAM
- && s2 != SCE_T3_HTML_TAG
- && s2 != SCE_T3_HTML_STRING;
+ return s1 != s2
+ && (s1 == SCE_T3_S_STRING || s1 == SCE_T3_X_STRING
+ || s1 == SCE_T3_D_STRING && s2 != SCE_T3_X_DEFAULT)
+ && s2 != SCE_T3_LIB_DIRECTIVE
+ && s2 != SCE_T3_MSG_PARAM
+ && s2 != SCE_T3_HTML_TAG
+ && s2 != SCE_T3_HTML_STRING;
}
static inline bool IsATADS3Punctuation(const int ch) {
- return ch == ':' || ch == ',' || ch == '(' || ch == ')';
+ return ch == ':' || ch == ',' || ch == '(' || ch == ')';
}
static inline bool IsAnIdentifier(const int style) {
- return style == SCE_T3_IDENTIFIER
- || style == SCE_T3_USER1
- || style == SCE_T3_USER2
- || style == SCE_T3_USER3;
+ return style == SCE_T3_IDENTIFIER
+ || style == SCE_T3_USER1
+ || style == SCE_T3_USER2
+ || style == SCE_T3_USER3;
+}
+
+static inline bool IsAnOperator(const int style) {
+ return style == SCE_T3_OPERATOR || SCE_T3_BRACE;
}
static inline bool IsSpaceEquivalent(const int ch, const int style) {
- return isspace(ch)
- || style == SCE_T3_BLOCK_COMMENT
- || style == SCE_T3_LINE_COMMENT
- || style == SCE_T3_PREPROCESSOR;
+ return isspace(ch)
+ || style == SCE_T3_BLOCK_COMMENT
+ || style == SCE_T3_LINE_COMMENT
+ || style == SCE_T3_PREPROCESSOR;
}
static char peekAhead(unsigned int startPos, unsigned int endPos,
- Accessor &styler) {
- for (unsigned int i = startPos; i < endPos; i++) {
- int style = styler.StyleAt(i);
- char ch = styler[i];
- if (!IsSpaceEquivalent(ch, style)) {
- if (IsAnIdentifier(style)) {
- return 'a';
- }
- if (IsATADS3Punctuation(ch)) {
- return ':';
- }
- if (ch == '{') {
- return '{';
- }
- return '*';
- }
- }
- return ' ';
+ Accessor &styler) {
+ for (unsigned int i = startPos; i < endPos; i++) {
+ int style = styler.StyleAt(i);
+ char ch = styler[i];
+ if (!IsSpaceEquivalent(ch, style)) {
+ if (IsAnIdentifier(style)) {
+ return 'a';
+ }
+ if (IsATADS3Punctuation(ch)) {
+ return ':';
+ }
+ if (ch == '{') {
+ return '{';
+ }
+ return '*';
+ }
+ }
+ return ' ';
}
static void FoldTADS3Doc(unsigned int startPos, int length, int initStyle,
WordList *[], Accessor &styler) {
- unsigned int endPos = startPos + length;
- int lineCurrent = styler.GetLine(startPos);
- int levelCurrent = SC_FOLDLEVELBASE;
- if (lineCurrent > 0)
- levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
- int seenStart = levelCurrent & T3_SEENSTART;
- int expectingIdentifier = levelCurrent & T3_EXPECTINGIDENTIFIER;
- int expectingPunctuation = levelCurrent & T3_EXPECTINGPUNCTUATION;
- levelCurrent &= SC_FOLDLEVELNUMBERMASK;
- int levelMinCurrent = levelCurrent;
- int levelNext = levelCurrent;
- char chNext = styler[startPos];
- int styleNext = styler.StyleAt(startPos);
- int style = initStyle;
- char ch = chNext;
- int stylePrev = style;
- bool redo = false;
- for (unsigned int i = startPos; i < endPos; i++) {
- if (redo) {
- redo = false;
- i--;
- } else {
- ch = chNext;
- chNext = styler.SafeGetCharAt(i + 1);
- stylePrev = style;
- style = styleNext;
- styleNext = styler.StyleAt(i + 1);
- }
- bool atEOL = IsEOL(ch, chNext);
-
- if (levelNext == SC_FOLDLEVELBASE) {
- if (IsSpaceEquivalent(ch, style)) {
- if (expectingPunctuation) {
- expectingIdentifier = 0;
- }
- if (style == SCE_T3_BLOCK_COMMENT) {
- levelNext++;
- }
- } else if (ch == '{') {
- levelNext++;
- seenStart = 0;
- } else if (ch == '\'' || ch == '"' || ch == '[') {
- levelNext++;
- if (seenStart) {
- redo = true;
- }
- } else if (ch == ';') {
- seenStart = 0;
- expectingIdentifier = 0;
- expectingPunctuation = 0;
- } else if (expectingIdentifier && expectingPunctuation) {
- if (IsATADS3Punctuation(ch)) {
- if (ch == ')' && peekAhead(i+1, endPos, styler) != '{') {
- levelNext++;
- } else {
- expectingPunctuation = 0;
- }
- } else if (!IsAnIdentifier(style)) {
- levelNext++;
- }
- } else if (expectingIdentifier && !expectingPunctuation) {
- if (!IsAnIdentifier(style)) {
- levelNext++;
- } else {
- expectingPunctuation = T3_EXPECTINGPUNCTUATION;
- }
- } else if (!expectingIdentifier && expectingPunctuation) {
- if (!IsATADS3Punctuation(ch)) {
- levelNext++;
- } else {
- if (ch == ')' && peekAhead(i+1, endPos, styler) != '{') {
- levelNext++;
- } else {
- expectingIdentifier = T3_EXPECTINGIDENTIFIER;
- expectingPunctuation = 0;
- }
- }
- } else if (!expectingIdentifier && !expectingPunctuation) {
- if (IsAnIdentifier(style)) {
- seenStart = T3_SEENSTART;
- expectingIdentifier = T3_EXPECTINGIDENTIFIER;
- expectingPunctuation = T3_EXPECTINGPUNCTUATION;
- }
- }
-
- if (levelNext != SC_FOLDLEVELBASE && style != SCE_T3_BLOCK_COMMENT) {
- expectingIdentifier = 0;
- expectingPunctuation = 0;
- }
-
- } else if (levelNext == SC_FOLDLEVELBASE+1 && seenStart
- && ch == ';' && style == SCE_T3_OPERATOR ) {
- levelNext--;
- seenStart = 0;
- } else if (style == SCE_T3_BLOCK_COMMENT) {
- if (stylePrev != SCE_T3_BLOCK_COMMENT) {
- levelNext++;
- } else if (styleNext != SCE_T3_BLOCK_COMMENT && !atEOL) {
- // Comments don't end at end of line and the next character may be unstyled.
- levelNext--;
- }
- } else if (ch == '\'' || ch == '"') {
- if (IsStringTransition(style, stylePrev)) {
- if (levelMinCurrent > levelNext) {
- levelMinCurrent = levelNext;
- }
- levelNext++;
- } else if (IsStringTransition(style, styleNext)) {
- levelNext--;
- }
- } else if (style == SCE_T3_OPERATOR) {
- if (ch == '{' || ch == '[') {
- // Measure the minimum before a '{' to allow
- // folding on "} else {"
- if (levelMinCurrent > levelNext) {
- levelMinCurrent = levelNext;
- }
- levelNext++;
- } else if (ch == '}' || ch == ']') {
- levelNext--;
- }
- }
-
- if (atEOL) {
- if (seenStart && levelNext == SC_FOLDLEVELBASE) {
- switch (peekAhead(i+1, endPos, styler)) {
- case ' ':
- case '{':
- break;
- case '*':
- levelNext++;
- break;
- case 'a':
- if (expectingPunctuation) {
- levelNext++;
- }
- break;
- case ':':
- if (expectingIdentifier) {
- levelNext++;
- }
- break;
- }
- if (levelNext != SC_FOLDLEVELBASE) {
- expectingIdentifier = 0;
- expectingPunctuation = 0;
- }
- }
- int lev = levelMinCurrent | (levelNext | expectingIdentifier
- | expectingPunctuation | seenStart) << 16;
- if (levelMinCurrent < levelNext)
- lev |= SC_FOLDLEVELHEADERFLAG;
- if (lev != styler.LevelAt(lineCurrent)) {
- styler.SetLevel(lineCurrent, lev);
- }
- lineCurrent++;
- levelCurrent = levelNext;
- levelMinCurrent = levelCurrent;
- }
- }
+ unsigned int endPos = startPos + length;
+ int lineCurrent = styler.GetLine(startPos);
+ int levelCurrent = SC_FOLDLEVELBASE;
+ if (lineCurrent > 0)
+ levelCurrent = styler.LevelAt(lineCurrent-1) >> 16;
+ int seenStart = levelCurrent & T3_SEENSTART;
+ int expectingIdentifier = levelCurrent & T3_EXPECTINGIDENTIFIER;
+ int expectingPunctuation = levelCurrent & T3_EXPECTINGPUNCTUATION;
+ levelCurrent &= SC_FOLDLEVELNUMBERMASK;
+ int levelMinCurrent = levelCurrent;
+ int levelNext = levelCurrent;
+ char chNext = styler[startPos];
+ int styleNext = styler.StyleAt(startPos);
+ int style = initStyle;
+ char ch = chNext;
+ int stylePrev = style;
+ bool redo = false;
+ for (unsigned int i = startPos; i < endPos; i++) {
+ if (redo) {
+ redo = false;
+ i--;
+ } else {
+ ch = chNext;
+ chNext = styler.SafeGetCharAt(i + 1);
+ stylePrev = style;
+ style = styleNext;
+ styleNext = styler.StyleAt(i + 1);
+ }
+ bool atEOL = IsEOL(ch, chNext);
+
+ if (levelNext == SC_FOLDLEVELBASE) {
+ if (IsSpaceEquivalent(ch, style)) {
+ if (expectingPunctuation) {
+ expectingIdentifier = 0;
+ }
+ if (style == SCE_T3_BLOCK_COMMENT) {
+ levelNext++;
+ }
+ } else if (ch == '{') {
+ levelNext++;
+ seenStart = 0;
+ } else if (ch == '\'' || ch == '"' || ch == '[') {
+ levelNext++;
+ if (seenStart) {
+ redo = true;
+ }
+ } else if (ch == ';') {
+ seenStart = 0;
+ expectingIdentifier = 0;
+ expectingPunctuation = 0;
+ } else if (expectingIdentifier && expectingPunctuation) {
+ if (IsATADS3Punctuation(ch)) {
+ if (ch == ')' && peekAhead(i+1, endPos, styler) != '{') {
+ levelNext++;
+ } else {
+ expectingPunctuation = 0;
+ }
+ } else if (!IsAnIdentifier(style)) {
+ levelNext++;
+ }
+ } else if (expectingIdentifier && !expectingPunctuation) {
+ if (!IsAnIdentifier(style)) {
+ levelNext++;
+ } else {
+ expectingPunctuation = T3_EXPECTINGPUNCTUATION;
+ }
+ } else if (!expectingIdentifier && expectingPunctuation) {
+ if (!IsATADS3Punctuation(ch)) {
+ levelNext++;
+ } else {
+ if (ch == ')' && peekAhead(i+1, endPos, styler) != '{') {
+ levelNext++;
+ } else {
+ expectingIdentifier = T3_EXPECTINGIDENTIFIER;
+ expectingPunctuation = 0;
+ }
+ }
+ } else if (!expectingIdentifier && !expectingPunctuation) {
+ if (IsAnIdentifier(style)) {
+ seenStart = T3_SEENSTART;
+ expectingIdentifier = T3_EXPECTINGIDENTIFIER;
+ expectingPunctuation = T3_EXPECTINGPUNCTUATION;
+ }
+ }
+
+ if (levelNext != SC_FOLDLEVELBASE && style != SCE_T3_BLOCK_COMMENT) {
+ expectingIdentifier = 0;
+ expectingPunctuation = 0;
+ }
+
+ } else if (levelNext == SC_FOLDLEVELBASE+1 && seenStart
+ && ch == ';' && IsAnOperator(style)) {
+ levelNext--;
+ seenStart = 0;
+ } else if (style == SCE_T3_BLOCK_COMMENT) {
+ if (stylePrev != SCE_T3_BLOCK_COMMENT) {
+ levelNext++;
+ } else if (styleNext != SCE_T3_BLOCK_COMMENT && !atEOL) {
+ // Comments don't end at end of line and the next character may be unstyled.
+ levelNext--;
+ }
+ } else if (ch == '\'' || ch == '"') {
+ if (IsStringTransition(style, stylePrev)) {
+ if (levelMinCurrent > levelNext) {
+ levelMinCurrent = levelNext;
+ }
+ levelNext++;
+ } else if (IsStringTransition(style, styleNext)) {
+ levelNext--;
+ }
+ } else if (IsAnOperator(style)) {
+ if (ch == '{' || ch == '[') {
+ // Measure the minimum before a '{' to allow
+ // folding on "} else {"
+ if (levelMinCurrent > levelNext) {
+ levelMinCurrent = levelNext;
+ }
+ levelNext++;
+ } else if (ch == '}' || ch == ']') {
+ levelNext--;
+ }
+ }
+
+ if (atEOL) {
+ if (seenStart && levelNext == SC_FOLDLEVELBASE) {
+ switch (peekAhead(i+1, endPos, styler)) {
+ case ' ':
+ case '{':
+ break;
+ case '*':
+ levelNext++;
+ break;
+ case 'a':
+ if (expectingPunctuation) {
+ levelNext++;
+ }
+ break;
+ case ':':
+ if (expectingIdentifier) {
+ levelNext++;
+ }
+ break;
+ }
+ if (levelNext != SC_FOLDLEVELBASE) {
+ expectingIdentifier = 0;
+ expectingPunctuation = 0;
+ }
+ }
+ int lev = levelMinCurrent | (levelNext | expectingIdentifier
+ | expectingPunctuation | seenStart) << 16;
+ if (levelMinCurrent < levelNext)
+ lev |= SC_FOLDLEVELHEADERFLAG;
+ if (lev != styler.LevelAt(lineCurrent)) {
+ styler.SetLevel(lineCurrent, lev);
+ }
+ lineCurrent++;
+ levelCurrent = levelNext;
+ levelMinCurrent = levelCurrent;
+ }
+ }
}
static const char * const tads3WordList[] = {
- "TADS3 Keywords",
- "User defined 1",
- "User defined 2",
- "User defined 3",
- 0
+ "TADS3 Keywords",
+ "User defined 1",
+ "User defined 2",
+ "User defined 3",
+ 0
};
LexerModule lmTADS3(SCLEX_TADS3, ColouriseTADS3Doc, "tads3", FoldTADS3Doc, tads3WordList);
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
// Extended to accept accented characters
static inline bool IsAWordChar(int ch) {
return ch >= 0x80 ||
// If you run into strange boundary cases, just tell me and I'll look into it.
+
+// TeX Folding code added by instanton (soft_share@126.com) with borrowed code from VisualTeX source by Alex Romanenko.
+// Version: June 22, 2007
+
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "SciLexer.h"
#include "StyleContext.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
// val SCE_TEX_DEFAULT = 0
// val SCE_TEX_SPECIAL = 1
// val SCE_TEX_GROUP = 2
styler.StartSegment(startPos) ;
bool processComment = styler.GetPropertyInt("lexer.tex.comment.process", 0) == 1 ;
- bool useKeywords = styler.GetPropertyInt("lexer.tex.use.keywords", 1) == 1 ;
+ bool useKeywords = styler.GetPropertyInt("lexer.tex.use.keywords", 1) == 1 ;
bool autoIf = styler.GetPropertyInt("lexer.tex.auto.if", 1) == 1 ;
- int defaultInterface = styler.GetPropertyInt("lexer.tex.interface.default", 1) ;
+ int defaultInterface = styler.GetPropertyInt("lexer.tex.interface.default", 1) ;
char key[100] ;
int k ;
}
-// Hooks into the system:
+static inline bool isNumber(int ch) {
+ return
+ (ch == '0') || (ch == '1') || (ch == '2') ||
+ (ch == '3') || (ch == '4') || (ch == '5') ||
+ (ch == '6') || (ch == '7') || (ch == '8') || (ch == '9');
+}
+
+static inline bool isWordChar(int ch) {
+ return ((ch >= 'a') && (ch <= 'z')) || ((ch >= 'A') && (ch <= 'Z'));
+}
+
+static int ParseTeXCommand(unsigned int pos, Accessor &styler, char *command)
+{
+ int length=0;
+ char ch=styler.SafeGetCharAt(pos+1);
+
+ if(ch==',' || ch==':' || ch==';' || ch=='%'){
+ command[0]=ch;
+ command[1]=0;
+ return 1;
+ }
+
+ // find end
+ while(isWordChar(ch) && !isNumber(ch) && ch!='_' && ch!='.' && length<100){
+ command[length]=ch;
+ length++;
+ ch=styler.SafeGetCharAt(pos+length+1);
+ }
+
+ command[length]='\0';
+ if(!length) return 0;
+ return length+1;
+}
+
+static int classifyFoldPointTeXPaired(const char* s) {
+ int lev=0;
+ if (!(isdigit(s[0]) || (s[0] == '.'))){
+ if (strcmp(s, "begin")==0||strcmp(s,"FoldStart")==0||
+ strcmp(s,"abstract")==0||strcmp(s,"unprotect")==0||
+ strcmp(s,"title")==0||strncmp(s,"start",5)==0||strncmp(s,"Start",5)==0||
+ strcmp(s,"documentclass")==0||strncmp(s,"if",2)==0
+ )
+ lev=1;
+ if (strcmp(s, "end")==0||strcmp(s,"FoldStop")==0||
+ strcmp(s,"maketitle")==0||strcmp(s,"protect")==0||
+ strncmp(s,"stop",4)==0||strncmp(s,"Stop",4)==0||
+ strcmp(s,"fi")==0
+ )
+ lev=-1;
+ }
+ return lev;
+}
+
+static int classifyFoldPointTeXUnpaired(const char* s) {
+ int lev=0;
+ if (!(isdigit(s[0]) || (s[0] == '.'))){
+ if (strcmp(s,"part")==0||
+ strcmp(s,"chapter")==0||
+ strcmp(s,"section")==0||
+ strcmp(s,"subsection")==0||
+ strcmp(s,"subsubsection")==0||
+ strcmp(s,"CJKfamily")==0||
+ strcmp(s,"appendix")==0||
+ strcmp(s,"Topic")==0||strcmp(s,"topic")==0||
+ strcmp(s,"subject")==0||strcmp(s,"subsubject")==0||
+ strcmp(s,"def")==0||strcmp(s,"gdef")==0||strcmp(s,"edef")==0||
+ strcmp(s,"xdef")==0||strcmp(s,"framed")==0||
+ strcmp(s,"frame")==0||
+ strcmp(s,"foilhead")==0||strcmp(s,"overlays")==0||strcmp(s,"slide")==0
+ ){
+ lev=1;
+ }
+ }
+ return lev;
+}
+
+static bool IsTeXCommentLine(int line, Accessor &styler) {
+ int pos = styler.LineStart(line);
+ int eol_pos = styler.LineStart(line + 1) - 1;
+
+ int startpos = pos;
+
+ while (startpos<eol_pos){
+ char ch = styler[startpos];
+ if (ch!='%' && ch!=' ') return false;
+ else if (ch=='%') return true;
+ startpos++;
+ }
+
+ return false;
+}
+
+// FoldTeXDoc: borrowed from VisualTeX with modifications
+
+static void FoldTexDoc(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=styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK;
+ int levelCurrent=levelPrev;
+ char chNext=styler[startPos];
+ char buffer[100]="";
+
+ for (unsigned int i=startPos; i < endPos; i++) {
+ char ch=chNext;
+ chNext=styler.SafeGetCharAt(i+1);
+ bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n');
+
+ if(ch=='\\') {
+ ParseTeXCommand(i, styler, buffer);
+ levelCurrent += classifyFoldPointTeXPaired(buffer)+classifyFoldPointTeXUnpaired(buffer);
+ }
+
+ if((ch == '\r' || ch=='\n') && (chNext == '\\')){
+ ParseTeXCommand(i+1, styler, buffer);
+ levelCurrent -= classifyFoldPointTeXUnpaired(buffer);
+ }
+
+ char chNext2;
+ char chNext3;
+ char chNext4;
+ char chNext5;
+ chNext2=styler.SafeGetCharAt(i+2);
+ chNext3=styler.SafeGetCharAt(i+3);
+ chNext4=styler.SafeGetCharAt(i+4);
+ chNext5=styler.SafeGetCharAt(i+5);
+
+ bool atEOfold = (ch == '%') &&
+ (chNext == '%') && (chNext2=='}') &&
+ (chNext3=='}')&& (chNext4=='-')&& (chNext5=='-');
+
+ bool atBOfold = (ch == '%') &&
+ (chNext == '%') && (chNext2=='-') &&
+ (chNext3=='-')&& (chNext4=='{')&& (chNext5=='{');
+
+ if(atBOfold){
+ levelCurrent+=1;
+ }
+
+ if(atEOfold){
+ levelCurrent-=1;
+ }
+
+ if(ch=='\\' && chNext=='['){
+ levelCurrent+=1;
+ }
+
+ if(ch=='\\' && chNext==']'){
+ levelCurrent-=1;
+ }
+
+ bool foldComment = styler.GetPropertyInt("fold.comment") != 0;
+
+ if (foldComment && atEOL && IsTeXCommentLine(lineCurrent, styler))
+ {
+ if (lineCurrent==0 && IsTeXCommentLine(lineCurrent + 1, styler)
+ )
+ levelCurrent++;
+ else if (lineCurrent!=0 && !IsTeXCommentLine(lineCurrent - 1, styler)
+ && IsTeXCommentLine(lineCurrent + 1, styler)
+ )
+ levelCurrent++;
+ else if (lineCurrent!=0 && IsTeXCommentLine(lineCurrent - 1, styler) &&
+ !IsTeXCommentLine(lineCurrent+1, styler))
+ levelCurrent--;
+ }
+
+//---------------------------------------------------------------------------------------------
+
+ if (atEOL) {
+ int lev = levelPrev;
+ if (visibleChars == 0 && foldCompact)
+ lev |= SC_FOLDLEVELWHITEFLAG;
+ if ((levelCurrent > levelPrev) && (visibleChars > 0))
+ lev |= SC_FOLDLEVELHEADERFLAG;
+ if (lev != styler.LevelAt(lineCurrent)) {
+ styler.SetLevel(lineCurrent, lev);
+ }
+ lineCurrent++;
+ levelPrev = levelCurrent;
+ visibleChars = 0;
+ }
+
+ 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 texWordListDesc[] = {
"TeX, eTeX, pdfTeX, Omega",
0,
} ;
-LexerModule lmTeX(SCLEX_TEX, ColouriseTeXDoc, "tex", 0, texWordListDesc);
+LexerModule lmTeX(SCLEX_TEX, ColouriseTeXDoc, "tex", FoldTexDoc, texWordListDesc);
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
// Internal state, highlighted as number
#define SCE_B_FILENUMBER SCE_B_DEFAULT+100
// VB doubles quotes to preserve them, so just end this string
// state now as a following quote will start again
if (sc.ch == '\"') {
- if (tolower(sc.chNext) == 'c') {
+ if (sc.chNext == '\"') {
sc.Forward();
+ } else {
+ if (tolower(sc.chNext) == 'c') {
+ sc.Forward();
+ }
+ sc.ForwardSetState(SCE_B_DEFAULT);
}
- sc.ForwardSetState(SCE_B_DEFAULT);
} else if (sc.atLineEnd) {
+ visibleChars = 0;
sc.ChangeState(SCE_B_STRINGEOL);
sc.ForwardSetState(SCE_B_DEFAULT);
}
} else if (sc.state == SCE_B_COMMENT) {
if (sc.atLineEnd) {
+ visibleChars = 0;
sc.ForwardSetState(SCE_B_DEFAULT);
}
} else if (sc.state == SCE_B_PREPROCESSOR) {
if (sc.atLineEnd) {
+ visibleChars = 0;
sc.ForwardSetState(SCE_B_DEFAULT);
}
} else if (sc.state == SCE_B_FILENUMBER) {
}
} else if (sc.state == SCE_B_DATE) {
if (sc.atLineEnd) {
+ visibleChars = 0;
sc.ChangeState(SCE_B_STRINGEOL);
sc.ForwardSetState(SCE_B_DEFAULT);
} else if (sc.ch == '#') {
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
static void ColouriseVHDLDoc(
unsigned int startPos,
int length,
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
static inline bool IsAWordChar(const int ch) {
return (ch < 0x80) && (isalnum(ch) || ch == '.' || ch == '_' || ch == '\'');
}
#include "Scintilla.h"
#include "SciLexer.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
static const char * const yamlWordListDesc[] = {
"Keywords",
0
static unsigned int SpaceCount(char* lineBuffer) {
if (lineBuffer == NULL)
return 0;
-
+
char* headBuffer = lineBuffer;
-
+
while (*headBuffer == ' ')
headBuffer++;
-
+
return headBuffer - lineBuffer;
}
unsigned int endPos,
WordList &keywords,
Accessor &styler) {
-
+
unsigned int i = 0;
bool bInQuotes = false;
unsigned int indentAmount = SpaceCount(lineBuffer);
-
+
if (currentLine > 0) {
int parentLineState = styler.GetLineState(currentLine - 1);
-
+
if ((parentLineState&YAML_STATE_MASK) == YAML_STATE_TEXT || (parentLineState&YAML_STATE_MASK) == YAML_STATE_TEXT_PARENT) {
unsigned int parentIndentAmount = parentLineState&(~YAML_STATE_MASK);
if (indentAmount > parentIndentAmount) {
if (lineBuffer[i] == '\'' || lineBuffer[i] == '\"') {
bInQuotes = !bInQuotes;
} else if (lineBuffer[i] == ':' && !bInQuotes) {
- styler.ColourTo(startLine + i, SCE_YAML_IDENTIFIER);
+ styler.ColourTo(startLine + i - 1, SCE_YAML_IDENTIFIER);
+ styler.ColourTo(startLine + i, SCE_YAML_OPERATOR);
// Non-folding scalar
i++;
while ((i < lengthLine) && isspacechar(lineBuffer[i]))
styler.ColourTo(endPos, SCE_YAML_ERROR);
return;
}
+ } else if (lineBuffer[i] == '#') {
+ styler.ColourTo(startLine + i - 1, SCE_YAML_DEFAULT);
+ styler.ColourTo(endPos, SCE_YAML_COMMENT);
+ return;
}
styler.SetLineState(currentLine, YAML_STATE_VALUE);
if (lineBuffer[i] == '&' || lineBuffer[i] == '*') {
unsigned int endPos = startPos + length;
unsigned int maxPos = styler.Length();
unsigned int lineCurrent = styler.GetLine(startPos);
-
+
for (unsigned int i = startPos; i < maxPos && i < endPos; i++) {
lineBuffer[linePos++] = styler[i];
if (AtEOL(styler, i) || (linePos >= sizeof(lineBuffer) - 1)) {
#include "XPM.h"
#include "LineMarker.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
void LineMarker::RefreshColourPalette(Palette &pal, bool want) {
pal.WantFind(fore, want);
pal.WantFind(back, want);
#ifndef LINEMARKER_H
#define LINEMARKER_H
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
/**
*/
class LineMarker {
void Draw(Surface *surface, PRectangle &rc, Font &fontForCharacter);
};
+#ifdef SCI_NAMESPACE
+}
+#endif
+
#endif
--- /dev/null
+// Scintilla source code edit control
+/** @file Partitioning.h
+ ** Data structure used to partition an interval. Used for holding line start/end positions.
+ **/
+// Copyright 1998-2007 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#ifndef PARTITIONING_H
+#define PARTITIONING_H
+
+/// A split vector of integers with a method for adding a value to all elements
+/// in a range.
+/// Used by the Partitioning class.
+
+class SplitVectorWithRangeAdd : public SplitVector<int> {
+public:
+ SplitVectorWithRangeAdd(int growSize_) {
+ SetGrowSize(growSize_);
+ ReAllocate(growSize_);
+ }
+ ~SplitVectorWithRangeAdd() {
+ }
+ void RangeAddDelta(int start, int end, int delta) {
+ // end is 1 past end, so end-start is number of elements to change
+ int i = 0;
+ int rangeLength = end - start;
+ int range1Length = rangeLength;
+ int part1Left = part1Length - start;
+ if (range1Length > part1Left)
+ range1Length = part1Left;
+ while (i < range1Length) {
+ body[start++] += delta;
+ i++;
+ }
+ start += gapLength;
+ while (i < rangeLength) {
+ body[start++] += delta;
+ i++;
+ }
+ }
+};
+
+/// Divide an interval into multiple partitions.
+/// Useful for breaking a document down into sections such as lines.
+
+class Partitioning {
+private:
+ // To avoid calculating all the partition positions whenever any text is inserted
+ // there may be a step somewhere in the list.
+ int stepPartition;
+ int stepLength;
+ SplitVectorWithRangeAdd *body;
+
+ // Move step forward
+ void ApplyStep(int partitionUpTo) {
+ if (stepLength != 0) {
+ body->RangeAddDelta(stepPartition+1, partitionUpTo + 1, stepLength);
+ }
+ stepPartition = partitionUpTo;
+ if (stepPartition >= body->Length()-1) {
+ stepPartition = body->Length()-1;
+ stepLength = 0;
+ }
+ }
+
+ // Move step backward
+ void BackStep(int partitionDownTo) {
+ if (stepLength != 0) {
+ body->RangeAddDelta(partitionDownTo+1, stepPartition+1, -stepLength);
+ }
+ stepPartition = partitionDownTo;
+ }
+
+ void Allocate(int growSize) {
+ body = new SplitVectorWithRangeAdd(growSize);
+ stepPartition = 0;
+ stepLength = 0;
+ body->Insert(0, 0); // This value stays 0 for ever
+ body->Insert(1, 0); // This is the end of the first partition and will be the start of the second
+ }
+
+public:
+ Partitioning(int growSize) {
+ Allocate(growSize);
+ }
+
+ ~Partitioning() {
+ delete body;
+ body = 0;
+ }
+
+ int Partitions() const {
+ return body->Length()-1;
+ }
+
+ void InsertPartition(int partition, int pos) {
+ if (stepPartition < partition) {
+ ApplyStep(partition);
+ }
+ body->Insert(partition, pos);
+ stepPartition++;
+ }
+
+ void SetPartitionStartPosition(int partition, int pos) {
+ ApplyStep(partition+1);
+ if ((partition < 0) || (partition > body->Length())) {
+ return;
+ }
+ body->SetValueAt(partition, pos);
+ }
+
+ void InsertText(int partitionInsert, int delta) {
+ // Point all the partitions after the insertion point further along in the buffer
+ if (stepLength != 0) {
+ if (partitionInsert >= stepPartition) {
+ // Fill in up to the new insertion point
+ ApplyStep(partitionInsert);
+ stepLength += delta;
+ } else if (partitionInsert >= (stepPartition - body->Length() / 10)) {
+ // Close to step but before so move step back
+ BackStep(partitionInsert);
+ stepLength += delta;
+ } else {
+ ApplyStep(body->Length()-1);
+ stepPartition = partitionInsert;
+ stepLength = delta;
+ }
+ } else {
+ stepPartition = partitionInsert;
+ stepLength = delta;
+ }
+ }
+
+ void RemovePartition(int partition) {
+ if (partition > stepPartition) {
+ ApplyStep(partition);
+ stepPartition--;
+ } else {
+ stepPartition--;
+ }
+ body->Delete(partition);
+ }
+
+ int PositionFromPartition(int partition) const {
+ PLATFORM_ASSERT(partition >= 0);
+ PLATFORM_ASSERT(partition < body->Length());
+ if ((partition < 0) || (partition >= body->Length())) {
+ return 0;
+ }
+ int pos = body->ValueAt(partition);
+ if (partition > stepPartition)
+ pos += stepLength;
+ return pos;
+ }
+
+ int PartitionFromPosition(int pos) {
+ if (body->Length() <= 1)
+ return 0;
+ if (pos >= (PositionFromPartition(body->Length()-1)))
+ return body->Length() - 1 - 1;
+ int lower = 0;
+ int upper = body->Length()-1;
+ do {
+ int middle = (upper + lower + 1) / 2; // Round high
+ int posMiddle = body->ValueAt(middle);
+ if (middle > stepPartition)
+ posMiddle += stepLength;
+ if (pos < posMiddle) {
+ upper = middle - 1;
+ } else {
+ lower = middle;
+ }
+ } while (lower < upper);
+ return lower;
+ }
+
+ void DeleteAll() {
+ int growSize = body->GetGrowSize();
+ delete body;
+ Allocate(growSize);
+ }
+};
+
+#endif
--- /dev/null
+// Scintilla source code edit control
+/** @file PositionCache.cxx
+ ** Classes for caching layout information.
+ **/
+// Copyright 1998-2007 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <ctype.h>
+
+#include "Platform.h"
+
+#include "Scintilla.h"
+
+#include "SplitVector.h"
+#include "Partitioning.h"
+#include "RunStyles.h"
+#include "ContractionState.h"
+#include "CellBuffer.h"
+#include "KeyMap.h"
+#include "Indicator.h"
+#include "XPM.h"
+#include "LineMarker.h"
+#include "Style.h"
+#include "ViewStyle.h"
+#include "CharClassify.h"
+#include "Decoration.h"
+#include "Document.h"
+#include "PositionCache.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+static inline bool IsControlCharacter(int ch) {
+ // iscntrl returns true for lots of chars > 127 which are displayable
+ return ch >= 0 && ch < ' ';
+}
+
+LineLayout::LineLayout(int maxLineLength_) :
+ lineStarts(0),
+ lenLineStarts(0),
+ lineNumber(-1),
+ inCache(false),
+ maxLineLength(-1),
+ numCharsInLine(0),
+ validity(llInvalid),
+ xHighlightGuide(0),
+ highlightColumn(0),
+ selStart(0),
+ selEnd(0),
+ containsCaret(false),
+ edgeColumn(0),
+ chars(0),
+ styles(0),
+ styleBitsSet(0),
+ indicators(0),
+ positions(0),
+ hsStart(0),
+ hsEnd(0),
+ widthLine(wrapWidthInfinite),
+ lines(1) {
+ Resize(maxLineLength_);
+}
+
+LineLayout::~LineLayout() {
+ Free();
+}
+
+void LineLayout::Resize(int maxLineLength_) {
+ if (maxLineLength_ > maxLineLength) {
+ Free();
+ chars = new char[maxLineLength_ + 1];
+ styles = new unsigned char[maxLineLength_ + 1];
+ indicators = new char[maxLineLength_ + 1];
+ // Extra position allocated as sometimes the Windows
+ // GetTextExtentExPoint API writes an extra element.
+ positions = new int[maxLineLength_ + 1 + 1];
+ maxLineLength = maxLineLength_;
+ }
+}
+
+void LineLayout::Free() {
+ delete []chars;
+ chars = 0;
+ delete []styles;
+ styles = 0;
+ delete []indicators;
+ indicators = 0;
+ delete []positions;
+ positions = 0;
+ delete []lineStarts;
+ lineStarts = 0;
+}
+
+void LineLayout::Invalidate(validLevel validity_) {
+ if (validity > validity_)
+ validity = validity_;
+}
+
+int LineLayout::LineStart(int line) const {
+ if (line <= 0) {
+ return 0;
+ } else if ((line >= lines) || !lineStarts) {
+ return numCharsInLine;
+ } else {
+ return lineStarts[line];
+ }
+}
+
+int LineLayout::LineLastVisible(int line) const {
+ if (line < 0) {
+ return 0;
+ } else if ((line >= lines-1) || !lineStarts) {
+ int startLine = LineStart(line);
+ int endLine = numCharsInLine;
+ while ((endLine > startLine) && IsEOLChar(chars[endLine-1])) {
+ endLine--;
+ }
+ return endLine;
+ } else {
+ return lineStarts[line+1];
+ }
+}
+
+bool LineLayout::InLine(int offset, int line) const {
+ return ((offset >= LineStart(line)) && (offset < LineStart(line + 1)) ||
+ ((offset == numCharsInLine) && (line == (lines-1))));
+}
+
+void LineLayout::SetLineStart(int line, int start) {
+ if ((line >= lenLineStarts) && (line != 0)) {
+ int newMaxLines = line + 20;
+ int *newLineStarts = new int[newMaxLines];
+ if (!newLineStarts)
+ return;
+ for (int i = 0; i < newMaxLines; i++) {
+ if (i < lenLineStarts)
+ newLineStarts[i] = lineStarts[i];
+ else
+ newLineStarts[i] = 0;
+ }
+ delete []lineStarts;
+ lineStarts = newLineStarts;
+ lenLineStarts = newMaxLines;
+ }
+ lineStarts[line] = start;
+}
+
+void LineLayout::SetBracesHighlight(Range rangeLine, Position braces[],
+ char bracesMatchStyle, int xHighlight) {
+ if (rangeLine.ContainsCharacter(braces[0])) {
+ int braceOffset = braces[0] - rangeLine.start;
+ if (braceOffset < numCharsInLine) {
+ bracePreviousStyles[0] = styles[braceOffset];
+ styles[braceOffset] = bracesMatchStyle;
+ }
+ }
+ if (rangeLine.ContainsCharacter(braces[1])) {
+ int braceOffset = braces[1] - rangeLine.start;
+ if (braceOffset < numCharsInLine) {
+ bracePreviousStyles[1] = styles[braceOffset];
+ styles[braceOffset] = bracesMatchStyle;
+ }
+ }
+ if ((braces[0] >= rangeLine.start && braces[1] <= rangeLine.end) ||
+ (braces[1] >= rangeLine.start && braces[0] <= rangeLine.end)) {
+ xHighlightGuide = xHighlight;
+ }
+}
+
+void LineLayout::RestoreBracesHighlight(Range rangeLine, Position braces[]) {
+ if (rangeLine.ContainsCharacter(braces[0])) {
+ int braceOffset = braces[0] - rangeLine.start;
+ if (braceOffset < numCharsInLine) {
+ styles[braceOffset] = bracePreviousStyles[0];
+ }
+ }
+ if (rangeLine.ContainsCharacter(braces[1])) {
+ int braceOffset = braces[1] - rangeLine.start;
+ if (braceOffset < numCharsInLine) {
+ styles[braceOffset] = bracePreviousStyles[1];
+ }
+ }
+ xHighlightGuide = 0;
+}
+
+int LineLayout::FindBefore(int x, int lower, int upper) const {
+ do {
+ int middle = (upper + lower + 1) / 2; // Round high
+ int posMiddle = positions[middle];
+ if (x < posMiddle) {
+ upper = middle - 1;
+ } else {
+ lower = middle;
+ }
+ } while (lower < upper);
+ return lower;
+}
+
+LineLayoutCache::LineLayoutCache() :
+ level(0), length(0), size(0), cache(0),
+ allInvalidated(false), styleClock(-1), useCount(0) {
+ Allocate(0);
+}
+
+LineLayoutCache::~LineLayoutCache() {
+ Deallocate();
+}
+
+void LineLayoutCache::Allocate(int length_) {
+ PLATFORM_ASSERT(cache == NULL);
+ allInvalidated = false;
+ length = length_;
+ size = length;
+ if (size > 1) {
+ size = (size / 16 + 1) * 16;
+ }
+ if (size > 0) {
+ cache = new LineLayout * [size];
+ }
+ for (int i = 0; i < size; i++)
+ cache[i] = 0;
+}
+
+void LineLayoutCache::AllocateForLevel(int linesOnScreen, int linesInDoc) {
+ PLATFORM_ASSERT(useCount == 0);
+ int lengthForLevel = 0;
+ if (level == llcCaret) {
+ lengthForLevel = 1;
+ } else if (level == llcPage) {
+ lengthForLevel = linesOnScreen + 1;
+ } else if (level == llcDocument) {
+ lengthForLevel = linesInDoc;
+ }
+ if (lengthForLevel > size) {
+ Deallocate();
+ Allocate(lengthForLevel);
+ } else {
+ if (lengthForLevel < length) {
+ for (int i = lengthForLevel; i < length; i++) {
+ delete cache[i];
+ cache[i] = 0;
+ }
+ }
+ length = lengthForLevel;
+ }
+ PLATFORM_ASSERT(length == lengthForLevel);
+ PLATFORM_ASSERT(cache != NULL || length == 0);
+}
+
+void LineLayoutCache::Deallocate() {
+ PLATFORM_ASSERT(useCount == 0);
+ for (int i = 0; i < length; i++)
+ delete cache[i];
+ delete []cache;
+ cache = 0;
+ length = 0;
+ size = 0;
+}
+
+void LineLayoutCache::Invalidate(LineLayout::validLevel validity_) {
+ if (cache && !allInvalidated) {
+ for (int i = 0; i < length; i++) {
+ if (cache[i]) {
+ cache[i]->Invalidate(validity_);
+ }
+ }
+ if (validity_ == LineLayout::llInvalid) {
+ allInvalidated = true;
+ }
+ }
+}
+
+void LineLayoutCache::SetLevel(int level_) {
+ allInvalidated = false;
+ if ((level_ != -1) && (level != level_)) {
+ level = level_;
+ Deallocate();
+ }
+}
+
+LineLayout *LineLayoutCache::Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_,
+ int linesOnScreen, int linesInDoc) {
+ AllocateForLevel(linesOnScreen, linesInDoc);
+ if (styleClock != styleClock_) {
+ Invalidate(LineLayout::llCheckTextAndStyle);
+ styleClock = styleClock_;
+ }
+ allInvalidated = false;
+ int pos = -1;
+ LineLayout *ret = 0;
+ if (level == llcCaret) {
+ pos = 0;
+ } else if (level == llcPage) {
+ if (lineNumber == lineCaret) {
+ pos = 0;
+ } else if (length > 1) {
+ pos = 1 + (lineNumber % (length - 1));
+ }
+ } else if (level == llcDocument) {
+ pos = lineNumber;
+ }
+ if (pos >= 0) {
+ PLATFORM_ASSERT(useCount == 0);
+ if (cache && (pos < length)) {
+ if (cache[pos]) {
+ if ((cache[pos]->lineNumber != lineNumber) ||
+ (cache[pos]->maxLineLength < maxChars)) {
+ delete cache[pos];
+ cache[pos] = 0;
+ }
+ }
+ if (!cache[pos]) {
+ cache[pos] = new LineLayout(maxChars);
+ }
+ if (cache[pos]) {
+ cache[pos]->lineNumber = lineNumber;
+ cache[pos]->inCache = true;
+ ret = cache[pos];
+ useCount++;
+ }
+ }
+ }
+
+ if (!ret) {
+ ret = new LineLayout(maxChars);
+ ret->lineNumber = lineNumber;
+ }
+
+ return ret;
+}
+
+void LineLayoutCache::Dispose(LineLayout *ll) {
+ allInvalidated = false;
+ if (ll) {
+ if (!ll->inCache) {
+ delete ll;
+ } else {
+ useCount--;
+ }
+ }
+}
+
+void BreakFinder::Insert(int val) {
+ // Expand if needed
+ if (saeLen >= saeSize) {
+ saeSize *= 2;
+ int *selAndEdgeNew = new int[saeSize];
+ for (unsigned int j = 0; j<saeLen; j++) {
+ selAndEdgeNew[j] = selAndEdge[j];
+ }
+ delete []selAndEdge;
+ selAndEdge = selAndEdgeNew;
+ }
+
+ if (val >= nextBreak) {
+ for (unsigned int j = 0; j<saeLen; j++) {
+ if (val == selAndEdge[j]) {
+ return;
+ } if (val < selAndEdge[j]) {
+ for (unsigned int k = saeLen; k>j; k--) {
+ selAndEdge[k] = selAndEdge[k-1];
+ }
+ saeLen++;
+ selAndEdge[j] = val;
+ return;
+ }
+ }
+ // Not less than any so append
+ selAndEdge[saeLen++] = val;
+ }
+}
+
+extern bool BadUTF(const char *s, int len, int &trailBytes);
+
+static int NextBadU(const char *s, int p, int len, int &trailBytes) {
+ while (p < len) {
+ p++;
+ if (BadUTF(s + p, len - p, trailBytes))
+ return p;
+ }
+ return -1;
+}
+
+BreakFinder::BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posLineStart_, bool utf8_, int xStart) :
+ ll(ll_),
+ lineStart(lineStart_),
+ lineEnd(lineEnd_),
+ posLineStart(posLineStart_),
+ utf8(utf8_),
+ nextBreak(lineStart_),
+ saeSize(0),
+ saeLen(0),
+ saeCurrentPos(0),
+ saeNext(0),
+ subBreak(-1) {
+ saeSize = 8;
+ selAndEdge = new int[saeSize];
+ for (unsigned int j=0; j < saeSize; j++) {
+ selAndEdge[j] = 0;
+ }
+
+ // Search for first visible break
+ // First find the first visible character
+ nextBreak = ll->FindBefore(xStart, lineStart, lineEnd);
+ // Now back to a style break
+ while ((nextBreak > lineStart) && (ll->styles[nextBreak] == ll->styles[nextBreak - 1])) {
+ nextBreak--;
+ }
+
+ if (ll->selStart != ll->selEnd) {
+ Insert(ll->selStart - posLineStart - 1);
+ Insert(ll->selEnd - posLineStart - 1);
+ }
+
+ Insert(ll->edgeColumn - 1);
+ Insert(lineEnd - 1);
+
+ if (utf8) {
+ int trailBytes=0;
+ for (int pos = -1;;) {
+ pos = NextBadU(ll->chars, pos, lineEnd, trailBytes);
+ if (pos < 0)
+ break;
+ Insert(pos-1);
+ Insert(pos);
+ }
+ }
+ saeNext = (saeLen > 0) ? selAndEdge[0] : -1;
+}
+
+BreakFinder::~BreakFinder() {
+ delete []selAndEdge;
+}
+
+int BreakFinder::First() {
+ return nextBreak;
+}
+
+int BreakFinder::Next() {
+ if (subBreak == -1) {
+ int prev = nextBreak;
+ while (nextBreak < lineEnd) {
+ if ((ll->styles[nextBreak] != ll->styles[nextBreak + 1]) ||
+ (nextBreak == saeNext) ||
+ IsControlCharacter(ll->chars[nextBreak]) || IsControlCharacter(ll->chars[nextBreak + 1])) {
+ if (nextBreak == saeNext) {
+ saeCurrentPos++;
+ saeNext = (saeLen > saeCurrentPos) ? selAndEdge[saeCurrentPos] : -1;
+ }
+ nextBreak++;
+ if ((nextBreak - prev) < lengthStartSubdivision) {
+ return nextBreak;
+ }
+ break;
+ }
+ nextBreak++;
+ }
+ if ((nextBreak - prev) < lengthStartSubdivision) {
+ return nextBreak;
+ }
+ subBreak = prev;
+ }
+ // Splitting up a long run from prev to nextBreak in lots of approximately lengthEachSubdivision.
+ // For very long runs add extra breaks after spaces or if no spaces before low punctuation.
+ if ((nextBreak - subBreak) <= lengthEachSubdivision) {
+ subBreak = -1;
+ return nextBreak;
+ } else {
+ int lastGoodBreak = -1;
+ int lastOKBreak = -1;
+ int j;
+ for (j = subBreak + 1; j <= nextBreak; j++) {
+ if (IsSpaceOrTab(ll->chars[j - 1]) && !IsSpaceOrTab(ll->chars[j])) {
+ lastGoodBreak = j;
+ }
+ if (ll->chars[j] < 'A') {
+ lastOKBreak = j;
+ }
+ if (((j - subBreak) >= lengthEachSubdivision) && ((lastGoodBreak >= 0) || (lastOKBreak >= 0))) {
+ break;
+ }
+ }
+ if (lastGoodBreak >= 0) {
+ subBreak = lastGoodBreak;
+ } else if (lastOKBreak >= 0) {
+ subBreak = lastOKBreak;
+ } else {
+ subBreak = nextBreak;
+ }
+ if (subBreak >= nextBreak) {
+ subBreak = -1;
+ return nextBreak;
+ } else {
+ return subBreak;
+ }
+ }
+}
+
+PositionCacheEntry::PositionCacheEntry() :
+ styleNumber(0), len(0), clock(0), positions(0) {
+}
+
+void PositionCacheEntry::Set(unsigned int styleNumber_, const char *s_,
+ unsigned int len_, int *positions_, unsigned int clock_) {
+ Clear();
+ styleNumber = styleNumber_;
+ len = len_;
+ clock = clock_;
+ if (s_ && positions_) {
+ positions = new short[len + (len + 1) / 2];
+ for (unsigned int i=0;i<len;i++) {
+ positions[i] = static_cast<short>(positions_[i]);
+ }
+ memcpy(reinterpret_cast<char *>(positions + len), s_, len);
+ }
+}
+
+PositionCacheEntry::~PositionCacheEntry() {
+ Clear();
+}
+
+void PositionCacheEntry::Clear() {
+ delete []positions;
+ positions = 0;
+ styleNumber = 0;
+ len = 0;
+ clock = 0;
+}
+
+bool PositionCacheEntry::Retrieve(unsigned int styleNumber_, const char *s_,
+ unsigned int len_, int *positions_) const {
+ if ((styleNumber == styleNumber_) && (len == len_) &&
+ (memcmp(reinterpret_cast<char *>(positions + len), s_, len)== 0)) {
+ for (unsigned int i=0;i<len;i++) {
+ positions_[i] = positions[i];
+ }
+ return true;
+ } else {
+ return false;
+ }
+}
+
+int PositionCacheEntry::Hash(unsigned int styleNumber, const char *s, unsigned int len) {
+ unsigned int ret = s[0] << 7;
+ for (unsigned int i=0; i<len; i++) {
+ ret *= 1000003;
+ ret ^= s[i];
+ }
+ ret *= 1000003;
+ ret ^= len;
+ ret *= 1000003;
+ ret ^= styleNumber;
+ return ret;
+}
+
+bool PositionCacheEntry::NewerThan(const PositionCacheEntry &other) {
+ return clock > other.clock;
+}
+
+void PositionCacheEntry::ResetClock() {
+ if (clock > 0) {
+ clock = 1;
+ }
+}
+
+PositionCache::PositionCache() {
+ size = 0x400;
+ clock = 1;
+ pces = new PositionCacheEntry[size];
+ allClear = true;
+}
+
+PositionCache::~PositionCache() {
+ Clear();
+ delete []pces;
+}
+
+void PositionCache::Clear() {
+ if (!allClear) {
+ for (size_t i=0;i<size;i++) {
+ pces[i].Clear();
+ }
+ }
+ clock = 1;
+ allClear = true;
+}
+
+void PositionCache::SetSize(size_t size_) {
+ Clear();
+ delete []pces;
+ size = size_;
+ pces = new PositionCacheEntry[size];
+}
+
+void PositionCache::MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned int styleNumber,
+ const char *s, unsigned int len, int *positions) {
+ allClear = false;
+ int probe = -1;
+ if ((size > 0) && (len < 30)) {
+ // Only store short strings in the cache so it doesn't churn with
+ // long comments with only a single comment.
+
+ // Two way associative: try two probe positions.
+ int hashValue = PositionCacheEntry::Hash(styleNumber, s, len);
+ probe = hashValue % size;
+ if (pces[probe].Retrieve(styleNumber, s, len, positions)) {
+ return;
+ }
+ int probe2 = (hashValue * 37) % size;
+ if (pces[probe2].Retrieve(styleNumber, s, len, positions)) {
+ return;
+ }
+ // Not found. Choose the oldest of the two slots to replace
+ if (pces[probe].NewerThan(pces[probe2])) {
+ probe = probe2;
+ }
+ }
+ surface->MeasureWidths(vstyle.styles[styleNumber].font, s, len, positions);
+ if (probe >= 0) {
+ clock++;
+ if (clock > 60000) {
+ // Since there are only 16 bits for the clock, wrap it round and
+ // reset all cache entries so none get stuck with a high clock.
+ for (size_t i=0;i<size;i++) {
+ pces[i].ResetClock();
+ }
+ clock = 2;
+ }
+ pces[probe].Set(styleNumber, s, len, positions, clock);
+ }
+}
--- /dev/null
+// Scintilla source code edit control
+/** @file PositionCache.h
+ ** Classes for caching layout information.
+ **/
+// Copyright 1998-2007 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#ifndef POSITIONCACHE_H
+#define POSITIONCACHE_H
+
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
+static inline bool IsEOLChar(char ch) {
+ return (ch == '\r') || (ch == '\n');
+}
+
+/**
+ */
+class LineLayout {
+private:
+ friend class LineLayoutCache;
+ int *lineStarts;
+ int lenLineStarts;
+ /// Drawing is only performed for @a maxLineLength characters on each line.
+ int lineNumber;
+ bool inCache;
+public:
+ enum { wrapWidthInfinite = 0x7ffffff };
+ int maxLineLength;
+ int numCharsInLine;
+ enum validLevel { llInvalid, llCheckTextAndStyle, llPositions, llLines } validity;
+ int xHighlightGuide;
+ bool highlightColumn;
+ int selStart;
+ int selEnd;
+ bool containsCaret;
+ int edgeColumn;
+ char *chars;
+ unsigned char *styles;
+ int styleBitsSet;
+ char *indicators;
+ int *positions;
+ char bracePreviousStyles[2];
+
+ // Hotspot support
+ int hsStart;
+ int hsEnd;
+
+ // Wrapped line support
+ int widthLine;
+ int lines;
+
+ LineLayout(int maxLineLength_);
+ virtual ~LineLayout();
+ void Resize(int maxLineLength_);
+ void Free();
+ void Invalidate(validLevel validity_);
+ int LineStart(int line) const;
+ int LineLastVisible(int line) const;
+ bool InLine(int offset, int line) const;
+ void SetLineStart(int line, int start);
+ void SetBracesHighlight(Range rangeLine, Position braces[],
+ char bracesMatchStyle, int xHighlight);
+ void RestoreBracesHighlight(Range rangeLine, Position braces[]);
+ int FindBefore(int x, int lower, int upper) const;
+};
+
+/**
+ */
+class LineLayoutCache {
+ int level;
+ int length;
+ int size;
+ LineLayout **cache;
+ bool allInvalidated;
+ int styleClock;
+ int useCount;
+ void Allocate(int length_);
+ void AllocateForLevel(int linesOnScreen, int linesInDoc);
+public:
+ LineLayoutCache();
+ virtual ~LineLayoutCache();
+ void Deallocate();
+ enum {
+ llcNone=SC_CACHE_NONE,
+ llcCaret=SC_CACHE_CARET,
+ llcPage=SC_CACHE_PAGE,
+ llcDocument=SC_CACHE_DOCUMENT
+ };
+ void Invalidate(LineLayout::validLevel validity_);
+ void SetLevel(int level_);
+ int GetLevel() { return level; }
+ LineLayout *Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_,
+ int linesOnScreen, int linesInDoc);
+ void Dispose(LineLayout *ll);
+};
+
+class PositionCacheEntry {
+ unsigned int styleNumber:8;
+ unsigned int len:8;
+ unsigned int clock:16;
+ short *positions;
+public:
+ PositionCacheEntry();
+ ~PositionCacheEntry();
+ void Set(unsigned int styleNumber_, const char *s_, unsigned int len_, int *positions_, unsigned int clock);
+ void Clear();
+ bool Retrieve(unsigned int styleNumber_, const char *s_, unsigned int len_, int *positions_) const;
+ static int Hash(unsigned int styleNumber, const char *s, unsigned int len);
+ bool NewerThan(const PositionCacheEntry &other);
+ void ResetClock();
+};
+
+// Class to break a line of text into shorter runs at sensible places.
+class BreakFinder {
+ // If a whole run is longer than lengthStartSubdivision then subdivide
+ // into smaller runs at spaces or punctuation.
+ enum { lengthStartSubdivision = 300 };
+ // Try to make each subdivided run lengthEachSubdivision or shorter.
+ enum { lengthEachSubdivision = 100 };
+ LineLayout *ll;
+ int lineStart;
+ int lineEnd;
+ int posLineStart;
+ bool utf8;
+ int nextBreak;
+ int *selAndEdge;
+ unsigned int saeSize;
+ unsigned int saeLen;
+ unsigned int saeCurrentPos;
+ int saeNext;
+ int subBreak;
+ void Insert(int val);
+public:
+ BreakFinder(LineLayout *ll_, int lineStart_, int lineEnd_, int posLineStart_, bool utf8_, int xStart);
+ ~BreakFinder();
+ int First();
+ int Next();
+};
+
+class PositionCache {
+ PositionCacheEntry *pces;
+ size_t size;
+ unsigned int clock;
+ bool allClear;
+public:
+ PositionCache();
+ ~PositionCache();
+ void Clear();
+ void SetSize(size_t size_);
+ int GetSize() { return size; }
+ void MeasureWidths(Surface *surface, ViewStyle &vstyle, unsigned int styleNumber,
+ const char *s, unsigned int len, int *positions);
+};
+
+inline bool IsSpaceOrTab(int ch) {
+ return ch == ' ' || ch == '\t';
+}
+
+#ifdef SCI_NAMESPACE
+}
+#endif
+
+#endif
#include "PropSet.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
// The comparison and case changing functions here assume ASCII
// or extended ASCII such as the normal Windows code page.
// End SString functions
-bool PropSet::caseSensitiveFilenames = false;
-
PropSet::PropSet() {
superPS = 0;
for (int root = 0; root < hashRoots; root++)
Set(s);
}
-SString PropSet::Get(const char *key) {
+SString PropSet::Get(const char *key) const {
unsigned int hash = HashString(key, strlen(key));
for (Property *p = props[hash % hashRoots]; p; p = p->next) {
if ((hash == p->hash) && (0 == strcmp(p->key, key))) {
}
}
-bool PropSet::IncludesVar(const char *value, const char *key) {
- const char *var = strstr(value, "$(");
- while (var) {
- if (isprefix(var + 2, key) && (var[2 + strlen(key)] == ')')) {
- // Found $(key) which would lead to an infinite loop so exit
- return true;
- }
- var = strstr(var + 2, ")");
- if (var)
- var = strstr(var + 1, "$(");
- }
- return false;
-}
-
-
// There is some inconsistency between GetExpanded("foo") and Expand("$(foo)").
// A solution is to keep a stack of variables that have been expanded, so that
// recursive expansions can be skipped. For now I'll just use the C++ stack
const VarChain *link;
};
-static int ExpandAllInPlace(PropSet &props, SString &withVars, int maxExpands, const VarChain &blankVars = VarChain()) {
+static int ExpandAllInPlace(const PropSet &props, SString &withVars, int maxExpands, const VarChain &blankVars = VarChain()) {
int varStart = withVars.search("$(");
while ((varStart >= 0) && (maxExpands > 0)) {
int varEnd = withVars.search(")", varStart+2);
return maxExpands;
}
-
-SString PropSet::GetExpanded(const char *key) {
+SString PropSet::GetExpanded(const char *key) const {
SString val = Get(key);
ExpandAllInPlace(*this, val, 100, VarChain(key));
return val;
}
-SString PropSet::Expand(const char *withVars, int maxExpands) {
+SString PropSet::Expand(const char *withVars, int maxExpands) const {
SString val = withVars;
ExpandAllInPlace(*this, val, maxExpands);
return val;
}
-int PropSet::GetInt(const char *key, int defaultValue) {
+int PropSet::GetInt(const char *key, int defaultValue) const {
SString val = GetExpanded(key);
if (val.length())
return val.value();
return true;
}
-static bool IsSuffix(const char *target, const char *suffix, bool caseSensitive) {
- size_t lentarget = strlen(target);
- size_t lensuffix = strlen(suffix);
- if (lensuffix > lentarget)
- return false;
- if (caseSensitive) {
- for (int i = static_cast<int>(lensuffix) - 1; i >= 0; i--) {
- if (target[i + lentarget - lensuffix] != suffix[i])
- return false;
- }
- } else {
- for (int i = static_cast<int>(lensuffix) - 1; i >= 0; i--) {
- if (MakeUpperCase(target[i + lentarget - lensuffix]) !=
- MakeUpperCase(suffix[i]))
- return false;
- }
- }
- return true;
-}
-
-SString PropSet::GetWild(const char *keybase, const char *filename) {
- for (int root = 0; root < hashRoots; root++) {
- for (Property *p = props[root]; p; p = p->next) {
- if (isprefix(p->key, keybase)) {
- char * orgkeyfile = p->key + strlen(keybase);
- char *keyfile = NULL;
-
- if (strstr(orgkeyfile, "$(") == orgkeyfile) {
- char *cpendvar = strchr(orgkeyfile, ')');
- if (cpendvar) {
- *cpendvar = '\0';
- SString s = GetExpanded(orgkeyfile + 2);
- *cpendvar = ')';
- keyfile = StringDup(s.c_str());
- }
- }
- char *keyptr = keyfile;
-
- if (keyfile == NULL)
- keyfile = orgkeyfile;
-
- for (;;) {
- char *del = strchr(keyfile, ';');
- if (del == NULL)
- del = keyfile + strlen(keyfile);
- char delchr = *del;
- *del = '\0';
- if (*keyfile == '*') {
- if (IsSuffix(filename, keyfile + 1, caseSensitiveFilenames)) {
- *del = delchr;
- delete []keyptr;
- return p->val;
- }
- } else if (0 == strcmp(keyfile, filename)) {
- *del = delchr;
- delete []keyptr;
- return p->val;
- }
- if (delchr == '\0')
- break;
- *del = delchr;
- keyfile = del + 1;
- }
- delete []keyptr;
-
- if (0 == strcmp(p->key, keybase)) {
- return p->val;
- }
- }
- }
- }
- if (superPS) {
- // Failed here, so try in base property set
- return superPS->GetWild(keybase, filename);
- } else {
- return "";
- }
-}
-
-
-
-// GetNewExpand does not use Expand as it has to use GetWild with the filename for each
-// variable reference found.
-SString PropSet::GetNewExpand(const char *keybase, const char *filename) {
- char *base = StringDup(GetWild(keybase, filename).c_str());
- char *cpvar = strstr(base, "$(");
- int maxExpands = 1000; // Avoid infinite expansion of recursive definitions
- while (cpvar && (maxExpands > 0)) {
- char *cpendvar = strchr(cpvar, ')');
- if (cpendvar) {
- int lenvar = cpendvar - cpvar - 2; // Subtract the $()
- char *var = StringDup(cpvar + 2, lenvar);
- SString val = GetWild(var, filename);
- if (0 == strcmp(var, keybase))
- val.clear(); // Self-references evaluate to empty string
- size_t newlenbase = strlen(base) + val.length() - lenvar;
- char *newbase = new char[newlenbase];
- strncpy(newbase, base, cpvar - base);
- strcpy(newbase + (cpvar - base), val.c_str());
- strcpy(newbase + (cpvar - base) + val.length(), cpendvar + 1);
- delete []var;
- delete []base;
- base = newbase;
- }
- cpvar = strstr(base, "$(");
- maxExpands--;
- }
- SString sret = base;
- delete []base;
- return sret;
-}
-
void PropSet::Clear() {
for (int root = 0; root < hashRoots; root++) {
Property *p = props[root];
}
}
-char *PropSet::ToString() {
+char *PropSet::ToString() const {
size_t len=0;
for (int r = 0; r < hashRoots; r++) {
for (Property *p = props[r]; p; p = p->next) {
return ret;
}
-/**
- * Initiate enumeration.
- */
-bool PropSet::GetFirst(char **key, char **val) {
- for (int i = 0; i < hashRoots; i++) {
- for (Property *p = props[i]; p; p = p->next) {
- if (p) {
- *key = p->key;
- *val = p->val;
- enumnext = p->next; // GetNext will begin here ...
- enumhash = i; // ... in this block
- return true;
- }
- }
- }
- return false;
-}
-
-/**
- * Continue enumeration.
- */
-bool PropSet::GetNext(char ** key, char ** val) {
- bool firstloop = true;
-
- // search begins where we left it : in enumhash block
- for (int i = enumhash; i < hashRoots; i++) {
- if (!firstloop)
- enumnext = props[i]; // Begin with first property in block
- // else : begin where we left
- firstloop = false;
-
- for (Property *p = enumnext; p; p = p->next) {
- if (p) {
- *key = p->key;
- *val = p->val;
- enumnext = p->next; // for GetNext
- enumhash = i;
- return true;
- }
- }
- }
- return false;
-}
-
/**
* Creates an array that points into each word in the string and puts \0 terminators
* after each word.
if (words) {
delete []list;
delete []words;
- delete []wordsNoCase;
}
words = 0;
- wordsNoCase = 0;
list = 0;
len = 0;
sorted = false;
- sortedNoCase = false;
}
void WordList::Set(const char *s) {
list = StringDup(s);
sorted = false;
- sortedNoCase = false;
words = ArrayFromWordList(list, &len, onlyLineEnds);
- wordsNoCase = new char * [len + 1];
- memcpy(wordsNoCase, words, (len + 1) * sizeof (*words));
}
-char *WordList::Allocate(int size) {
- list = new char[size + 1];
- list[size] = '\0';
- return list;
-}
-
-void WordList::SetFromAllocated() {
- sorted = false;
- sortedNoCase = false;
- words = ArrayFromWordList(list, &len, onlyLineEnds);
- wordsNoCase = new char * [len + 1];
- memcpy(wordsNoCase, words, (len + 1) * sizeof (*words));
-}
-
-int cmpString(const void *a1, const void *a2) {
+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));
}
-int cmpStringNoCase(const void *a1, const void *a2) {
- // Can't work out the correct incantation to use modern casts here
- return CompareCaseInsensitive(*(char**)(a1), *(char**)(a2));
-}
-
static void SortWordList(char **words, unsigned int len) {
qsort(reinterpret_cast<void*>(words), len, sizeof(*words),
cmpString);
}
-static void SortWordListNoCase(char **wordsNoCase, unsigned int len) {
- qsort(reinterpret_cast<void*>(wordsNoCase), len, sizeof(*wordsNoCase),
- cmpStringNoCase);
-}
-
bool WordList::InList(const char *s) {
if (0 == words)
return false;
unsigned char firstChar = s[0];
int j = starts[firstChar];
if (j >= 0) {
- while (words[j][0] == firstChar) {
+ while ((unsigned char)words[j][0] == firstChar) {
if (s[1] == words[j][1]) {
const char *a = words[j] + 1;
const char *b = s + 1;
}
return false;
}
-
-/**
- * Returns an element (complete) of the wordlist array which has
- * the same beginning as the passed string.
- * The length of the word to compare is passed too.
- * Letter case can be ignored or preserved (default).
- */
-const char *WordList::GetNearestWord(const char *wordStart, int searchLen, bool ignoreCase /*= false*/, SString wordCharacters /*='/0' */, int wordIndex /*= -1 */) {
- int start = 0; // lower bound of the api array block to search
- int end = len - 1; // upper bound of the api array block to search
- int pivot; // index of api array element just being compared
- int cond; // comparison result (in the sense of strcmp() result)
- const char *word; // api array element just being compared
-
- if (0 == words)
- return NULL;
- if (ignoreCase) {
- if (!sortedNoCase) {
- sortedNoCase = true;
- SortWordListNoCase(wordsNoCase, len);
- }
- while (start <= end) { // binary searching loop
- pivot = (start + end) >> 1;
- word = wordsNoCase[pivot];
- cond = CompareNCaseInsensitive(wordStart, word, searchLen);
- if (!cond) {
- // find first word
- start = pivot;
- while (start > 0 && !CompareNCaseInsensitive(wordStart, wordsNoCase[start-1], searchLen)) {
- start--;
- }
- // find last word
- end = pivot;
- while (end < len-1 && !CompareNCaseInsensitive(wordStart, wordsNoCase[end+1], searchLen)) {
- end++;
- }
-
- // Finds first word in a series of equal words
- for (pivot = start; pivot <= end; pivot++) {
- word = wordsNoCase[pivot];
- if (!wordCharacters.contains(word[searchLen])) {
- if (wordIndex <= 0) // Checks if a specific index was requested
- return word; // result must not be freed with free()
- wordIndex--;
- }
- }
- return NULL;
- }
- else if (cond > 0)
- start = pivot + 1;
- else if (cond < 0)
- end = pivot - 1;
- }
- } else { // preserve the letter case
- if (!sorted) {
- sorted = true;
- SortWordList(words, len);
- }
- while (start <= end) { // binary searching loop
- pivot = (start + end) >> 1;
- word = words[pivot];
- cond = strncmp(wordStart, word, searchLen);
- if (!cond) {
- // find first word
- start = pivot;
- while (start > 0 && !strncmp(wordStart, words[start-1], searchLen)) {
- start--;
- }
- // find last word
- end = pivot;
- while (end < len-1 && !strncmp(wordStart, words[end+1], searchLen)) {
- end++;
- }
-
- // Finds first word in a series of equal words
- pivot = start;
- while (pivot <= end) {
- word = words[pivot];
- if (!wordCharacters.contains(word[searchLen])) {
- if (wordIndex <= 0) // Checks if a specific index was requested
- return word; // result must not be freed with free()
- wordIndex--;
- }
- pivot++;
- }
- return NULL;
- }
- else if (cond > 0)
- start = pivot + 1;
- else if (cond < 0)
- end = pivot - 1;
- }
- }
- return NULL;
-}
-
-/**
- * Find the length of a 'word' which is actually an identifier in a string
- * which looks like "identifier(..." or "identifier" and where
- * there may be extra spaces after the identifier that should not be
- * counted in the length.
- */
-static unsigned int LengthWord(const char *word, char otherSeparator) {
- // Find a '('. If that fails go to the end of the string.
- const char *endWord = strchr(word, '(');
- if (!endWord && otherSeparator)
- endWord = strchr(word, otherSeparator);
- if (!endWord)
- endWord = word + strlen(word);
- // Last case always succeeds so endWord != 0
-
- // Drop any space characters.
- if (endWord > word) {
- endWord--; // Back from the '(', otherSeparator, or '\0'
- // Move backwards over any spaces
- while ((endWord > word) && (IsASpace(*endWord))) {
- endWord--;
- }
- }
- return endWord - word;
-}
-
-/**
- * Returns elements (first words of them) of the wordlist array which have
- * the same beginning as the passed string.
- * The length of the word to compare is passed too.
- * Letter case can be ignored or preserved (default).
- * If there are more words meeting the condition they are returned all of
- * them in the ascending order separated with spaces.
- *
- * NOTE: returned buffer has to be freed with delete[].
- */
-char *WordList::GetNearestWords(
- const char *wordStart,
- int searchLen,
- bool ignoreCase /*= false*/,
- char otherSeparator /*= '\0'*/,
- bool exactLen /*=false*/) {
- unsigned int wordlen; // length of the word part (before the '(' brace) of the api array element
- SString wordsNear;
- wordsNear.setsizegrowth(1000);
- int start = 0; // lower bound of the api array block to search
- int end = len - 1; // upper bound of the api array block to search
- int pivot; // index of api array element just being compared
- int cond; // comparison result (in the sense of strcmp() result)
-
- if (0 == words)
- return NULL;
- if (ignoreCase) {
- if (!sortedNoCase) {
- sortedNoCase = true;
- SortWordListNoCase(wordsNoCase, len);
- }
- while (start <= end) { // Binary searching loop
- pivot = (start + end) / 2;
- cond = CompareNCaseInsensitive(wordStart, wordsNoCase[pivot], searchLen);
- if (!cond) {
- // Find first match
- while ((pivot > start) &&
- (0 == CompareNCaseInsensitive(wordStart,
- wordsNoCase[pivot-1], searchLen))) {
- --pivot;
- }
- // Grab each match
- while ((pivot <= end) &&
- (0 == CompareNCaseInsensitive(wordStart,
- wordsNoCase[pivot], searchLen))) {
- wordlen = LengthWord(wordsNoCase[pivot], otherSeparator) + 1;
- ++pivot;
- if (exactLen && wordlen != LengthWord(wordStart, otherSeparator) + 1)
- continue;
- wordsNear.append(wordsNoCase[pivot-1], wordlen, ' ');
- }
- return wordsNear.detach();
- } else if (cond < 0) {
- end = pivot - 1;
- } else if (cond > 0) {
- start = pivot + 1;
- }
- }
- } else { // Preserve the letter case
- if (!sorted) {
- sorted = true;
- SortWordList(words, len);
- }
- while (start <= end) { // Binary searching loop
- pivot = (start + end) / 2;
- cond = strncmp(wordStart, words[pivot], searchLen);
- if (!cond) {
- // Find first match
- while ((pivot > start) &&
- (0 == strncmp(wordStart,
- words[pivot-1], searchLen))) {
- --pivot;
- }
- // Grab each match
- while ((pivot <= end) &&
- (0 == strncmp(wordStart,
- words[pivot], searchLen))) {
- wordlen = LengthWord(words[pivot], otherSeparator) + 1;
- ++pivot;
- if (exactLen && wordlen != LengthWord(wordStart, otherSeparator) + 1)
- continue;
- wordsNear.append(words[pivot-1], wordlen, ' ');
- }
- return wordsNear.detach();
- } else if (cond < 0) {
- end = pivot - 1;
- } else if (cond > 0) {
- start = pivot + 1;
- }
- }
- }
- return NULL;
-}
* Converted to modern function prototypes.
* Put all global/static variables into an object so this code can be
* used from multiple threads, etc.
+ * Some extensions by Philippe Lhoste PhiLho(a)GMX.net
*
* These routines are the PUBLIC DOMAIN equivalents of regex
* routines as found in 4.nBSD UN*X, with minor extensions.
* [2] . matches any character.
*
* [3] \ matches the character following it, except:
- * - \a, \b, \f, \n, \t, \v match the
- * corresponding C escape char;
+ * - \a, \b, \f, \n, \r, \t, \v match the corresponding C
+ * escape char, respectively BEL, BS, FF, LF, CR, TAB and VT;
+ * Note that \r and \n are never matched because Scintilla
+ * regex searches are made line per line
+ * (stripped of end-of-line chars).
* - if not in posix mode, when followed by a
* left or right round bracket (see [7]);
* - when followed by a digit 1 to 9 (see [8]);
* - when followed by a left or right angle bracket
- * (see [9]).
- * It is used as an escape character for all
- * other meta-characters, and itself. When used
- * in a set ([4]), it is treated as an ordinary
- * character (except for escape chars).
+ * (see [9]);
+ * - when followed by d, D, s, S, w or W (see [10]);
+ * - when followed by x and two hexa digits (see [11].
+ * Backslash is used as an escape character for all
+ * other meta-characters, and itself.
*
* [4] [set] matches one of the characters in the set.
* If the first character in the set is "^",
- * it matches a character NOT in the set, i.e.
- * complements the set. A shorthand S-E (start-end)
- * is used to specify a set of characters S upto
- * E, inclusive. The special characters "]" and
- * "-" have no special meaning if they appear
- * as the first chars in the set. To include both,
- * put - first: [-]A-Z]:
- * [-]|] matches these 2 chars,
- * []-|] matches from ] to | chars.
+ * it matches the characters NOT in the set, i.e.
+ * complements the set. A shorthand S-E (start dash end)
+ * is used to specify a set of characters S up to
+ * E, inclusive. S and E must be characters, otherwise
+ * the dash is taken literally (eg. in expression [\d-a]).
+ * The special characters "]" and "-" have no special
+ * meaning if they appear as the first chars in the set.
+ * To include both, put - first: [-]A-Z]
+ * (or just backslash them).
* examples: match:
*
+ * [-]|] matches these 3 chars,
+ *
+ * []-|] matches from ] to | chars
+ *
* [a-z] any lowercase alpha
*
* [^-]] any char except - and ]
*
* [a-zA-Z] any alpha
*
- * [5] * any regular expression form [1] to [4], followed by
- * closure char (*) matches zero or more matches of
- * that form.
+ * [5] * any regular expression form [1] to [4]
+ * (except [7], [8] and [9] forms of [3]),
+ * followed by closure char (*)
+ * matches zero or more matches of that form.
*
* [6] + same as [5], except it matches one or more.
+ * Both [5] and [6] are greedy (they match as much as possible).
*
- * [7] a regular expression in the form [1] to [10], enclosed
+ * [7] a regular expression in the form [1] to [12], enclosed
* as \(form\) (or (form) with posix flag) matches what
* form matches. The enclosure creates a set of tags,
* used for [8] and for pattern substitution.
* pattern matching to the beginning of a word, and/or
* the end of a word. A word is defined to be a character
* string beginning and/or ending with the characters
- * A-Z a-z 0-9 and _. It must also be preceded and/or
+ * A-Z a-z 0-9 and _. Scintilla extends this definition
+ * by user setting. The word must also be preceded and/or
* followed by any character outside those mentioned.
*
- * [10] a composite regular expression xy where x and y
- * are in the form [1] to [10] matches the longest
+ * [10] \l a backslash followed by d, D, s, S, w or W,
+ * becomes a character class (both inside and
+ * outside sets []).
+ * d: decimal digits
+ * D: any char except decimal digits
+ * s: whitespace (space, \t \n \r \f \v)
+ * S: any char except whitespace (see above)
+ * w: alphanumeric & underscore (changed by user setting)
+ * W: any char except alphanumeric & underscore (see above)
+ *
+ * [11] \xHH a backslash followed by x and two hexa digits,
+ * becomes the character whose Ascii code is equal
+ * to these digits. If not followed by two digits,
+ * it is 'x' char itself.
+ *
+ * [12] a composite regular expression xy where x and y
+ * are in the form [1] to [11] matches the longest
* match of x followed by a match for y.
*
- * [11] ^ a regular expression starting with a ^ character
+ * [13] ^ a regular expression starting with a ^ character
* $ and/or ending with a $ character, restricts the
* pattern matching to the beginning of the line,
* or the end of line. [anchors] Elsewhere in the
*
* Notes:
*
- * This implementation uses a bit-set representation for character
- * classes for speed and compactness. Each character is represented
- * by one bit in a 256-bit block. Thus, CCL always takes a
+ * This implementation uses a bit-set representation for character
+ * classes for speed and compactness. Each character is represented
+ * by one bit in a 256-bit block. Thus, CCL always takes a
* constant 32 bytes in the internal nfa, and RESearch::Execute does a single
- * bit comparison to locate the character in the set.
+ * bit comparison to locate the character in the set.
*
* Examples:
*
#pragma warning(disable: 4514)
#endif
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
#define OKP 1
#define NOP 0
#define BLKIND 0370
#define BITIND 07
-const char bitarr[] = {1,2,4,8,16,32,64,'\200'};
+const char bitarr[] = { 1, 2, 4, 8, 16, 32, 64, '\200' };
#define badpat(x) (*nfa = END, x)
* Character classification table for word boundary operators BOW
* and EOW is passed in by the creator of this object (Scintilla
* Document). The Document default state is that word chars are:
- * 0-9,a-z, A-Z and _
+ * 0-9, a-z, A-Z and _
*/
RESearch::RESearch(CharClassify *charClassTable) {
void RESearch::Init() {
sta = NOP; /* status of lastpat */
bol = 0;
- for (int i=0; i<MAXTAG; i++)
+ for (int i = 0; i < MAXTAG; i++)
pat[i] = 0;
- for (int j=0; j<BITBLK; j++)
+ for (int j = 0; j < BITBLK; j++)
bittab[j] = 0;
}
void RESearch::Clear() {
- for (int i=0; i<MAXTAG; i++) {
+ for (int i = 0; i < MAXTAG; i++) {
delete []pat[i];
pat[i] = 0;
bopat[i] = NOTFOUND;
bool RESearch::GrabMatches(CharacterIndexer &ci) {
bool success = true;
- for (unsigned int i=0; i<MAXTAG; i++) {
+ for (unsigned int i = 0; i < MAXTAG; i++) {
if ((bopat[i] != NOTFOUND) && (eopat[i] != NOTFOUND)) {
unsigned int len = eopat[i] - bopat[i];
pat[i] = new char[len + 1];
if (pat[i]) {
- for (unsigned int j=0; j<len; j++)
+ for (unsigned int j = 0; j < len; j++)
pat[i][j] = ci.CharAt(bopat[i] + j);
pat[i][len] = '\0';
} else {
return success;
}
-void RESearch::ChSet(char c) {
+void RESearch::ChSet(unsigned char c) {
bittab[((c) & BLKIND) >> 3] |= bitarr[(c) & BITIND];
}
-void RESearch::ChSetWithCase(char c, bool caseSensitive) {
+void RESearch::ChSetWithCase(unsigned char c, bool caseSensitive) {
if (caseSensitive) {
ChSet(c);
} else {
if ((c >= 'a') && (c <= 'z')) {
ChSet(c);
- ChSet(static_cast<char>(c - 'a' + 'A'));
+ ChSet(static_cast<unsigned char>(c - 'a' + 'A'));
} else if ((c >= 'A') && (c <= 'Z')) {
ChSet(c);
- ChSet(static_cast<char>(c - 'A' + 'a'));
+ ChSet(static_cast<unsigned char>(c - 'A' + 'a'));
} else {
ChSet(c);
}
}
}
-const char escapeValue(char ch) {
+const unsigned char escapeValue(unsigned char ch) {
switch (ch) {
case 'a': return '\a';
case 'b': return '\b';
return 0;
}
+static int GetHexaChar(unsigned char hd1, unsigned char hd2) {
+ int hexValue = 0;
+ if (hd1 >= '0' && hd1 <= '9') {
+ hexValue += 16 * (hd1 - '0');
+ } else if (hd1 >= 'A' && hd1 <= 'F') {
+ hexValue += 16 * (hd1 - 'A' + 10);
+ } else if (hd1 >= 'a' && hd1 <= 'f') {
+ hexValue += 16 * (hd1 - 'a' + 10);
+ } else
+ return -1;
+ if (hd2 >= '0' && hd2 <= '9') {
+ hexValue += hd2 - '0';
+ } else if (hd2 >= 'A' && hd2 <= 'F') {
+ hexValue += hd2 - 'A' + 10;
+ } else if (hd2 >= 'a' && hd2 <= 'f') {
+ hexValue += hd2 - 'a' + 10;
+ } else
+ return -1;
+ return hexValue;
+}
+
+/**
+ * Called when the parser finds a backslash not followed
+ * by a valid expression (like \( in non-Posix mode).
+ * @param pat: pointer on the char after the backslash.
+ * @param incr: (out) number of chars to skip after expression evaluation.
+ * @return the char if it resolves to a simple char,
+ * or -1 for a char class. In this case, bittab is changed.
+ */
+int RESearch::GetBackslashExpression(
+ const char *pat,
+ int &incr) {
+ // Since error reporting is primitive and messages are not used anyway,
+ // I choose to interpret unexpected syntax in a logical way instead
+ // of reporting errors. Otherwise, we can stick on, eg., PCRE behavior.
+ incr = 0; // Most of the time, will skip the char "naturally".
+ int c;
+ int result = -1;
+ unsigned char bsc = *pat;
+ if (!bsc) {
+ // Avoid overrun
+ result = '\\'; // \ at end of pattern, take it literally
+ return result;
+ }
+
+ switch (bsc) {
+ case 'a':
+ case 'b':
+ case 'n':
+ case 'f':
+ case 'r':
+ case 't':
+ case 'v':
+ result = escapeValue(bsc);
+ break;
+ case 'x': {
+ unsigned char hd1 = *(pat + 1);
+ unsigned char hd2 = *(pat + 2);
+ int hexValue = GetHexaChar(hd1, hd2);
+ if (hexValue >= 0) {
+ result = hexValue;
+ incr = 2; // Must skip the digits
+ } else {
+ result = 'x'; // \x without 2 digits: see it as 'x'
+ }
+ }
+ break;
+ case 'd':
+ for (c = '0'; c <= '9'; c++) {
+ ChSet(static_cast<unsigned char>(c));
+ }
+ break;
+ case 'D':
+ for (c = 0; c < MAXCHR; c++) {
+ if (c < '0' || c > '9') {
+ ChSet(static_cast<unsigned char>(c));
+ }
+ }
+ break;
+ case 's':
+ ChSet(' ');
+ ChSet('\t');
+ ChSet('\n');
+ ChSet('\r');
+ ChSet('\f');
+ ChSet('\v');
+ break;
+ case 'S':
+ for (c = 0; c < MAXCHR; c++) {
+ if (c != ' ' && !(c >= 0x09 && c <= 0x0D)) {
+ ChSet(static_cast<unsigned char>(c));
+ }
+ }
+ case 'w':
+ for (c = 0; c < MAXCHR; c++) {
+ if (iswordc(static_cast<unsigned char>(c))) {
+ ChSet(static_cast<unsigned char>(c));
+ }
+ }
+ break;
+ case 'W':
+ for (c = 0; c < MAXCHR; c++) {
+ if (!iswordc(static_cast<unsigned char>(c))) {
+ ChSet(static_cast<unsigned char>(c));
+ }
+ }
+ break;
+ default:
+ result = bsc;
+ }
+ return result;
+}
+
const char *RESearch::Compile(const char *pat, int length, bool caseSensitive, bool posix) {
char *mp=nfa; /* nfa pointer */
char *lp; /* saved pointer */
int n;
char mask; /* xor mask -CCL/NCL */
- int c1, c2;
+ int c1, c2, prevChar;
if (!pat || !length)
if (sta)
if (mp > mpMax)
return badpat("Pattern too long");
lp = mp;
- switch(*p) {
+ switch (*p) {
case '.': /* match any char */
*mp++ = ANY;
case '[': /* match char class */
*mp++ = CCL;
+ prevChar = 0;
i++;
if (*++p == '^') {
if (*p == '-') { /* real dash */
i++;
+ prevChar = *p;
ChSet(*p++);
}
if (*p == ']') { /* real brace */
i++;
+ prevChar = *p;
ChSet(*p++);
}
while (*p && *p != ']') {
- if (*p == '-' && *(p+1) && *(p+1) != ']') {
- i++;
- p++;
- c1 = *(p-2) + 1;
- i++;
- c2 = *p++;
- while (c1 <= c2) {
- ChSetWithCase(static_cast<char>(c1++), caseSensitive);
+ if (*p == '-') {
+ if (prevChar < 0) {
+ // Previous def. was a char class like \d, take dash literally
+ prevChar = *p;
+ ChSet(*p);
+ } else if (*(p+1)) {
+ if (*(p+1) != ']') {
+ c1 = prevChar + 1;
+ i++;
+ c2 = *++p;
+ if (c2 == '\\') {
+ if (!*(p+1)) // End of RE
+ return badpat("Missing ]");
+ else {
+ i++;
+ p++;
+ int incr;
+ c2 = GetBackslashExpression(p, incr);
+ i += incr;
+ p += incr;
+ if (c2 >= 0) {
+ // Convention: \c (c is any char) is case sensitive, whatever the option
+ ChSet(static_cast<unsigned char>(c2));
+ prevChar = c2;
+ } else {
+ // bittab is already changed
+ prevChar = -1;
+ }
+ }
+ }
+ if (prevChar < 0) {
+ // Char after dash is char class like \d, take dash literally
+ prevChar = '-';
+ ChSet('-');
+ } else {
+ // Put all chars between c1 and c2 included in the char set
+ while (c1 <= c2) {
+ ChSetWithCase(static_cast<unsigned char>(c1++), caseSensitive);
+ }
+ }
+ } else {
+ // Dash before the ], take it literally
+ prevChar = *p;
+ ChSet(*p);
+ }
+ } else {
+ return badpat("Missing ]");
}
} else if (*p == '\\' && *(p+1)) {
i++;
p++;
- char escape = escapeValue(*p);
- if (escape)
- ChSetWithCase(escape, caseSensitive);
- else
- ChSetWithCase(*p, caseSensitive);
- i++;
- p++;
+ int incr;
+ int c = GetBackslashExpression(p, incr);
+ i += incr;
+ p += incr;
+ if (c >= 0) {
+ // Convention: \c (c is any char) is case sensitive, whatever the option
+ ChSet(static_cast<unsigned char>(c));
+ prevChar = c;
+ } else {
+ // bittab is already changed
+ prevChar = -1;
+ }
} else {
- i++;
- ChSetWithCase(*p++, caseSensitive);
+ prevChar = *p;
+ ChSetWithCase(*p, caseSensitive);
}
+ i++;
+ p++;
}
if (!*p)
return badpat("Missing ]");
- for (n = 0; n < BITBLK; bittab[n++] = (char) 0)
+ for (n = 0; n < BITBLK; bittab[n++] = 0)
*mp++ = static_cast<char>(mask ^ bittab[n]);
break;
lp = sp; /* previous opcode */
if (*lp == CLO) /* equivalence... */
break;
- switch(*lp) {
+ switch (*lp) {
case BOL:
case BOT:
case '\\': /* tags, backrefs... */
i++;
- switch(*++p) {
-
+ switch (*++p) {
case '<':
*mp++ = BOW;
break;
if (tagc > n) {
*mp++ = static_cast<char>(REF);
*mp++ = static_cast<char>(n);
- }
- else
+ } else
return badpat("Undetermined reference");
break;
- case 'a':
- case 'b':
- case 'n':
- case 'f':
- case 'r':
- case 't':
- case 'v':
- *mp++ = CHR;
- *mp++ = escapeValue(*p);
- break;
default:
if (!posix && *p == '(') {
if (tagc < MAXTAG) {
tagstk[++tagi] = tagc;
*mp++ = BOT;
*mp++ = static_cast<char>(tagc++);
- }
- else
+ } else
return badpat("Too many \\(\\) pairs");
} else if (!posix && *p == ')') {
if (*sp == BOT)
if (tagi > 0) {
*mp++ = static_cast<char>(EOT);
*mp++ = static_cast<char>(tagstk[tagi--]);
- }
- else
+ } else
return badpat("Unmatched \\)");
} else {
- *mp++ = CHR;
- *mp++ = *p;
+ int incr;
+ int c = GetBackslashExpression(p, incr);
+ i += incr;
+ p += incr;
+ if (c >= 0) {
+ *mp++ = CHR;
+ *mp++ = static_cast<unsigned char>(c);
+ } else {
+ *mp++ = CCL;
+ mask = 0;
+ for (n = 0; n < BITBLK; bittab[n++] = 0)
+ *mp++ = static_cast<char>(mask ^ bittab[n]);
+ }
}
}
break;
tagstk[++tagi] = tagc;
*mp++ = BOT;
*mp++ = static_cast<char>(tagc++);
- }
- else
+ } else
return badpat("Too many () pairs");
} else if (posix && *p == ')') {
if (*sp == BOT)
if (tagi > 0) {
*mp++ = static_cast<char>(EOT);
*mp++ = static_cast<char>(tagstk[tagi--]);
- }
- else
+ } else
return badpat("Unmatched )");
- } else if (caseSensitive) {
- *mp++ = CHR;
- *mp++ = *p;
} else {
- *mp++ = CCL;
- mask = 0;
- ChSetWithCase(*p, false);
- for (n = 0; n < BITBLK; bittab[n++] = (char) 0)
- *mp++ = static_cast<char>(mask ^ bittab[n]);
+ unsigned char c = *p;
+ if (!c) // End of RE
+ c = '\\'; // We take it as raw backslash
+ if (caseSensitive || !iswordc(c)) {
+ *mp++ = CHR;
+ *mp++ = c;
+ } else {
+ *mp++ = CCL;
+ mask = 0;
+ ChSetWithCase(c, false);
+ for (n = 0; n < BITBLK; bittab[n++] = 0)
+ *mp++ = static_cast<char>(mask ^ bittab[n]);
+ }
}
break;
}
* respectively.
*
*/
-
int RESearch::Execute(CharacterIndexer &ci, int lp, int endp) {
- char c;
+ unsigned char c;
int ep = NOTFOUND;
char *ap = nfa;
Clear();
- switch(*ap) {
+ switch (*ap) {
case BOL: /* anchored: match from BOL only */
ep = PMatch(ci, lp, endp, ap);
int are; /* to save the line ptr. */
while ((op = *ap++) != END)
- switch(op) {
+ switch (op) {
case CHR:
if (ci.CharAt(lp++) != *ap++)
break;
case CLO:
are = lp;
- switch(*ap) {
+ switch (*ap) {
case ANY:
while (lp < endp)
* tagged subpattern does not exist, null is substituted.
*/
int RESearch::Substitute(CharacterIndexer &ci, char *src, char *dst) {
- char c;
+ unsigned char c;
int pin;
int bp;
int ep;
return 0;
while ((c = *src++) != 0) {
- switch(c) {
+ switch (c) {
case '&':
pin = 0;
return 0;
}
}
- *dst = (char) 0;
+ *dst = '\0';
return 1;
}
+
#ifndef RESEARCH_H
#define RESEARCH_H
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
/*
* The following defines are not meant to be changeable.
* They are for readability only.
int Execute(CharacterIndexer &ci, int lp, int endp);
int Substitute(CharacterIndexer &ci, char *src, char *dst);
- enum {MAXTAG=10};
- enum {MAXNFA=2048};
- enum {NOTFOUND=-1};
+ enum { MAXTAG=10 };
+ enum { MAXNFA=2048 };
+ enum { NOTFOUND=-1 };
int bopat[MAXTAG];
int eopat[MAXTAG];
private:
void Init();
void Clear();
- void ChSet(char c);
- void ChSetWithCase(char c, bool caseSensitive);
+ void ChSet(unsigned char c);
+ void ChSetWithCase(unsigned char c, bool caseSensitive);
+ int GetBackslashExpression(const char *pat, int &incr);
int PMatch(CharacterIndexer &ci, int lp, int endp, char *ap);
int bol;
- int tagstk[MAXTAG]; /* subpat tag stack */
+ int tagstk[MAXTAG]; /* subpat tag stack */
char nfa[MAXNFA]; /* automaton */
int sta;
- char bittab[BITBLK]; /* bit table for CCL pre-set bits */
+ unsigned char bittab[BITBLK]; /* bit table for CCL pre-set bits */
int failure;
CharClassify *charClass;
bool iswordc(unsigned char x) {
}
};
+#ifdef SCI_NAMESPACE
+}
#endif
+
+#endif
+
--- /dev/null
+/** @file RunStyles.cxx
+ ** Data structure used to store sparse styles.
+ **/
+// Copyright 1998-2007 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include "Platform.h"
+
+#include "Scintilla.h"
+#include "SplitVector.h"
+#include "Partitioning.h"
+#include "RunStyles.h"
+
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
+// Find the first run at a position
+int RunStyles::RunFromPosition(int position) {
+ int run = starts->PartitionFromPosition(position);
+ // Go to first element with this position
+ while ((run > 0) && (position == starts->PositionFromPartition(run-1))) {
+ run--;
+ }
+ return run;
+}
+
+// If there is no run boundary at position, insert one continuing style.
+int RunStyles::SplitRun(int position) {
+ int run = RunFromPosition(position);
+ int posRun = starts->PositionFromPartition(run);
+ if (posRun < position) {
+ int runStyle = ValueAt(position);
+ run++;
+ starts->InsertPartition(run, position);
+ styles->InsertValue(run, 1, runStyle);
+ }
+ return run;
+}
+
+void RunStyles::RemoveRun(int run) {
+ starts->RemovePartition(run);
+ styles->DeleteRange(run, 1);
+}
+
+void RunStyles::RemoveRunIfEmpty(int run) {
+ if ((run < starts->Partitions()) && (starts->Partitions() > 1)) {
+ if (starts->PositionFromPartition(run) == starts->PositionFromPartition(run+1)) {
+ RemoveRun(run);
+ }
+ }
+}
+
+void RunStyles::RemoveRunIfSameAsPrevious(int run) {
+ if ((run > 0) && (run < starts->Partitions())) {
+ if (styles->ValueAt(run-1) == styles->ValueAt(run)) {
+ RemoveRun(run);
+ }
+ }
+}
+
+RunStyles::RunStyles() {
+ starts = new Partitioning(8);
+ styles = new SplitVector<int>();
+ styles->InsertValue(0, 2, 0);
+}
+
+RunStyles::~RunStyles() {
+ delete starts;
+ starts = NULL;
+ delete styles;
+ styles = NULL;
+}
+
+int RunStyles::Length() {
+ return starts->PositionFromPartition(starts->Partitions());
+}
+
+int RunStyles::ValueAt(int position) {
+ return styles->ValueAt(starts->PartitionFromPosition(position));
+}
+
+int RunStyles::FindNextChange(int position, int end) {
+ int run = starts->PartitionFromPosition(position);
+ if (run < starts->Partitions()) {
+ int runChange = starts->PositionFromPartition(run);
+ if (runChange > position)
+ return runChange;
+ int nextChange = starts->PositionFromPartition(run + 1);
+ if (nextChange > position) {
+ return nextChange;
+ } else if (position < end) {
+ return end;
+ } else {
+ return end + 1;
+ }
+ } else {
+ return end + 1;
+ }
+}
+
+int RunStyles::StartRun(int position) {
+ return starts->PositionFromPartition(starts->PartitionFromPosition(position));
+}
+
+int RunStyles::EndRun(int position) {
+ return starts->PositionFromPartition(starts->PartitionFromPosition(position) + 1);
+}
+
+bool RunStyles::FillRange(int &position, int value, int &fillLength) {
+ int end = position + fillLength;
+ int runEnd = RunFromPosition(end);
+ if (styles->ValueAt(runEnd) == value) {
+ // End already has value so trim range.
+ end = starts->PositionFromPartition(runEnd);
+ if (position >= end) {
+ // Whole range is already same as value so no action
+ return false;
+ }
+ fillLength = end - position;
+ } else {
+ runEnd = SplitRun(end);
+ }
+ int runStart = RunFromPosition(position);
+ if (styles->ValueAt(runStart) == value) {
+ // Start is in expected value so trim range.
+ runStart++;
+ position = starts->PositionFromPartition(runStart);
+ fillLength = end - position;
+ } else {
+ if (starts->PositionFromPartition(runStart) < position) {
+ runStart = SplitRun(position);
+ runEnd++;
+ }
+ }
+ if (runStart < runEnd) {
+ styles->SetValueAt(runStart, value);
+ // Remove each old run over the range
+ for (int run=runStart+1; run<runEnd; run++) {
+ RemoveRun(runStart+1);
+ }
+ runEnd = RunFromPosition(end);
+ RemoveRunIfSameAsPrevious(runEnd);
+ RemoveRunIfSameAsPrevious(runStart);
+ }
+ return true;
+}
+
+void RunStyles::SetValueAt(int position, int value) {
+ int len = 1;
+ FillRange(position, value, len);
+}
+
+void RunStyles::InsertSpace(int position, int insertLength) {
+ int runStart = RunFromPosition(position);
+ if (starts->PositionFromPartition(runStart) == position) {
+ int runStyle = ValueAt(position);
+ // Inserting at start of run so make previous longer
+ if (runStart == 0) {
+ // Inserting at start of document so ensure 0
+ if (runStyle) {
+ styles->SetValueAt(0, 0);
+ starts->InsertPartition(1, 0);
+ styles->InsertValue(1, 1, runStyle);
+ starts->InsertText(0, insertLength);
+ } else {
+ starts->InsertText(runStart, insertLength);
+ }
+ } else {
+ if (runStyle) {
+ starts->InsertText(runStart-1, insertLength);
+ } else {
+ // Insert at end of run so do not extend style
+ starts->InsertText(runStart, insertLength);
+ }
+ }
+ } else {
+ starts->InsertText(runStart, insertLength);
+ }
+}
+
+void RunStyles::DeleteAll() {
+ delete starts;
+ starts = NULL;
+ delete styles;
+ styles = NULL;
+ starts = new Partitioning(8);
+ styles = new SplitVector<int>();
+ styles->InsertValue(0, 2, 0);
+}
+
+void RunStyles::DeleteRange(int position, int deleteLength) {
+ int end = position + deleteLength;
+ int runStart = RunFromPosition(position);
+ int runEnd = RunFromPosition(end);
+ if (runStart == runEnd) {
+ // Deleting from inside one run
+ starts->InsertText(runStart, -deleteLength);
+ } else {
+ runStart = SplitRun(position);
+ runEnd = SplitRun(end);
+ starts->InsertText(runStart, -deleteLength);
+ // Remove each old run over the range
+ for (int run=runStart; run<runEnd; run++) {
+ RemoveRun(runStart);
+ }
+ RemoveRunIfEmpty(runStart);
+ RemoveRunIfSameAsPrevious(runStart);
+ }
+}
+
--- /dev/null
+/** @file RunStyles.h
+ ** Data structure used to store sparse styles.
+ **/
+// Copyright 1998-2007 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+/// Styling buffer using one element for each run rather than using
+/// a filled buffer.
+
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
+class RunStyles {
+public:
+ Partitioning *starts;
+ SplitVector<int> *styles;
+ int RunFromPosition(int position);
+ int SplitRun(int position);
+ void RemoveRun(int run);
+ void RemoveRunIfEmpty(int run);
+ void RemoveRunIfSameAsPrevious(int run);
+public:
+ RunStyles();
+ ~RunStyles();
+ int Length();
+ int ValueAt(int position);
+ int FindNextChange(int position, int end);
+ int StartRun(int position);
+ int EndRun(int position);
+ // Returns true if some values may have changed
+ bool FillRange(int &position, int value, int &fillLength);
+ void SetValueAt(int position, int value);
+ void InsertSpace(int position, int insertLength);
+ void DeleteAll();
+ void DeleteRange(int position, int deleteLength);
+};
+
+#ifdef SCI_NAMESPACE
+}
+#endif
-// Scintilla source code edit control
-/** @file SVector.h
- ** A simple expandable vector.
- **/
-// Copyright 1998-2001 by Neil Hodgson <neilh@hare.net.au>
-// The License.txt file describes the conditions under which this software may be distributed.
-
-#ifndef SVECTOR_H
-#define SVECTOR_H
-
-/**
- * A simple expandable integer vector.
- * Storage not allocated for elements until an element is used.
- * This makes it very lightweight unless used so is a good match for optional features.
- */
-class SVector {
- enum { allocSize = 4000 };
-
- int *v; ///< The vector
- unsigned int size; ///< Number of elements allocated
- unsigned int len; ///< Number of elements used in vector
- bool allocFailure; ///< A memory allocation call has failed
-
- /** Internally allocate more elements than the user wants
- * to avoid thrashing the memory allocator. */
- void SizeTo(int newSize) {
- if (newSize < allocSize)
- newSize += allocSize;
- else
- newSize = (newSize * 3) / 2;
- int* newv = new int[newSize];
- if (!newv) {
- allocFailure = true;
- return;
- }
- size = newSize;
- unsigned int i=0;
- for (; i<len; i++) {
- newv[i] = v[i];
- }
- for (; i<size; i++) {
- newv[i] = 0;
- }
- delete []v;
- v = newv;
- }
-
-public:
- SVector() {
- allocFailure = false;
- v = 0;
- len = 0;
- size = 0;
- }
- ~SVector() {
- Free();
- }
- /// Constructor from another vector.
- SVector(const SVector &other) {
- allocFailure = false;
- v = 0;
- len = 0;
- size = 0;
- if (other.Length() > 0) {
- SizeTo(other.Length());
- if (!allocFailure) {
- for (int i=0;i<other.Length();i++)
- v[i] = other.v[i];
- len = other.Length();
- }
- }
- }
- /// Copy constructor.
- SVector &operator=(const SVector &other) {
- if (this != &other) {
- delete []v;
- allocFailure = false;
- v = 0;
- len = 0;
- size = 0;
- if (other.Length() > 0) {
- SizeTo(other.Length());
- if (!allocFailure) {
- for (int i=0;i<other.Length();i++)
- v[i] = other.v[i];
- }
- len = other.Length();
- }
- }
- return *this;
- }
- /** @brief Accessor.
- * Allows to access values from the list, and grows it if accessing
- * outside the current bounds. The returned value in this case is 0. */
- int &operator[](unsigned int i) {
- if (i >= len) {
- if (i >= size) {
- SizeTo(i);
- }
- len = i+1;
- }
- return v[i];
- }
- /// Reset vector.
- void Free() {
- delete []v;
- v = 0;
- size = 0;
- len = 0;
- }
- /** @brief Grow vector size.
- * Doesn't allow a vector to be shrinked. */
- void SetLength(unsigned int newLength) {
- if (newLength > len) {
- if (newLength >= size) {
- SizeTo(newLength);
- }
- }
- len = newLength;
- }
- /// Get the current length (number of used elements) of the vector.
- int Length() const {
- return len;
- }
-};
-
-#endif
#include "DocumentAccessor.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 "ViewStyle.h"
#include "AutoComplete.h"
#include "CharClassify.h"
+#include "Decoration.h"
#include "Document.h"
+#include "PositionCache.h"
#include "Editor.h"
#include "ScintillaBase.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
ScintillaBase::ScintillaBase() {
displayPopupMenu = true;
listType = 0;
(iMessage != SCI_CHARLEFT) &&
(iMessage != SCI_CHARLEFTEXTEND) &&
(iMessage != SCI_CHARRIGHT) &&
- (iMessage != SCI_CHARLEFTEXTEND) &&
+ (iMessage != SCI_CHARRIGHTEXTEND) &&
(iMessage != SCI_EDITTOGGLEOVERTYPE) &&
(iMessage != SCI_DELETEBACK) &&
(iMessage != SCI_DELETEBACKNOTLINE)
PRectangle rcClient = GetClientRectangle();
Point pt = LocationFromPosition(currentPos - lenEntered);
+ PRectangle rcPopupBounds = wMain.GetMonitorRect(pt);
+ if (rcPopupBounds.Height() == 0)
+ rcPopupBounds = rcClient;
int heightLB = 100;
int widthLB = 100;
}
PRectangle rcac;
rcac.left = pt.x - ac.lb->CaretFromEdge();
- if (pt.y >= rcClient.bottom - heightLB && // Wont fit below.
- pt.y >= (rcClient.bottom + rcClient.top) / 2) { // and there is more room above.
+ if (pt.y >= rcPopupBounds.bottom - heightLB && // Wont fit below.
+ pt.y >= (rcPopupBounds.bottom + rcPopupBounds.top) / 2) { // and there is more room above.
rcac.top = pt.y - heightLB;
- if (rcac.top < 0) {
- heightLB += rcac.top;
- rcac.top = 0;
+ if (rcac.top < rcPopupBounds.top) {
+ heightLB -= (rcPopupBounds.top - rcac.top);
+ rcac.top = rcPopupBounds.top;
}
} else {
rcac.top = pt.y + vs.lineHeight;
}
rcac.right = rcac.left + widthLB;
- rcac.bottom = Platform::Minimum(rcac.top + heightLB, rcClient.bottom);
+ rcac.bottom = Platform::Minimum(rcac.top + heightLB, rcPopupBounds.bottom);
ac.lb->SetPositionRelative(rcac, wMain);
ac.lb->SetFont(vs.styles[STYLE_DEFAULT].font);
unsigned int aveCharWidth = vs.styles[STYLE_DEFAULT].aveCharWidth;
// Make an allowance for large strings in list
rcList.left = pt.x - ac.lb->CaretFromEdge();
rcList.right = rcList.left + widthLB;
- if (((pt.y + vs.lineHeight) >= (rcClient.bottom - heightAlloced)) && // Wont fit below.
- ((pt.y + vs.lineHeight / 2) >= (rcClient.bottom + rcClient.top) / 2)) { // and there is more room above.
+ if (((pt.y + vs.lineHeight) >= (rcPopupBounds.bottom - heightAlloced)) && // Wont fit below.
+ ((pt.y + vs.lineHeight / 2) >= (rcPopupBounds.bottom + rcPopupBounds.top) / 2)) { // and there is more room above.
rcList.top = pt.y - heightAlloced;
} else {
rcList.top = pt.y + vs.lineHeight;
SetEmptySelection(ac.posStart);
if (item != -1) {
SString piece = selected;
- pdoc->InsertString(firstPos, piece.c_str());
+ pdoc->InsertCString(firstPos, piece.c_str());
SetEmptySelection(firstPos + static_cast<int>(piece.length()));
}
pdoc->EndUndoAction();
case SCI_CALLTIPSETBACK:
ct.colourBG = ColourDesired(wParam);
- vs.styles[STYLE_CALLTIP].fore = ct.colourBG;
+ vs.styles[STYLE_CALLTIP].back = ct.colourBG;
InvalidateStyleRedraw();
break;
#ifndef SCINTILLABASE_H
#define SCINTILLABASE_H
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
/**
*/
class ScintillaBase : public Editor {
virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam);
};
+#ifdef SCI_NAMESPACE
+}
+#endif
+
#endif
--- /dev/null
+// Scintilla source code edit control
+/** @file SplitVector.h
+ ** Main data structure for holding arrays that handle insertions
+ ** and deletions efficiently.
+ **/
+// Copyright 1998-2007 by Neil Hodgson <neilh@scintilla.org>
+// The License.txt file describes the conditions under which this software may be distributed.
+
+#ifndef SPLITVECTOR_H
+#define SPLITVECTOR_H
+
+template <typename T>
+class SplitVector {
+protected:
+ T *body;
+ int size;
+ int lengthBody;
+ int part1Length;
+ int gapLength; /// invariant: gapLength == size - lengthBody
+ int growSize;
+
+ /// Move the gap to a particular position so that insertion and
+ /// deletion at that point will not require much copying and
+ /// hence be fast.
+ void GapTo(int position) {
+ if (position != part1Length) {
+ if (position < part1Length) {
+ memmove(
+ body + position + gapLength,
+ body + position,
+ sizeof(T) * (part1Length - position));
+ } else { // position > part1Length
+ memmove(
+ body + part1Length,
+ body + part1Length + gapLength,
+ sizeof(T) * (position - part1Length));
+ }
+ part1Length = position;
+ }
+ }
+
+ /// Check that there is room in the buffer for an insertion,
+ /// reallocating if more space needed.
+ void RoomFor(int insertionLength) {
+ if (gapLength <= insertionLength) {
+ if (growSize * 6 < size)
+ growSize *= 2;
+ ReAllocate(size + insertionLength + growSize);
+ }
+ }
+
+ void Init() {
+ body = NULL;
+ growSize = 8;
+ size = 0;
+ lengthBody = 0;
+ part1Length = 0;
+ gapLength = 0;
+ }
+
+public:
+ /// Construct a split buffer.
+ SplitVector() {
+ Init();
+ }
+
+ ~SplitVector() {
+ delete []body;
+ body = 0;
+ }
+
+ int GetGrowSize() const {
+ return growSize;
+ }
+
+ void SetGrowSize(int growSize_) {
+ growSize = growSize_;
+ }
+
+ /// Reallocate the storage for the buffer to be newSize and
+ /// copy exisiting contents to the new buffer.
+ /// Must not be used to decrease the size of the buffer.
+ void ReAllocate(int newSize) {
+ if (newSize > size) {
+ // Move the gap to the end
+ GapTo(lengthBody);
+ T *newBody = new T[newSize];
+ if ((size != 0) && (body != 0)) {
+ memmove(newBody, body, sizeof(T) * lengthBody);
+ delete []body;
+ }
+ body = newBody;
+ gapLength += newSize - size;
+ size = newSize;
+ }
+ }
+
+ /// Retrieve the character at a particular position.
+ /// Retrieving positions outside the range of the buffer returns 0.
+ /// The assertions here are disabled since calling code can be
+ /// simpler if out of range access works and returns 0.
+ T ValueAt(int position) const {
+ if (position < part1Length) {
+ //PLATFORM_ASSERT(position >= 0);
+ if (position < 0) {
+ return 0;
+ } else {
+ return body[position];
+ }
+ } else {
+ //PLATFORM_ASSERT(position < lengthBody);
+ if (position >= lengthBody) {
+ return 0;
+ } else {
+ return body[gapLength + position];
+ }
+ }
+ }
+
+ void SetValueAt(int position, T v) {
+ if (position < part1Length) {
+ PLATFORM_ASSERT(position >= 0);
+ if (position < 0) {
+ ;
+ } else {
+ body[position] = v;
+ }
+ } else {
+ PLATFORM_ASSERT(position < lengthBody);
+ if (position >= lengthBody) {
+ ;
+ } else {
+ body[gapLength + position] = v;
+ }
+ }
+ }
+
+ T& operator[](int position) const {
+ PLATFORM_ASSERT(position >= 0 && position < lengthBody);
+ if (position < part1Length) {
+ return body[position];
+ } else {
+ return body[gapLength + position];
+ }
+ }
+
+ /// Retrieve the length of the buffer.
+ int Length() const {
+ return lengthBody;
+ }
+
+ /// Insert a single value into the buffer.
+ /// Inserting at positions outside the current range fails.
+ void Insert(int position, T v) {
+ PLATFORM_ASSERT((position >= 0) && (position <= lengthBody));
+ if ((position < 0) || (position > lengthBody)) {
+ return;
+ }
+ RoomFor(1);
+ GapTo(position);
+ body[part1Length] = v;
+ lengthBody++;
+ part1Length++;
+ gapLength--;
+ }
+
+ /// Insert a number of elements into the buffer setting their value.
+ /// Inserting at positions outside the current range fails.
+ void InsertValue(int position, int insertLength, T v) {
+ PLATFORM_ASSERT((position >= 0) && (position <= lengthBody));
+ if (insertLength > 0) {
+ if ((position < 0) || (position > lengthBody)) {
+ return;
+ }
+ RoomFor(insertLength);
+ GapTo(position);
+ for (int i = 0; i < insertLength; i++)
+ body[part1Length + i] = v;
+ lengthBody += insertLength;
+ part1Length += insertLength;
+ gapLength -= insertLength;
+ }
+ }
+
+ /// Ensure at least length elements allocated,
+ /// appending zero valued elements if needed.
+ void EnsureLength(int wantedLength) {
+ if (Length() < wantedLength) {
+ InsertValue(Length(), wantedLength - Length(), 0);
+ }
+ }
+
+ /// Insert text into the buffer from an array.
+ void InsertFromArray(int positionToInsert, const T s[], int positionFrom, int insertLength) {
+ PLATFORM_ASSERT((positionToInsert >= 0) && (positionToInsert <= lengthBody));
+ if (insertLength > 0) {
+ if ((positionToInsert < 0) || (positionToInsert > lengthBody)) {
+ return;
+ }
+ RoomFor(insertLength);
+ GapTo(positionToInsert);
+ memmove(body + part1Length, s + positionFrom, sizeof(T) * insertLength);
+ lengthBody += insertLength;
+ part1Length += insertLength;
+ gapLength -= insertLength;
+ }
+ }
+
+ /// Delete one element from the buffer.
+ void Delete(int position) {
+ PLATFORM_ASSERT((position >= 0) && (position < lengthBody));
+ if ((position < 0) || (position >= lengthBody)) {
+ return;
+ }
+ DeleteRange(position, 1);
+ }
+
+ /// Delete a range from the buffer.
+ /// Deleting positions outside the current range fails.
+ void DeleteRange(int position, int deleteLength) {
+ PLATFORM_ASSERT((position >= 0) && (position + deleteLength <= lengthBody));
+ if ((position < 0) || ((position + deleteLength) > lengthBody)) {
+ return;
+ }
+ if ((position == 0) && (deleteLength == lengthBody)) {
+ // Full deallocation returns storage and is faster
+ delete []body;
+ Init();
+ } else if (deleteLength > 0) {
+ GapTo(position);
+ lengthBody -= deleteLength;
+ gapLength += deleteLength;
+ }
+ }
+
+ /// Delete all the buffer contents.
+ void DeleteAll() {
+ DeleteRange(0, lengthBody);
+ }
+
+};
+
+#endif
#include "Scintilla.h"
#include "Style.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
Style::Style() {
aliasOfDefaultFont = true;
Clear(ColourDesired(0, 0, 0), ColourDesired(0xff, 0xff, 0xff),
#ifndef STYLE_H
#define STYLE_H
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
/**
*/
class Style {
void ClearTo(const Style &source);
bool EquivalentFontTo(const Style *other) const;
void Realise(Surface &surface, int zoomLevel, Style *defaultStyle = 0, bool extraFontFlag = false);
- bool IsProtected() const { return !(changeable && visible);}
+ bool IsProtected() const { return !(changeable && visible);};
};
+#ifdef SCI_NAMESPACE
+}
+#endif
+
#endif
#include "Accessor.h"
#include "StyleContext.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
static void getRange(unsigned int start,
unsigned int end,
Accessor &styler,
// Copyright 1998-2004 by Neil Hodgson <neilh@scintilla.org>
// This file is in the public domain.
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
// All languages handled so far can treat all characters >= 0x80 as one class
// which just continues the current token or starts an identifier if in default.
// DBCS treated specially as the second character can be < 0x80 and hence
return static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+n));
}
bool Match(char ch0) {
- return ch == ch0;
+ return ch == static_cast<unsigned char>(ch0);
}
bool Match(char ch0, char ch1) {
- return (ch == ch0) && (chNext == ch1);
+ return (ch == static_cast<unsigned char>(ch0)) && (chNext == static_cast<unsigned char>(ch1));
}
bool Match(const char *s) {
- if (ch != *s)
+ if (ch != static_cast<unsigned char>(*s))
return false;
s++;
- if (chNext != *s)
+ if (!*s)
+ return true;
+ if (chNext != static_cast<unsigned char>(*s))
return false;
s++;
for (int n=2; *s; n++) {
return true;
}
bool MatchIgnoreCase(const char *s) {
- if (tolower(ch) != *s)
+ if (tolower(ch) != static_cast<unsigned char>(*s))
return false;
s++;
- if (tolower(chNext) != *s)
+ if (tolower(chNext) != static_cast<unsigned char>(*s))
return false;
s++;
for (int n=2; *s; n++) {
- if (*s !=
+ if (static_cast<unsigned char>(*s) !=
tolower(static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+n))))
return false;
s++;
void GetCurrentLowered(char *s, unsigned int len);
};
+#ifdef SCI_NAMESPACE
+}
+#endif
+
inline bool IsASpace(unsigned int ch) {
return (ch == ' ') || ((ch >= 0x09) && (ch <= 0x0d));
}
#include "UniConversion.h"
+enum { SURROGATE_LEAD_FIRST = 0xD800 };
+enum { SURROGATE_TRAIL_FIRST = 0xDC00 };
+enum { SURROGATE_TRAIL_LAST = 0xDFFF };
+
unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen) {
unsigned int len = 0;
- for (unsigned int i = 0; i < tlen && uptr[i]; i++) {
+ for (unsigned int i = 0; i < tlen && uptr[i];) {
unsigned int uch = uptr[i];
- if (uch < 0x80)
+ if (uch < 0x80) {
len++;
- else if (uch < 0x800)
+ } else if (uch < 0x800) {
len += 2;
- else
- len +=3;
+ } else if ((uch >= SURROGATE_LEAD_FIRST) &&
+ (uch <= SURROGATE_TRAIL_LAST)) {
+ len += 4;
+ i++;
+ } else {
+ len += 3;
+ }
+ i++;
}
return len;
}
-void UTF8FromUCS2(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len) {
+void UTF8FromUTF16(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len) {
int k = 0;
- for (unsigned int i = 0; i < tlen && uptr[i]; i++) {
+ for (unsigned int i = 0; i < tlen && uptr[i];) {
unsigned int uch = uptr[i];
if (uch < 0x80) {
putf[k++] = static_cast<char>(uch);
} else if (uch < 0x800) {
putf[k++] = static_cast<char>(0xC0 | (uch >> 6));
putf[k++] = static_cast<char>(0x80 | (uch & 0x3f));
+ } else if ((uch >= SURROGATE_LEAD_FIRST) &&
+ (uch <= SURROGATE_TRAIL_LAST)) {
+ // Half a surrogate pair
+ i++;
+ unsigned int xch = 0x10000 + ((uch & 0x3ff) << 10) + (uptr[i] & 0x3ff);
+ putf[k++] = static_cast<char>(0xF0 | (xch >> 18));
+ putf[k++] = static_cast<char>(0x80 | (xch >> 12) & 0x3f);
+ putf[k++] = static_cast<char>(0x80 | ((xch >> 6) & 0x3f));
+ putf[k++] = static_cast<char>(0x80 | (xch & 0x3f));
} else {
putf[k++] = static_cast<char>(0xE0 | (uch >> 12));
putf[k++] = static_cast<char>(0x80 | ((uch >> 6) & 0x3f));
putf[k++] = static_cast<char>(0x80 | (uch & 0x3f));
}
+ i++;
}
putf[len] = '\0';
}
-unsigned int UCS2Length(const char *s, unsigned int len) {
+unsigned int UTF16Length(const char *s, unsigned int len) {
unsigned int ulen = 0;
- for (unsigned int i=0;i<len;i++) {
+ unsigned int charLen;
+ for (unsigned int i=0;i<len;) {
unsigned char ch = static_cast<unsigned char>(s[i]);
- if ((ch < 0x80) || (ch > (0x80 + 0x40)))
+ if (ch < 0x80) {
+ charLen = 1;
+ } else if (ch < 0x80 + 0x40 + 0x20) {
+ charLen = 2;
+ } else if (ch < 0x80 + 0x40 + 0x20 + 0x10) {
+ charLen = 3;
+ } else {
+ charLen = 4;
ulen++;
+ }
+ i += charLen;
+ ulen++;
}
return ulen;
}
-unsigned int UCS2FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsigned int tlen) {
+unsigned int UTF16FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsigned int tlen) {
unsigned int ui=0;
const unsigned char *us = reinterpret_cast<const unsigned char *>(s);
unsigned int i=0;
tbuf[ui] = static_cast<wchar_t>((ch & 0x1F) << 6);
ch = us[i++];
tbuf[ui] = static_cast<wchar_t>(tbuf[ui] + (ch & 0x7F));
- } else {
+ } else if (ch < 0x80 + 0x40 + 0x20 + 0x10) {
tbuf[ui] = static_cast<wchar_t>((ch & 0xF) << 12);
ch = us[i++];
tbuf[ui] = static_cast<wchar_t>(tbuf[ui] + ((ch & 0x7F) << 6));
ch = us[i++];
tbuf[ui] = static_cast<wchar_t>(tbuf[ui] + (ch & 0x7F));
+ } else {
+ // Outside the BMP so need two surrogates
+ int val = (ch & 0x7) << 18;
+ ch = us[i++];
+ val += (ch & 0x3F) << 12;
+ ch = us[i++];
+ val += (ch & 0x3F) << 6;
+ ch = us[i++];
+ val += (ch & 0x3F);
+ tbuf[ui] = static_cast<wchar_t>(((val - 0x10000) >> 10) + SURROGATE_LEAD_FIRST);
+ ui++;
+ tbuf[ui] = static_cast<wchar_t>((val & 0x3ff) + SURROGATE_TRAIL_FIRST);
}
ui++;
}
// The License.txt file describes the conditions under which this software may be distributed.
unsigned int UTF8Length(const wchar_t *uptr, unsigned int tlen);
-void UTF8FromUCS2(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len);
-unsigned int UCS2Length(const char *s, unsigned int len);
-unsigned int UCS2FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsigned int tlen);
+void UTF8FromUTF16(const wchar_t *uptr, unsigned int tlen, char *putf, unsigned int len);
+unsigned int UTF16Length(const char *s, unsigned int len);
+unsigned int UTF16FromUTF8(const char *s, unsigned int len, wchar_t *tbuf, unsigned int tlen);
#include "Platform.h"
#include "Scintilla.h"
+#include "SplitVector.h"
+#include "Partitioning.h"
+#include "RunStyles.h"
#include "Indicator.h"
#include "XPM.h"
#include "LineMarker.h"
#include "Style.h"
#include "ViewStyle.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
MarginStyle::MarginStyle() :
style(SC_MARGIN_SYMBOL), width(0), mask(0), sensitive(false) {
}
// A list of the fontnames - avoids wasting space in each style
FontNames::FontNames() {
+ size = 8;
+ names = new char *[size];
max = 0;
}
FontNames::~FontNames() {
Clear();
+ delete []names;
+ names = 0;
}
void FontNames::Clear() {
return names[i];
}
}
+ if (max >= size) {
+ // Grow array
+ int sizeNew = size * 2;
+ char **namesNew = new char *[sizeNew];
+ for (int j=0;j<max;j++) {
+ namesNew[j] = names[j];
+ }
+ delete []names;
+ names = namesNew;
+ size = sizeNew;
+ }
names[max] = new char[strlen(name) + 1];
strcpy(names[max], name);
max++;
}
ViewStyle::ViewStyle(const ViewStyle &source) {
- Init();
- for (unsigned int sty=0;sty<(sizeof(styles)/sizeof(styles[0]));sty++) {
+ Init(source.stylesSize);
+ for (unsigned int sty=0;sty<source.stylesSize;sty++) {
styles[sty] = source.styles[sty];
// Can't just copy fontname as its lifetime is relative to its owning ViewStyle
styles[sty].fontName = fontNames.Save(source.styles[sty].fontName);
selbackground.desired = source.selbackground.desired;
selbackground2.desired = source.selbackground2.desired;
selAlpha = source.selAlpha;
+ selEOLFilled = source.selEOLFilled;
foldmarginColourSet = source.foldmarginColourSet;
foldmarginColour.desired = source.foldmarginColour.desired;
caretLineAlpha = source.caretLineAlpha;
edgecolour.desired = source.edgecolour.desired;
edgeState = source.edgeState;
+ caretStyle = source.caretStyle;
caretWidth = source.caretWidth;
someStylesProtected = false;
leftMarginWidth = source.leftMarginWidth;
}
ViewStyle::~ViewStyle() {
+ delete []styles;
+ styles = NULL;
}
-void ViewStyle::Init() {
+void ViewStyle::Init(size_t stylesSize_) {
+ stylesSize = 0;
+ styles = NULL;
+ AllocStyles(stylesSize_);
fontNames.Clear();
ResetDefaultStyle();
indicators[0].style = INDIC_SQUIGGLE;
+ indicators[0].under = false;
indicators[0].fore = ColourDesired(0, 0x7f, 0);
indicators[1].style = INDIC_TT;
+ indicators[1].under = false;
indicators[1].fore = ColourDesired(0, 0, 0xff);
indicators[2].style = INDIC_PLAIN;
+ indicators[2].under = false;
indicators[2].fore = ColourDesired(0xff, 0, 0);
lineHeight = 1;
selbackground.desired = ColourDesired(0xc0, 0xc0, 0xc0);
selbackground2.desired = ColourDesired(0xb0, 0xb0, 0xb0);
selAlpha = SC_ALPHA_NOALPHA;
+ selEOLFilled = false;
foldmarginColourSet = false;
foldmarginColour.desired = ColourDesired(0xff, 0, 0);
caretLineAlpha = SC_ALPHA_NOALPHA;
edgecolour.desired = ColourDesired(0xc0, 0xc0, 0xc0);
edgeState = EDGE_NONE;
+ caretStyle = CARETSTYLE_LINE;
caretWidth = 1;
someStylesProtected = false;
}
zoomLevel = 0;
viewWhitespace = wsInvisible;
- viewIndentationGuides = false;
+ viewIndentationGuides = ivNone;
viewEOL = false;
showMarkedLines = true;
extraFontFlag = false;
void ViewStyle::RefreshColourPalette(Palette &pal, bool want) {
unsigned int i;
- for (i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
+ for (i=0;i<stylesSize;i++) {
pal.WantFind(styles[i].fore, want);
pal.WantFind(styles[i].back, want);
}
maxAscent = styles[STYLE_DEFAULT].ascent;
maxDescent = styles[STYLE_DEFAULT].descent;
someStylesProtected = false;
- for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
+ for (unsigned int i=0; i<stylesSize; i++) {
if (i != STYLE_DEFAULT) {
styles[i].Realise(surface, zoomLevel, &styles[STYLE_DEFAULT], extraFontFlag);
if (maxAscent < styles[i].ascent)
}
}
+void ViewStyle::AllocStyles(size_t sizeNew) {
+ Style *stylesNew = new Style[sizeNew];
+ size_t i=0;
+ for (; i<stylesSize; i++) {
+ stylesNew[i] = styles[i];
+ stylesNew[i].fontName = styles[i].fontName;
+ }
+ if (stylesSize > STYLE_DEFAULT) {
+ for (; i<sizeNew; i++) {
+ if (i != STYLE_DEFAULT) {
+ stylesNew[i].ClearTo(styles[STYLE_DEFAULT]);
+ }
+ }
+ }
+ delete []styles;
+ styles = stylesNew;
+ stylesSize = sizeNew;
+}
+
+void ViewStyle::EnsureStyle(size_t index) {
+ if (index >= stylesSize) {
+ size_t sizeNew = stylesSize * 2;
+ while (sizeNew < index)
+ sizeNew *= 2;
+ AllocStyles(sizeNew);
+ }
+}
+
void ViewStyle::ResetDefaultStyle() {
styles[STYLE_DEFAULT].Clear(ColourDesired(0,0,0),
ColourDesired(0xff,0xff,0xff),
- Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()),
+ Platform::DefaultFontSize(), fontNames.Save(Platform::DefaultFont()),
SC_CHARSET_DEFAULT,
false, false, false, false, Style::caseMixed, true, true, false);
}
void ViewStyle::ClearStyles() {
// Reset all styles to be like the default style
- for (unsigned int i=0;i<(sizeof(styles)/sizeof(styles[0]));i++) {
+ for (unsigned int i=0; i<stylesSize; i++) {
if (i != STYLE_DEFAULT) {
styles[i].ClearTo(styles[STYLE_DEFAULT]);
}
}
bool ViewStyle::ProtectionActive() const {
- return someStylesProtected;
+ return someStylesProtected;
}
#ifndef VIEWSTYLE_H
#define VIEWSTYLE_H
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
/**
*/
class MarginStyle {
*/
class FontNames {
private:
- char *names[STYLE_MAX + 1];
+ char **names;
+ int size;
int max;
public:
const char *Save(const char *name);
};
+enum IndentView {ivNone, ivReal, ivLookForward, ivLookBoth};
+
enum WhiteSpaceVisibility {wsInvisible=0, wsVisibleAlways=1, wsVisibleAfterIndent=2};
/**
class ViewStyle {
public:
FontNames fontNames;
- Style styles[STYLE_MAX + 1];
+ size_t stylesSize;
+ Style *styles;
LineMarker markers[MARKER_MAX + 1];
Indicator indicators[INDIC_MAX + 1];
int lineHeight;
ColourPair selbackground;
ColourPair selbackground2;
int selAlpha;
+ bool selEOLFilled;
bool whitespaceForegroundSet;
ColourPair whitespaceForeground;
bool whitespaceBackgroundSet;
int fixedColumnWidth;
int zoomLevel;
WhiteSpaceVisibility viewWhitespace;
- bool viewIndentationGuides;
+ IndentView viewIndentationGuides;
bool viewEOL;
bool showMarkedLines;
ColourPair caretcolour;
int caretLineAlpha;
ColourPair edgecolour;
int edgeState;
+ int caretStyle;
int caretWidth;
bool someStylesProtected;
bool extraFontFlag;
ViewStyle();
ViewStyle(const ViewStyle &source);
~ViewStyle();
- void Init();
+ void Init(size_t stylesSize_=64);
void RefreshColourPalette(Palette &pal, bool want);
void Refresh(Surface &surface);
+ void AllocStyles(size_t sizeNew);
+ void EnsureStyle(size_t index);
void ResetDefaultStyle();
void ClearStyles();
void SetStyleFontName(int styleIndex, const char *name);
bool ProtectionActive() const;
};
+#ifdef SCI_NAMESPACE
+}
+#endif
+
#endif
#include "WindowAccessor.h"
#include "Scintilla.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
WindowAccessor::~WindowAccessor() {
}
return indent;
}
+void WindowAccessor::IndicatorFill(int start, int end, int indicator, int value) {
+ Platform::SendScintilla(id, SCI_SETINDICATORCURRENT, indicator);
+ if (value) {
+ Platform::SendScintilla(id, SCI_SETINDICATORVALUE, value);
+ Platform::SendScintilla(id, SCI_INDICATORFILLRANGE, start, end - start);
+ } else {
+ Platform::SendScintilla(id, SCI_INDICATORCLEARRANGE, start, end - start);
+ }
+}
#include "XPM.h"
+#ifdef SCI_NAMESPACE
+using namespace Scintilla;
+#endif
+
static const char *NextField(const char *s) {
// In case there are leading spaces in the string
while (*s && *s == ' ') {
#ifndef XPM_H
#define XPM_H
+#ifdef SCI_NAMESPACE
+namespace Scintilla {
+#endif
+
/**
* Hold a pixmap in XPM format.
*/
int GetWidth();
};
+#ifdef SCI_NAMESPACE
+}
+#endif
+
#endif
DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_CLICK )
DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_DCLICK )
DEFINE_EVENT_TYPE( wxEVT_STC_CALLTIP_CLICK )
-DEFINE_EVENT_TYPE( wxEVT_STC_AUTOCOMP_SELECTION )
+DEFINE_EVENT_TYPE( wxEVT_STC_AUTOCOMP_SELECTION )
+DEFINE_EVENT_TYPE( wxEVT_STC_INDICATOR_CLICK )
+DEFINE_EVENT_TYPE( wxEVT_STC_INDICATOR_RELEASE )
SendMsg(2059, style, underline);
}
+// Get the foreground colour of a style.
+wxColour wxStyledTextCtrl::StyleGetForeground(int style) {
+ long c = SendMsg(2481, style, 0);
+ return wxColourFromLong(c);
+}
+
+// Get the background colour of a style.
+wxColour wxStyledTextCtrl::StyleGetBackground(int style) {
+ long c = SendMsg(2482, style, 0);
+ return wxColourFromLong(c);
+}
+
+// Get is a style bold or not.
+bool wxStyledTextCtrl::StyleGetBold(int style) {
+ return SendMsg(2483, style, 0) != 0;
+}
+
+// Get is a style italic or not.
+bool wxStyledTextCtrl::StyleGetItalic(int style) {
+ return SendMsg(2484, style, 0) != 0;
+}
+
+// Get the size of characters of a style.
+int wxStyledTextCtrl::StyleGetSize(int style) {
+ return SendMsg(2485, style, 0);
+}
+
+// Get the font facename of a style
+wxString wxStyledTextCtrl::StyleGetFaceName(int style) {
+ long msg = 2486;
+ long len = SendMsg(msg, style, 0);
+ wxMemoryBuffer mbuf(len+1);
+ char* buf = (char*)mbuf.GetWriteBuf(len+1);
+ SendMsg(msg, style, (long)buf);
+ mbuf.UngetWriteBuf(len);
+ mbuf.AppendByte(0);
+ return stc2wx(buf);
+}
+
+// Get is a style to have its end of line filled or not.
+bool wxStyledTextCtrl::StyleGetEOLFilled(int style) {
+ return SendMsg(2487, style, 0) != 0;
+}
+
+// Get is a style underlined or not.
+bool wxStyledTextCtrl::StyleGetUnderline(int style) {
+ return SendMsg(2488, style, 0) != 0;
+}
+
+// Get is a style mixed case, or to force upper or lower case.
+int wxStyledTextCtrl::StyleGetCase(int style) {
+ return SendMsg(2489, style, 0);
+}
+
+// Get the character set of the font in a style.
+int wxStyledTextCtrl::StyleGetCharacterSet(int style) {
+ return SendMsg(2490, style, 0);
+}
+
+// Get is a style visible or not.
+bool wxStyledTextCtrl::StyleGetVisible(int style) {
+ return SendMsg(2491, style, 0) != 0;
+}
+
+// Get is a style changeable or not (read only).
+// Experimental feature, currently buggy.
+bool wxStyledTextCtrl::StyleGetChangeable(int style) {
+ return SendMsg(2492, style, 0) != 0;
+}
+
+// Get is a style a hotspot or not.
+bool wxStyledTextCtrl::StyleGetHotSpot(int style) {
+ return SendMsg(2493, style, 0) != 0;
+}
+
// Set a style to be mixed case, or to force upper or lower case.
void wxStyledTextCtrl::StyleSetCase(int style, int caseForce) {
SendMsg(2060, style, caseForce);
SendMsg(2478, alpha, 0);
}
+// Is the selection end of line filled?
+bool wxStyledTextCtrl::GetSelEOLFilled() {
+ return SendMsg(2479, 0, 0) != 0;
+}
+
+// Set the selection to have its end of line filled or not.
+void wxStyledTextCtrl::SetSelEOLFilled(bool filled) {
+ SendMsg(2480, filled, 0);
+}
+
// Set the foreground colour of the caret.
void wxStyledTextCtrl::SetCaretForeground(const wxColour& fore) {
SendMsg(2069, wxColourAsLong(fore), 0);
return wxColourFromLong(c);
}
+// Set an indicator to draw under text or over(default).
+void wxStyledTextCtrl::IndicatorSetUnder(int indic, bool under) {
+ SendMsg(2510, indic, under);
+}
+
+// Retrieve whether indicator drawn under or over text.
+bool wxStyledTextCtrl::IndicatorGetUnder(int indic) {
+ return SendMsg(2511, indic, 0) != 0;
+}
+
// Set the foreground colour of all whitespace and whether to use this setting.
void wxStyledTextCtrl::SetWhitespaceForeground(bool useSetting, const wxColour& fore) {
SendMsg(2084, useSetting, wxColourAsLong(fore));
}
// Show or hide indentation guides.
-void wxStyledTextCtrl::SetIndentationGuides(bool show) {
- SendMsg(2132, show, 0);
+void wxStyledTextCtrl::SetIndentationGuides(int indentView) {
+ SendMsg(2132, indentView, 0);
}
// Are the indentation guides visible?
-bool wxStyledTextCtrl::GetIndentationGuides() {
- return SendMsg(2133, 0, 0) != 0;
+int wxStyledTextCtrl::GetIndentationGuides() {
+ return SendMsg(2133, 0, 0);
}
// Set the highlighted indentation guide column.
return SendMsg(2275, 0, 0);
}
+// Sets whether the maximum width line displayed is used to set scroll width.
+void wxStyledTextCtrl::SetScrollWidthTracking(bool tracking) {
+ SendMsg(2516, tracking, 0);
+}
+
+// Retrieve whether the scroll width tracks wide lines.
+bool wxStyledTextCtrl::GetScrollWidthTracking() {
+ return SendMsg(2517, 0, 0) != 0;
+}
+
// Measure the pixel width of some text in a particular style.
// NUL terminated text argument.
// Does not handle tab or control characters.
SendMsg(2336, 0, 0);
}
+// Delete the word to the right of the caret, but not the trailing non-word characters.
+void wxStyledTextCtrl::DelWordRightEnd() {
+ SendMsg(2518, 0, 0);
+}
+
// Cut the line containing the caret.
void wxStyledTextCtrl::LineCut() {
SendMsg(2337, 0, 0);
SendMsg(2410, useSetting, wxColourAsLong(fore));
}
+// Get the fore colour for active hotspots.
+wxColour wxStyledTextCtrl::GetHotspotActiveForeground() {
+ long c = SendMsg(2494, 0, 0);
+ return wxColourFromLong(c);
+}
+
// Set a back colour for active hotspots.
void wxStyledTextCtrl::SetHotspotActiveBackground(bool useSetting, const wxColour& back) {
SendMsg(2411, useSetting, wxColourAsLong(back));
}
+// Get the back colour for active hotspots.
+wxColour wxStyledTextCtrl::GetHotspotActiveBackground() {
+ long c = SendMsg(2495, 0, 0);
+ return wxColourFromLong(c);
+}
+
// Enable / Disable underlining active hotspots.
void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline) {
SendMsg(2412, underline, 0);
}
+// Get whether underlining for active hotspots.
+bool wxStyledTextCtrl::GetHotspotActiveUnderline() {
+ return SendMsg(2496, 0, 0) != 0;
+}
+
// Limit hotspots to single line so hotspots on two lines don't merge.
void wxStyledTextCtrl::SetHotspotSingleLine(bool singleLine) {
SendMsg(2421, singleLine, 0);
}
+// Get the HotspotSingleLine property
+bool wxStyledTextCtrl::GetHotspotSingleLine() {
+ return SendMsg(2497, 0, 0) != 0;
+}
+
// Move caret between paragraphs (delimited by empty lines).
void wxStyledTextCtrl::ParaDown() {
SendMsg(2413, 0, 0);
return SendMsg(2471, 0, 0);
}
+// Set the style of the caret to be drawn.
+void wxStyledTextCtrl::SetCaretStyle(int caretStyle) {
+ SendMsg(2512, caretStyle, 0);
+}
+
+// Returns the current style of the caret.
+int wxStyledTextCtrl::GetCaretStyle() {
+ return SendMsg(2513, 0, 0);
+}
+
+// Set the indicator used for IndicatorFillRange and IndicatorClearRange
+void wxStyledTextCtrl::SetIndicatorCurrent(int indicator) {
+ SendMsg(2500, indicator, 0);
+}
+
+// Get the current indicator
+int wxStyledTextCtrl::GetIndicatorCurrent() {
+ return SendMsg(2501, 0, 0);
+}
+
+// Set the value used for IndicatorFillRange
+void wxStyledTextCtrl::SetIndicatorValue(int value) {
+ SendMsg(2502, value, 0);
+}
+
+// Get the current indicator vaue
+int wxStyledTextCtrl::GetIndicatorValue() {
+ return SendMsg(2503, 0, 0);
+}
+
+// Turn a indicator on over a range.
+void wxStyledTextCtrl::IndicatorFillRange(int position, int fillLength) {
+ SendMsg(2504, position, fillLength);
+}
+
+// Turn a indicator off over a range.
+void wxStyledTextCtrl::IndicatorClearRange(int position, int clearLength) {
+ SendMsg(2505, position, clearLength);
+}
+
+// Are any indicators present at position?
+int wxStyledTextCtrl::IndicatorAllOnFor(int position) {
+ return SendMsg(2506, position, 0);
+}
+
+// What value does a particular indicator have at at a position?
+int wxStyledTextCtrl::IndicatorValueAt(int indicator, int position) {
+ return SendMsg(2507, indicator, position);
+}
+
+// Where does a particular indicator start?
+int wxStyledTextCtrl::IndicatorStart(int indicator, int position) {
+ return SendMsg(2508, indicator, position);
+}
+
+// Where does a particular indicator end?
+int wxStyledTextCtrl::IndicatorEnd(int indicator, int position) {
+ return SendMsg(2509, indicator, position);
+}
+
+// Set number of entries in position cache
+void wxStyledTextCtrl::SetPositionCacheSize(int size) {
+ SendMsg(2514, size, 0);
+}
+
+// How many entries are allocated to the position cache?
+int wxStyledTextCtrl::GetPositionCacheSize() {
+ return SendMsg(2515, 0, 0);
+}
+
// Start notifying the container of all key presses and commands.
void wxStyledTextCtrl::StartRecord() {
SendMsg(3001, 0, 0);
}
+// Get the font of a style
+wxFont wxStyledTextCtrl::StyleGetFont(int style) {
+ wxFont font;
+ font.SetPointSize(StyleGetSize(style));
+ font.SetFaceName(StyleGetFaceName(style));
+ if( StyleGetBold(style) )
+ font.SetWeight(wxFONTWEIGHT_BOLD);
+ else
+ font.SetWeight(wxFONTWEIGHT_NORMAL);
+
+ if( StyleGetItalic(style) )
+ font.SetStyle(wxFONTSTYLE_ITALIC);
+ else
+ font.SetStyle(wxFONTSTYLE_NORMAL);
+
+ return font;
+}
+
+
// Set style size, face, bold, italic, and underline attributes from
// a wxFont's attributes.
void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
bool italic = font.GetStyle() != wxNORMAL;
bool under = font.GetUnderlined();
wxFontEncoding encoding = font.GetEncoding();
-
+
StyleSetFontAttr(styleNum, size, faceName, bold, italic, under, encoding);
}
case wxSTC_CHARSET_CYRILLIC:
encoding = wxFONTENCODING_ISO8859_5;
break;
-
+
case wxSTC_CHARSET_8859_15:
encoding = wxFONTENCODING_ISO8859_15;;
break;
if (!len) {
wxCharBuffer empty;
return empty;
- }
+ }
wxCharBuffer buf(len);
SendMsg(SCI_GETSELTEXT, 0, (long)buf.data());
if (!len) {
wxCharBuffer empty;
return empty;
- }
+ }
wxCharBuffer buf(len);
TextRange tr;
}
#endif
}
-
+
evt.Skip();
}
SetEventText(evt, scn.text, strlen(scn.text));
evt.SetPosition(scn.lParam);
break;
-
+
case SCN_USERLISTSELECTION:
evt.SetEventType(wxEVT_STC_USERLISTSELECTION);
evt.SetListType(scn.listType);
case SCN_CALLTIPCLICK:
evt.SetEventType(wxEVT_STC_CALLTIP_CLICK);
break;
-
+
+ case SCN_INDICATORCLICK:
+ evt.SetEventType(wxEVT_STC_INDICATOR_CLICK);
+ break;
+
+ case SCN_INDICATORRELEASE:
+ evt.SetEventType(wxEVT_STC_INDICATOR_RELEASE);
+ break;
+
default:
return;
}
DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_CLICK )
DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_DCLICK )
DEFINE_EVENT_TYPE( wxEVT_STC_CALLTIP_CLICK )
-DEFINE_EVENT_TYPE( wxEVT_STC_AUTOCOMP_SELECTION )
+DEFINE_EVENT_TYPE( wxEVT_STC_AUTOCOMP_SELECTION )
+DEFINE_EVENT_TYPE( wxEVT_STC_INDICATOR_CLICK )
+DEFINE_EVENT_TYPE( wxEVT_STC_INDICATOR_RELEASE )
}
+// Get the font of a style
+wxFont wxStyledTextCtrl::StyleGetFont(int style) {
+ wxFont font;
+ font.SetPointSize(StyleGetSize(style));
+ font.SetFaceName(StyleGetFaceName(style));
+ if( StyleGetBold(style) )
+ font.SetWeight(wxFONTWEIGHT_BOLD);
+ else
+ font.SetWeight(wxFONTWEIGHT_NORMAL);
+
+ if( StyleGetItalic(style) )
+ font.SetStyle(wxFONTSTYLE_ITALIC);
+ else
+ font.SetStyle(wxFONTSTYLE_NORMAL);
+
+ return font;
+}
+
+
// Set style size, face, bold, italic, and underline attributes from
// a wxFont's attributes.
void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
bool italic = font.GetStyle() != wxNORMAL;
bool under = font.GetUnderlined();
wxFontEncoding encoding = font.GetEncoding();
-
+
StyleSetFontAttr(styleNum, size, faceName, bold, italic, under, encoding);
}
case wxSTC_CHARSET_CYRILLIC:
encoding = wxFONTENCODING_ISO8859_5;
break;
-
+
case wxSTC_CHARSET_8859_15:
encoding = wxFONTENCODING_ISO8859_15;;
break;
if (!len) {
wxCharBuffer empty;
return empty;
- }
+ }
wxCharBuffer buf(len);
SendMsg(SCI_GETSELTEXT, 0, (long)buf.data());
if (!len) {
wxCharBuffer empty;
return empty;
- }
+ }
wxCharBuffer buf(len);
TextRange tr;
}
#endif
}
-
+
evt.Skip();
}
SetEventText(evt, scn.text, strlen(scn.text));
evt.SetPosition(scn.lParam);
break;
-
+
case SCN_USERLISTSELECTION:
evt.SetEventType(wxEVT_STC_USERLISTSELECTION);
evt.SetListType(scn.listType);
case SCN_CALLTIPCLICK:
evt.SetEventType(wxEVT_STC_CALLTIP_CLICK);
break;
-
+
+ case SCN_INDICATORCLICK:
+ evt.SetEventType(wxEVT_STC_INDICATOR_CLICK);
+ break;
+
+ case SCN_INDICATORRELEASE:
+ evt.SetEventType(wxEVT_STC_INDICATOR_RELEASE);
+ break;
+
default:
return;
}
#include "wx/dnd.h"
#include "wx/stopwatch.h"
-class WXDLLIMPEXP_CORE wxScrollBar;
-
-#ifdef WXMAKINGDLL_STC
- #define WXDLLIMPEXP_STC WXEXPORT
-#elif defined(WXUSINGDLL)
- #define WXDLLIMPEXP_STC WXIMPORT
-#else // not making nor using DLL
- #define WXDLLIMPEXP_STC
-#endif
-
+class WXDLLIMPEXP_FWD_CORE wxScrollBar;
// SWIG can't handle "#if" type of conditionals, only "#ifdef"
#ifdef SWIG
#ifndef SWIG
extern WXDLLIMPEXP_STC const wxChar* wxSTCNameStr;
-class WXDLLIMPEXP_STC wxStyledTextCtrl;
-class WXDLLIMPEXP_STC wxStyledTextEvent;
+class WXDLLIMPEXP_FWD_STC wxStyledTextCtrl;
+class WXDLLIMPEXP_FWD_STC wxStyledTextEvent;
#endif
//----------------------------------------------------------------------
void StyleSetSpec(int styleNum, const wxString& spec);
+ // Get the font of a style.
+ wxFont StyleGetFont(int style);
+
// Set style size, face, bold, italic, and underline attributes from
// a wxFont's attributes.
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_STC, wxEVT_STC_HOTSPOT_DCLICK, 1674)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_STC, wxEVT_STC_CALLTIP_CLICK, 1675)
DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_STC, wxEVT_STC_AUTOCOMP_SELECTION, 1676)
+ DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_STC, wxEVT_STC_INDICATOR_CLICK, 1677)
+ DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_STC, wxEVT_STC_INDICATOR_RELEASE, 1678)
END_DECLARE_EVENT_TYPES()
#else
enum {
wxEVT_STC_HOTSPOT_CLICK,
wxEVT_STC_HOTSPOT_DCLICK,
wxEVT_STC_CALLTIP_CLICK,
- wxEVT_STC_AUTOCOMP_SELECTION
+ wxEVT_STC_AUTOCOMP_SELECTION,
+ wxEVT_STC_INDICATOR_CLICK,
+ wxEVT_STC_INDICATOR_RELEASE
};
#endif
#define EVT_STC_HOTSPOT_DCLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_HOTSPOT_DCLICK, id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxStyledTextEventFunction, & fn ), (wxObject *) NULL ),
#define EVT_STC_CALLTIP_CLICK(id, fn)) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CALLTIP_CLICK id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxStyledTextEventFunction, & fn ), (wxObject *) NULL ),
#define EVT_STC_AUTOCOMP_SELECTION(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_AUTOCOMP_SELECTION id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxStyledTextEventFunction, & fn ), (wxObject *) NULL ),
+#define EVT_STC_INDICATOR_CLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_INDICATOR_CLICK id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxStyledTextEventFunction, & fn ), (wxObject *) NULL ),
+#define EVT_STC_INDICATOR_RELEASE(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_INDICATOR_RELEASE id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) wxStaticCastEvent( wxStyledTextEventFunction, & fn ), (wxObject *) NULL ),
+
#endif
#endif // wxUSE_STC